Logo ROOT   6.19/01
Reference Guide
TEnum.h
Go to the documentation of this file.
1 // @(#)root/meta:$Id$
2 // Author: Bianca-Cristina Cristescu 09/07/13
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TEnum
13 #define ROOT_TEnum
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TEnum //
18 // //
19 // TEnum class defines enum type. //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include "TDataType.h"
24 #include "TDictionary.h"
25 #include "THashList.h"
26 
27 #include <string>
28 
29 class ClassInfo_t;
30 class TClass;
31 class TEnumConstant;
32 
33 class TEnum : public TDictionary {
34 
35 private:
36  THashList fConstantList; //list of constants the enum type
37  ClassInfo_t *fInfo; //!interpreter information, owned by TEnum
38  TClass *fClass; //!owning class
39  std::string fQualName; // fully qualified type name
40 
41  enum EBits {
42  kBitIsScopedEnum = BIT(14) ///< The enum is an enum class.
43  };
44 
45 public:
46 
47  enum ESearchAction {kNone = 0,
48  kAutoload = 1,
51  };
52 
53  TEnum(): fInfo(nullptr), fClass(nullptr) {}
54  TEnum(const char *name, DeclId_t declid, TClass *cls);
55  virtual ~TEnum();
56 
57  void AddConstant(TEnumConstant *constant);
58  TClass *GetClass() const { return fClass; }
59  const TSeqCollection *GetConstants() const { return &fConstantList; }
60  const TEnumConstant *GetConstant(const char *name) const { return (TEnumConstant *)fConstantList.FindObject(name); }
61  DeclId_t GetDeclId() const;
63  Bool_t IsValid();
64  Long_t Property() const;
65  void SetClass(TClass *cl) { fClass = cl; }
66  void Update(DeclId_t id);
67  const char* GetQualifiedName() const { return fQualName.c_str(); }
68  static TEnum *GetEnum(const std::type_info &ti, ESearchAction sa = kALoadAndInterpLookup);
69  static TEnum *GetEnum(const char *enumName, ESearchAction sa = kALoadAndInterpLookup);
70 
71  ClassDef(TEnum, 2) //Enum type class
72 };
73 
74 #endif
The TEnum class implements the enum type.
Definition: TEnum.h:33
void Update(DeclId_t id)
Definition: TEnum.cxx:126
EDataType GetUnderlyingType() const
Get the unterlying integer type of the enum: enum E { kOne }; // ==> int enum F: long; // ==> long Re...
Definition: TEnum.cxx:107
#define BIT(n)
Definition: Rtypes.h:83
TEnum()
Definition: TEnum.h:53
bool Bool_t
Definition: RtypesCore.h:59
TClass * fClass
interpreter information, owned by TEnum
Definition: TEnum.h:38
const char * GetQualifiedName() const
Definition: TEnum.h:67
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:262
const TSeqCollection * GetConstants() const
Definition: TEnum.h:59
const void * DeclId_t
Definition: TDictionary.h:209
ClassInfo_t * fInfo
Definition: TEnum.h:37
virtual ~TEnum()
Destructor.
Definition: TEnum.cxx:63
Sequenceable collection abstract base class.
#define ClassDef(name, id)
Definition: Rtypes.h:326
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:34
This class defines an abstract interface that must be implemented by all classes that contain diction...
Definition: TDictionary.h:162
The TEnumConstant class implements the constants of the enum type.
Definition: TEnumConstant.h:29
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:75
The enum is an enum class.
Definition: TEnum.h:42
void SetClass(TClass *cl)
Definition: TEnum.h:65
void AddConstant(TEnumConstant *constant)
Add a EnumConstant to the list of constants of the Enum Type.
Definition: TEnum.cxx:71
std::string fQualName
owning class
Definition: TEnum.h:39
DeclId_t GetDeclId() const
Definition: TEnum.cxx:116
long Long_t
Definition: RtypesCore.h:50
EDataType
Definition: TDataType.h:28
Bool_t IsValid()
Return true if this enum object is pointing to a currently loaded enum.
Definition: TEnum.cxx:81
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
Definition: TEnum.cxx:143
TClass * GetClass() const
Definition: TEnum.h:58
EBits
Definition: TEnum.h:41
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Definition: TEnum.cxx:96
ESearchAction
Definition: TEnum.h:47
THashList fConstantList
Definition: TEnum.h:36
char name[80]
Definition: TGX11.cxx:109
const TEnumConstant * GetConstant(const char *name) const
Definition: TEnum.h:60