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>
60 template<
class t_type>
65 , default_value(
String(value))
70 , description(option.description)
72 , value(option.value.get())
73 , default_value(option.default_value)
74 , file_extensions(option.file_extensions)
77 , parameter_type(option.parameter_type)
78 , available_options(option.available_options)
79 , value_bounds(option.value_bounds)
81 , allow_custom_option(option.allow_custom_option)
82 , is_editable(option.is_editable)
83 , is_viewable(option.is_viewable)
85 template<
class t_type>
86 [[nodiscard]] t_type
getAs()
const
88 return value.get().getAs<t_type>();
90 template<
class t_type>
91 void set(
const t_type& new_value)
93 return value.set(
String(new_value));
97 return value.set(new_value);
101 value.set(default_value);
105 return option.
value.get() == value.get();
109 return option.
value.get() != value.get();
119 regex = option.
regex;
128 value.set(option.
value.get());
143 bool allow_custom_option =
false;
144 bool is_editable =
true;
145 bool is_viewable =
true;
156 template<
class t_type>
166 options.add(option.
id, option);
167 ordered_options.add(option.
id);
175 return options.hasKey(option_name);
178 template<
class t_type>
184 template<
class t_type>
187 lib_assert(options.hasKey(name),
"Bad Option");
188 options[name].value.set(
String(value));
193 if (!options.hasKey(option.
id))
194 ordered_options.add(option.
id);
195 options[option.
id] = option;
207 template<
class t_type>
212 template<
class t_type>
215 return options.get(name).getAs<t_type>();
218 template<
class t_type>
222 if (iter != options.end())
223 return iter.value().getAs<t_type>();
225 return value_if_not_exist;
227 template<
class t_type>
230 auto iter = options.find(name);
231 if (iter != options.end())
232 return iter.value().getAs<t_type>();
234 return value_if_not_exist;
#define lib_assert(expression, message)
Definition LibAssert.h:61
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:52
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition GraphicsPipeline.h:42
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
Stores a groups of GenericOptions that can be used to group them.
Definition GenericOptions.h:151
bool hasOption(const String &option_name) const
Definition GenericOptions.h:173
virtual JSONNode toJSONNode(bool only_value=true) const
bool operator==(const GenericOptionGroup &option_group) const
t_type getValue(const TranslatedString &name, const t_type &value_if_not_exist) const
Definition GenericOptions.h:219
void addOption(const GenericOption &option)
Definition GenericOptions.h:163
t_type getValue(const TranslatedString &name) const
Definition GenericOptions.h:208
GenericOption & getOption(const TranslatedString &n)
Definition GenericOptions.h:202
t_type getValue(const String &name) const
Definition GenericOptions.h:213
void setValue(const TranslatedString &name, const t_type &value)
Definition GenericOptions.h:179
bool hasOption(const TranslatedString &option_name) const
Definition GenericOptions.h:169
const GenericOption & getOption(const TranslatedString &n) const
Definition GenericOptions.h:198
TranslatedString name
Definition GenericOptions.h:245
GenericOptionGroup(const TranslatedString &group_name, const String &group_id=String())
bool operator!=(const GenericOptionGroup &option_group) const
GenericOptionGroup()=default
String id
Definition GenericOptions.h:246
Buffer< String > ordered_options
Definition GenericOptions.h:244
void addOptionsToINI(INIFactory &factory)
void setValue(const String &name, const t_type &value)
Definition GenericOptions.h:185
Dictionary< String, GenericOption > options
Definition GenericOptions.h:243
virtual void fromJSONNode(const JSONNode &node)
t_type getValue(const String &name, const t_type &value_if_not_exist) const
Definition GenericOptions.h:228
void addOption(const TranslatedString &name, const t_type &value, bool is_editable=true)
Definition GenericOptions.h:157
virtual ~GenericOptionGroup()
void setOption(const GenericOption &option)
Definition GenericOptions.h:190
Contains methods for easily reading and writing to an INI file including efficient casting,...
Definition INIReader.h:68
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
Definition JSONParser.h:60
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
Definition Toggle.h:41
The core String class for the NDEVR API.
Definition String.h:69
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
const String & translationID() const
Stores information about a type, relevant for certain templated functions. To get information about a...
Definition TypeInfo.h:43
constexpr std::enable_if<!ObjectInfo< t_type >::Buffer, TypeInfo >::type GetTypeInfo()
Definition TypeInfo.h:103
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
Stores a generic option of any type as well as some information about how the user might interact wit...
Definition GenericOptions.h:57
GenericOption & operator=(const GenericOption &option)
Definition GenericOptions.h:111
String icon
Definition GenericOptions.h:137
bool allow_custom_option
Definition GenericOptions.h:143
String regex
Definition GenericOptions.h:138
bool is_viewable
Definition GenericOptions.h:145
GenericOption(const String &id, const TranslatedString &name, const String &value)
void setToDefault()
Definition GenericOptions.h:99
Resource< String > value
Definition GenericOptions.h:134
TranslatedString description
Definition GenericOptions.h:132
TranslatedString name
Definition GenericOptions.h:131
ConstPointer< Unit > unit
Definition GenericOptions.h:142
String id
Definition GenericOptions.h:133
Buffer< std::pair< TranslatedString, String > > available_options
Definition GenericOptions.h:140
GenericOption(const String &id, const TranslatedString &name, const t_type &value)
Definition GenericOptions.h:61
bool is_editable
Definition GenericOptions.h:144
t_type getAs() const
Definition GenericOptions.h:86
GenericOption(const GenericOption &option)
Definition GenericOptions.h:68
bool operator==(const GenericOption &option) const
Definition GenericOptions.h:103
void set(const String &new_value)
Definition GenericOptions.h:95
void set(const t_type &new_value)
Definition GenericOptions.h:91
bool operator!=(const GenericOption &option) const
Definition GenericOptions.h:107
String default_value
Definition GenericOptions.h:135
TypeInfo parameter_type
Definition GenericOptions.h:139
Bounds< 1, fltp08 > value_bounds
Definition GenericOptions.h:141
String file_extensions
Definition GenericOptions.h:136