CMS 3D CMS Logo

ConfObject.h
Go to the documentation of this file.
1 #ifndef ConfObject_h
2 #define ConfObject_h
3 
5 
6 #include <iostream>
7 #include <vector>
8 #include <map>
9 #include <algorithm>
10 #include <iterator>
11 #include <sstream>
12 
14 
30 {
31  public:
33 
34  template <class valueType>
35  bool put( const std::string & name, const valueType & inputValue )
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  }
42 
43  template <class valueType>
44  valueType get( const std::string & name ) const
45  {
46  valueType returnValue;
47  parMap::const_iterator it = parameters.find(name);
48  std::stringstream ss;
49  if( it != parameters.end() ) {
50  ss << it->second;
51  ss >> returnValue;
52  }
53  else {
54  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
55  }
56  return returnValue;
57  }
58 
59  bool isParameter( const std::string & name ) const
60  {
61  return( parameters.find(name) != parameters.end() );
62  }
63 
65  void printSummary(std::stringstream & ss) const;
67  void printDebug(std::stringstream & ss) const;
68 
69  typedef std::map<std::string, std::string> parMap;
70 
71  parMap parameters;
72 
74 };
75 
76 #endif
std::map< std::string, std::string > parMap
Definition: ConfObject.h:69
bool put(const std::string &name, const valueType &inputValue)
Definition: ConfObject.h:35
void printDebug(std::stringstream &ss) const
Prints the full list of parameters.
Definition: ConfObject.cc:11
void printSummary(std::stringstream &ss) const
Prints the full list of parameters.
Definition: ConfObject.cc:3
bool isParameter(const std::string &name) const
Definition: ConfObject.h:59
#define COND_SERIALIZABLE
Definition: Serializable.h:38
parMap parameters
Definition: ConfObject.h:71