CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  namespace flag {
8  //
9  // State Definition. In the increasing order of worsiness.
10  // States(as flags) can be added
11  // s1 + s2 = max(s1,s2) - that allows to set the worse of the 2
12  //
13  enum State {
14  fNONE = 0, // No State - can't have... not used....
15  fNCDAQ = 1, // not @cDAQ
16  fNA = 2, // Not Applicable
17  fGOOD = 3, // GOOD
18  fPROBLEMATIC = 4, // problem
19  fBAD = 5, // bad
20  fRESERVED = 6, // reserved
21  nState = 7
22  };
23 
24  struct Flag {
25  Flag() : _name("SOMEFLAG"), _state(fNA) {}
26  Flag(std::string const &name, State s = fNA) : _name(name), _state(s) {}
27  Flag(Flag const &f) : _name(f._name), _state(f._state) {}
28 
29  //
30  // add 2 flags
31  //
32  Flag operator+(Flag const &f) {
33  return Flag(_name != f._name ? "SOMEFLAG" : _name, (State)(std::max(_state, f._state)));
34  }
35 
36  //
37  // add 2 flags and save
38  //
39  Flag &operator+=(Flag const &f) {
41  return *this;
42  }
43 
44  //
45  // compare 2 flags
46  //
47  bool operator==(Flag const &f) { return (_state == f._state && _name == f._name); }
48 
49  //
50  // Assignment
51  //
52  Flag &operator=(Flag const &f) {
53  _name = f._name;
54  _state = f._state;
55  return *this;
56  }
57 
58  // reset the state to NA
59  void reset() { _state = fNA; }
60 
63  };
64  } // namespace flag
65 } // namespace hcaldqm
66 
67 #endif
Flag(Flag const &f)
Definition: Flag.h:27
std::string _name
Definition: Flag.h:61
State _state
Definition: Flag.h:62
void reset()
Definition: Flag.h:59
Flag operator+(Flag const &f)
Definition: Flag.h:32
Flag(std::string const &name, State s=fNA)
Definition: Flag.h:26
bool operator==(Flag const &f)
Definition: Flag.h:47
Flag & operator=(Flag const &f)
Definition: Flag.h:52
Flag & operator+=(Flag const &f)
Definition: Flag.h:39