Class Reference for E1039 Core & Analysis Software
FlagSavev1.cc
Go to the documentation of this file.
1 #include "FlagSavev1.h"
2 #include <phool/PHFlag.h>
3 
4 using namespace std;
5 
6 FlagSavev1 *
8 {
9  FlagSavev1 * ret = new FlagSavev1();
10 
11  ret->intflag = this->intflag;
12  ret->doubleflag = this->doubleflag;
13  ret->floatflag = this->floatflag;
14  ret->stringflag = this->stringflag;
15 
16  return ret;
17 }
18 
19 int
21 {
22  if (intflag.empty() &&
23  doubleflag.empty() &&
24  floatflag.empty() &&
25  stringflag.empty())
26  {
27  return 0;
28  }
29  return 1;
30 }
31 
32 void
33 FlagSavev1::identify(ostream& out) const
34 {
35  out << "identify yourself: I am an FlagSavev1 Object" << endl;
36  PrintIntFlag(out) ;
37  PrintDoubleFlag(out);
38  PrintFloatFlag(out);
39  PrintStringFlag(out);
40  return ;
41 }
42 
43 int
45 {
46  int iret = FillIntFromPHFlag(flags);
47  iret += FillDoubleFromPHFlag(flags);
48  iret += FillFloatFromPHFlag(flags);
49  iret += FillCharFromPHFlag(flags);
50  return iret;
51 }
52 
53 int
55 {
56  int iret = PutIntToPHFlag(flags);
57  iret += PutDoubleToPHFlag(flags);
58  iret += PutFloatToPHFlag(flags);
59  iret += PutCharToPHFlag(flags);
60  return iret;
61 }
62 
63 
64 int
66 {
67  map<string, int>::const_iterator iter;
68  const map<string, int> *intm = flags->IntMap();
69  for (iter = intm->begin(); iter != intm->end(); ++iter)
70  {
71  intflag[iter->first] = iter->second;
72  }
73  return 0;
74 }
75 
76 int
78 {
79  map<string, double>::const_iterator iter;
80  const map<string, double> *intm = flags->DoubleMap();
81  for (iter = intm->begin(); iter != intm->end(); ++iter)
82  {
83  doubleflag[iter->first] = iter->second;
84  }
85  return 0;
86 }
87 
88 int
90 {
91  map<string, float>::const_iterator iter;
92  const map<string, float> *intm = flags->FloatMap();
93  for (iter = intm->begin(); iter != intm->end(); ++iter)
94  {
95  floatflag[iter->first] = iter->second;
96  }
97  return 0;
98 }
99 
100 int
102 {
103  map<string, string>::const_iterator iter;
104  const map<string, string> *intm = flags->CharMap();
105  for (iter = intm->begin(); iter != intm->end(); ++iter)
106  {
107  string input(iter->second);
108  stringflag[iter->first] = input;
109  }
110  return 0;
111 }
112 
113 int
115 {
116  map<string, int>::const_iterator iter;
117  for (iter = intflag.begin(); iter != intflag.end(); ++iter)
118  {
119  flags->set_IntFlag(iter->first,iter->second);
120  }
121  return 0;
122 }
123 
124 int
126 {
127  map<string, double>::const_iterator iter;
128  for (iter = doubleflag.begin(); iter != doubleflag.end(); ++iter)
129  {
130  flags->set_DoubleFlag(iter->first,iter->second);
131  }
132  return 0;
133 }
134 
135 int
137 {
138  map<string, float>::const_iterator iter;
139  for (iter = floatflag.begin(); iter != floatflag.end(); ++iter)
140  {
141  flags->set_FloatFlag(iter->first,iter->second);
142  }
143  return 0;
144 }
145 
146 int
148 {
149  map<string, string>::const_iterator iter;
150  for (iter = stringflag.begin(); iter != stringflag.end(); ++iter)
151  {
152  flags->set_CharFlag(iter->first,iter->second);
153  }
154  return 0;
155 }
156 
157 void
158 FlagSavev1::PrintIntFlag(std::ostream& os) const
159 {
160  if (intflag.empty())
161  {
162  return ;
163  }
164  map<string, int>::const_iterator iter;
165  os << "Int Flags: " << endl;
166  for (iter = intflag.begin(); iter != intflag.end(); ++iter)
167  {
168  os << iter->first << ": " << iter->second << endl;
169  }
170  return ;
171 }
172 
173 void
174 FlagSavev1::PrintDoubleFlag(std::ostream& os) const
175 {
176  if (doubleflag.empty())
177  {
178  return ;
179  }
180  map<string, double>::const_iterator iter;
181  os << "Double Flags: " << endl;
182  for (iter = doubleflag.begin(); iter != doubleflag.end(); ++iter)
183  {
184  os << iter->first << ": " << iter->second << endl;
185  }
186  return ;
187 }
188 
189 void
190 FlagSavev1::PrintFloatFlag(std::ostream& os) const
191 {
192  if (floatflag.empty())
193  {
194  return ;
195  }
196  map<string, float>::const_iterator iter;
197  os << "Float Flags: " << endl;
198  for (iter = floatflag.begin(); iter != floatflag.end(); ++iter)
199  {
200  os << iter->first << ": " << iter->second << endl;
201  }
202  return ;
203 }
204 
205 void
206 FlagSavev1::PrintStringFlag(std::ostream& os) const
207 {
208  if (stringflag.empty())
209  {
210  return ;
211  }
212  map<string, string>::const_iterator iter;
213  os << "String Flags: " << endl;
214  for (iter = stringflag.begin(); iter != stringflag.end(); ++iter)
215  {
216  os << iter->first << ": " << iter->second << endl;
217  }
218  return ;
219  }
int isValid() const
isValid returns non zero if object contains valid data
Definition: FlagSavev1.cc:20
int FillDoubleFromPHFlag(const PHFlag *flags)
Definition: FlagSavev1.cc:77
int FillCharFromPHFlag(const PHFlag *flags)
Definition: FlagSavev1.cc:101
int PutIntToPHFlag(PHFlag *flags)
Definition: FlagSavev1.cc:114
void PrintIntFlag(std::ostream &os) const
Definition: FlagSavev1.cc:158
int PutCharToPHFlag(PHFlag *flags)
Definition: FlagSavev1.cc:147
void PrintFloatFlag(std::ostream &os) const
Definition: FlagSavev1.cc:190
std::map< std::string, float > floatflag
Definition: FlagSavev1.h:53
std::map< std::string, double > doubleflag
Definition: FlagSavev1.h:52
void identify(std::ostream &os=std::cout) const
Definition: FlagSavev1.cc:33
int FillIntFromPHFlag(const PHFlag *flags)
Definition: FlagSavev1.cc:65
void PrintDoubleFlag(std::ostream &os) const
Definition: FlagSavev1.cc:174
std::map< std::string, std::string > stringflag
Definition: FlagSavev1.h:54
int PutFlagsBack(PHFlag *flags)
Definition: FlagSavev1.cc:54
FlagSavev1 * clone() const
Virtual copy constructor.
Definition: FlagSavev1.cc:7
int FillFloatFromPHFlag(const PHFlag *flags)
Definition: FlagSavev1.cc:89
std::map< std::string, int > intflag
Definition: FlagSavev1.h:51
int PutDoubleToPHFlag(PHFlag *flags)
Definition: FlagSavev1.cc:125
void PrintStringFlag(std::ostream &os) const
Definition: FlagSavev1.cc:206
int PutFloatToPHFlag(PHFlag *flags)
Definition: FlagSavev1.cc:136
int FillFromPHFlag(const PHFlag *flags)
Definition: FlagSavev1.cc:44
Definition: PHFlag.h:20
virtual void set_IntFlag(const std::string &name, const int flag)
Definition: PHFlag.cc:145
virtual void set_DoubleFlag(const std::string &name, const double flag)
Definition: PHFlag.cc:77
virtual void set_CharFlag(const std::string &name, const std::string &flag)
Definition: PHFlag.cc:43
virtual const std::map< std::string, int > * IntMap() const
Definition: PHFlag.h:57
virtual const std::map< std::string, std::string > * CharMap() const
Definition: PHFlag.h:60
virtual void set_FloatFlag(const std::string &name, const float flag)
Definition: PHFlag.cc:111
virtual const std::map< std::string, double > * DoubleMap() const
Definition: PHFlag.h:59
virtual const std::map< std::string, float > * FloatMap() const
Definition: PHFlag.h:58