Logo ROOT   6.08/07
Reference Guide
TMemberInspector.h
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 #ifndef ROOT_TMemberInspector
13 #define ROOT_TMemberInspector
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TMemberInspector //
18 // //
19 // Abstract base class for accessing the datamembers of a class. //
20 // Classes derived from this class can be given as argument to the //
21 // ShowMembers() methods of ROOT classes. This feature facilitates //
22 // the writing of class browsers and inspectors. //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #include "Rtypes.h"
27 
28 class TObject;
29 class TClass;
30 
32 public:
34  kUnset, // No Inspect() call has been seen yet.
35  kNoObjectGiven, // No object was given to the initial Inspect() call.
36  kValidObjectGiven // The address points to an actual object.
37  };
38 private:
39  class TParentBuf;
40  TParentBuf* fParent; // current inspection "path"
41  EObjectPointerState fObjectPointerState; // whether the address is valid or only an offset
42 
43  TMemberInspector(const TMemberInspector&); // Not implemented.
44  TMemberInspector &operator=(const TMemberInspector&); // Not implemented.
45 
46 public:
48  virtual ~TMemberInspector();
49 
51  void SetObjectValidity(EObjectPointerState val) { fObjectPointerState = val; }
52  virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr);
53  virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t /* isTransient */) { Inspect(cl,parent,name,addr); }
54 
55  const char* GetParent() const;
56  Ssiz_t GetParentLen() const;
57  void AddToParent(const char* name);
58  void RemoveFromParent(Ssiz_t startingAt);
59 
61 
62  template <class T>
63  void InspectMember(const T& obj, const char* name, Bool_t isTransient) {
64  Ssiz_t len = GetParentLen();
65  AddToParent(name);
66  obj.IsA()->CallShowMembers(&obj, *this, isTransient);
67  RemoveFromParent(len);
68  }
69 
70  void InspectMember(const TObject& obj, const char* name, Bool_t isTransient);
71  void InspectMember(const char* topclassname, const void* pobj, const char* name,
72  Bool_t transient);
73  void InspectMember(TClass* cl, const void* pobj, const char* name,
74  Bool_t isTransient);
75 
76  void GenericShowMembers(const char *topClassName, const void *obj,
77  Bool_t transientMember);
78 
79  ClassDef(TMemberInspector,0) //ABC for inspecting class data members
80 };
81 
82 #endif
TParentBuf * fParent
void GenericShowMembers(const char *topClassName, const void *obj, Bool_t transientMember)
Ssiz_t GetParentLen() const
double T(double x)
Definition: ChebyshevPol.h:34
virtual Bool_t IsTreatingNonAccessibleTypes()
bool Bool_t
Definition: RtypesCore.h:59
Abstract base class for accessing the data-members of a class.
#define ClassDef(name, id)
Definition: Rtypes.h:254
void SetObjectValidity(EObjectPointerState val)
virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t)
TMemberInspector & operator=(const TMemberInspector &)
virtual ~TMemberInspector()
EObjectPointerState fObjectPointerState
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
void AddToParent(const char *name)
int Ssiz_t
Definition: RtypesCore.h:63
void RemoveFromParent(Ssiz_t startingAt)
const char * GetParent() const
EObjectPointerState GetObjectValidity() const
void InspectMember(const T &obj, const char *name, Bool_t isTransient)
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr)
const Bool_t kTRUE
Definition: Rtypes.h:91
char name[80]
Definition: TGX11.cxx:109