// @(#)root/base:$Id$
// Author: Fons Rademakers   15/07/96

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TMemberInspector
#define ROOT_TMemberInspector

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TMemberInspector                                                     //
//                                                                      //
// Abstract base class for accessing the datamembers of a class.        //
// Classes derived from this class can be given as argument to the      //
// ShowMembers() methods of ROOT classes. This feature facilitates      //
// the writing of class browsers and inspectors.                        //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#include "Rtypes.h"

class TObject;
class TClass;

class TMemberInspector {
public:
   enum EObjectPointerState {
      kUnset, // No Inspect() call has been seen yet.
      kNoObjectGiven, // No object was given to the initial Inspect() call.
      kValidObjectGiven // The address points to an actual object.
   };
private:
   class TParentBuf;
   TParentBuf* fParent; // current inspection "path"
   EObjectPointerState fObjectPointerState; // whether the address is valid or only an offset

   TMemberInspector(const TMemberInspector&);            // Not implemented.
   TMemberInspector &operator=(const TMemberInspector&); // Not implemented.

public:
   TMemberInspector();
   virtual ~TMemberInspector();

   EObjectPointerState GetObjectValidity() const { return fObjectPointerState; }
   void SetObjectValidity(EObjectPointerState val) { fObjectPointerState = val; }
   virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr);
   virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t /* isTransient */) { Inspect(cl,parent,name,addr); }

   const char* GetParent() const;
   Ssiz_t GetParentLen() const;
   void AddToParent(const char* name);
   void RemoveFromParent(Ssiz_t startingAt);

   template <class T>
   void InspectMember(const T& obj, const char* name, Bool_t isTransient) {
      Ssiz_t len = GetParentLen();
      AddToParent(name);
      obj.IsA()->CallShowMembers(&obj, *this, isTransient);
      RemoveFromParent(len);
   }

   void InspectMember(const TObject& obj, const char* name, Bool_t isTransient);
   void InspectMember(const char* topclassname, const void* pobj, const char* name,
                      Bool_t transient);
   void InspectMember(TClass* cl, const void* pobj, const char* name,
                      Bool_t isTransient);

   void GenericShowMembers(const char *topClassName, const void *obj,
                           Bool_t transientMember);

   ClassDef(TMemberInspector,0)  //ABC for inspecting class data members
};

#endif
 TMemberInspector.h:1
 TMemberInspector.h:2
 TMemberInspector.h:3
 TMemberInspector.h:4
 TMemberInspector.h:5
 TMemberInspector.h:6
 TMemberInspector.h:7
 TMemberInspector.h:8
 TMemberInspector.h:9
 TMemberInspector.h:10
 TMemberInspector.h:11
 TMemberInspector.h:12
 TMemberInspector.h:13
 TMemberInspector.h:14
 TMemberInspector.h:15
 TMemberInspector.h:16
 TMemberInspector.h:17
 TMemberInspector.h:18
 TMemberInspector.h:19
 TMemberInspector.h:20
 TMemberInspector.h:21
 TMemberInspector.h:22
 TMemberInspector.h:23
 TMemberInspector.h:24
 TMemberInspector.h:25
 TMemberInspector.h:26
 TMemberInspector.h:27
 TMemberInspector.h:28
 TMemberInspector.h:29
 TMemberInspector.h:30
 TMemberInspector.h:31
 TMemberInspector.h:32
 TMemberInspector.h:33
 TMemberInspector.h:34
 TMemberInspector.h:35
 TMemberInspector.h:36
 TMemberInspector.h:37
 TMemberInspector.h:38
 TMemberInspector.h:39
 TMemberInspector.h:40
 TMemberInspector.h:41
 TMemberInspector.h:42
 TMemberInspector.h:43
 TMemberInspector.h:44
 TMemberInspector.h:45
 TMemberInspector.h:46
 TMemberInspector.h:47
 TMemberInspector.h:48
 TMemberInspector.h:49
 TMemberInspector.h:50
 TMemberInspector.h:51
 TMemberInspector.h:52
 TMemberInspector.h:53
 TMemberInspector.h:54
 TMemberInspector.h:55
 TMemberInspector.h:56
 TMemberInspector.h:57
 TMemberInspector.h:58
 TMemberInspector.h:59
 TMemberInspector.h:60
 TMemberInspector.h:61
 TMemberInspector.h:62
 TMemberInspector.h:63
 TMemberInspector.h:64
 TMemberInspector.h:65
 TMemberInspector.h:66
 TMemberInspector.h:67
 TMemberInspector.h:68
 TMemberInspector.h:69
 TMemberInspector.h:70
 TMemberInspector.h:71
 TMemberInspector.h:72
 TMemberInspector.h:73
 TMemberInspector.h:74
 TMemberInspector.h:75
 TMemberInspector.h:76
 TMemberInspector.h:77
 TMemberInspector.h:78
 TMemberInspector.h:79
 TMemberInspector.h:80