Logo ROOT   6.10/09
Reference Guide
TRealData.cxx
Go to the documentation of this file.
1 // @(#)root/meta:$Id$
2 // Author: Rene Brun 05/03/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 #include "TRealData.h"
13 #include "TDataMember.h"
14 #include "TClass.h"
15 #include "TClassEdit.h"
16 #include "TStreamer.h"
17 
19 
20 /** \class TRealData
21 The TRealData class manages the effective list of all data members
22 for a given class. For example for an object of class TLine that inherits
23 from TObject and TAttLine, the TRealData object for a line contains the
24 complete list of all data members of the 3 classes.
25 
26 The list of TRealData members in TClass is built when functions like
27 object.Inspect or object.DrawClass are called.
28 */
29 
30 ////////////////////////////////////////////////////////////////////////////////
31 /// RealData default constructor.
32 
33 TRealData::TRealData() : TObject(), fDataMember(0), fThisOffset(-1),
34  fStreamer(0), fIsObject(kFALSE)
35 {
36 }
37 
38 
39 ////////////////////////////////////////////////////////////////////////////////
40 /// Constructor to define one persistent data member.
41 /// datamember is the pointer to the data member descriptor.
42 
43 TRealData::TRealData(const char *name, Long_t offset, TDataMember *datamember)
44  : TObject(), fDataMember(datamember), fThisOffset(offset), fName(name),
45  fStreamer(0), fIsObject(kFALSE)
46 {
47 }
48 
49 ////////////////////////////////////////////////////////////////////////////////
50 /// RealData default destructor.
51 
53 {
54  delete fStreamer;
55 }
56 
57 ////////////////////////////////////////////////////////////////////////////////
58 /// Write one persistent data member on output buffer.
59 /// pointer points to the current persistent data member
60 
61 void TRealData::WriteRealData(void *, char *&)
62 {
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66 
68 {
69 // fDataMember->SetStreamer(str);
70 // delete fStreamer;
71  fStreamer = str;
72 }
73 
74 ////////////////////////////////////////////////////////////////////////////////
75 /// Return the name of the data member as represented in the list of
76 /// real data.
77 
79 {
80  output.Clear();
81  const char* dmType = dm->GetTypeName();
82  if (TClassEdit::IsStdArray(dmType)) {
83  std::string typeNameBuf;
84  Int_t ndim = dm->GetArrayDim();
85  std::array<Int_t, 5> maxIndices; // 5 is the maximum supported in TStreamerElement::SetMaxIndex
86  TClassEdit::GetStdArrayProperties(dmType,
87  typeNameBuf,
88  maxIndices,
89  ndim);
90  output = dm->GetName();
91  for (Int_t idim = 0; idim < ndim; ++idim) {
92  output += TString::Format("[%d]",maxIndices[idim] );
93  }
94  return;
95  }
96 
97  // keep an empty name if data member is not found
98  if (dm) output = dm->GetName();
99  if (dm->IsaPointer())
100  output = TString("*")+output;
101  else {
102  if (dm && dm->GetArrayDim() > 0) {
103  // in case of array (like fMatrix[2][2] we need to add max index )
104  // this only in case of it os not a pointer
105  for (int idim = 0; idim < dm->GetArrayDim(); ++idim)
106  output += TString::Format("[%d]",dm->GetMaxIndex(idim) );
107  }
108  }
109 }
110 
111 
112 ////////////////////////////////////////////////////////////////////////////////
113 /// Return the associate streamer object.
114 
116 {
117  return fStreamer; // return fDataMember->GetStreamer();
118 }
119 
TMemberStreamer * fStreamer
Definition: TRealData.h:36
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:31
TRealData()
RealData default constructor.
Definition: TRealData.cxx:33
const char * GetTypeName() const
Get type of data member, e,g.: "class TDirectory*" -> "TDirectory".
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2345
void Clear()
Clear string without changing its capacity.
Definition: TString.cxx:1150
void AdoptStreamer(TMemberStreamer *p)
Definition: TRealData.cxx:67
virtual ~TRealData()
RealData default destructor.
Definition: TRealData.cxx:52
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
void WriteRealData(void *pointer, char *&buffer)
Write one persistent data member on output buffer.
Definition: TRealData.cxx:61
TMemberStreamer * GetStreamer() const
Return the associate streamer object.
Definition: TRealData.cxx:115
The TRealData class manages the effective list of all data members for a given class.
Definition: TRealData.h:30
Int_t GetArrayDim() const
Return number of array dimensions.
const Bool_t kFALSE
Definition: RtypesCore.h:92
long Long_t
Definition: RtypesCore.h:50
#define ClassImp(name)
Definition: Rtypes.h:336
Mother of all ROOT objects.
Definition: TObject.h:37
virtual const char * GetName() const
Returns name of object.
Definition: TRealData.h:52
Bool_t IsaPointer() const
Return true if data member is a pointer.