NDEVR
API Documentation
ApplicationOption< t_type >

The default object to store data of any type that should persist through sessions of the application. More...

Inheritance diagram for ApplicationOption< t_type >:
[legend]
Collaboration diagram for ApplicationOption< t_type >:
[legend]

Public Member Functions

 ApplicationOption (const TranslatedString &group, const TranslatedString &label, const t_type &value, ApplicationOptions &options=ApplicationOptions::UserOptions())
 Constructs an ApplicationOption with a group, label, and default value using copy semantics.
 ApplicationOption (const TranslatedString &label, const t_type &value, ApplicationOptions &options=ApplicationOptions::UserOptions())
 Constructs an ApplicationOption with no group, using the default group.
 ApplicationOption (TranslatedString &&group, TranslatedString &&label, const t_type &value, ApplicationOptions &options=ApplicationOptions::UserOptions())
 Constructs an ApplicationOption with a group, label, and default value using move semantics.
void addListener (ResourceListener *listener, bool silent_add=false)
 Registers a ResourceListener to be notified when this option's value changes.
virtual void fromString (const String &value) override
 Sets the option value by parsing the given string.
template<class t_other_type = t_type>
decltype(auto) get () const
 Retrieves the current value of this option.
Resource< t_type > & getResource ()
 Returns a reference to the underlying Resource holding this option's value.
const TranslatedStringgroup () const
 Returns the translated group name for this option.
virtual INIOptioniniOption () override
 Creates an INIOption representation of this option for INI file serialization.
virtual bool isDefault () const override
 Checks whether the current value matches the default value.
const TranslatedStringlabel () const
 Returns the translated display label for this option.
void set (const t_type &value, bool make_default=false)
 Sets the option to a new value, optionally updating the default as well.
void setDefaultValue (const t_type &value)
 Updates the default value without changing the current value.
virtual void setToDefaultValue () override
 Resets the option value back to its default.
virtual StringAllocatingView toString () const override
 Converts the stored option value to a string representation.
Public Member Functions inherited from ApplicationOptionBase
virtual ~ApplicationOptionBase ()
 Destructor.

Protected Attributes

t_type m_default_value
 The default value used for reset operations.
const TranslatedString m_group
 The group this option belongs to for categorization.
const TranslatedString m_label
 The display label identifying this option.
ApplicationOptionsm_options
 Reference to the owning ApplicationOptions container.
Resource< t_type > m_value
 The resource holding the current option value.

Detailed Description

template<class t_type>
class ApplicationOption< t_type >

The default object to store data of any type that should persist through sessions of the application.


Stores data of any type that can easily be saved or retrieved at runtime. Option belongs to a specific group for easy sorting and can be used to automatically generate widgets.

Definition at line 170 of file ApplicationOptions.h.

Constructor & Destructor Documentation

◆ ApplicationOption() [1/3]

template<class t_type>
ApplicationOption< t_type >::ApplicationOption ( TranslatedString && group,
TranslatedString && label,
const t_type & value,
ApplicationOptions & options = ApplicationOptions::UserOptions() )
inline

Constructs an ApplicationOption with a group, label, and default value using move semantics.

Parameters
[in]groupThe translated group name (moved).
[in]labelThe translated display label (moved).
[in]valueThe initial and default value for this option.
[in]optionsThe ApplicationOptions container to register with.

Definition at line 180 of file ApplicationOptions.h.

References group(), label(), m_default_value, m_group, m_label, m_options, m_value, and ApplicationOptions::UserOptions().

◆ ApplicationOption() [2/3]

template<class t_type>
ApplicationOption< t_type >::ApplicationOption ( const TranslatedString & group,
const TranslatedString & label,
const t_type & value,
ApplicationOptions & options = ApplicationOptions::UserOptions() )
inline

Constructs an ApplicationOption with a group, label, and default value using copy semantics.

Parameters
[in]groupThe translated group name.
[in]labelThe translated display label.
[in]valueThe initial and default value for this option.
[in]optionsThe ApplicationOptions container to register with.

Definition at line 197 of file ApplicationOptions.h.

References group(), label(), m_default_value, m_group, m_label, m_options, m_value, and ApplicationOptions::UserOptions().

◆ ApplicationOption() [3/3]

