3#include <NDEVR/Pointer.h>
4#include <NDEVR/TypeInfo.h>
5#include <NDEVR/String.h>
7#include <NDEVR/TranslatedString.h>
8#include <NDEVR/Dictionary.h>
9#include <NDEVR/Resource.h>
96 template<
class t_type>
113 template<
class t_type>
116 return value.get().getAs<t_type>();
122 template<
class t_type>
123 void set(
const t_type& new_value)
141 return value.set(new_value);
218 template<
class t_type>
231 lib_assert(!
options.hasKey(option.
id),
"Bad Option");
251 return options.hasKey(option_name);
259 template<
class t_type>
262 lib_assert(
options.hasKey(
name.readableID()),
"Bad Option");
270 template<
class t_type>
282 lib_assert(
options.hasKey(option.
id),
"Bad Option");
312 template<
class t_type>
315 return options.get(
name.readableID()).getAs<t_type>();
322 template<
class t_type>
334 template<
class t_type>
339 return iter.value().getAs<t_type>();
341 return value_if_not_exist;
349 template<
class t_type>
354 return iter.value().getAs<t_type>();
356 return value_if_not_exist;
A specification of upper and lower bounds in N-dimensions.
The equivelent of std::vector but with a bit more control.
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
A hash-based key-value store, useful for quick associative lookups.
virtual void fromJSONNode(const JSONNode &node)
Deserializes this option group from a JSON node.
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 ex...
void setOption(const GenericOption &option)
Replaces an existing option with the given GenericOption, matched by its identifier.
void setValue(const StringView &name, const t_type &value)
Sets the value of an existing option identified by its string name.
TranslatedString name
The user-facing display name of this option group.
GenericOption & getOption(const TranslatedString &n)
Retrieves a mutable reference to the option with the given translated name.
Dictionary< String, GenericOption > options
The dictionary mapping option identifiers to their GenericOption instances.
String id
The unique identifier for this option group.
void addOption(const GenericOption &option)
Adds a fully configured GenericOption to this group.
void addOptionsToINI(INIFactory &factory)
Adds all options in this group to an existing INIFactory for serialization.
INIFactory ini()
Creates an INIFactory for serializing this option group to INI format.
const GenericOption & getOption(const TranslatedString &n) const
Retrieves a const reference to the option with the given translated name.
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.
Buffer< String > ordered_options
The insertion-ordered list of option identifiers for preserving display order.
virtual ~GenericOptionGroup()
Virtual destructor.
void setValue(const TranslatedString &name, const t_type &value)
Sets the value of an existing option identified by its translated name.
bool hasOption(const StringView &option_name) const
Checks whether an option with the given string identifier exists in this group.
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 exis...
t_type getValue(const TranslatedString &name) const
Retrieves the value of an option converted to the requested type, looked up by translated name.
void clear()
Removes all options from this group.
virtual JSONNode toJSONNode(bool only_value=true) const
Serializes this option group to a JSON node.
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.
GenericOptionGroup()=default
Default constructor.
t_type getValue(const StringView &name) const
Retrieves the value of an option converted to the requested type, looked up by string identifier.
bool hasOption(const TranslatedString &option_name) const
Checks whether an option with the given translated name exists in this group.
GenericOptionGroup(const TranslatedString &group_name, const StringView &group_id=StringView())
Constructs an option group with the given name and optional identifier.
Contains methods for easily reading and writing to an INI file including efficient casting,...
A light-weight base class for Log that allows processes to update, without the need for additional in...
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
const String readableID() const
Returns a human-readable identifier for this translated string, useful for debugging.
Stores information about a type, relevant for certain templated functions.
The primary namespace for the NDEVR SDK.
constexpr std::enable_if<!ObjectInfo< t_type >::Buffer, TypeInfo >::type GetTypeInfo()
Constructs a TypeInfo for a non-buffer type at compile time using ObjectInfo traits.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Stores a generic option of any type as well as some information about how the user might interact wit...
GenericOption(const GenericOption &option)
Copy constructor.
GenericOption(const StringView &id, const TranslatedString &name, const t_type &value)
Constructs a GenericOption with the given identifier, display name, and typed value.
Bounds< 1, fltp08 > value_bounds
The numeric bounds constraining valid values for this option.
bool is_create_file
Whether this option represents a file path for creating a new file.
bool is_viewable
Whether this option is visible in the user interface.
String id
A unique identifier string for this option.
Resource< String > value
The current value of the option stored as a string Resource.
bool allow_multi_line
Whether the option value supports multi-line text input.
TypeInfo parameter_type
The type information describing the underlying data type of this option.
void setupForDelimiter()
Sets this option up for being a delimiter, commas, tabs, etc or custom.
TranslatedString description
A user-facing description of what this option controls.
bool is_password
Whether this option represents a password and should be masked.
void setupForFolder()
Sets this option up for being a folder, including the regax and extension.
void setToDefault()
Resets the option value back to its default.
GenericOption(const StringView &id, const TranslatedString &name, const StringView &value)
Constructs a GenericOption with the given identifier, display name, and string value.
TranslatedString name
The user-facing display name of the option.
String password_encode_key
The key used for password encoding when this option is a password.
void setupForFile(const StringView &extensions=StringView())
Sets this option up for being a file, including the regax and extension.
String file_extensions
Allowed file extensions for file-type options. If blank, the option is not a file.
String regex
A regular expression used to validate the option value.
GenericOption & operator=(const GenericOption &option)
Copy assignment operator.
void set(const String &new_value)
Sets the option value from a String.
bool is_editable
Whether the user is allowed to edit this option.
String default_value
The default value to revert to when resetting the option.
bool operator!=(const GenericOption &option) const
Checks inequality by comparing the current string values of two options.
Buffer< std::pair< TranslatedString, StringAllocatingView > > available_options
The set of predefined choices available for this option.
ConstPointer< Unit > unit
The unit of measurement associated with this option value.
void set(const StringView &new_value)
Sets the option value from a StringView.
bool allow_custom_option
Whether the user may enter a custom value outside the predefined choices.
t_type getAs() const
Retrieves the current value converted to the requested type.
bool operator==(const GenericOption &option) const
Checks equality by comparing the current string values of two options.
void set(const t_type &new_value)
Sets the option value from the given typed value by converting it to a String.
bool show_resolved_links
Whether to display resolved link paths instead of raw values.
GenericOption()
Constructs a default GenericOption with no values set.
String icon
The icon name associated with this option for display purposes.