CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Friends
ConfObject Class Reference

#include <ConfObject.h>

Public Types

typedef std::map< std::string, std::string > parMap
 

Public Member Functions

 ConfObject ()
 
template<class valueType >
valueType get (const std::string &name) const
 
bool isParameter (const std::string &name) const
 
void printDebug (std::stringstream &ss) const
 Prints the full list of parameters. More...
 
void printSummary (std::stringstream &ss) const
 Prints the full list of parameters. More...
 
template<class valueType >
bool put (const std::string &name, const valueType &inputValue)
 

Public Attributes

parMap parameters
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Author M. De Mattia - 16/11/2009

Simple class used to store configuration values.
It stores a map<std::string, std::string> with all the parameters and their values.
The put and get methods are provided to store and access the parameters.
The put method retuns a bool which is true if the insertion was successuful. If the parameter is already existing the insertion will not happen and the return value will be false.
The get method is templated and works like the getParameter<type> of the framework.
The isParameter method can be used to check whether a parameter exists. It will return a bool with the result.
The printSummary and printDebug method return both the full list of parameters.

Definition at line 29 of file ConfObject.h.

Member Typedef Documentation

typedef std::map<std::string, std::string> ConfObject::parMap

Definition at line 69 of file ConfObject.h.

Constructor & Destructor Documentation

ConfObject::ConfObject ( )
inline

Definition at line 32 of file ConfObject.h.

32 {}

Member Function Documentation

template<class valueType >
valueType ConfObject::get ( const std::string &  name) const
inline
bool ConfObject::isParameter ( const std::string &  name) const
inline

Definition at line 59 of file ConfObject.h.

References printDebug(), and printSummary().

60  {
61  return( parameters.find(name) != parameters.end() );
62  }
void ConfObject::printDebug ( std::stringstream &  ss) const

Prints the full list of parameters.

Definition at line 11 of file ConfObject.cc.

References printSummary().

Referenced by isParameter().

12 {
13  printSummary(ss);
14 }
void printSummary(std::stringstream &ss) const
Prints the full list of parameters.
Definition: ConfObject.cc:3
void ConfObject::printSummary ( std::stringstream &  ss) const

Prints the full list of parameters.

Definition at line 3 of file ConfObject.cc.

Referenced by isParameter(), and printDebug().

4 {
5  parMap::const_iterator it = parameters.begin();
6  for( ; it != parameters.end(); ++it ) {
7  ss << "parameter name = " << it->first << " value = " << it->second << std::endl;
8  }
9 }
template<class valueType >
bool ConfObject::put ( const std::string &  name,
const valueType &  inputValue 
)
inline

Definition at line 35 of file ConfObject.h.

36  {
37  std::stringstream ss;
38  ss << inputValue;
39  if( parameters.insert(std::make_pair(name, ss.str())).second ) return true;
40  return false;
41  }
template<class Archive >
void ConfObject::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 73 of file ConfObject.h.

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 73 of file ConfObject.h.

Member Data Documentation

parMap ConfObject::parameters