NDEVR
API Documentation
GenericOptionGroup

Stores a groups of GenericOptions that can be used to group them. More...

Inheritance diagram for GenericOptionGroup:
[legend]
Collaboration diagram for GenericOptionGroup:
[legend]

Public Member Functions

 GenericOptionGroup ()=default
 Default constructor.
 GenericOptionGroup (const TranslatedString &group_name, const StringView &group_id=StringView())
 Constructs an option group with the given name and optional identifier.
virtual ~GenericOptionGroup ()
 Virtual destructor.
void addOption (const GenericOption &option)
 Adds a fully configured GenericOption to this group.
template<class t_type>
void addOption (const TranslatedString &name, const t_type &value, bool is_editable=true)
 Adds a new option to this group with the given name and typed value.
void addOptionsToINI (INIFactory &factory)
 Adds all options in this group to an existing INIFactory for serialization.
void clear ()
 Removes all options from this group.
virtual void fromJSONNode (const JSONNode &node)
 Deserializes this option group from a JSON node.
GenericOptiongetOption (const TranslatedString &n)
 Retrieves a mutable reference to the option with the given translated name.
const GenericOptiongetOption (const TranslatedString &n) const
 Retrieves a const reference to the option with the given translated name.
template<class t_type>
t_type getValue (const StringView &name) const
 Retrieves the value of an option converted to the requested type, looked up by string identifier.
template<class t_type>
t_type getValue (const StringView &name, const t_type &value_if_not_exist) const
 Retrieves the value of an option by string identifier, returning a fallback if the option does not exist.
template<class t_type>
t_type getValue (const TranslatedString &name) const
 Retrieves the value of an option converted to the requested type, looked up by translated name.
template<class t_type>
t_type getValue (const TranslatedString &name, const t_type &value_if_not_exist) const
 Retrieves the value of an option by translated name, returning a fallback if the option does not exist.
bool hasOption (const StringView &option_name) const
 Checks whether an option with the given string identifier exists in this group.
bool hasOption (const TranslatedString &option_name) const
 Checks whether an option with the given translated name exists in this group.
INIFactory ini ()
 Creates an INIFactory for serializing this option group to INI format.
bool operator!= (const GenericOptionGroup &option_group) const
 Checks inequality between two option groups.
bool operator== (const GenericOptionGroup &option_group) const
 Checks equality between two option groups by comparing all option values.
void setOption (const GenericOption &option)
 Replaces an existing option with the given GenericOption, matched by its identifier.
template<class t_type>
void setValue (const StringView &name, const t_type &value)
 Sets the value of an existing option identified by its string name.
template<class t_type>
void setValue (const TranslatedString &name, const t_type &value)
 Sets the value of an existing option identified by its translated name.
virtual JSONNode toJSONNode (bool only_value=true) const
 Serializes this option group to a JSON node.

Public Attributes

String id
 The unique identifier for this option group.
TranslatedString name
 The user-facing display name of this option group.
Dictionary< String, GenericOptionoptions
 The dictionary mapping option identifiers to their GenericOption instances.
Buffer< Stringordered_options
 The insertion-ordered list of option identifiers for preserving display order.

Detailed Description

Stores a groups of GenericOptions that can be used to group them.


Definition at line 195 of file GenericOptions.h.

Constructor & Destructor Documentation

◆ GenericOptionGroup() [1/2]

GenericOptionGroup::GenericOptionGroup ( )
default

Default constructor.

Creates an empty option group.

Referenced by operator!=(), and operator==().

◆ GenericOptionGroup() [2/2]

GenericOptionGroup::GenericOptionGroup ( const TranslatedString & group_name,
const StringView & group_id = StringView() )

Constructs an option group with the given name and optional identifier.

Parameters
[in]group_nameThe user-facing display name for this group.
[in]group_idAn optional unique identifier for this group.

Member Function Documentation

◆ addOption() [1/2]

void GenericOptionGroup::addOption ( const GenericOption & option)
inline

Adds a fully configured GenericOption to this group.

Parameters
[in]optionThe GenericOption to add.

Definition at line 229 of file GenericOptions.h.

References GenericOption::id, options, and ordered_options.

◆ addOption() [2/2]

template<class t_type>
void GenericOptionGroup::addOption ( const TranslatedString & name,
const t_type & value,
bool is_editable = true )
inline

Adds a new option to this group with the given name and typed value.

Parameters
[in]nameThe user-facing display name for the option.
[in]valueThe initial value for the option.
[in]is_editableWhether the option should be editable by the user.

Definition at line 219 of file GenericOptions.h.

References addOption(), GenericOption::is_editable, and name.

Referenced by addOption(), IMUNoiseSimulator::addVector(), IMUNoiseSimulator::groups(), and ProgressWidgetDemo::options().

◆ addOptionsToINI()

void GenericOptionGroup::addOptionsToINI ( INIFactory & factory)

Adds all options in this group to an existing INIFactory for serialization.

Parameters
[in]factoryThe INIFactory to add options to.

◆ fromJSONNode()

virtual void GenericOptionGroup::fromJSONNode ( const JSONNode & node)
virtual

Deserializes this option group from a JSON node.

Parameters
[in]nodeThe JSONNode to read option data from.

◆ getOption() [1/2]

GenericOption & GenericOptionGroup::getOption ( const TranslatedString & n)
inline

