Flag

State

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#ifndef DQM_HcalCommon_Flag_h
#define DQM_HcalCommon_Flag_h

#include "DQM/HcalCommon/interface/HcalCommonHeaders.h"

namespace hcaldqm {
  namespace flag {
    //
    //	State Definition. In the increasing order of worsiness.
    //	States(as flags) can be added
    //	s1 + s2 = max(s1,s2) - that allows to set the worse of the 2
    //
    enum State {
      fNONE = 0,         // No State - can't have... not used....
      fNCDAQ = 1,        // not @cDAQ
      fNA = 2,           // Not Applicable
      fGOOD = 3,         // GOOD
      fPROBLEMATIC = 4,  // problem
      fBAD = 5,          //	bad
      fRESERVED = 6,     // reserved
      nState = 7
    };

    struct Flag {
      Flag() : _name("SOMEFLAG"), _state(fNA) {}
      Flag(std::string const &name, State s = fNA) : _name(name), _state(s) {}
      Flag(Flag const &f) : _name(f._name), _state(f._state) {}

      //
      //	add 2 flags
      //
      Flag operator+(Flag const &f) {
        return Flag(_name != f._name ? "SOMEFLAG" : _name, (State)(std::max(_state, f._state)));
      }

      //
      //	add 2 flags and save
      //
      Flag &operator+=(Flag const &f) {
        _state = (State)(std::max(_state, f._state));
        return *this;
      }

      //
      //	compare 2 flags
      //
      bool operator==(Flag const &f) { return (_state == f._state && _name == f._name); }

      //
      //	Assignment
      //
      Flag &operator=(Flag const &f) {
        _name = f._name;
        _state = f._state;
        return *this;
      }

      //	reset the state to NA
      void reset() { _state = fNA; }

      std::string _name;
      State _state;
    };
  }  // namespace flag
}  // namespace hcaldqm

#endif