3#include <NDEVR/String.h>
4#include <NDEVR/GenericOption.h>
5#include <NDEVR/INIFactory.h>
6#include <NDEVR/Dictionary.h>
90 lib_assert(!
m_options[group_name].hasKey(
name),
"Duplicate entry");
169 template<
class t_type>
226 template<
class t_other_type = t_type>
227 decltype(
auto)
get()
const
246 void set(
const t_type& value,
bool make_default =
false)
269 m_value.addListener(listener, silent_add);
The core of the default object to store data of any type that should persist through sessions of the ...
virtual ~ApplicationOptionBase()
Destructor.
virtual StringAllocatingView toString() const =0
Converts the stored option value to a string representation.
virtual INIOption * iniOption()=0
Creates an INIOption representation of this option for INI file serialization.
virtual bool isDefault() const =0
Checks whether the current value matches the default value.
virtual void fromString(const String &)=0
Sets the option value by parsing the given string.
virtual void setToDefaultValue()=0
Resets the option value back to its default.
const TranslatedString m_label
The display label identifying this option.
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.
virtual void setToDefaultValue() override
Resets the option value back to its default.
t_type m_default_value
The default value used for reset operations.
const TranslatedString & group() const
Returns the translated group name for this option.
const TranslatedString m_group
The group this option belongs to for categorization.
const TranslatedString & label() const
Returns the translated display label for this option.
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.
decltype(auto) get() const
Retrieves the current value of this option.
virtual void fromString(const String &value) override
Sets the option value by parsing the given string.
ApplicationOption(const TranslatedString &label, const t_type &value, ApplicationOptions &options=ApplicationOptions::UserOptions())
Constructs an ApplicationOption with no group, using the default group.
void addListener(ResourceListener *listener, bool silent_add=false)
Registers a ResourceListener to be notified when this option's value changes.
void setDefaultValue(const t_type &value)
Updates the default value without changing the current value.
ApplicationOptions & m_options
Reference to the owning ApplicationOptions container.
Resource< t_type > & getResource()
Returns a reference to the underlying Resource holding this option's value.
void set(const t_type &value, bool make_default=false)
Sets the option to a new value, optionally updating the default as well.
virtual bool isDefault() const override
Checks whether the current value matches the default value.
virtual StringAllocatingView toString() const override
Converts the stored option value to a string representation.
Resource< t_type > m_value
The resource holding the current option value.
virtual INIOption * iniOption() override
Creates an INIOption representation of this option for INI file serialization.
The container for storing N-number of ApplicationOption for the program.
Dictionary< TranslatedString, ApplicationOptionBase * > optionGroup(TranslatedString)
Returns all options belonging to a specific group.
void logOptions(LogPtr &log, bool log_only_non_defaults)
Writes option names and values to the given log.
void addToINI(INIFactory &factory)
Serializes all option groups into the given INI factory.
Dictionary< TranslatedString, Dictionary< TranslatedString, ApplicationOptionBase * > > m_options
Nested dictionary mapping group names to option dictionaries.
void addToINI(const TranslatedString &group_name, INIFactory &factory)
Serializes a specific option group into the given INI factory.
const ApplicationOptionBase * getOption(const TranslatedString &name) const
Retrieves an option from the default group by name.
static ApplicationOptions & UserOptions()
Returns the global user options container singleton.
void setToDefaults(const TranslatedString &group_name)
Resets all options in a specific group to their default values.
const ApplicationOptionBase * getOption(const TranslatedString &group, const TranslatedString &name) const
Retrieves an option by group and name.
void addOption(const TranslatedString &group_name, const TranslatedString &name, ApplicationOptionBase *value)
Adds an option under a specific group name.
void addOption(const TranslatedString &name, ApplicationOptionBase *value)
Adds an option with no group, placing it in the default group.
void setToDefaults()
Resets all options across all groups to their default values.
ApplicationOptions()
Constructs an empty ApplicationOptions container.
A hash-based key-value store, useful for quick associative lookups.
Contains methods for easily reading and writing to an INI file including efficient casting,...
static INIOption * ToOption(t_type &mem_loc)
Creates an INIOption wrapper for a raw typed variable.
A class used with INIFactory to store a reference to an object in the program that can be inherited t...
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
A class that can subscribe to any number of Resources which will get updates when the Resource(s) hav...
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
This class is like a string view, but may optionally store the data internally Useful if the return t...
The core String class for the NDEVR API.
decltype(auto) getAs() const
Converts a string into an object.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
@ name
The display name of the object.