Blue Brain BioExplorer
core::PropertyMap Class Reference

#include <PropertyMap.h>

Public Member Functions

 PropertyMap ()=default
 
 PropertyMap (const std::string &name)
 
 PropertyMap (const PropertyMap &other)=default
 
 PropertyMap (PropertyMap &&other) noexcept
 
PropertyMapoperator= (PropertyMap other) noexcept
 
bool empty () const
 
const auto & getName () const
 
template<typename T >
void updateProperty (const std::string &name, const T &t)
 
void setProperty (const Property &newProperty)
 
template<typename T >
getProperty (const std::string &name, T valIfNotFound) const
 
template<typename T >
getProperty (const std::string &name) const
 
bool hasProperty (const std::string &name) const
 
const auto & getEnums (const std::string &name) const
 
Property::Type getPropertyType (const std::string &name) const
 
const auto & getMetaData (const std::string &name) const
 
const auto & getProperties () const
 
void merge (const PropertyMap &input)
 
void update (const PropertyMap &input)
 
bool parse (int argc, const char **argv)
 

Detailed Description

Container class for holding properties that are mapped by name to a supported C++ type and their respective value.

Definition at line 262 of file PropertyMap.h.

Constructor & Destructor Documentation

◆ PropertyMap() [1/4]

core::PropertyMap::PropertyMap ( )
default

◆ PropertyMap() [2/4]

core::PropertyMap::PropertyMap ( const std::string &  name)
inline

Definition at line 266 of file PropertyMap.h.

◆ PropertyMap() [3/4]

core::PropertyMap::PropertyMap ( const PropertyMap other)
default

◆ PropertyMap() [4/4]

core::PropertyMap::PropertyMap ( PropertyMap &&  other)
inlinenoexcept

Definition at line 275 of file PropertyMap.h.

Member Function Documentation

◆ empty()

bool core::PropertyMap::empty ( ) const
inline

Definition at line 288 of file PropertyMap.h.

◆ getEnums()

const auto& core::PropertyMap::getEnums ( const std::string &  name) const
inline
Returns
the enum values for the given property, empty if no enum property.

Definition at line 349 of file PropertyMap.h.

◆ getMetaData()

const auto& core::PropertyMap::getMetaData ( const std::string &  name) const
inline
Returns
the metadata for the given property.

Definition at line 365 of file PropertyMap.h.

◆ getName()

const auto& core::PropertyMap::getName ( ) const
inline
Returns
the name of this property map e.g. to name commandline option group

Definition at line 293 of file PropertyMap.h.

◆ getProperties()

const auto& core::PropertyMap::getProperties ( ) const
inline
Returns
all the registered properties.

Definition at line 373 of file PropertyMap.h.

◆ getProperty() [1/2]

template<typename T >
T core::PropertyMap::getProperty ( const std::string &  name) const
inline
Returns
the property value of the given name
Exceptions
std::runtime_errorif value property value was not found.

Definition at line 335 of file PropertyMap.h.

◆ getProperty() [2/2]

template<typename T >
T core::PropertyMap::getProperty ( const std::string &  name,
valIfNotFound 
) const
inline
Returns
the property value of the given name or valIfNotFound otherwise.

Definition at line 323 of file PropertyMap.h.

◆ getPropertyType()

Property::Type core::PropertyMap::getPropertyType ( const std::string &  name) const
inline
Returns
the type of the given property name.

Definition at line 357 of file PropertyMap.h.

◆ hasProperty()

bool core::PropertyMap::hasProperty ( const std::string &  name) const
inline
Returns
true if the property with the given name exists.

Definition at line 343 of file PropertyMap.h.

◆ merge()

void core::PropertyMap::merge ( const PropertyMap input)

Merge this property map with properties from another.

Exceptions
std::runtimeerror if a property with the same name but incompatible types is found in both maps.

Definition at line 256 of file PropertyMap.cpp.

◆ operator=()

PropertyMap& core::PropertyMap::operator= ( PropertyMap  other)
inlinenoexcept

Definition at line 281 of file PropertyMap.h.

◆ parse()

bool core::PropertyMap::parse ( int  argc,
const char **  argv 
)

Parse and fill values from the commandline.

Options are added by converting the camelCase property name to hyphenated-case.

Integer enums are handled by matching the string to int value from the index in the enums vector of the property.

Parameters
argcnumber of commandline arguments
argvlist of strings of commandline arguments
Returns
true if parsing went without errors for no '–help', false otherwise and error(s) or 'help' will be printed.

Definition at line 278 of file PropertyMap.cpp.

◆ setProperty()

void core::PropertyMap::setProperty ( const Property newProperty)
inline

Update or add the given property.

Definition at line 307 of file PropertyMap.h.

◆ update()

void core::PropertyMap::update ( const PropertyMap input)

Take the values from another property map only for properties that are known and compatible to this one.

Exceptions
std::runtimeerror if a property with the same name but incompatible types is found in both maps.

Definition at line 269 of file PropertyMap.cpp.

◆ updateProperty()

template<typename T >
void core::PropertyMap::updateProperty ( const std::string &  name,
const T &  t 
)
inline

Update the property of the given name

Definition at line 296 of file PropertyMap.h.


The documentation for this class was generated from the following files: