File indexing completed on 2025-01-18 10:10:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROO_CAT_TYPE
0017 #define ROO_CAT_TYPE
0018
0019 #include "TObject.h"
0020 #include "RooPrintable.h"
0021 #include "strlcpy.h"
0022
0023 class RooCatType : public TObject, public RooPrintable {
0024 public:
0025 inline RooCatType()
0026 {
0027 _label[0] = 0;
0028 }
0029
0030
0031 inline RooCatType(const char *name, Int_t value) : _value(value)
0032 {
0033 SetName(name);
0034 }
0035
0036 inline RooCatType(const RooCatType& other) :
0037 TObject(other), RooPrintable(other), _value(other._value) {
0038 strlcpy(_label,other._label,256) ;
0039 }
0040
0041 TObject* Clone(const char*) const override { return new RooCatType(*this); }
0042
0043 const Text_t* GetName() const override {
0044
0045 return _label[0] ? _label : nullptr ;
0046 }
0047 void SetName(const Text_t* name) ;
0048
0049 inline RooCatType& operator=(const RooCatType& other) {
0050
0051 if (&other==this) return *this ;
0052 SetName(other.GetName()) ;
0053 _value = other._value ;
0054 return *this ;
0055 }
0056
0057 inline void assignFast(const RooCatType& other) {
0058
0059 _label[0] = 0 ;
0060 _value = other._value ;
0061 }
0062
0063 inline bool operator==(const RooCatType& other) const {
0064
0065 return (_value==other._value) ;
0066 }
0067
0068 inline bool operator==(Int_t index) const {
0069
0070 return (_value==index) ;
0071 }
0072
0073 bool operator==(const char* label) const {
0074
0075 return label && !strcmp(_label,label) ;
0076 }
0077
0078 inline Int_t getVal() const {
0079
0080 return _value ;
0081 }
0082 void setVal(Int_t newValue) {
0083
0084 _value = newValue ;
0085 }
0086
0087 void printName(std::ostream& os) const override ;
0088 void printTitle(std::ostream& os) const override ;
0089 void printClassName(std::ostream& os) const override ;
0090 void printValue(std::ostream& os) const override ;
0091
0092 inline void Print(Option_t *options= nullptr) const override {
0093
0094 printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
0095 }
0096
0097 protected:
0098
0099 friend class RooAbsCategoryLValue ;
0100 friend class RooAbsCategory ;
0101 Int_t _value = 0;
0102 char _label[256] ;
0103
0104 ClassDefOverride(RooCatType,1)
0105 } R__SUGGEST_ALTERNATIVE("Instead of RooCatType, directly use the category number returned by RooAbsCategory::getIndex().\n"
0106 "Convert it into a name using RooAbsCategory::lookupName(index).");
0107
0108
0109 #endif
0110