MTC
|
#include <properties.h>
Public Types | |
using | iterator = std::map< std::string, Property >::iterator |
using | const_iterator = std::map< std::string, Property >::const_iterator |
Public Member Functions | |
template<typename T > | |
Property & | declare (const std::string &name, const std::string &description="") |
declare a property for future use | |
template<typename T > | |
Property & | declare (const std::string &name, const T &default_value, const std::string &description="") |
declare a property with default value | |
void | exposeTo (PropertyMap &other, const std::set< std::string > &properties) const |
declare all given properties also in other PropertyMap | |
void | exposeTo (PropertyMap &other, const std::string &name, const std::string &other_name) const |
declare given property name as other_name in other PropertyMap | |
bool | hasProperty (const std::string &name) const |
check whether given property is declared | |
Property & | property (const std::string &name) |
get the property with given name, throws Property::undeclared for unknown name | |
const Property & | property (const std::string &name) const |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
void | configureInitFrom (Property::SourceFlags source, const std::set< std::string > &properties={}) |
allow initialization from given source for listed properties - always using the same name | |
template<typename T > | |
void | set (const std::string &name, const T &value) |
set (and, if neccessary, declare) the value of a property | |
void | set (const std::string &name, const char *value) |
overloading: const char* is stored as std::string | |
void | setCurrent (const std::string &name, const boost::any &value) |
temporarily set the value of a property | |
const boost::any & | get (const std::string &name) const |
Get the value of a property. Throws undeclared if unknown name. | |
template<typename T > | |
const T & | get (const std::string &name) const |
Get typed value of property. Throws undeclared, undefined, or bad_any_cast. | |
template<typename T > | |
const T & | get (const std::string &name, const T &fallback) const |
get typed value of property, using fallback if undefined. Throws bad_any_cast on type mismatch. | |
size_t | countDefined (const std::vector< std::string > &list) const |
count number of defined properties from given list | |
void | reset () |
reset all properties to their defaults | |
void | performInitFrom (Property::SourceFlags source, const PropertyMap &other) |
perform initialization of still undefined properties using configured initializers | |
template<> | |
void | set (const std::string &name, const boost::any &value) |
PropertyMap is map of (name, Property) pairs.
Conveniency methods are provided to setup property initialization for several properties at once - always inheriting from the identically named external property.