Abstract, virtual struct which provides meta-information about types storable in the StringTree nodes of class Configuration. A pointer to a singleton of this type is stored together with a reinterpreted pointer to the custom data record.
To register a custom data type with the configuration system, this type has to inherited and all methods implemented. It is recommended to define custom derived types using macro ALIB_VARIABLES_DEFINE_TYPE. Derived types are to be registered with the configuration instance by invoking void RegisterType() .
Public Method Index: | |
| virtual | ~VMeta () |
| Virtual empty destructor. | |
| virtual void | construct (detail::VDATA *memory, PoolAllocator &pool)=0 |
| virtual const std::type_info & | dbgTypeID ()=0 |
| virtual void | destruct (detail::VDATA *memory, PoolAllocator &pool)=0 |
| virtual void | exPort (detail::VDATA *data, Configuration &cfg, const StringEscaper &escaper, AString &dest)=0 |
| virtual void | imPort (detail::VDATA *data, Configuration &cfg, const StringEscaper &escaper, const String &src)=0 |
| virtual bool | isWriteBack (detail::VDATA *data) const |
| virtual size_t | size ()=0 |
| virtual String | typeName () const =0 |
|
inlinevirtual |
|
pure virtual |
Abstract virtual method. Descendants need to construct a custom instance at the given memory. This is done using a "placement-new" as follows:
new (memory) MyType();
The pool allocator is not provided to allocate the custom type itself (this was already done before calling this method). Instead, it may be used to allocate members in the custom type. It may also be passed to the instance for further use during it's lifecycle. However, in this case chapter 11. Multi-Threading / Racing Conditions of the Programmer's Manual has to be considered.
| memory | The pointer to the object of custom type. |
| pool | The object pool of the configuration. May be used to dispose pool objects. |
|
pure virtual |
Abstract virtual method. Descendants need to return the std::type_info& received with typeid(). This method is available only in debug-compilations and is used to assert that the correct types are read from declared variables.
Types declared with macro ALIB_VARIABLES_DEFINE_TYPE implement this method rightfully.
|
pure virtual |
Abstract virtual method. Descendants need to destruct a custom instance at the given memory. This is done by calling the destructor as follows:
reinterpret_cast<MyTypeName*>(memory)->~MyTypeName();
The pool allocator is not provided to free the custom type itself (this will be done automatically right after the call to this method). Instead, it may be used to free members of the type, which had been allocated during construction or during the use.
construct has to be implemented to pass the pool object to the members, but this method simply invokes the destructor of the custom type as shown above.| memory | The place to construct the custom type at. |
| pool | The object pool of the configuration. May be used to allocate pool objects. |
|
pure virtual |
Abstract virtual method. Descendants need to implement this method. It is invoked when a variable is written into an external configuration source (in this case 'drain') or otherwise needs to be serialized.
Note that export functions are allowed to add NEW_LINE codes into the export string. This allows external configuration systems to nicely format their entries, in case those are human-readable. See chapter 7.4 Attaching a Custom Configuration System of the Programmer's Manual for more information.
| data | A pointer to the user type which is to be serialized. |
| cfg | The configuration that holds the variable. |
| escaper | An escaper to be used to escape strings. |
| dest | The destination string. Must not be reset prior writing, but appended. |
|
pure virtual |
Abstract virtual method. Descendants need to implement this method and de-serialize (aka parse) the custom type from the given string value.
| data | A pointer to the user type which is to be initialized. |
| cfg | The configuration that holds the variable. |
| escaper | An escaper to be used to convert external strings to C++ native strings. |
| src | The source string to parse. This may be assigned to a value of type TSubstring which already provides simple parser mechanics. Likewise, TTokenizer might be an easy helper to be used for parsing. |
|
inlinevirtual |
Virtual method which returns false in its default version. Descendants may return true, if the values should automatically be written back to configuration data sources, if such sources support this. Of course, instead of returning a fixed value, implementations may also return a value stored in the given data struct.
The value can be requested with method bool IsWriteBack() const. The macro ALIB_VARIABLES_DEFINE_TYPE is not enabled to override this method. Hence, variables that should support this flag, need to define their type without the help of this macro.
| data | A pointer to the user data struct. |
true if configuration systems should write values of this variable back.
|
pure virtual |
Abstract virtual method. Descendants need to return 'sizeof(T)', with T being the custom type. Types declared with macro ALIB_VARIABLES_DEFINE_TYPE implement this method rightfully. With that, it is also asserted that the alignment of the custom type is not greater than 'alignof(uint64_t)', respectively not greater than what is specified with the configuration macro ALIB_MONOMEM_POOLALLOCATOR_DEFAULT_ALIGNMENT.
|
pure virtual |
Abstract virtual method. Descendants need to return the type name they care of.
Types declared with macro ALIB_VARIABLES_DEFINE_TYPE implement this method rightfully.