template<class t_type>
ApplicationOption< t_type >::ApplicationOption ( const TranslatedString & label,
const t_type & value,
ApplicationOptions & options = ApplicationOptions::UserOptions() )
inline

Constructs an ApplicationOption with no group, using the default group.

Parameters
[in]labelThe translated display label.
[in]valueThe initial and default value for this option.
[in]optionsThe ApplicationOptions container to register with.

Definition at line 213 of file ApplicationOptions.h.

References label(), m_default_value, m_label, m_options, m_value, and ApplicationOptions::UserOptions().

Member Function Documentation

◆ addListener()

template<class t_type>
void ApplicationOption< t_type >::addListener ( ResourceListener * listener,
bool silent_add = false )
inline

Registers a ResourceListener to be notified when this option's value changes.

Parameters
[in]listenerThe listener to add.
[in]silent_addIf true, the listener is not immediately notified of the current value.

Definition at line 267 of file ApplicationOptions.h.

References m_value.

◆ fromString()

template<class t_type>
virtual void ApplicationOption< t_type >::fromString ( const String & value)
inlineoverridevirtual

Sets the option value by parsing the given string.

Parameters
[in]valueThe string to parse into the option's type.

Implements ApplicationOptionBase.

Definition at line 285 of file ApplicationOptions.h.

References String::getAs(), and m_value.

◆ get()

template<class t_type>
template<class t_other_type = t_type>
decltype(auto) ApplicationOption< t_type >::get ( ) const
inline

Retrieves the current value of this option.

Returns
The current value held by the underlying resource.

Definition at line 227 of file ApplicationOptions.h.

References m_value.

◆ getResource()

template<class t_type>
Resource< t_type > & ApplicationOption< t_type >::getResource ( )
inline

Returns a reference to the underlying Resource holding this option's value.

Returns
A reference to the Resource of type t_type.

Definition at line 236 of file ApplicationOptions.h.

References m_value.

Referenced by QCustomLineEdit::setup().

◆ group()

template<class t_type>
const TranslatedString & ApplicationOption< t_type >::group ( ) const
inline

Returns the translated group name for this option.

Returns
A const reference to the group string.

Definition at line 329 of file ApplicationOptions.h.

References m_group.

Referenced by ApplicationOption(), and ApplicationOption().

◆ iniOption()

template<class t_type>
virtual INIOption * ApplicationOption< t_type >::iniOption ( )
inlineoverridevirtual

Creates an INIOption representation of this option for INI file serialization.

Returns
A pointer to the INIOption representing this option.

Implements ApplicationOptionBase.

Definition at line 311 of file ApplicationOptions.h.

References m_value, and INIFactory::ToOption().

◆ isDefault()

template<class t_type>
virtual bool ApplicationOption< t_type >::isDefault ( ) const
inlineoverridevirtual

Checks whether the current value matches the default value.

Returns
True if the value is equal to the default, false otherwise.

Implements ApplicationOptionBase.

Definition at line 294 of file ApplicationOptions.h.

References m_default_value, and m_value.

◆ label()

template<class t_type>
const TranslatedString & ApplicationOption< t_type >::label ( ) const
inline

Returns the translated display label for this option.

Returns
A const reference to the label string.

Definition at line 320 of file ApplicationOptions.h.

References m_label.

Referenced by ApplicationOption(), ApplicationOption(), ApplicationOption(), and QCustomLineEdit::setup().

◆ set()

template<class t_type>
void ApplicationOption< t_type >::set ( const t_type & value,
bool make_default = false )
inline

Sets the option to a new value, optionally updating the default as well.

Parameters
[in]valueThe new value to assign.
[in]make_defaultIf true, also updates the default value to match.

Definition at line 246 of file ApplicationOptions.h.

References m_default_value, and m_value.

◆ setDefaultValue()

template<class t_type>
void ApplicationOption< t_type >::setDefaultValue ( const t_type & value)
inline

Updates the default value without changing the current value.

Parameters
[in]valueThe new default value.

Definition at line 257 of file ApplicationOptions.h.

References m_default_value.

◆ toString()

template<class t_type>
virtual StringAllocatingView ApplicationOption< t_type >::toString ( ) const
inlineoverridevirtual

Converts the stored option value to a string representation.

Returns
A string view containing the serialized value.

Implements ApplicationOptionBase.

Definition at line 276 of file ApplicationOptions.h.

References m_value.


The documentation for this class was generated from the following file: