ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FlagSavev1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file FlagSavev1.cc
1 #include "FlagSavev1.h"
2 
3 #include <phool/PHFlag.h>
4 
5 #include <utility> // for pair
6 
7 class PHObject;
8 
9 PHObject *
11 {
12  FlagSavev1 *ret = new FlagSavev1();
13 
14  ret->intflag = this->intflag;
15  ret->doubleflag = this->doubleflag;
16  ret->floatflag = this->floatflag;
17  ret->stringflag = this->stringflag;
18 
19  return ret;
20 }
21 
23 {
24  if (intflag.empty() &&
25  doubleflag.empty() &&
26  floatflag.empty() &&
27  stringflag.empty())
28  {
29  return 0;
30  }
31  return 1;
32 }
33 
34 void FlagSavev1::identify(std::ostream &out) const
35 {
36  out << "identify yourself: I am an FlagSavev1 Object" << std::endl;
37  PrintIntFlag(out);
38  PrintDoubleFlag(out);
39  PrintFloatFlag(out);
40  PrintStringFlag(out);
41  return;
42 }
43 
45 {
46  int iret = FillIntFromPHFlag(flags);
47  iret += FillDoubleFromPHFlag(flags);
48  iret += FillFloatFromPHFlag(flags);
49  iret += FillCharFromPHFlag(flags);
50  return iret;
51 }
52 
54 {
55  int iret = PutIntToPHFlag(flags);
56  iret += PutDoubleToPHFlag(flags);
57  iret += PutFloatToPHFlag(flags);
58  iret += PutCharToPHFlag(flags);
59  return iret;
60 }
61 
63 {
64  std::map<std::string, int>::const_iterator iter;
65  const std::map<std::string, int> *intm = flags->IntMap();
66  for (iter = intm->begin(); iter != intm->end(); ++iter)
67  {
68  intflag[iter->first] = iter->second;
69  }
70  return 0;
71 }
72 
74 {
75  std::map<std::string, double>::const_iterator iter;
76  const std::map<std::string, double> *intm = flags->DoubleMap();
77  for (iter = intm->begin(); iter != intm->end(); ++iter)
78  {
79  doubleflag[iter->first] = iter->second;
80  }
81  return 0;
82 }
83 
85 {
86  std::map<std::string, float>::const_iterator iter;
87  const std::map<std::string, float> *intm = flags->FloatMap();
88  for (iter = intm->begin(); iter != intm->end(); ++iter)
89  {
90  floatflag[iter->first] = iter->second;
91  }
92  return 0;
93 }
94 
96 {
97  std::map<std::string, std::string>::const_iterator iter;
98  const std::map<std::string, std::string> *intm = flags->CharMap();
99  for (iter = intm->begin(); iter != intm->end(); ++iter)
100  {
101  std::string input(iter->second);
102  stringflag[iter->first] = input;
103  }
104  return 0;
105 }
106 
108 {
109  std::map<std::string, int>::const_iterator iter;
110  for (iter = intflag.begin(); iter != intflag.end(); ++iter)
111  {
112  flags->set_IntFlag(iter->first, iter->second);
113  }
114  return 0;
115 }
116 
118 {
119  std::map<std::string, double>::const_iterator iter;
120  for (iter = doubleflag.begin(); iter != doubleflag.end(); ++iter)
121  {
122  flags->set_DoubleFlag(iter->first, iter->second);
123  }
124  return 0;
125 }
126 
128 {
129  std::map<std::string, float>::const_iterator iter;
130  for (iter = floatflag.begin(); iter != floatflag.end(); ++iter)
131  {
132  flags->set_FloatFlag(iter->first, iter->second);
133  }
134  return 0;
135 }
136 
138 {
139  std::map<std::string, std::string>::const_iterator iter;
140  for (iter = stringflag.begin(); iter != stringflag.end(); ++iter)
141  {
142  flags->set_CharFlag(iter->first, iter->second);
143  }
144  return 0;
145 }
146 
147 void FlagSavev1::PrintIntFlag(std::ostream &os) const
148 {
149  if (intflag.empty())
150  {
151  return;
152  }
153  std::map<std::string, int>::const_iterator iter;
154  os << "Int Flags: " << std::endl;
155  for (iter = intflag.begin(); iter != intflag.end(); ++iter)
156  {
157  os << iter->first << ": " << iter->second << std::endl;
158  }
159  return;
160 }
161 
162 void FlagSavev1::PrintDoubleFlag(std::ostream &os) const
163 {
164  if (doubleflag.empty())
165  {
166  return;
167  }
168  std::map<std::string, double>::const_iterator iter;
169  os << "Double Flags: " << std::endl;
170  for (iter = doubleflag.begin(); iter != doubleflag.end(); ++iter)
171  {
172  os << iter->first << ": " << iter->second << std::endl;
173  }
174  return;
175 }
176 
177 void FlagSavev1::PrintFloatFlag(std::ostream &os) const
178 {
179  if (floatflag.empty())
180  {
181  return;
182  }
183  std::map<std::string, float>::const_iterator iter;
184  os << "Float Flags: " << std::endl;
185  for (iter = floatflag.begin(); iter != floatflag.end(); ++iter)
186  {
187  os << iter->first << ": " << iter->second << std::endl;
188  }
189  return;
190 }
191 
192 void FlagSavev1::PrintStringFlag(std::ostream &os) const
193 {
194  if (stringflag.empty())
195  {
196  return;
197  }
198  std::map<std::string, std::string>::const_iterator iter;
199  os << "String Flags: " << std::endl;
200  for (iter = stringflag.begin(); iter != stringflag.end(); ++iter)
201  {
202  os << iter->first << ": " << iter->second << std::endl;
203  }
204  return;
205 }