ifw  0.0.1-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ctd::file::ParameterSet Class Reference

Class to handle a set of parameters. More...

#include <ParameterSet.hpp>

Inheritance diagram for ctd::file::ParameterSet:
ctd::file::Yaml ctd::file::Yaml ctd::file::Yaml

Public Member Functions

 ParameterSet ()
 
 ParameterSet (const ParameterSet &source)
 Copy constructor. More...
 
 ~ParameterSet ()
 
virtual void Load (const std::string &filename, const bool merge=false)
 Load a file containing parameters. More...
 
virtual void LoadUser (const std::string &filename, const bool merge=false)
 
void Store (const std::string &par_name, const std::string &value, const std::string &comment="")
 Store a parameter name, value and possibly comment in the object. More...
 
std::string GetValueAsString (const std::string &par_name, const bool exception=false) const
 Return value for the referenced parameter as a string. More...
 
template<class TYPE >
bool GetValue (const std::string &name, TYPE &value, const bool exception=false) const
 Return value for the referenced parameter as its native data type. More...
 
const ctd::file::ParameterGetPar (const std::string &par_name) const
 Get reference to parameter object, referenced by its name. More...
 
bool HasPar (const std::string &par_name) const
 Returns true if parameter is defined. More...
 
bool HasPar (const std::string &par_name, ctd::file::Parameter &parameter) const
 Returns true if parameter defined, copies parameter object to object provided. More...
 
template<class TYPE >
bool HasPar (const std::string &par_name, TYPE &value) const
 Return trie if parameter defined, sets the value as the native value. More...
 
uint32_t Scan (const std::string &filter_reg_exp, ctd::defines::List< ctd::file::Parameter > &matches) const
 Scans through the parameter object namespace and creates list of matching parameters. More...
 
std::string Print (const std::string &filter_reg_exp="") const
 Prints out contents of object, applying regular expression filtering, if specified. More...
 
ctd::defines::List< std::string > ParNames () const
 Returns list of parameter names. More...
 
const std::map< std::string,
ctd::file::Parameter > & 
GetParameterMap () const
 Return reference to the internal map with the names/parameter objects. More...
 
const std::string & GetProcFile () const
 Return reference to file being processed (loaded). More...
 
ParameterSetoperator= (const ParameterSet &source)
 Assignment operator. More...
 
 ParameterSet ()
 
 ParameterSet (const ParameterSet &source)
 Copy constructor. More...
 
 ~ParameterSet ()
 
virtual void Load (const std::string &filename, const bool merge=false)
 Load a file containing parameters. More...
 
virtual void LoadUser (const std::string &filename, const bool merge=false)
 
void Store (const std::string &par_name, const std::string &value, const std::string &comment="")
 Store a parameter name, value and possibly comment in the object. More...
 
std::string GetValueAsString (const std::string &par_name, const bool exception=false) const
 Return value for the referenced parameter as a string. More...
 
template<class TYPE >
bool GetValue (const std::string &name, TYPE &value, const bool exception=false) const
 Return value for the referenced parameter as its native data type. More...
 
const ctd::file::ParameterGetPar (const std::string &par_name) const
 Get reference to parameter object, referenced by its name. More...
 
bool HasPar (const std::string &par_name) const
 Returns true if parameter is defined. More...
 
bool HasPar (const std::string &par_name, ctd::file::Parameter &parameter) const
 Returns true if parameter defined, copies parameter object to object provided. More...
 
template<class TYPE >
bool HasPar (const std::string &par_name, TYPE &value) const
 Return trie if parameter defined, sets the value as the native value. More...
 
uint32_t Scan (const std::string &filter_reg_exp, ctd::defines::List< ctd::file::Parameter > &matches) const
 Scans through the parameter object namespace and creates list of matching parameters. More...
 
std::string Print (const std::string &filter_reg_exp="") const
 Prints out contents of object, applying regular expression filtering, if specified. More...
 
ctd::defines::List< std::string > ParNames () const
 Returns list of parameter names. More...
 
const std::map< std::string,
ctd::file::Parameter > & 
GetParameterMap () const
 Return reference to the internal map with the names/parameter objects. More...
 
const std::string & GetProcFile () const
 Return reference to file being processed (loaded). More...
 
