Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-06 10:02:17

0001 // @(#)root/meta:$Id$
0002 // Author: Bianca-Cristina Cristescu   09/07/13
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TEnum
0013 #define ROOT_TEnum
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TEnum                                                                //
0018 //                                                                      //
0019 // TEnum class defines enum type.                                       //
0020 //                                                                      //
0021 //////////////////////////////////////////////////////////////////////////
0022 
0023 #include "TDataType.h"
0024 #include "TDictionary.h"
0025 #include "THashList.h"
0026 
0027 #include <string>
0028 
0029 class ClassInfo_t;
0030 class TClass;
0031 class TEnumConstant;
0032 
0033 class TEnum : public TDictionary {
0034 
0035 private:
0036    THashList    fConstantList;            // List of constants the enum type
0037    ClassInfo_t *fInfo  = nullptr;         //!Interpreter information, owned by TEnum
0038    TClass      *fClass = nullptr;         //!Owning class
0039    std::string  fQualName;                // Fully qualified type name
0040    EDataType    fUnderlyingType = kInt_t; // Type (size) used to store the enum in memory
0041 
0042    enum EStatusBits {
0043       kBitIsScopedEnum = BIT(14), ///< The enum is an enum class.
0044       kBitIsValid = BIT(15)       ///< The TEnum object was read from file (assumed valid)
0045    };
0046 
0047 public:
0048 
0049    enum ESearchAction {kNone                 = 0,
0050                        kAutoload             = 1,
0051                        kInterpLookup         = 2,
0052                        kALoadAndInterpLookup = 3
0053                       };
0054 
0055    TEnum() : TDictionary()  {}
0056    TEnum(const char *name, DeclId_t declid, TClass *cls);
0057    TEnum(const TEnum &);
0058    TEnum& operator=(const TEnum &);
0059 
0060    virtual ~TEnum();
0061 
0062    void                  AddConstant(TEnumConstant *constant);
0063    TClass               *GetClass() const { return fClass; }
0064    const TSeqCollection *GetConstants() const { return &fConstantList; }
0065    const TEnumConstant  *GetConstant(const char *name) const { return (TEnumConstant *)fConstantList.FindObject(name); }
0066    DeclId_t              GetDeclId() const;
0067 
0068    /// Get the underlying integer type of the enum:
0069    ///     enum E { kOne }; //  ==> int
0070    ///     enum F: long; //  ==> long
0071    /// Returns kNumDataTypes if the enum is unknown / invalid.
0072    EDataType             GetUnderlyingType() const { return fUnderlyingType; };
0073 
0074    Bool_t                IsValid();
0075    Long_t                Property() const override;
0076    void                  SetClass(TClass *cl) { fClass = cl; }
0077    void                  Update(DeclId_t id);
0078    const char*           GetQualifiedName() const { return fQualName.c_str(); }
0079    static TEnum         *GetEnum(const std::type_info &ti, ESearchAction sa = kALoadAndInterpLookup);
0080    static TEnum         *GetEnum(const char *enumName, ESearchAction sa = kALoadAndInterpLookup);
0081 
0082    ClassDefOverride(TEnum, 2) //Enum type class
0083 };
0084 
0085 #endif