Configuration
 All Classes Files Functions Pages
Public Member Functions | List of all members
o2::configuration::ConfigurationInterface Class Referenceabstract

Interface for configuration back ends. More...

#include <ConfigurationInterface.h>

Public Member Functions

virtual void putString (const std::string &path, const std::string &value)=0
 
virtual boost::optional
< std::string > 
getString (const std::string &path)=0
 
template<typename T >
void put (const std::string &path, const T &value)
 
virtual void putRecursive (const std::string &path, const boost::property_tree::ptree &tree)
 
template<typename T >
get (const std::string &path)
 
template<typename T >
get (const std::string &path, const T &defaultValue)
 
virtual void setPrefix (const std::string &prefix)=0
 
virtual KeyValueMap getRecursiveMap (const std::string &path={})=0
 
virtual boost::property_tree::ptree getRecursive (const std::string &path={})=0
 
template<>
void put (const std::string &path, const std::string &value)
 
template<>
void put (const std::string &path, const int &value)
 
template<>
void put (const std::string &path, const double &value)
 
template<>
std::string get (const std::string &path)
 
template<>
int get (const std::string &path)
 
template<>
double get (const std::string &path)
 
template<>
auto get (const std::string &path, const std::string &defaultValue) -> std::string
 
template<>
auto get (const std::string &path, const int &defaultValue) -> int
 
template<>
auto get (const std::string &path, const double &defaultValue) -> double
 

Detailed Description

Interface for configuration back ends.

Interface for configuration back-ends, to put and get configuration parameters.

To maintain runtime polymorphism, while also having a convenient template-like interface, the implementations of put/get operations are in the virtual methods.

Member Function Documentation

template<typename T >
T o2::configuration::ConfigurationInterface::get ( const std::string &  path)

Template convenience interface for get operations.

Parameters
pathThe path of the value
Returns
The retrieved value.
Exceptions
std::runtime_errorwhen value does not exist
template<typename T >
T o2::configuration::ConfigurationInterface::get ( const std::string &  path,
const T &  defaultValue 
)

Template convenience interface for get operations with a default value

Parameters
pathThe path of the value
defaultValuedefault value which is returned when requested key does not exist
virtual boost::property_tree::ptree o2::configuration::ConfigurationInterface::getRecursive ( const std::string &  path = {})
pure virtual

Provides subtree from given path

Parameters
pathThe path to the subtree
Returns
Subtree
virtual KeyValueMap o2::configuration::ConfigurationInterface::getRecursiveMap ( const std::string &  path = {})
pure virtual

Gets key-values recursively from the given path

Parameters
pathThe path of the values to get
Returns
A map containing the key-values
virtual boost::optional<std::string> o2::configuration::ConfigurationInterface::getString ( const std::string &  path)
pure virtual

Retrieves a string value from the configuration.

Parameters
pathThe path of the value
Returns
The retrieved value
template<typename T >
void o2::configuration::ConfigurationInterface::put ( const std::string &  path,
const T &  value 
)

Template convenience interface for put operations. Redirects to the appropriate virtual method.

Parameters
TThe type of the value. Supported types are "std::string", "int" and "double"
pathThe path of the value
valueThe value to put
void o2::configuration::ConfigurationInterface::putRecursive ( const std::string &  path,
const boost::property_tree::ptree &  tree 
)
virtual

Recursively puts values to the given path

Parameters
pathThe path to the destination
treeTree-like data structure
virtual void o2::configuration::ConfigurationInterface::putString ( const std::string &  path,
const std::string &  value 
)
pure virtual

Puts a string into the configuration.

Parameters
pathThe path of the value
valueThe value to put
virtual void o2::configuration::ConfigurationInterface::setPrefix ( const std::string &  prefix)
pure virtual

Sets a prefix After this call, all paths given to this object will be prefixed with this. The implementation of this is very backend-dependent and it may not be a trivial call.

Parameters
prefixThe prefix path

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