Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
21The TRealData class manages the effective list of all data members
22for a given class. For example for an object of class TLine that inherits
23from TObject and TAttLine, the TRealData object for a line contains the
24complete list of all data members of the 3 classes.
25
26The list of TRealData members in TClass is built when functions like
27object.Inspect or object.DrawClass are called.
28*/
29
30////////////////////////////////////////////////////////////////////////////////
31/// RealData default constructor.
32
33TRealData::TRealData() : TObject(), fDataMember(nullptr), fThisOffset(-1),
34 fStreamer(nullptr), 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
44 : TObject(), fDataMember(datamember), fThisOffset(offset), fName(name),
45 fStreamer(nullptr), 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
61void 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
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
long Long_t
Definition RtypesCore.h:54
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
#define ClassImp(name)
Definition Rtypes.h:377
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
char name[80]
Definition TGX11.cxx:110
All ROOT classes may have RTTI (run time type identification) support added.
Definition TDataMember.h:31
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
Int_t GetArrayDim() const
Return number of array dimensions.
Bool_t IsaPointer() const
Return true if data member is a pointer.
const char * GetTypeName() const
Get the decayed type name of this data member, removing const and volatile qualifiers,...
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:41
The TRealData class manages the effective list of all data members for a given class.
Definition TRealData.h:30
const char * GetName() const override
Returns name of object.
Definition TRealData.h:52
void WriteRealData(void *pointer, char *&buffer)
Write one persistent data member on output buffer.
Definition TRealData.cxx:61
TMemberStreamer * fStreamer
Definition TRealData.h:36
void AdoptStreamer(TMemberStreamer *p)
Definition TRealData.cxx:67
TRealData()
RealData default constructor.
Definition TRealData.cxx:33
TMemberStreamer * GetStreamer() const
Return the associate streamer object.
virtual ~TRealData()
RealData default destructor.
Definition TRealData.cxx:52
Basic string class.
Definition TString.h:139
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:2356
bool IsStdArray(std::string_view name)
Definition TClassEdit.h:189
bool GetStdArrayProperties(const char *typeName, std::string &typeNameBuf, std::array< int, 5 > &maxIndices, int &ndim)
static void output()