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
55 TEnum(const char *name, DeclId_t declid, TClass *cls);
56 TEnum(const TEnum &);
57 TEnum& operator=(const TEnum &);
58
59 virtual ~TEnum();
60
61 void AddConstant(TEnumConstant *constant);
62 TClass *GetClass() const { return fClass; }
63 const TSeqCollection *GetConstants() const { return &fConstantList; }
64 const TEnumConstant *GetConstant(const char *name) const { return (TEnumConstant *)fConstantList.FindObject(name); }
65 DeclId_t GetDeclId() const;
66
67 /// Get the underlying integer type of the enum:
68 /// enum E { kOne }; // ==> int
69 /// enum F: long; // ==> long
70 /// Returns kNumDataTypes if the enum is unknown / invalid.
72
74 Long_t Property() const override;
75 void SetClass(TClass *cl) { fClass = cl; }
76 void Update(DeclId_t id);
77 const char* GetQualifiedName() const { return fQualName.c_str(); }
78 static TEnum *GetEnum(const std::type_info &ti, ESearchAction sa = kALoadAndInterpLookup);
79 static TEnum *GetEnum(const char *enumName, ESearchAction sa = kALoadAndInterpLookup);
80
81 ClassDefOverride(TEnum, 2) //Enum type class
82};
83
84#endif
bool Bool_t
Definition RtypesCore.h:63
long Long_t
Definition RtypesCore.h:54
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
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:81
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 underlying integer type of the enum: enum E { kOne }; // ==> int enum F: long; // ==> long Re...
Definition TEnum.h:71
TEnum & operator=(const TEnum &)
Assign operator.
Definition TEnum.cxx:81
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:62
void AddConstant(TEnumConstant *constant)
Add a EnumConstant to the list of constants of the Enum Type.
Definition TEnum.cxx:114
const char * GetQualifiedName() const
Definition TEnum.h:77
const TSeqCollection * GetConstants() const
Definition TEnum.h:63
const TEnumConstant * GetConstant(const char *name) const
Definition TEnum.h:64
ClassInfo_t * fInfo
Definition TEnum.h:37
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
Definition TEnum.cxx:139
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:175
void Update(DeclId_t id)
Definition TEnum.cxx:156
Bool_t IsValid()
Return true if this enum object is pointing to a currently loaded enum.
Definition TEnum.cxx:124
EDataType fUnderlyingType
Definition TEnum.h:40
DeclId_t GetDeclId() const
Definition TEnum.cxx:146
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
TEnum()
Definition TEnum.h:54
virtual ~TEnum()
Destructor.
Definition TEnum.cxx:106
void SetClass(TClass *cl)
Definition TEnum.h:75
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 override
Find object using its name.
Sequenceable collection abstract base class.