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 
3 template <>
4 bool SiStripConfObject::put<std::vector<int> >( const std::string & name, const std::vector<int> & inputValue )
5 {
6  std::stringstream ss;
7  for(std::vector<int>::const_iterator elem=inputValue.begin();elem!=inputValue.end();++elem) {
8  ss << *elem << " ";
9  }
10  if( parameters.insert(std::make_pair(name, ss.str())).second ) return true;
11  return false;
12 }
13 
14 template <>
15 bool SiStripConfObject::update<std::vector<int> >( const std::string & name, const std::vector<int> & inputValue )
16 {
17  parMap::iterator it = parameters.find(name);
18  if (it == parameters.end()) {
19  std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
20  << "so cannot be updated to the vector of int of size'" << inputValue.size() << "'." << std::endl;
21  return false;
22  } else {
23  std::stringstream ss;
24  for(std::vector<int>::const_iterator elem=inputValue.begin();elem!=inputValue.end();++elem) {
25  ss << *elem << " ";
26  }
27  it->second = ss.str();
28  return true;
29  }
30 }
31 
32 template <>
33 std::vector<int> SiStripConfObject::get<std::vector<int> >( const std::string & name ) const
34 {
35  std::vector<int> returnValue;
36  parMap::const_iterator it = parameters.find(name);
37  std::stringstream ss;
38  if( it != parameters.end() ) {
39  ss << it->second;
40  int elem;
41  while(ss >> elem) returnValue.push_back(elem);
42  }
43  else {
44  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
45  }
46  return returnValue;
47 }
48 
49 template <>
50 bool SiStripConfObject::put<std::vector<std::string> >( const std::string & name, const std::vector<std::string> & inputValue )
51 {
52  std::stringstream ss;
53  for(std::vector<std::string>::const_iterator elem=inputValue.begin();elem!=inputValue.end();++elem) {
54  ss << *elem << " ";
55  }
56  if( parameters.insert(std::make_pair(name, ss.str())).second ) return true;
57  return false;
58 }
59 
60 template <>
61 bool SiStripConfObject::update<std::vector<std::string> >( const std::string & name, const std::vector<std::string> & inputValue )
62 {
63  parMap::iterator it = parameters.find(name);
64  if (it == parameters.end()) {
65  std::cout << "WARNING in SiStripConfObject::update: parameter " << name << " not found, "
66  << "so cannot be updated to the vector of std::string of size'" << inputValue.size() << "'." << std::endl;
67  return false;
68  } else {
69  std::stringstream ss;
70  for(std::vector<std::string>::const_iterator elem=inputValue.begin();elem!=inputValue.end();++elem) {
71  ss << *elem << " ";
72  }
73  it->second = ss.str();
74  return true;
75  }
76 }
77 
78 template <>
79 std::vector<std::string> SiStripConfObject::get<std::vector<std::string> >( const std::string & name ) const
80 {
81  std::vector<std::string> returnValue;
82  parMap::const_iterator it = parameters.find(name);
83  std::stringstream ss;
84  if( it != parameters.end() ) {
85  ss << it->second;
87  while(ss >> elem) returnValue.push_back(elem);
88  }
89  else {
90  std::cout << "WARNING: parameter " << name << " not found. Returning default value" << std::endl;
91  }
92  return returnValue;
93 }
94 
95 
96 void SiStripConfObject::printSummary(std::stringstream & ss) const
97 {
98  parMap::const_iterator it = parameters.begin();
99  for( ; it != parameters.end(); ++it ) {
100  ss << "parameter name = " << it->first << " value = " << it->second << std::endl;
101  }
102 }
103 
104 void SiStripConfObject::printDebug(std::stringstream & ss) const
105 {
106  printSummary(ss);
107 }
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