ParameterSetoperator= (const ParameterSet &source)
 Assignment operator. More...
 
 ParameterSet ()
 
 ParameterSet (const ParameterSet &source)
 Copy constructor. More...
 
 ~ParameterSet ()
 
virtual void Load (const std::string &filename, const bool merge=false)
 Load a file containing parameters. More...
 
virtual void LoadUser (const std::string &filename, const bool merge=false)
 
void Store (const std::string &par_name, const std::string &value, const std::string &comment="")
 Store a parameter name, value and possibly comment in the object. More...
 
std::string GetValueAsString (const std::string &par_name, const bool exception=false) const
 Return value for the referenced parameter as a string. More...
 
template<class TYPE >
bool GetValue (const std::string &name, TYPE &value, const bool exception=false) const
 Return value for the referenced parameter as its native data type. More...
 
const ctd::file::ParameterGetPar (const std::string &par_name) const
 Get reference to parameter object, referenced by its name. More...
 
bool HasPar (const std::string &par_name) const
 Returns true if parameter is defined. More...
 
bool HasPar (const std::string &par_name, ctd::file::Parameter &parameter) const
 Returns true if parameter defined, copies parameter object to object provided. More...
 
template<class TYPE >
bool HasPar (const std::string &par_name, TYPE &value) const
 Return trie if parameter defined, sets the value as the native value. More...
 
uint32_t Scan (const std::string &filter_reg_exp, ctd::defines::List< ctd::file::Parameter > &matches) const
 Scans through the parameter object namespace and creates list of matching parameters. More...
 
std::string Print (const std::string &filter_reg_exp="") const
 Prints out contents of object, applying regular expression filtering, if specified. More...
 
ctd::defines::List< std::string > ParNames () const
 Returns list of parameter names. More...
 
const std::map< std::string,
ctd::file::Parameter > & 
GetParameterMap () const
 Return reference to the internal map with the names/parameter objects. More...
 
const std::string & GetProcFile () const
 Return reference to file being processed (loaded). More...
 
ParameterSetoperator= (const ParameterSet &source)
 Assignment operator. More...
 

Static Public Member Functions

static std::string Print (ctd::defines::List< ctd::file::Parameter > &par_list)
 Create an ASCII print out of the parameters in the list. More...
 
static std::string Print (ctd::defines::List< ctd::file::Parameter > &par_list)
 Create an ASCII print out of the parameters in the list. More...
 
static std::string Print (ctd::defines::List< ctd::file::Parameter > &par_list)
 Create an ASCII print out of the parameters in the list. More...
 

Protected Member Functions

void _Copy (const ParameterSet &source)
 
void _Copy (const ParameterSet &source)
 
void _Copy (const ParameterSet &source)
 

Protected Attributes

std::map< std::string,
ctd::file::Parameter
m_par_map
 
std::string m_proc_file
 
ctd::defines::List< std::string > m_loaded_files
 

Detailed Description

Class to handle a set of parameters.

Constructor & Destructor Documentation

ctd::file::ParameterSet::ParameterSet ( )
ctd::file::ParameterSet::ParameterSet ( const ParameterSet source)

Copy constructor.

ctd::file::ParameterSet::~ParameterSet ( )
ctd::file::ParameterSet::ParameterSet ( )
ctd::file::ParameterSet::ParameterSet ( const ParameterSet source)

Copy constructor.

ctd::file::ParameterSet::~ParameterSet ( )
ctd::file::ParameterSet::ParameterSet ( )
ctd::file::ParameterSet::ParameterSet ( const ParameterSet source)

Copy constructor.

ctd::file::ParameterSet::~ParameterSet ( )

Member Function Documentation

void ctd::file::ParameterSet::_Copy ( const ParameterSet source)
protected
void ctd::file::ParameterSet::_Copy ( const ParameterSet source)
protected
void ctd::file::ParameterSet::_Copy ( const ParameterSet source)
protected
const Parameter & ctd::file::ParameterSet::GetPar ( const std::string &  par_name) const

Get reference to parameter object, referenced by its name.

const ctd::file::Parameter& ctd::file::ParameterSet::GetPar ( const std::string &  par_name) const

Get reference to parameter object, referenced by its name.

const ctd::file::Parameter& ctd::file::ParameterSet::GetPar ( const std::string &  par_name) const

Get reference to parameter object, referenced by its name.

const std::map< std::string, Parameter > & ctd::file::ParameterSet::GetParameterMap ( ) const

