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