Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TMemberInspector.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Fons Rademakers 15/07/96
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/** \class TMemberInspector
13\ingroup Base
14
15Abstract base class for accessing the data-members of a class.
16Classes derived from this class can be given as argument to the
17ShowMembers() methods of ROOT classes. This feature facilitates
18the writing of class browsers and inspectors.
19*/
20
21#include "TMemberInspector.h"
22#include "TInterpreter.h"
23#include "TClassEdit.h"
24#include "TClass.h"
25#include "TError.h"
26
28private:
29 std::vector<char> fBuf;
31public:
32 TParentBuf(): fBuf(1024), fLen(0) {}
33 Ssiz_t GetLength() const { return fLen; }
34 void Append(const char*);
36 operator const char*() const { return &fBuf[0]; }
37};
38
40{
41 // Add "add" to string
42 if (!add || !add[0]) return;
43 Ssiz_t addlen = strlen(add);
44 fBuf.resize(fLen + addlen + 1);
45 const char* i = add;
46 while (*i) {
47 fBuf[fLen++] = *i;
48 ++i;
49 }
50 fBuf[fLen] = 0;
51}
52
54{
55 // Remove characters starting at "startingAt"
56 fLen = startingAt;
57 fBuf[startingAt] = 0;
58}
59
60
63{
64 // Construct a member inspector
65
66 fParent = new TParentBuf();
67}
68
70 // Destruct a member inspector
71 delete fParent;
72}
73
74const char* TMemberInspector::GetParent() const
75{
76 // Get the parent string.
77 return *fParent;
78}
79
81{
82 // Get the length of the parent string.
83 return fParent->GetLength();
84}
85
87{
88 // Append "name" to the parent string.
90}
91
93{
94 // Remove trailing characters starting at "startingAt".
96}
97
98void TMemberInspector::Inspect(TClass *, const char *, const char *, const void *)
99{
100 // Obsolete signature
101 Fatal("Inspect","This version of Inspect is obsolete");
102}
103
104void TMemberInspector::GenericShowMembers(const char *topClassName, const void *obj,
106 // Call ShowMember() on obj.
107
108 // This could be faster if we implemented this either as a templated
109 // function or by rootcint-generated code using the typeid (i.e. the
110 // difference is a lookup in a TList instead of in a map).
111
112 // To avoid a spurious error message in case the data member is
113 // transient and does not have a dictionary we check first.
114 if (isTransient) {
116 ClassInfo_t *b = gInterpreter->ClassInfo_Factory(topClassName);
117 Bool_t isloaded = gInterpreter->ClassInfo_IsLoaded(b);
118 gInterpreter->ClassInfo_Delete(b);
119 if (!isloaded) return;
120 }
121 }
122
124 if (top) {
125 top->CallShowMembers(obj, *this, isTransient);
126 } else {
127 // This might be worth an error message
128 }
129}
130
132{
133 // Routine driving the visiting of the class information/data members.
134
136}
137
139 const char* name, Bool_t isTransient)
140{
141 // Routine driving the visiting of the class information/data members.
142
147}
148
150{
151 // Routine driving the visiting of the class information/data members.
152
155 cl->CallShowMembers(pobj, *this, isTransient);
157}
#define b(i)
Definition RSha256.hxx:100
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
Definition TError.cxx:267
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 Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
char name[80]
Definition TGX11.cxx:110
#define gInterpreter
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
Bool_t CallShowMembers(const void *obj, TMemberInspector &insp, Bool_t isTransient=kFALSE) const
Call ShowMembers() on the obj of this class type, passing insp and parent.
Definition TClass.cxx:2210
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2973
void Remove(Ssiz_t startingAt)
const char * GetParent() const
void GenericShowMembers(const char *topClassName, const void *obj, Bool_t transientMember)
void RemoveFromParent(Ssiz_t startingAt)
virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr)
void AddToParent(const char *name)
Ssiz_t GetParentLen() const
TParentBuf * fParent
EObjectPointerState fObjectPointerState
void InspectMember(const T &obj, const char *name, Bool_t isTransient)
Mother of all ROOT objects.
Definition TObject.h:41
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...