ROOT  6.06/09
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 #ifndef ROOT_TNamed
17 #include "TNamed.h"
18 #endif
19 
20 class TClass;
21 class TList;
22 class TRealData;
23 
24 #include "TDataMember.h"
25 
26 #include <vector>
27 
28 //////////////////////////////////////////////////////////////////////////
29 // //
30 // TProtoClass //
31 // //
32 // Stores enough information to create a TClass from a dictionary //
33 // without interpreter information. //
34 // //
35 //////////////////////////////////////////////////////////////////////////
36 
37 class TProtoClass: public TNamed {
38 public:
39  struct TProtoRealData {
40  Long_t fOffset; // data member offset
41  Int_t fDMIndex; // index of data member in vector of data members
42  Int_t fLevel; // member level (0 : belong to this class, 1 is a data member of a data member object, etc...)
43  Int_t fClassIndex; // index of class belonging to in list of dep classes
44  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)
45 
46  enum {
47  kIsObject = BIT(0), // member is object
48  kIsTransient = BIT(1), // data member is transient
49  kIsPointer = BIT(2), // data member is a pointer
50  kBitMask = 0x000000ff
51  };
52 
53  public:
54  bool IsAClass() const { return fClassIndex >= 0; }
55  TProtoRealData() : fOffset(0), fDMIndex(-1), fLevel(0), fClassIndex(-1), fStatusFlag(0) {}
56  TProtoRealData(const TRealData *rd);
57  virtual ~TProtoRealData();
58  TRealData *CreateRealData(TClass *currentClass, TClass *parent, TRealData * parentData, int prevLevel) const;
59 
60  Bool_t TestFlag(UInt_t f) const { return (Bool_t) ((fStatusFlag & f) != 0); }
61  void SetFlag(UInt_t f, Bool_t on = kTRUE) {
62  if (on)
63  fStatusFlag |= f & kBitMask;
64  else
65  fStatusFlag &= ~(f & kBitMask);
66  }
67 
68  ClassDef(TProtoRealData, 3);//Persistent version of TRealData
69  };
70 
71 private:
72  TList *fBase; // List of base classes
73  //TList *fData; //! List of data members
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), fCanSplit(0),
99  fStreamerType(0), fProperty(0), fClassProperty(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
Long_t fProperty
Definition: TProtoClass.h:82
const TList * GetListOfEnums()
Definition: TProtoClass.h:108
const char Option_t
Definition: RtypesCore.h:62
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:33
#define BIT(n)
Definition: Rtypes.h:120
Persistent version of a TClass.
Definition: TProtoClass.h:37
UInt_t fCheckSum
Definition: TProtoClass.h:79
std::vector< TString > & GetDepClasses()
Definition: TProtoClass.h:119
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TList * fEnums
Definition: TProtoClass.h:74
Int_t fStreamerType
Definition: TProtoClass.h:81
void Delete(Option_t *opt="")
Delete the containers that are usually owned by their TClass.
std::vector< TProtoRealData > & GetPRDList()
Definition: TProtoClass.h:117
Bool_t FillTClass(TClass *pcl)
Move data from this TProtoClass into cl.
TList * GetEnumList()
Definition: TProtoClass.h:116
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
std::vector< TDataMember * > fData
Definition: TProtoClass.h:76
virtual ~TProtoRealData()
Destructor to pin vtable.
Bool_t TestFlag(UInt_t f) const
Definition: TProtoClass.h:60
ClassDef(TProtoClass, 2)
const char * GetClassName(Int_t index) const
Definition: TProtoClass.h:89
Int_t fCanSplit
Definition: TProtoClass.h:80
TProtoClass & operator=(const TProtoClass &)=delete
A doubly linked list.
Definition: TList.h:47
int GetSize()
Definition: TProtoClass.h:113
virtual ~TProtoClass()
Destructor.
Int_t fSizeof
Definition: TProtoClass.h:78
ClassDef(TProtoRealData, 3)
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:34
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
std::vector< TDataMember * > & GetData()
Definition: TProtoClass.h:118
long Long_t
Definition: RtypesCore.h:50
TRealData * CreateRealData(TClass *currentClass, TClass *parent, TRealData *parentData, int prevLevel) const
Create a TRealData from this, with its data member coming from dmClass.
Long_t fClassProperty
Definition: TProtoClass.h:83
double f(double x)
void SetFlag(UInt_t f, Bool_t on=kTRUE)
Definition: TProtoClass.h:61
TList * GetBaseList()
Definition: TProtoClass.h:114
#define name(a, b)
Definition: linkTestLib0.cpp:5
TList * fBase
Definition: TProtoClass.h:72
std::vector< TString > fDepClasses
Definition: TProtoClass.h:77
Long_t fOffsetStreamer
Definition: TProtoClass.h:84
static TDataMember * FindDataMember(TClass *cl, Int_t index)
const Bool_t kTRUE
Definition: Rtypes.h:91
static Int_t DataMemberIndex(TClass *cl, const char *name)
std::vector< TProtoRealData > fPRealData
Definition: TProtoClass.h:75