ROOT  6.06/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 "TStreamer.h"
16 
18 
19 /** \class TRealData
20 The TRealData class manages the effective list of all data members
21 for a given class. For example for an object of class TLine that inherits
22 from TObject and TAttLine, the TRealData object for a line contains the
23 complete list of all data members of the 3 classes.
24 
25 The list of TRealData members in TClass is built when functions like
26 object.Inspect or object.DrawClass are called.
27 */
28 
29 ////////////////////////////////////////////////////////////////////////////////
30 /// RealData default constructor.
31 
32 TRealData::TRealData() : TObject(), fDataMember(0), fThisOffset(-1),
33  fStreamer(0), fIsObject(kFALSE)
34 {
35 }
36 
37 
38 ////////////////////////////////////////////////////////////////////////////////
39 /// Constructor to define one persistent data member.
40 /// datamember is the pointer to the data member descriptor.
41 
42 TRealData::TRealData(const char *name, Long_t offset, TDataMember *datamember)
43  : TObject(), fDataMember(datamember), fThisOffset(offset), fName(name),
44  fStreamer(0), fIsObject(kFALSE)
45 {
46 }
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 /// RealData default destructor.
50 
52 {
53  delete fStreamer;
54 }
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Write one persistent data member on output buffer.
58 /// pointer points to the current persistent data member
59 
60 void TRealData::WriteRealData(void *, char *&)
61 {
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 
67 {
68 // fDataMember->SetStreamer(str);
69 // delete fStreamer;
70  fStreamer = str;
71 }
72 
73 ////////////////////////////////////////////////////////////////////////////////
74 /// Return the name of the data member as represented in the list of
75 /// real data.
76 
78 {
79  output.Clear();
80  // keep an empty name if data member is not found
81  if (dm) output = dm->GetName();
82  if (dm->IsaPointer())
83  output = TString("*")+output;
84  else {
85  if (dm && dm->GetArrayDim() > 0) {
86  // in case of array (like fMatrix[2][2] we need to add max index )
87  // this only in case of it os not a pointer
88  for (int idim = 0; idim < dm->GetArrayDim(); ++idim)
89  output += TString::Format("[%d]",dm->GetMaxIndex(idim) );
90  }
91  }
92 }
93 
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 /// Return the associate streamer object.
97 
99 {
100  return fStreamer; // return fDataMember->GetStreamer();
101 }
102 
TMemberStreamer * fStreamer
Definition: TRealData.h:40
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:33
Basic string class.
Definition: TString.h:137
Bool_t IsaPointer() const
Return true if data member is a pointer.
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
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:2334
void Clear()
Clear string without changing its capacity.
Definition: TString.cxx:1139
void AdoptStreamer(TMemberStreamer *p)
Definition: TRealData.cxx:66
virtual ~TRealData()
RealData default destructor.
Definition: TRealData.cxx:51
void WriteRealData(void *pointer, char *&buffer)
Write one persistent data member on output buffer.
Definition: TRealData.cxx:60
The TRealData class manages the effective list of all data members for a given class.
Definition: TRealData.h:34
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
long Long_t
Definition: RtypesCore.h:50
#define ClassImp(name)
Definition: Rtypes.h:279
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
Int_t GetArrayDim() const
Return number of array dimensions.
TMemberStreamer * GetStreamer() const
Return the associate streamer object.
Definition: TRealData.cxx:98
static void output(int code)
Definition: gifencode.c:226
virtual const char * GetName() const
Returns name of object.
Definition: TRealData.h:56