Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TEnum.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 EBits {
0043      kBitIsScopedEnum = BIT(14) ///< The enum is an enum class.
0044    };
0045 
0046 public:
0047 
0048    enum ESearchAction {kNone                 = 0,
0049                        kAutoload             = 1,
0050                        kInterpLookup         = 2,
0051                        kALoadAndInterpLookup = 3
0052                       };
0053 
0054    TEnum() : TDictionary()  {}
0055    TEnum(const char *name, DeclId_t declid, TClass *cls);
0056    TEnum(const TEnum &);
0057    TEnum& operator=(const TEnum &);
0058 
0059    virtual ~TEnum();
0060 
0061    void                  AddConstant(TEnumConstant *constant);
0062    TClass               *GetClass() const { return fClass; }
0063    const TSeqCollection *GetConstants() const { return &fConstantList; }
0064    const TEnumConstant  *GetConstant(const char *name) const { return (TEnumConstant *)fConstantList.FindObject(name); }
0065    DeclId_t              GetDeclId() const;
0066 
0067    /// Get the underlying integer type of the enum:
0068    ///     enum E { kOne }; //  ==> int
0069    ///     enum F: long; //  ==> long
0070    /// Returns kNumDataTypes if the enum is unknown / invalid.
0071    EDataType             GetUnderlyingType() const { return fUnderlyingType; };
0072 
0073    Bool_t                IsValid();
0074    Long_t                Property() const override;
0075    void                  SetClass(TClass *cl) { fClass = cl; }
0076    void                  Update(DeclId_t id);
0077    const char*           GetQualifiedName() const { return fQualName.c_str(); }
0078    static TEnum         *GetEnum(const std::type_info &ti, ESearchAction sa = kALoadAndInterpLookup);
0079    static TEnum         *GetEnum(const char *enumName, ESearchAction sa = kALoadAndInterpLookup);
0080 
0081    ClassDefOverride(TEnum, 2) //Enum type class
0082 };
0083 
0084 #endif