CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Public Attributes
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
 

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 27 of file ConfObject.h.

Member Typedef Documentation

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

Definition at line 67 of file ConfObject.h.

Constructor & Destructor Documentation

ConfObject::ConfObject ( )
inline

Definition at line 30 of file ConfObject.h.

30 {}

Member Function Documentation

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

Definition at line 42 of file ConfObject.h.

References gather_cfg::cout, mergeVDriftHistosByStation::name, and parameters.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), and betterConfigParser.BetterConfigParser::getResultingSection().

43  {
44  valueType returnValue;
45  parMap::const_iterator it = parameters.find(name);
46  std::stringstream ss;
47  if( it != parameters.end() ) {
48  ss << it->second;
49  ss >> returnValue;
50  }
51  else {
52  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
53  }
54  return returnValue;
55  }
parMap parameters
Definition: ConfObject.h:69
tuple cout
Definition: gather_cfg.py:121
bool ConfObject::isParameter ( const std::string &  name) const
inline

Definition at line 57 of file ConfObject.h.

References parameters.

58  {
59  return( parameters.find(name) != parameters.end() );
60  }
parMap parameters
Definition: ConfObject.h:69
void ConfObject::printDebug ( std::stringstream &  ss) const

Prints the full list of parameters.

Definition at line 11 of file ConfObject.cc.

References printSummary().

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.

References parameters.

Referenced by 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 }
parMap parameters
Definition: ConfObject.h:69
template<class valueType >
bool ConfObject::put ( const std::string &  name,
const valueType &  inputValue 
)
inline

Definition at line 33 of file ConfObject.h.

References parameters.

34  {
35  std::stringstream ss;
36  ss << inputValue;
37  if( parameters.insert(std::make_pair(name, ss.str())).second ) return true;
38  return false;
39  }
parMap parameters
Definition: ConfObject.h:69

Member Data Documentation

parMap ConfObject::parameters