Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-14 09:30:53

0001 // @(#)root/meta:$Id$
0002 // Author: Axel Naumann 2014-04-28
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2014, 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 
0013 #ifndef ROOT_TProtoClass
0014 #define ROOT_TProtoClass
0015 
0016 #include "TNamed.h"
0017 
0018 #include <vector>
0019 
0020 class TClass;
0021 class TList;
0022 class TRealData;
0023 #ifdef R__LESS_INCLUDES
0024 class TDataMember;
0025 #else
0026 #include "TDataMember.h"
0027 #endif
0028 
0029 //////////////////////////////////////////////////////////////////////////
0030 //                                                                      //
0031 // TProtoClass                                                          //
0032 //                                                                      //
0033 // Stores enough information to create a TClass from a dictionary       //
0034 // without interpreter information.                                     //
0035 //                                                                      //
0036 //////////////////////////////////////////////////////////////////////////
0037 
0038 class TProtoClass: public TNamed {
0039 public:
0040    struct TProtoRealData  {
0041       Long_t fOffset;     // data member offset
0042       Int_t  fDMIndex;    // index of data member in vector of data members
0043       Int_t  fLevel;      // member level (0 : belong to this class, 1 is a data member of a data member object, etc...)
0044       Int_t  fClassIndex; // index of class belonging to in list of dep classes
0045       char   fStatusFlag; // status of the real data member (if bit 0 set is an object, if bit 1 set is transient if bit 2 set is a pointer)
0046 
0047       enum EStatusFlags {
0048          kIsObject    = BIT(0),    // member is object
0049          kIsTransient = BIT(1),    // data member is transient
0050 // clang++ <v20 (-Wshadow) complains about shadowing TDictionary.h global enum EProperty. Let's silence warning:
0051 #if defined(__clang__) && __clang_major__ < 20
0052 #pragma clang diagnostic push
0053 #pragma clang diagnostic ignored "-Wshadow"
0054 #endif
0055          kIsPointer   = BIT(2),    // data member is a pointer
0056 #if defined(__clang__) && __clang_major__ < 20
0057 #pragma clang diagnostic pop
0058 #endif
0059          kBitMask     = 0x000000ff
0060       };
0061 
0062    public:
0063       bool IsAClass() const { return fClassIndex >= 0; }
0064       TProtoRealData() : fOffset(0), fDMIndex(-1), fLevel(0), fClassIndex(-1), fStatusFlag(0) {}
0065       TProtoRealData(const TRealData *rd);
0066       virtual ~TProtoRealData();
0067       TRealData *CreateRealData(TClass *currentClass, TClass *parent, TRealData * parentData, int prevLevel, bool quiet) const;
0068 
0069       Bool_t TestFlag(UInt_t f) const { return (Bool_t) ((fStatusFlag & f) != 0); }
0070       void SetFlag(UInt_t f, Bool_t on = kTRUE) {
0071          if (on)
0072             fStatusFlag |= f & kBitMask;
0073          else
0074             fStatusFlag &= ~(f & kBitMask);
0075       }
0076 
0077       ClassDef(TProtoRealData, 3);//Persistent version of TRealData
0078    };
0079 
0080 private:
0081    TList   *fBase;     // List of base classes
0082    TList   *fEnums;    // List of enums in this scope
0083    std::vector<TProtoRealData> fPRealData;  // List of TProtoRealData
0084    std::vector<TDataMember *>  fData;       // collection of data members
0085    std::vector<TString>        fDepClasses; // list of dependent classes
0086    Int_t    fSizeof;         // Size of the class
0087    UInt_t   fCheckSum;       //checksum of data members and base classes
0088    Int_t    fCanSplit;       // Whether this class can be split
0089    Int_t    fStreamerType;   // Which streaming method to use
0090    Long_t   fProperty;       // Class properties, see EProperties
0091    Long_t   fClassProperty;  // Class C++ properties, see EClassProperties
0092    Long_t   fOffsetStreamer; // Offset to streamer function
0093    bool     fOwner = true;   ///<! True if owns its content, false if it got a reference to the TClass content.
0094 
0095    TProtoClass(const TProtoClass &) = delete;
0096    TProtoClass &operator=(const TProtoClass &) = delete;
0097 
0098    const char * GetClassName(Int_t index) const { return (index >= 0) ? fDepClasses[index].Data() : nullptr; }
0099 
0100    // compute index of data member in the list
0101    static Int_t DataMemberIndex(TClass * cl, const char * name);
0102    // find data member  given an index
0103    static TDataMember * FindDataMember(TClass * cl,  Int_t index, bool quiet);
0104 
0105 public:
0106    TProtoClass():
0107       fBase(nullptr), fEnums(nullptr), fSizeof(0), fCheckSum(0), fCanSplit(0),
0108       fStreamerType(0), fProperty(0), fClassProperty(0),
0109       fOffsetStreamer(0) {
0110    }
0111 
0112    TProtoClass(TProtoClass *pc);
0113    TProtoClass(TClass *cl);
0114    virtual ~TProtoClass();
0115 
0116    Bool_t FillTClass(TClass *pcl);
0117    const TList *GetListOfEnums() { return fEnums; };
0118    void Delete(Option_t *opt = "") override;
0119 
0120    int GetSize() { return fSizeof; }
0121    TList * GetBaseList() { return fBase; }
0122    //TList * GetDataList() { return fData; }
0123    TList * GetEnumList() { return fEnums; }
0124    std::vector<TProtoRealData> & GetPRDList() { return fPRealData; }
0125    std::vector<TDataMember *> & GetData() { return fData; }
0126    std::vector<TString> & GetDepClasses() { return fDepClasses; }
0127 
0128    ClassDefOverride(TProtoClass, 2); //Persistent TClass
0129 };
0130 
0131 #endif