Logo ROOT  
Reference Guide
TProtoClass.h
Go to the documentation of this file.
1 // @(#)root/meta:$Id$
2 // Author: Axel Naumann 2014-04-28
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2014, 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 
13 #ifndef ROOT_TProtoClass
14 #define ROOT_TProtoClass
15 
16 #include "TNamed.h"
17 
18 #include <vector>
19 
20 class TClass;
21 class TList;
22 class TRealData;
23 #ifdef R__LESS_INCLUDES
24 class TDataMember;
25 #else
26 #include "TDataMember.h"
27 #endif
28 
29 //////////////////////////////////////////////////////////////////////////
30 // //
31 // TProtoClass //
32 // //
33 // Stores enough information to create a TClass from a dictionary //
34 // without interpreter information. //
35 // //
36 //////////////////////////////////////////////////////////////////////////
37 
38 class TProtoClass: public TNamed {
39 public:
40  struct TProtoRealData {
41  Long_t fOffset; // data member offset
42  Int_t fDMIndex; // index of data member in vector of data members
43  Int_t fLevel; // member level (0 : belong to this class, 1 is a data member of a data member object, etc...)
44  Int_t fClassIndex; // index of class belonging to in list of dep classes
45  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)
46 
47  enum EStatusFlags {
48  kIsObject = BIT(0), // member is object
49  kIsTransient = BIT(1), // data member is transient
50  kIsPointer = BIT(2), // data member is a pointer
51  kBitMask = 0x000000ff
52  };
53 
54  public:
55  bool IsAClass() const { return fClassIndex >= 0; }
57  TProtoRealData(const TRealData *rd);
58  virtual ~TProtoRealData();
59  TRealData *CreateRealData(TClass *currentClass, TClass *parent, TRealData * parentData, int prevLevel) const;
60 
61  Bool_t TestFlag(UInt_t f) const { return (Bool_t) ((fStatusFlag & f) != 0); }
62  void SetFlag(UInt_t f, Bool_t on = kTRUE) {
63  if (on)
64  fStatusFlag |= f & kBitMask;
65  else
66  fStatusFlag &= ~(f & kBitMask);
67  }
68 
69  ClassDef(TProtoRealData, 3);//Persistent version of TRealData
70  };
71 
72 private:
73  TList *fBase; // List of base classes
74  TList *fEnums; // List of enums in this scope
75  std::vector<TProtoRealData> fPRealData; // List of TProtoRealData
76  std::vector<TDataMember *> fData; // collection of data members
77  std::vector<TString> fDepClasses; // list of dependent classes
78  Int_t fSizeof; // Size of the class
79  UInt_t fCheckSum; //checksum of data members and base classes
80  Int_t fCanSplit; // Whether this class can be split
81  Int_t fStreamerType; // Which streaming method to use
82  Long_t fProperty; // Class properties, see EProperties
83  Long_t fClassProperty; // Class C++ properties, see EClassProperties
84  Long_t fOffsetStreamer; // Offset to streamer function
85 
86  TProtoClass(const TProtoClass &) = delete;
87  TProtoClass &operator=(const TProtoClass &) = delete;
88 
89  const char * GetClassName(Int_t index) const { return (index >= 0) ? fDepClasses[index].Data() : 0; }
90 
91  // compute index of data member in the list
92  static Int_t DataMemberIndex(TClass * cl, const char * name);
93  // find data member given an index
94  static TDataMember * FindDataMember(TClass * cl, Int_t index);
95 
96 public:
98  fBase(0), fEnums(0), fSizeof(0), fCheckSum(0), fCanSplit(0),
100  fOffsetStreamer(0) {
101  }
102 
104  TProtoClass(TClass *cl);
105  virtual ~TProtoClass();
106 
107  Bool_t FillTClass(TClass *pcl);
109  return fEnums;
110  };
111  void Delete(Option_t *opt = "");
112 
113  int GetSize() { return fSizeof; }
114  TList * GetBaseList() { return fBase; }
115  //TList * GetDataList() { return fData; }
116  TList * GetEnumList() { return fEnums; }
117  std::vector<TProtoRealData> & GetPRDList() { return fPRealData; }
118  std::vector<TDataMember *> & GetData() { return fData; }
119  std::vector<TString> & GetDepClasses() { return fDepClasses; }
120 
121 
122  ClassDef(TProtoClass, 2); //Persistent TClass
123 };
124 
125 #endif
TProtoClass::TProtoRealData::fLevel
Int_t fLevel
Definition: TProtoClass.h:43
TProtoClass::fOffsetStreamer
Long_t fOffsetStreamer
Definition: TProtoClass.h:84
TProtoClass::fPRealData
std::vector< TProtoRealData > fPRealData
Definition: TProtoClass.h:75
TProtoClass::TProtoRealData::CreateRealData
TRealData * CreateRealData(TClass *currentClass, TClass *parent, TRealData *parentData, int prevLevel) const
Create a TRealData from this, with its data member coming from dmClass.
Definition: TProtoClass.cxx:393
TProtoClass::GetDepClasses
std::vector< TString > & GetDepClasses()
Definition: TProtoClass.h:119
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TProtoClass::FindDataMember
static TDataMember * FindDataMember(TClass *cl, Int_t index)
Definition: TProtoClass.cxx:484
f
#define f(i)
Definition: RSha256.hxx:122
TProtoClass::fCheckSum
UInt_t fCheckSum
Definition: TProtoClass.h:79
TNamed.h
TProtoClass::fEnums
TList * fEnums
Definition: TProtoClass.h:74
TProtoClass::TProtoRealData::SetFlag
void SetFlag(UInt_t f, Bool_t on=kTRUE)
Definition: TProtoClass.h:62
TProtoClass::GetPRDList
std::vector< TProtoRealData > & GetPRDList()
Definition: TProtoClass.h:117
TProtoClass::TProtoClass
TProtoClass()
Definition: TProtoClass.h:97
TProtoClass::TProtoRealData::IsAClass
bool IsAClass() const
Definition: TProtoClass.h:55
TProtoClass::fProperty
Long_t fProperty
Definition: TProtoClass.h:82
TDataMember.h
TProtoClass::TProtoRealData::kIsObject
@ kIsObject
Definition: TProtoClass.h:48
Int_t
int Int_t
Definition: RtypesCore.h:45
TDataMember
Definition: TDataMember.h:31
TGeant4Unit::pc
static constexpr double pc
Definition: TGeant4SystemOfUnits.h:136
TProtoClass::GetListOfEnums
const TList * GetListOfEnums()
Definition: TProtoClass.h:108
TProtoClass::operator=
TProtoClass & operator=(const TProtoClass &)=delete
TProtoClass::TProtoRealData::kIsPointer
@ kIsPointer
Definition: TProtoClass.h:50
TProtoClass::TProtoRealData::fClassIndex
Int_t fClassIndex
Definition: TProtoClass.h:44
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TProtoClass::fCanSplit
Int_t fCanSplit
Definition: TProtoClass.h:80
bool
TProtoClass::fStreamerType
Int_t fStreamerType
Definition: TProtoClass.h:81
TProtoClass::fSizeof
Int_t fSizeof
Definition: TProtoClass.h:78
TProtoClass::fData
std::vector< TDataMember * > fData
Definition: TProtoClass.h:76
TProtoClass::TProtoRealData::fOffset
Long_t fOffset
Definition: TProtoClass.h:41
TProtoClass
Definition: TProtoClass.h:38
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TProtoClass::Delete
void Delete(Option_t *opt="")
Delete the containers that are usually owned by their TClass.
Definition: TProtoClass.cxx:143
TProtoClass::TProtoRealData::TProtoRealData
TProtoRealData()
Definition: TProtoClass.h:56
TProtoClass::TProtoRealData::TestFlag
Bool_t TestFlag(UInt_t f) const
Definition: TProtoClass.h:61
TProtoClass::FillTClass
Bool_t FillTClass(TClass *pcl)
Move data from this TProtoClass into cl.
Definition: TProtoClass.cxx:163
TProtoClass::GetEnumList
TList * GetEnumList()
Definition: TProtoClass.h:116
TProtoClass::TProtoRealData::kIsTransient
@ kIsTransient
Definition: TProtoClass.h:49
TProtoClass::GetSize
int GetSize()
Definition: TProtoClass.h:113
TNamed
Definition: TNamed.h:29
Long_t
long Long_t
Definition: RtypesCore.h:54
TProtoClass::TProtoRealData::EStatusFlags
EStatusFlags
Definition: TProtoClass.h:47
BIT
#define BIT(n)
Definition: Rtypes.h:85
TProtoClass::~TProtoClass
virtual ~TProtoClass()
Destructor.
Definition: TProtoClass.cxx:133
TProtoClass::TProtoRealData::fDMIndex
Int_t fDMIndex
Definition: TProtoClass.h:42
TProtoClass::fBase
TList * fBase
Definition: TProtoClass.h:73
unsigned int
TProtoClass::GetBaseList
TList * GetBaseList()
Definition: TProtoClass.h:114
TProtoClass::TProtoRealData::kBitMask
@ kBitMask
Definition: TProtoClass.h:51
TProtoClass::fClassProperty
Long_t fClassProperty
Definition: TProtoClass.h:83
TRealData
Definition: TRealData.h:30
TClass
Definition: TClass.h:80
TProtoClass::GetData
std::vector< TDataMember * > & GetData()
Definition: TProtoClass.h:118
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
TProtoClass::TProtoRealData
Definition: TProtoClass.h:40
TProtoClass::fDepClasses
std::vector< TString > fDepClasses
Definition: TProtoClass.h:77
TProtoClass::DataMemberIndex
static Int_t DataMemberIndex(TClass *cl, const char *name)
Definition: TProtoClass.cxx:464
TProtoClass::TProtoRealData::~TProtoRealData
virtual ~TProtoRealData()
Destructor to pin vtable.
Definition: TProtoClass.cxx:385
TList
Definition: TList.h:44
TProtoClass::TProtoRealData::fStatusFlag
char fStatusFlag
Definition: TProtoClass.h:45
int
TProtoClass::GetClassName
const char * GetClassName(Int_t index) const
Definition: TProtoClass.h:89