Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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,
49  kInterpLookup = 2,
50  kALoadAndInterpLookup = 3
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;
62  EDataType GetUnderlyingType() 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