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>
56 template<
class t_type>
61 , default_value(
String(value))
66 , description(option.description)
68 , value(option.value.get())
69 , default_value(option.default_value)
70 , file_extensions(option.file_extensions)
73 , parameter_type(option.parameter_type)
74 , available_options(option.available_options)
75 , value_bounds(option.value_bounds)
77 , allow_custom_option(option.allow_custom_option)
78 , is_editable(option.is_editable)
79 , is_viewable(option.is_viewable)
81 template<
class t_type>
82 [[nodiscard]] t_type
getAs()
const
84 return value.
get().getAs<t_type>();
86 template<
class t_type>
87 void set(
const t_type& new_value)
89 return value.set(
String(new_value));
93 return value.set(new_value);
97 value.set(default_value);
101 return option.
value.get() == value.
get();
105 return option.
value.get() != value.
get();
115 regex = option.
regex;
124 value.set(option.
value.get());
139 bool allow_custom_option =
false;
140 bool is_editable =
true;
141 bool is_viewable =
true;
150 template<
class t_type>
160 options.add(option.
id, option);
161 ordered_options.add(option.
id);
169 return options.hasKey(option_name);
172 template<
class t_type>
178 template<
class t_type>
181 lib_assert(options.hasKey(name),
"Bad Option");
182 options[name].value.set(
String(value));
187 if (!options.hasKey(option.
id))
188 ordered_options.add(option.
id);
189 options[option.
id] = option;
201 template<
class t_type>
206 template<
class t_type>
209 return options.get(name).getAs<t_type>();
212 template<
class t_type>
216 if (iter != options.end())
217 return iter.value().getAs<t_type>();
219 return value_if_not_exist;
221 template<
class t_type>
224 auto iter = options.find(name);
225 if (iter != options.end())
226 return iter.value().getAs<t_type>();
228 return value_if_not_exist;
234 [[nodiscard]]
virtual JSONNode toJSONNode(
bool only_value =
true)
const;
235 virtual void fromJSONNode(
const JSONNode& node);
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
bool operator!=(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
Definition VulkanRenderObject.cpp:10
bool operator==(const VkVertexInputAttributeDescription &a, const VkVertexInputAttributeDescription &b)
Definition VulkanRenderObject.cpp:18
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:57
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
decltype(auto) get(t_index_type index)
Definition Buffer.hpp:857
Definition GraphicsPipeline.h:42
Definition Dictionary.h:48
Definition GenericOptions.h:145
bool hasOption(const String &option_name) const
Definition GenericOptions.h:167
t_type getValue(const TranslatedString &name, const t_type &value_if_not_exist) const
Definition GenericOptions.h:213
void addOption(const GenericOption &option)
Definition GenericOptions.h:157
t_type getValue(const TranslatedString &name) const
Definition GenericOptions.h:202
GenericOption & getOption(const TranslatedString &n)
Definition GenericOptions.h:196
t_type getValue(const String &name) const
Definition GenericOptions.h:207
void setValue(const TranslatedString &name, const t_type &value)
Definition GenericOptions.h:173
bool hasOption(const TranslatedString &option_name) const
Definition GenericOptions.h:163
const GenericOption & getOption(const TranslatedString &n) const
Definition GenericOptions.h:192
TranslatedString name
Definition GenericOptions.h:239
GenericOptionGroup()=default
String id
Definition GenericOptions.h:240
Buffer< String > ordered_options
Definition GenericOptions.h:238
void setValue(const String &name, const t_type &value)
Definition GenericOptions.h:179
Dictionary< String, GenericOption > options
Definition GenericOptions.h:237
t_type getValue(const String &name, const t_type &value_if_not_exist) const
Definition GenericOptions.h:222
void addOption(const TranslatedString &name, const t_type &value, bool is_editable=true)
Definition GenericOptions.h:151
void setOption(const GenericOption &option)
Definition GenericOptions.h:184
Definition INIReader.h:57
JavaScript Object Notation or JSON is an open - standard file format that uses human - readable text ...
Definition JSONParser.h:121
Definition TranslatedString.h:9
NDEVR_BASE_API const String & translationID() const
Definition TranslatedString.cpp:134
constexpr std::enable_if<!ObjectInfo< t_type >::Buffer, TypeInfo >::type GetTypeInfo()
Definition TypeInfo.h:99
Definition BaseValues.hpp:272
Definition GenericOptions.h:53
GenericOption & operator=(const GenericOption &option)
Definition GenericOptions.h:107
String icon
Definition GenericOptions.h:133
bool allow_custom_option
Definition GenericOptions.h:139
String regex
Definition GenericOptions.h:134
bool is_viewable
Definition GenericOptions.h:141
void setToDefault()
Definition GenericOptions.h:95
Resource< String > value
Definition GenericOptions.h:130
TranslatedString description
Definition GenericOptions.h:128
TranslatedString name
Definition GenericOptions.h:127
ConstPointer< Unit > unit
Definition GenericOptions.h:138
String id
Definition GenericOptions.h:129
Buffer< std::pair< TranslatedString, String > > available_options
Definition GenericOptions.h:136
GenericOption(const String &id, const TranslatedString &name, const t_type &value)
Definition GenericOptions.h:57
bool is_editable
Definition GenericOptions.h:140
t_type getAs() const
Definition GenericOptions.h:82
GenericOption(const GenericOption &option)
Definition GenericOptions.h:64
bool operator==(const GenericOption &option) const
Definition GenericOptions.h:99
void set(const String &new_value)
Definition GenericOptions.h:91
void set(const t_type &new_value)
Definition GenericOptions.h:87
bool operator!=(const GenericOption &option) const
Definition GenericOptions.h:103
String default_value
Definition GenericOptions.h:131
TypeInfo parameter_type
Definition GenericOptions.h:135
Bounds< 1, fltp08 > value_bounds
Definition GenericOptions.h:137
String file_extensions
Definition GenericOptions.h:132