CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripConfObject.cc
Go to the documentation of this file.
2 #include <string>
3 
4 template <>
5 std::string SiStripConfObject::get<std::string>( const std::string & name ) const
6 {
7  std::string returnValue;
8  parMap::const_iterator it = parameters.find(name);
9  std::stringstream ss;
10  if( it != parameters.end() ) {
11  ss << it->second;
12  ss >> returnValue;
13  }
14  else {
15  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
16  }
17  return returnValue;
18 }
19 
20 template <>
21 bool SiStripConfObject::put<std::vector<int> >( const std::string & name, const std::vector<int> & inputValue )
22 {
23  std::stringstream ss;
24  for(std::vector<int>::const_iterator elem=inputValue.begin();elem!=inputValue.end();++elem) {
25  ss << *elem << " ";
26  }
27  if( parameters.insert(std::make_pair(name, ss.str())).second ) return true;
28  return false;
29 }
30 
31 template <>
32 bool SiStripConfObject::update<std::vector<int> >( const std::string & name, const std::vector<int> & inputValue )
33 {
34  parMap::iterator it = parameters.find(name);
35  if (it == parameters.end()) {
36  std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
37  << "so cannot be updated to the vector of int of size'" << inputValue.size() << "'." << std::endl;
38  return false;
39  } else {
40  std::stringstream ss;
41  for(std::vector<int>::const_iterator elem=inputValue.begin();elem!=inputValue.end();++elem) {
42  ss << *elem << " ";
43  }
44  it->second = ss.str();
45  return true;
46  }
47 }
48 
49 template <>
50 std::vector<int> SiStripConfObject::get<std::vector<int> >( const std::string & name ) const
51 {
52  std::vector<int> returnValue;
53  parMap::const_iterator it = parameters.find(name);
54  std::stringstream ss;
55  if( it != parameters.end() ) {
56  ss << it->second;
57  int elem;
58  while(ss >> elem) returnValue.push_back(elem);
59  }
60  else {
61  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
62  }
63  return returnValue;
64 }
65 
66 template <>
67 bool SiStripConfObject::put<std::vector<std::string> >( const std::string & name, const std::vector<std::string> & inputValue )
68 {
69  std::stringstream ss;
70  for(std::vector<std::string>::const_iterator elem=inputValue.begin();elem!=inputValue.end();++elem) {
71  ss << *elem << " ";
72  }
73  if( parameters.insert(std::make_pair(name, ss.str())).second ) return true;
74  return false;
75 }
76 
77 template <>
78 bool SiStripConfObject::update<std::vector<std::string> >( const std::string & name, const std::vector<std::string> & inputValue )
79 {
80  parMap::iterator it = parameters.find(name);
81  if (it == parameters.end()) {
82  std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
83  << "so cannot be updated to the vector of std::string of size'" << inputValue.size() << "'." << std::endl;
84  return false;
85  } else {
86  std::stringstream ss;
87  for(std::vector<std::string>::const_iterator elem=inputValue.begin();elem!=inputValue.end();++elem) {
88  ss << *elem << " ";
89  }
90  it->second = ss.str();
91  return true;
92  }
93 }
94 
95 template <>
96 std::vector<std::string> SiStripConfObject::get<std::vector<std::string> >( const std::string & name ) const
97 {
98  std::vector<std::string> returnValue;
99  parMap::const_iterator it = parameters.find(name);
100  std::stringstream ss;
101  if( it != parameters.end() ) {
102  ss << it->second;
104  while(ss >> elem) returnValue.push_back(elem);
105  }
106  else {
107  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
108  }
109  return returnValue;
110 }
111 
112 
113 void SiStripConfObject::printSummary(std::stringstream & ss) const
114 {
115  parMap::const_iterator it = parameters.begin();
116  for( ; it != parameters.end(); ++it ) {
117  ss << "parameter name = " << it->first << " value = " << it->second << std::endl;
118  }
119 }
120 
121 void SiStripConfObject::printDebug(std::stringstream & ss) const
122 {
123  printSummary(ss);
124 }
void printSummary(std::stringstream &ss) const
Prints the full list of parameters.
dictionary parameters
Definition: Parameters.py:2
void printDebug(std::stringstream &ss) const
Prints the full list of parameters.
tuple cout
Definition: gather_cfg.py:121