44 #ifndef _ConfigValueContainer_H__ 45 #define _ConfigValueContainer_H__ 60 virtual void call(
void*
object) = 0;
70 virtual inline void call(
void*
object)
override 73 (
static_cast<T*
>(object)->*this->function_)();
110 template <
class D,
class V>
113 this->init(type, identifier, sectionname, varname);
114 this->initValue(static_cast<V>(defvalue));
126 template <
class D,
class V>
129 this->init(type, identifier, sectionname, varname);
132 for (
const D& defvalueElement : defvalue)
133 this->valueVector_.emplace_back(defvalueElement);
146 template <
typename T,
class C>
149 if ((this->callback_ &&
object) || this->bContainerIsNew_)
152 this->value_.getValue(value);
153 if (this->bContainerIsNew_ || (*value) != temp)
155 this->bContainerIsNew_ =
false;
156 if (this->callback_ &&
object)
157 this->callback_->call(
object);
159 this->bDoInitialCallback_ =
true;
164 this->value_.getValue(value);
175 template <
typename T,
class C>
178 if ((this->callback_ &&
object) || this->bContainerIsNew_)
180 if (this->bContainerIsNew_)
181 this->bContainerIsNew_ =
false;
183 std::vector<T> temp = *value;
185 for (
const MultiType& vectorEntry : this->valueVector_)
186 value->push_back(vectorEntry);
188 if (value->size() != temp.size())
190 if (this->callback_ &&
object)
191 this->callback_->call(
object);
193 this->bDoInitialCallback_ =
true;
197 for (
unsigned int i = 0; i < value->size(); ++i)
199 if ((*value)[i] != temp[i])
201 if (this->callback_ &&
object)
202 this->callback_->call(
object);
204 this->bDoInitialCallback_ =
true;
213 for (
const MultiType& vectorEntry : this->valueVector_)
214 value->push_back(vectorEntry);
221 {
return this->varname_; }
224 {
return this->sectionname_; }
227 {
return this->identifier_; }
230 {
return this->bIsVector_; }
233 {
return this->valueVector_.size(); }
246 if (!this->callback_)
250 if (this->bDoInitialCallback_)
252 this->bDoInitialCallback_ =
false;
253 this->callback_->
call(
object);
263 bool set(
unsigned int index,
const MultiType& input);
264 bool tset(
unsigned int index,
const MultiType& input);
266 bool remove(
unsigned int index);
273 {
return this->value_; }
276 {
return this->value_.getTypename(); }
280 void initValue(
const MultiType& defvalue);
ConfigValueContainer & callback(T *object, void(T::*function)(void))
Adds a callback function, that gets called after getValue() if the newly assigned value differs from ...
Definition: ConfigValueContainer.h:244
The ConfigValuecontainer contains all needed information about a configurable variable.
Definition: ConfigValueContainer.h:98
std::string toString() const
Converts the config-value to a string.
Definition: ConfigValueContainer.h:272
virtual ~ConfigValueCallbackBase()
Definition: ConfigValueContainer.h:61
ConfigValueContainer(ConfigFileType::Value type, Identifier *identifier, const std::string §ionname, const std::string &varname, const D &defvalue, const V &value)
Constructor: Converts the default-value to a string, checks the config-file for a changed value...
Definition: ConfigValueContainer.h:111
ConfigFileType::Value type_
The type of the corresponding config-file.
Definition: ConfigValueContainer.h:286
unsigned int getVectorSize() const
Returns the vectors size (or zero if it's not a vector).
Definition: ConfigValueContainer.h:232
Definition: InputPrereqs.h:90
MultiType value_
The value.
Definition: ConfigValueContainer.h:293
Shared library macros, enums, constants and forward declarations for the core library ...
::std::string string
Definition: gtest-port.h:756
bool bAddedDescription_
True if a description was added.
Definition: ConfigValueContainer.h:296
std::vector< MultiType > valueVector_
A vector, containg the values in case we're storing a vector.
Definition: ConfigValueContainer.h:294
ConfigValueContainer & getValue(std::vector< T > *value, C *object)
Returns the configured vector.
Definition: ConfigValueContainer.h:176
std::vector< std::string > defvalueStringVector_
A vector, containg the strings of the default-values in case we're storing a vector.
Definition: ConfigValueContainer.h:291
std::string getTypename() const
Returns the typename of the assigned config-value.
Definition: ConfigValueContainer.h:275
virtual void call(void *object) override
Definition: ConfigValueContainer.h:70
Identifier * getIdentifier() const
Returns the associated identifier (can be nullptr).
Definition: ConfigValueContainer.h:226
ConfigValueContainer(ConfigFileType::Value type, Identifier *identifier, const std::string §ionname, const std::string &varname, const std::vector< D > &defvalue, const std::vector< V > &value)
Constructor: Converts the default-value to a string, checks the config-file for a changed value...
Definition: ConfigValueContainer.h:127
Definition: InputPrereqs.h:104
Identifier * identifier_
The identifier of the class.
Definition: ConfigValueContainer.h:287
Value
Definition: CorePrereqs.h:113
std::string defvalueString_
The string of the default-value.
Definition: ConfigValueContainer.h:290
Declaration of Identifier, definition of ClassIdentifier<T>; used to identify the class of an object...
typedef void(ENET_CALLBACK *ENetPacketFreeCallback)(struct _ENetPacket *)
bool bIsVector_
True if the container contains a std::vector.
Definition: ConfigValueContainer.h:284
LanguageEntryLabel description_
The description.
Definition: ConfigValueContainer.h:297
bool bContainerIsNew_
True if it's the first time getValue() gets called.
Definition: ConfigValueContainer.h:300
ConfigValueCallback(void(T::*function)(void))
Definition: ConfigValueContainer.h:68
const std::string & getSectionName() const
Returns the name of the section this config value is in.
Definition: ConfigValueContainer.h:223
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Declaration of the MultiType and some helper constructs.
#define _CoreExport
Definition: CorePrereqs.h:61
Definition: ConfigValueContainer.h:57
Definition: ConfigValueContainer.h:65
The MultiType can hold a value of many possible types and convert them to other types.
Definition: MultiType.h:130
The Identifier is used to identify the class of an object and to store information about the class...
Definition: Identifier.h:109
Definition: InputPrereqs.h:105
Definition: InputPrereqs.h:78
bool isVector() const
Returns true if this config-value is a vector.
Definition: ConfigValueContainer.h:229
std::string sectionname_
The name of the class the variable belongs to.
Definition: ConfigValueContainer.h:288
ConfigValueContainer & getValue(T *value, C *object)
Returns the configured value.
Definition: ConfigValueContainer.h:147
virtual void call(void *object)=0
bool bDoInitialCallback_
True if the callback should be called as soon as it gets created.
Definition: ConfigValueContainer.h:301
std::string LanguageEntryLabel
Definition: CorePrereqs.h:141
static IdentifierManager & getInstance()
Returns a reference to the singleton instance.
Definition: Singleton.h:118
ConfigValueCallbackBase * callback_
A callback function to call after getValue if the value changed.
Definition: ConfigValueContainer.h:298
std::string varname_
The name of the variable.
Definition: ConfigValueContainer.h:289
const std::string & getName() const
Returns the name of this container.
Definition: ConfigValueContainer.h:220