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 
29 class ConfObject {
30 public:
32 
33  template <class valueType>
34  bool put(const std::string& name, const valueType& inputValue) {
35  std::stringstream ss;
36  ss << inputValue;
37  if (parameters.insert(std::make_pair(name, ss.str())).second)
38  return true;
39  return false;
40  }
41 
42  template <class valueType>
43  valueType get(const std::string& name) const {
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  } else {
51  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
52  }
53  return returnValue;
54  }
55 
56  bool isParameter(const std::string& name) const { return (parameters.find(name) != parameters.end()); }
57 
59  void printSummary(std::stringstream& ss) const;
61  void printDebug(std::stringstream& ss) const;
62 
63  typedef std::map<std::string, std::string> parMap;
64 
65  parMap parameters;
66 
68 };
69 
70 #endif
std::map< std::string, std::string > parMap
Definition: ConfObject.h:63
bool put(const std::string &name, const valueType &inputValue)
Definition: ConfObject.h:34
void printDebug(std::stringstream &ss) const
Prints the full list of parameters.
Definition: ConfObject.cc:10
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:56
#define COND_SERIALIZABLE
Definition: Serializable.h:38
parMap parameters
Definition: ConfObject.h:65