Logo ROOT   6.08/07
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 #ifndef ROOT_TNamed
24 #include "TNamed.h"
25 #endif
26 #ifndef ROOT_THashList
27 #include "THashList.h"
28 #endif
29 #ifndef ROOT_TString
30 #include "TString.h"
31 #endif
32 #ifndef ROOT_TDictionary
33 #include "TDictionary.h"
34 #endif
35 #ifndef ROOT_Rtypeinfo
36 #include "Rtypeinfo.h"
37 #endif
38 
39 class TClass;
40 class TEnumConstant;
41 
42 class TEnum : public TDictionary {
43 
44 private:
45  THashList fConstantList; //list of constants the enum type
46  void *fInfo; //!interpreter implementation provided declaration
47  TClass *fClass; //!owning class
48  std::string fQualName; // fully qualified type name
49 
50 public:
51 
52  enum ESearchAction {kNone = 0,
53  kAutoload = 1,
56  };
57 
58  TEnum(): fInfo(0), fClass(0) {}
59  TEnum(const char *name, void *info, TClass *cls);
60  virtual ~TEnum();
61 
62  void AddConstant(TEnumConstant *constant);
63  TClass *GetClass() const {
64  return fClass;
65  }
66  const TSeqCollection *GetConstants() const {
67  return &fConstantList;
68  }
69  const TEnumConstant *GetConstant(const char *name) const {
70  return (TEnumConstant *) fConstantList.FindObject(name);
71  }
72  DeclId_t GetDeclId() const {
73  return (DeclId_t)fInfo;
74  }
75  Bool_t IsValid();
76  Long_t Property() const;
77  void SetClass(TClass *cl) {
78  fClass = cl;
79  }
80  void Update(DeclId_t id);
81  const char* GetQualifiedName() const { return fQualName.c_str(); }
82  static TEnum *GetEnum(const std::type_info &ti, ESearchAction sa = kALoadAndInterpLookup);
83  static TEnum *GetEnum(const char *enumName, ESearchAction sa = kALoadAndInterpLookup);
84 
85  ClassDef(TEnum, 2) //Enum type class
86 };
87 
88 #endif
The TEnum class implements the enum type.
Definition: TEnum.h:42
void Update(DeclId_t id)
Definition: TEnum.cxx:101
TEnum()
Definition: TEnum.h:58
bool Bool_t
Definition: RtypesCore.h:59
TClass * fClass
interpreter implementation provided declaration
Definition: TEnum.h:47
const char * GetQualifiedName() const
Definition: TEnum.h:81
TObject * FindObject(const char *name) const
Find object using its name.
Definition: THashList.cxx:213
const TSeqCollection * GetConstants() const
Definition: TEnum.h:66
const void * DeclId_t
Definition: TDictionary.h:209
DeclId_t GetDeclId() const
Definition: TEnum.h:72
virtual ~TEnum()
Destructor.
Definition: TEnum.cxx:61
Sequenceable collection abstract base class.
#define ClassDef(name, id)
Definition: Rtypes.h:254
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition: THashList.h:36
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:33
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
void SetClass(TClass *cl)
Definition: TEnum.h:77
void AddConstant(TEnumConstant *constant)
Add a EnumConstant to the list of constants of the Enum Type.
Definition: TEnum.cxx:68
std::string fQualName
owning class
Definition: TEnum.h:48
long Long_t
Definition: RtypesCore.h:50
Bool_t IsValid()
Return true if this enum object is pointing to a currently loaded enum.
Definition: TEnum.cxx:78
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
Definition: TEnum.cxx:108
void * fInfo
Definition: TEnum.h:46
TClass * GetClass() const
Definition: TEnum.h:63
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Definition: TEnum.cxx:94
ESearchAction
Definition: TEnum.h:52
THashList fConstantList
Definition: TEnum.h:45
char name[80]
Definition: TGX11.cxx:109
const TEnumConstant * GetConstant(const char *name) const
Definition: TEnum.h:69