CMS 3D CMS Logo

SiStripConfObject.h
Go to the documentation of this file.
1 #ifndef SiStripConfObject_h
2 #define SiStripConfObject_h
3 
5 
6 #include <iostream>
7 #include <vector>
8 #include <map>
9 #include <algorithm>
10 #include <iterator>
11 #include <sstream>
12 
14 
15 class TrackerTopology;
16 
32 {
33  public:
35 
36  template <class valueType>
37  bool put( const std::string & name, const valueType & inputValue )
38  {
39  std::stringstream ss;
40  ss << inputValue;
41  if( parameters.insert(std::make_pair(name, ss.str())).second ) return true;
42  return false;
43  }
44 
45 
49  template <class valueType>
50  bool update( const std::string & name, const valueType & inputValue )
51  {
52  parMap::iterator it = parameters.find(name);
53  if (it == parameters.end()) {
54  std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
55  << "so cannot be updated to '" << inputValue << "'." << std::endl;
56  return false;
57  } else {
58  std::stringstream ss;
59  ss << inputValue;
60  it->second = ss.str();
61  return true;
62  }
63  }
64 
65  template <class valueType>
66  valueType get( const std::string & name ) const
67  {
68  valueType returnValue = 0;
69  parMap::const_iterator it = parameters.find(name);
70  std::stringstream ss;
71  if( it != parameters.end() ) {
72  ss << it->second;
73  ss >> returnValue;
74  }
75  else {
76  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
77  }
78  return returnValue;
79  }
80 
81  bool isParameter( const std::string & name ) const
82  {
83  return( parameters.find(name) != parameters.end() );
84  }
85 
87  void printSummary(std::stringstream & ss, const TrackerTopology* trackerTopo) const;
89  void printDebug(std::stringstream & ss, const TrackerTopology* trackerTopo) const;
90 
91  typedef std::map<std::string, std::string> parMap;
92 
93  parMap parameters;
94 
96 };
97 
98 template <>
99 std::string SiStripConfObject::get<std::string>( const std::string & name ) const;
100 template <>
101 bool SiStripConfObject::put<std::vector<int> >( const std::string & name, const std::vector<int> & inputValue );
102 template <>
103 bool SiStripConfObject::update<std::vector<int> >( const std::string & name, const std::vector<int> & inputValue );
104 template <>
105 std::vector<int> SiStripConfObject::get<std::vector<int> >( const std::string & name ) const;
106 template <>
107 bool SiStripConfObject::put<std::vector<std::string> >( const std::string & name, const std::vector<std::string> & inputValue );
108 template <>
109 bool SiStripConfObject::update<std::vector<std::string> >( const std::string & name, const std::vector<std::string> & inputValue );
110 template <>
111 std::vector<std::string> SiStripConfObject::get<std::vector<std::string> >( const std::string & name ) const;
112 
113 
114 #endif
bool update(const std::string &name, const valueType &inputValue)
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the full list of parameters.
std::map< std::string, std::string > parMap
bool put(const std::string &name, const valueType &inputValue)
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the full list of parameters.
#define COND_SERIALIZABLE
Definition: Serializable.h:38
bool isParameter(const std::string &name) const