Return reference to the internal map with the names/parameter objects.

const std::map<std::string, ctd::file::Parameter>& ctd::file::ParameterSet::GetParameterMap ( ) const

Return reference to the internal map with the names/parameter objects.

const std::map<std::string, ctd::file::Parameter>& ctd::file::ParameterSet::GetParameterMap ( ) const

Return reference to the internal map with the names/parameter objects.

const std::string& ctd::file::ParameterSet::GetProcFile ( ) const

Return reference to file being processed (loaded).

const std::string& ctd::file::ParameterSet::GetProcFile ( ) const

Return reference to file being processed (loaded).

const std::string & ctd::file::ParameterSet::GetProcFile ( ) const

Return reference to file being processed (loaded).

template<class TYPE >
bool ctd::file::ParameterSet::GetValue ( const std::string &  name,
TYPE &  value,
const bool  exception = false 
) const
inline

Return value for the referenced parameter as its native data type.

template<class TYPE >
bool ctd::file::ParameterSet::GetValue ( const std::string &  name,
TYPE &  value,
const bool  exception = false 
) const
inline

Return value for the referenced parameter as its native data type.

template<class TYPE >
bool ctd::file::ParameterSet::GetValue ( const std::string &  name,
TYPE &  value,
const bool  exception = false 
) const
inline

Return value for the referenced parameter as its native data type.

std::string ctd::file::ParameterSet::GetValueAsString ( const std::string &  par_name,
const bool  exception = false 
) const

Return value for the referenced parameter as a string.

std::string ctd::file::ParameterSet::GetValueAsString ( const std::string &  par_name,
const bool  exception = false 
) const

Return value for the referenced parameter as a string.

std::string ctd::file::ParameterSet::GetValueAsString ( const std::string &  par_name,
const bool  exception = false 
) const

Return value for the referenced parameter as a string.

bool ctd::file::ParameterSet::HasPar ( const std::string &  par_name) const

Returns true if parameter is defined.

bool ctd::file::ParameterSet::HasPar ( const std::string &  par_name) const

Returns true if parameter is defined.

bool ctd::file::ParameterSet::HasPar ( const std::string &  par_name) const

Returns true if parameter is defined.

bool ctd::file::ParameterSet::HasPar ( const std::string &  par_name,
ctd::file::Parameter parameter 
) const

Returns true if parameter defined, copies parameter object to object provided.

bool ctd::file::ParameterSet::HasPar ( const std::string &  par_name,
ctd::file::Parameter parameter 
) const

Returns true if parameter defined, copies parameter object to object provided.

bool ctd::file::ParameterSet::HasPar ( const std::string &  par_name,
ctd::file::Parameter parameter 
) const

Returns true if parameter defined, copies parameter object to object provided.

template<class TYPE >
bool ctd::file::ParameterSet::HasPar ( const std::string &  par_name,
TYPE &  value 
) const
inline

Return trie if parameter defined, sets the value as the native value.

template<class TYPE >
bool ctd::file::ParameterSet::HasPar ( const std::string &  par_name,
TYPE &  value 
) const
inline

Return trie if parameter defined, sets the value as the native value.

template<class TYPE >
bool ctd::file::ParameterSet::HasPar ( const std::string &  par_name,
TYPE &  value 
) const
inline

Return trie if parameter defined, sets the value as the native value.

virtual void ctd::file::ParameterSet::Load ( const std::string &  filename,
const bool  merge = false 
)
virtual

Load a file containing parameters.

virtual void ctd::file::ParameterSet::Load ( const std::string &  filename,
const bool  merge = false 
)
virtual

Load a file containing parameters.

void ctd::file::ParameterSet::Load ( const std::string &  filename,
const bool  merge = false 
)
virtual

Load a file containing parameters.

void ctd::file::ParameterSet::LoadUser ( const std::string &  filename,
const bool  merge = false 
)
virtual

Method to load the parameters from a simple format file containing parameters. The following rules are applied while parsing the file:

  • Lines initiated with "#" are ignored.
  • Lines containing <parameter>: "<value>" are split and added in the internal map. The value shall be contained between ""'s.
  • Inline comments are allowed, i.e.: "<parameter>: "

" # <comment".

Reimplemented in ctd::file::Yaml, ctd::file::Yaml, and ctd::file::Yaml.

