Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
29class ClassInfo_t;
30class TClass;
31class TEnumConstant;
32
33class TEnum : public TDictionary {
34
35private:
36 THashList fConstantList; // List of constants the enum type
37 ClassInfo_t *fInfo = nullptr; //!Interpreter information, owned by TEnum
38 TClass *fClass = nullptr; //!Owning class
39 std::string fQualName; // Fully qualified type name
40 EDataType fUnderlyingType = kInt_t; // Type (size) used to store the enum in memory
41
42 enum EBits {
43 kBitIsScopedEnum = BIT(14) ///< The enum is an enum class.
44 };
45
46public:
47
52 };
53
54 TEnum() = default;
55 TEnum(const char *name, DeclId_t declid, TClass *cls);
56 virtual ~TEnum();
57
58 void AddConstant(TEnumConstant *constant);
59 TClass *GetClass() const { return fClass; }
60 const TSeqCollection *GetConstants() const { return &fConstantList; }
61 const TEnumConstant *GetConstant(const char *name) const { return (TEnumConstant *)fConstantList.FindObject(name); }
62 DeclId_t GetDeclId() const;
63
64 /// Get the unterlying integer type of the enum:
65 /// enum E { kOne }; // ==> int
66 /// enum F: long; // ==> long
67 /// Returns kNumDataTypes if the enum is unknown / invalid.
69
71 Long_t Property() const;
72 void SetClass(TClass *cl) { fClass = cl; }
73 void Update(DeclId_t id);
74 const char* GetQualifiedName() const { return fQualName.c_str(); }
75 static TEnum *GetEnum(const std::type_info &ti, ESearchAction sa = kALoadAndInterpLookup);
76 static TEnum *GetEnum(const char *enumName, ESearchAction sa = kALoadAndInterpLookup);
77
78 ClassDef(TEnum, 2) //Enum type class
79};
80
81#endif
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
#define ClassDef(name, id)
Definition Rtypes.h:325
#define BIT(n)
Definition Rtypes.h:85
EDataType
Definition TDataType.h:28
@ kInt_t
Definition TDataType.h:30
char name[80]
Definition TGX11.cxx:110
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:80
This class defines an abstract interface that must be implemented by all classes that contain diction...
const void * DeclId_t
The TEnumConstant class implements the constants of the enum type.
The TEnum class implements the enum type.
Definition TEnum.h:33
EDataType GetUnderlyingType() const
Get the unterlying integer type of the enum: enum E { kOne }; // ==> int enum F: long; // ==> long Re...
Definition TEnum.h:68
EBits
Definition TEnum.h:42
@ kBitIsScopedEnum
The enum is an enum class.
Definition TEnum.h:43
THashList fConstantList
Definition TEnum.h:36
TClass * GetClass() const
Definition TEnum.h:59
void AddConstant(TEnumConstant *constant)
Add a EnumConstant to the list of constants of the Enum Type.
Definition TEnum.cxx:71
const char * GetQualifiedName() const
Definition TEnum.h:74
const TSeqCollection * GetConstants() const
Definition TEnum.h:60
const TEnumConstant * GetConstant(const char *name) const
Definition TEnum.h:61
ClassInfo_t * fInfo
Definition TEnum.h:37
TEnum()=default
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Definition TEnum.cxx:96
TClass * fClass
Interpreter information, owned by TEnum.
Definition TEnum.h:38
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
Definition TEnum.cxx:132
void Update(DeclId_t id)
Definition TEnum.cxx:113
Bool_t IsValid()
Return true if this enum object is pointing to a currently loaded enum.
Definition TEnum.cxx:81
EDataType fUnderlyingType
Definition TEnum.h:40
DeclId_t GetDeclId() const
Definition TEnum.cxx:103
std::string fQualName
Owning class.
Definition TEnum.h:39
ESearchAction
Definition TEnum.h:48
@ kALoadAndInterpLookup
Definition TEnum.h:51
@ kNone
Definition TEnum.h:48
@ kAutoload
Definition TEnum.h:49
@ kInterpLookup
Definition TEnum.h:50
virtual ~TEnum()
Destructor.
Definition TEnum.cxx:63
void SetClass(TClass *cl)
Definition TEnum.h:72
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
TObject * FindObject(const char *name) const
Find object using its name.
Sequenceable collection abstract base class.