CMS 3D CMS Logo

Flag.h
Go to the documentation of this file.
1 #ifndef DQM_HcalCommon_Flag_h
2 #define DQM_HcalCommon_Flag_h
3 
5 
6 namespace hcaldqm
7 {
8  namespace flag
9  {
10  //
11  // State Definition. In the increasing order of worsiness.
12  // States(as flags) can be added
13  // s1 + s2 = max(s1,s2) - that allows to set the worse of the 2
14  //
15  enum State
16  {
17  fNONE=0, // No State - can't have... not used....
18  fNCDAQ=1, // not @cDAQ
19  fNA = 2, // Not Applicable
20  fGOOD = 3, // GOOD
21  fPROBLEMATIC = 4, // problem
22  fBAD = 5, // bad
23  fRESERVED = 6, // reserved
24  nState = 7
25  };
26 
27  struct Flag
28  {
29  Flag() :
30  _name("SOMEFLAG"), _state(fNA)
31  {}
33  _name(name), _state(s)
34  {}
35  Flag(Flag const& f):
36  _name(f._name), _state(f._state)
37  {}
38 
39  //
40  // add 2 flags
41  //
42  Flag operator+(Flag const& f)
43  {
44  return Flag(_name!=f._name?"SOMEFLAG":_name,
45  (State)(std::max(_state, f._state)));
46  }
47 
48  //
49  // add 2 flags and save
50  //
51  Flag& operator+=(Flag const& f)
52  {
54  return *this;
55  }
56 
57  //
58  // compare 2 flags
59  //
60  bool operator==(Flag const& f)
61  {
62  return (_state==f._state && _name==f._name);
63  }
64 
65  //
66  // Assignment
67  //
68  Flag& operator=(Flag const& f)
69  {
70  _name = f._name;
71  _state = f._state;
72  return *this;
73  }
74 
75  // reset the state to NA
76  void reset() {_state = fNA;}
77 
80  };
81  }
82 }
83 
84 #endif
Flag(Flag const &f)
Definition: Flag.h:35
std::string _name
Definition: Flag.h:78
State _state
Definition: Flag.h:79
void reset()
Definition: Flag.h:76
Flag operator+(Flag const &f)
Definition: Flag.h:42
double f[11][100]
Flag(std::string const &name, State s=fNA)
Definition: Flag.h:32
bool operator==(Flag const &f)
Definition: Flag.h:60
Flag & operator=(Flag const &f)
Definition: Flag.h:68
Flag & operator+=(Flag const &f)
Definition: Flag.h:51