virtual void ctd::file::ParameterSet::LoadUser ( const std::string &  filename,
const bool  merge = false 
)
virtual

Method to load the parameters from a simple format file containing parameters. The following rules are applied while parsing the file:

  • Lines initiated with "#" are ignored.
  • Lines containing <parameter>: "<value>" are split and added in the internal map. The value shall be contained between ""'s.
  • Inline comments are allowed, i.e.: "<parameter>: "

" # <comment".

Reimplemented in ctd::file::Yaml, ctd::file::Yaml, and ctd::file::Yaml.

virtual void ctd::file::ParameterSet::LoadUser ( const std::string &  filename,
const bool  merge = false 
)
virtual

Method to load the parameters from a simple format file containing parameters. The following rules are applied while parsing the file:

  • Lines initiated with "#" are ignored.
  • Lines containing <parameter>: "<value>" are split and added in the internal map. The value shall be contained between ""'s.
  • Inline comments are allowed, i.e.: "<parameter>: "

" # <comment".

Reimplemented in ctd::file::Yaml, ctd::file::Yaml, and ctd::file::Yaml.

ParameterSet& ctd::file::ParameterSet::operator= ( const ParameterSet source)

Assignment operator.

ParameterSet & ctd::file::ParameterSet::operator= ( const ParameterSet source)

Assignment operator.

ParameterSet& ctd::file::ParameterSet::operator= ( const ParameterSet source)

Assignment operator.

ctd::defines::List<std::string> ctd::file::ParameterSet::ParNames ( ) const

Returns list of parameter names.

ctd::defines::List< std::string > ctd::file::ParameterSet::ParNames ( ) const

Returns list of parameter names.

ctd::defines::List<std::string> ctd::file::ParameterSet::ParNames ( ) const

Returns list of parameter names.

static std::string ctd::file::ParameterSet::Print ( ctd::defines::List< ctd::file::Parameter > &  par_list)
static

Create an ASCII print out of the parameters in the list.

std::string ctd::file::ParameterSet::Print ( ctd::defines::List< ctd::file::Parameter > &  par_list)
static

Create an ASCII print out of the parameters in the list.

static std::string ctd::file::ParameterSet::Print ( ctd::defines::List< ctd::file::Parameter > &  par_list)
static

Create an ASCII print out of the parameters in the list.

std::string ctd::file::ParameterSet::Print ( const std::string &  filter_reg_exp = "") const

Prints out contents of object, applying regular expression filtering, if specified.

std::string ctd::file::ParameterSet::Print ( const std::string &  filter_reg_exp = "") const

Prints out contents of object, applying regular expression filtering, if specified.

std::string ctd::file::ParameterSet::Print ( const std::string &  filter_reg_exp = "") const

Prints out contents of object, applying regular expression filtering, if specified.

uint32_t ctd::file::ParameterSet::Scan ( const std::string &  filter_reg_exp,
ctd::defines::List< ctd::file::Parameter > &  matches 
) const

Scans through the parameter object namespace and creates list of matching parameters.

uint32_t ctd::file::ParameterSet::Scan ( const std::string &  filter_reg_exp,
ctd::defines::List< ctd::file::Parameter > &  matches 
) const

Scans through the parameter object namespace and creates list of matching parameters.

uint32_t ctd::file::ParameterSet::Scan ( const std::string &  filter_reg_exp,
ctd::defines::List< ctd::file::Parameter > &  matches 
) const

Scans through the parameter object namespace and creates list of matching parameters.

void ctd::file::ParameterSet::Store ( const std::string &  par_name,
const std::string &  value,
const std::string &  comment = "" 
)

Store a parameter name, value and possibly comment in the object.

void ctd::file::ParameterSet::Store ( const std::string &  par_name,
const std::string &  value,
const std::string &  comment = "" 
)

Store a parameter name, value and possibly comment in the object.

void ctd::file::ParameterSet::Store ( const std::string &  par_name,
const std::string &  value,
const std::string &  comment = "" 
)

Store a parameter name, value and possibly comment in the object.

Member Data Documentation

ctd::defines::List< std::string > ctd::file::ParameterSet::m_loaded_files
protected
std::map< std::string, ctd::file::Parameter > ctd::file::ParameterSet::m_par_map
protected
std::string ctd::file::ParameterSet::m_proc_file
protected

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