Darwin Neuroevolution Framework
|
The foundation for data structures supporting runtime reflection. More...
#include <properties.h>
Public Member Functions | |
vector< Property * > | properties () |
Accessor to the list of properties. | |
vector< const Property * > | properties () const |
Accessor to the list of properties. | |
void | resetToDefaultValues () |
Resets all the properties to the default values. | |
void | copyFrom (const PropertySet &src) |
Transfer values between two property sets. | |
void | seal (bool sealed=true) |
After sealing a PropertySet, all attempts to modify it through the Property interface will throw an exception (even if setting to the same value) | |
bool | sealed () const |
Returns true if the property set is sealed. | |
void | onPropertyChange (const Property *property) |
Called before updating a property value. | |
json | toJson () const |
Serialize all the properties to a json object. More... | |
void | fromJson (const json &json_obj) |
Deserialize a set of properties from a json object. More... | |
The foundation for data structures supporting runtime reflection.
PropertySet provides portable-C++ support for structures containing self-describing properties (no build time pre-processing or external tools are required, this is a compiler-only solution)
In order to support the runtime reflection, a structure must derive from core::Properties. The individual properties are then declared using the PROPERTY() macro, for example:
This zero-overhead compared with regular C++ structs was one of the key requirements, since the reflected structures are commonly configuration values which could be read on the hot paths (in contrast, the high PropertySet instantiation cost and the reflection path overhead were deemed acceptable)
|
inline |
Deserialize a set of properties from a json object.
The deserialization is not strict:
|
inline |
Serialize all the properties to a json object.