CMS 3D CMS Logo

Public Types | Public Member Functions | Public Attributes

SiStripConfObject Class Reference

#include <SiStripConfObject.h>

List of all members.

Public Types

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

Public Member Functions

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.
void printSummary (std::stringstream &ss) const
 Prints the full list of parameters.
template<class valueType >
bool put (const std::string &name, const valueType &inputValue)
 SiStripConfObject ()
template<class valueType >
bool update (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 SiStripConfObject.h.


Member Typedef Documentation

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

Definition at line 86 of file SiStripConfObject.h.


Constructor & Destructor Documentation

SiStripConfObject::SiStripConfObject ( ) [inline]

Definition at line 30 of file SiStripConfObject.h.

{}

Member Function Documentation

template<class valueType >
valueType SiStripConfObject::get ( const std::string &  name) const [inline]

Definition at line 61 of file SiStripConfObject.h.

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

Referenced by StripCPE::StripCPE().

  {
    valueType returnValue;
    parMap::const_iterator it = parameters.find(name);
    std::stringstream ss;
    if( it != parameters.end() ) {
      ss << it->second;
      ss >> returnValue;
    }
    else {
      std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
    }
    return returnValue;
  }
bool SiStripConfObject::isParameter ( const std::string &  name) const [inline]

Definition at line 76 of file SiStripConfObject.h.

References parameters.

Referenced by StripCPE::StripCPE().

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

Prints the full list of parameters.

Definition at line 11 of file SiStripConfObject.cc.

References printSummary().

{
  printSummary(ss);
}
void SiStripConfObject::printSummary ( std::stringstream &  ss) const

Prints the full list of parameters.

Definition at line 3 of file SiStripConfObject.cc.

References parameters.

Referenced by printDebug().

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

Definition at line 33 of file SiStripConfObject.h.

References parameters.

Referenced by SiStripConfObjectGenerator::createObject().

  {
    std::stringstream ss;
    ss << inputValue;
    if( parameters.insert(std::make_pair(name, ss.str())).second ) return true;
    return false;
  }
template<class valueType >
bool SiStripConfObject::update ( const std::string &  name,
const valueType &  inputValue 
) [inline]

Updating the value stored as 'name' with 'inputValue'. False if parameter 'name' does not exist (and nothing is done then - use put(..) instead!), otherwise true.

Definition at line 45 of file SiStripConfObject.h.

References gather_cfg::cout, and parameters.

  {
    parMap::iterator it = parameters.find(name);
    if (it == parameters.end()) {
      std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
                << "so cannot be updated to '" << inputValue << "'." << std::endl;
      return false;
    } else {
      std::stringstream ss;
      ss << inputValue;
      it->second = ss.str();
      return true;
    }
  }

Member Data Documentation

Definition at line 88 of file SiStripConfObject.h.

Referenced by get(), isParameter(), printSummary(), put(), and update().