CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripConfObject.h
Go to the documentation of this file.
1 #ifndef SiStripConfObject_h
2 #define SiStripConfObject_h
3 
4 #include <iostream>
5 #include <vector>
6 #include <map>
7 #include <algorithm>
8 #include <iterator>
9 #include <sstream>
10 
12 
28 {
29  public:
31 
32  template <class valueType>
33  bool put( const std::string & name, const valueType & inputValue )
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  }
40 
44  template <class valueType>
45  bool update( const std::string & name, const valueType & inputValue )
46  {
47  parMap::iterator it = parameters.find(name);
48  if (it == parameters.end()) {
49  std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
50  << "so cannot be updated to '" << inputValue << "'." << std::endl;
51  return false;
52  } else {
53  std::stringstream ss;
54  ss << inputValue;
55  it->second = ss.str();
56  return true;
57  }
58  }
59 
60  template <class valueType>
61  valueType get( const std::string & name ) const
62  {
63  valueType returnValue;
64  parMap::const_iterator it = parameters.find(name);
65  std::stringstream ss;
66  if( it != parameters.end() ) {
67  ss << it->second;
68  ss >> returnValue;
69  }
70  else {
71  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
72  }
73  return returnValue;
74  }
75 
76  bool isParameter( const std::string & name ) const
77  {
78  return( parameters.find(name) != parameters.end() );
79  }
80 
82  void printSummary(std::stringstream & ss) const;
84  void printDebug(std::stringstream & ss) const;
85 
86  typedef std::map<std::string, std::string> parMap;
87 
89 };
90 
91 #endif
void printSummary(std::stringstream &ss) const
Prints the full list of parameters.
bool update(const std::string &name, const valueType &inputValue)
std::map< std::string, std::string > parMap
bool put(const std::string &name, const valueType &inputValue)
void printDebug(std::stringstream &ss) const
Prints the full list of parameters.
tuple cout
Definition: gather_cfg.py:121
bool isParameter(const std::string &name) const