Retrieves a mutable reference to the option with the given translated name.

Parameters
[in]nThe translated name of the option.
Returns
A mutable reference to the matching GenericOption.

Definition at line 302 of file GenericOptions.h.

References options, and TranslatedString::readableID().

◆ getOption() [2/2]

const GenericOption & GenericOptionGroup::getOption ( const TranslatedString & n) const
inline

Retrieves a const reference to the option with the given translated name.

Parameters
[in]nThe translated name of the option.
Returns
A const reference to the matching GenericOption.

Definition at line 293 of file GenericOptions.h.

References options, and TranslatedString::readableID().

◆ getValue() [1/4]

template<class t_type>
t_type GenericOptionGroup::getValue ( const StringView & name) const
inline

Retrieves the value of an option converted to the requested type, looked up by string identifier.

Parameters
[in]nameThe string identifier of the option.
Returns
The option value converted to t_type.

Definition at line 323 of file GenericOptions.h.

References name, and options.

◆ getValue() [2/4]

template<class t_type>
t_type GenericOptionGroup::getValue ( const StringView & name,
const t_type & value_if_not_exist ) const
inline

Retrieves the value of an option by string identifier, returning a fallback if the option does not exist.

Parameters
[in]nameThe string identifier of the option.
[in]value_if_not_existThe fallback value returned if the option is not found.
Returns
The option value converted to t_type, or value_if_not_exist if the option is absent.

Definition at line 350 of file GenericOptions.h.

References name, and options.

◆ getValue() [3/4]

template<class t_type>
t_type GenericOptionGroup::getValue ( const TranslatedString & name) const
inline

Retrieves the value of an option converted to the requested type, looked up by translated name.

Parameters
[in]nameThe translated name of the option.
Returns
The option value converted to t_type.

Definition at line 313 of file GenericOptions.h.

References name, and options.

Referenced by IMUNoiseSimulator::setAccelerometerOptions(), IMUNoiseSimulator::setGyroOptions(), IMUNoiseSimulator::setVector(), and ProgressWidgetDemo::UpdateWidgetDemo().

◆ getValue() [4/4]

template<class t_type>
t_type GenericOptionGroup::getValue ( const TranslatedString & name,
const t_type & value_if_not_exist ) const
inline

Retrieves the value of an option by translated name, returning a fallback if the option does not exist.

Parameters
[in]nameThe translated name of the option.
[in]value_if_not_existThe fallback value returned if the option is not found.
Returns
The option value converted to t_type, or value_if_not_exist if the option is absent.

Definition at line 335 of file GenericOptions.h.

References name, and options.

◆ hasOption() [1/2]

bool GenericOptionGroup::hasOption ( const StringView & option_name) const
inline

Checks whether an option with the given string identifier exists in this group.

Parameters
[in]option_nameThe string identifier to look up.
Returns
True if an option with the given identifier exists.

Definition at line 249 of file GenericOptions.h.

References options.

◆ hasOption() [2/2]

bool GenericOptionGroup::hasOption ( const TranslatedString & option_name) const
inline

Checks whether an option with the given translated name exists in this group.

Parameters
[in]option_nameThe translated name to look up.
Returns
True if an option with the given name exists.

Definition at line 240 of file GenericOptions.h.

References options, and TranslatedString::readableID().

◆ ini()

INIFactory GenericOptionGroup::ini ( )

Creates an INIFactory for serializing this option group to INI format.

Returns
An INIFactory configured with this group's options.

◆ operator!=()

bool GenericOptionGroup::operator!= ( const GenericOptionGroup & option_group) const

Checks inequality between two option groups.

Parameters
[in]option_groupThe GenericOptionGroup to compare against.
Returns
True if any option values differ.

References GenericOptionGroup().

◆ operator==()

bool GenericOptionGroup::operator== ( const GenericOptionGroup & option_group) const

Checks equality between two option groups by comparing all option values.

Parameters
[in]option_groupThe GenericOptionGroup to compare against.
Returns
True if all options have matching values.

References GenericOptionGroup().

◆ setOption()

void GenericOptionGroup::setOption ( const GenericOption & option)
inline

Replaces an existing option with the given GenericOption, matched by its identifier.

Parameters
[in]optionThe GenericOption to replace with.

Definition at line 280 of file GenericOptions.h.

References GenericOption::id, options, and ordered_options.

◆ setValue() [1/2]

template<class t_type>
void GenericOptionGroup::setValue ( const StringView & name,
const t_type & value )
inline

Sets the value of an existing option identified by its string name.

Parameters
[in]nameThe string identifier of the option to update.
[in]valueThe new value to set.

Definition at line 271 of file GenericOptions.h.

References name, and options.

◆ setValue() [2/2]

template<class t_type>
void GenericOptionGroup::setValue ( const TranslatedString & name,
const t_type & value )
inline

Sets the value of an existing option identified by its translated name.

Parameters
[in]nameThe translated name of the option to update.
[in]valueThe new value to set.

Definition at line 260 of file GenericOptions.h.

References name, and options.

◆ toJSONNode()

virtual JSONNode GenericOptionGroup::toJSONNode ( bool only_value = true) const
nodiscardvirtual

Serializes this option group to a JSON node.

Parameters
[in]only_valueWhether to serialize only the current values or include metadata.
Returns
A JSONNode representing this option group.

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