16 #ifndef ROO_ABS_CATEGORY 
   17 #define ROO_ABS_CATEGORY 
   27 class RooVectorDataStore ;
 
   29 class RooAbsCategory : 
public RooAbsArg {
 
   32   RooAbsCategory() : _byteValue(0), _treeVar(false) { };
 
   33   RooAbsCategory(
const char *name, 
const char *title);
 
   34   RooAbsCategory(
const RooAbsCategory& other, 
const char* name=0) ;
 
   35   virtual ~RooAbsCategory();
 
   38   virtual Int_t getIndex() 
const ;
 
   39   virtual const char* getLabel() 
const ;
 
   40   Bool_t operator==(Int_t index) 
const ;
 
   41   Bool_t operator!=(Int_t index) {  
return !operator==(index);}
 
   42   Bool_t operator==(
const char* label) 
const ;
 
   43   Bool_t operator!=(
const char* label) { 
return !operator==(label);}
 
   44   virtual Bool_t operator==(
const RooAbsArg& other) ;
 
   45   Bool_t         operator!=(
const RooAbsArg& other) { 
return !operator==(other);}
 
   46   virtual Bool_t isIdentical(
const RooAbsArg& other, Bool_t assumeSameType=kFALSE)  ;
 
   48   Bool_t isValidIndex(Int_t index) 
const ;
 
   49   Bool_t isValidLabel(
const char* label) 
const ;  
 
   50   const RooCatType* lookupType(Int_t index, Bool_t printError=kFALSE) 
const ;
 
   51   const RooCatType* lookupType(
const char* label, Bool_t printError=kFALSE) 
const ;
 
   52   const RooCatType* lookupType(
const RooCatType& type, Bool_t printError=kFALSE) 
const ;
 
   55   R__SUGGEST_ALTERNATIVE(
"Use begin(), end() or range-based for loops.")
 
   56   typeIterator()
 const {
 
   57     return new LegacyIterator(_types);
 
   60   Int_t numTypes(
const char* =0)
 const { 
 
   63   Bool_t isSignType(Bool_t mustHaveZero=kFALSE) 
const ;
 
   65   Roo1DTable *createTable(
const char *label) 
const ;
 
   68   virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
 
   69   virtual void writeToStream(std::ostream& os, Bool_t compact) 
const ;
 
   71   virtual void printValue(std::ostream& os) 
const ;
 
   72   virtual void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent=
"") 
const ;
 
   74   virtual Bool_t isIntegrationSafeLValue(
const RooArgSet* )
 const { 
 
   79   RooAbsArg *createFundamental(
const char* newname=0) 
const;
 
   81   std::vector<RooCatType*>::const_iterator begin()
 const {
 
   82     return _types.cbegin();
 
   85   std::vector<RooCatType*>::const_iterator end()
 const {
 
   89   std::size_t size()
 const {
 
   96   RooCatType traceEval() 
const ;
 
   98   virtual Bool_t traceEvalHook(RooCatType )
 const { 
 
  102   virtual RooCatType evaluate() 
const = 0 ;
 
  105   const RooCatType* defineType(
const char* label) ;
 
  106   const RooCatType* defineType(
const char* label, Int_t index) ;
 
  107   const RooCatType* defineTypeUnchecked(
const char* label, Int_t index) ;
 
  108   const RooCatType* getOrdinal(UInt_t n, 
const char* rangeName=0) 
const;
 
  111   virtual Bool_t isValid() 
const ;
 
  112   virtual Bool_t isValid(
const RooCatType& value) 
const ;
 
  114   friend class RooVectorDataStore ;
 
  115   virtual void syncCache(
const RooArgSet* set=0) ;
 
  116   virtual void copyCache(
const RooAbsArg* source, Bool_t valueOnly=kFALSE, Bool_t setValueDirty=kTRUE) ;
 
  117   virtual void attachToTree(TTree& t, Int_t bufSize=32000) ;
 
  118   virtual void attachToVStore(RooVectorDataStore& vstore) ;
 
  119   virtual void setTreeBranchStatus(TTree& t, Bool_t active) ;
 
  120   virtual void fillTreeBranch(TTree& t) ;
 
  122   mutable UChar_t    _byteValue ; 
 
  123   mutable RooCatType _value ; 
 
  126   std::vector<RooCatType*> _types; 
 
  130   class LegacyIterator : 
public TIterator {
 
  132       LegacyIterator(
const std::vector<RooCatType*>& vec) : _vec(&vec), index(-1) { }
 
  133       const TCollection *GetCollection()
 const override {
 
  136       TObject* Next()
 override {
 
  138         return this->operator*();
 
  140       void Reset()
 override {
 
  143       TObject* operator*()
 const override {
 
  145         return 0 <= index && index < (int)_vec->size() ? 
const_cast<RooCatType*
>((*_vec)[index]) : 
nullptr;
 
  147       LegacyIterator& operator=(
const LegacyIterator&) = 
default;
 
  148       TIterator& operator=(
const TIterator& other)
 override {
 
  149         auto otherLeg = 
dynamic_cast<LegacyIterator*
>(*other);
 
  151           return this->operator=(*otherLeg);
 
  153         throw std::logic_error(
"Cannot assign to category iterators from incompatible types.");
 
  157       const std::vector<RooCatType*>* _vec;
 
  161   ClassDef(RooAbsCategory, 2)