File indexing completed on 2026-09-04 09:28:02
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TEnum
0013 #define ROOT_TEnum
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #include "TDataType.h"
0024 #include "TDictionary.h"
0025 #include "THashList.h"
0026
0027 #include <string>
0028
0029 class ClassInfo_t;
0030 class TClass;
0031 class TEnumConstant;
0032
0033 class TEnum : public TDictionary {
0034
0035 private:
0036 THashList fConstantList;
0037 ClassInfo_t *fInfo = nullptr;
0038 TClass *fClass = nullptr;
0039 std::string fQualName;
0040 EDataType fUnderlyingType = kInt_t;
0041
0042 enum EStatusBits {
0043 kBitIsScopedEnum = BIT(14),
0044 kBitIsValid = BIT(15)
0045 };
0046
0047 public:
0048
0049 enum ESearchAction {
0050
0051 #if defined(__clang__) && __clang_major__ < 20
0052 #pragma clang diagnostic push
0053 #pragma clang diagnostic ignored "-Wshadow"
0054 #endif
0055 kNone = 0,
0056 #if defined(__clang__) && __clang_major__ < 20
0057 #pragma clang diagnostic pop
0058 #endif
0059 kAutoload = 1,
0060 kInterpLookup = 2,
0061 kALoadAndInterpLookup = 3
0062 };
0063
0064 TEnum() : TDictionary() {}
0065 TEnum(const char *name, DeclId_t declid, TClass *cls);
0066 TEnum(const TEnum &);
0067 TEnum& operator=(const TEnum &);
0068
0069 virtual ~TEnum();
0070
0071 void AddConstant(TEnumConstant *constant);
0072 TClass *GetClass() const { return fClass; }
0073 const TSeqCollection *GetConstants() const { return &fConstantList; }
0074 const TEnumConstant *GetConstant(const char *name) const { return (TEnumConstant *)fConstantList.FindObject(name); }
0075 DeclId_t GetDeclId() const;
0076
0077
0078
0079
0080
0081 EDataType GetUnderlyingType() const { return fUnderlyingType; };
0082
0083 Bool_t IsValid();
0084 Long_t Property() const override;
0085 void SetClass(TClass *cl) { fClass = cl; }
0086 void Update(DeclId_t id);
0087 const char* GetQualifiedName() const { return fQualName.c_str(); }
0088 static TEnum *GetEnum(const std::type_info &ti, ESearchAction sa = kALoadAndInterpLookup);
0089 static TEnum *GetEnum(const char *enumName, ESearchAction sa = kALoadAndInterpLookup);
0090
0091 ClassDefOverride(TEnum, 2)
0092 };
0093
0094 #endif