Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 09:09:51

0001 // @(#)root/base:$Id$
0002 // Author: Fons Rademakers   15/07/96
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TMemberInspector
0013 #define ROOT_TMemberInspector
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TMemberInspector                                                     //
0018 //                                                                      //
0019 // Abstract base class for accessing the datamembers of a class.        //
0020 // Classes derived from this class can be given as argument to the      //
0021 // ShowMembers() methods of ROOT classes. This feature facilitates      //
0022 // the writing of class browsers and inspectors.                        //
0023 //                                                                      //
0024 //////////////////////////////////////////////////////////////////////////
0025 
0026 #include "Rtypes.h"
0027 
0028 class TObject;
0029 class TClass;
0030 
0031 class TMemberInspector {
0032 public:
0033    enum EObjectPointerState {
0034       kUnset, // No Inspect() call has been seen yet.
0035       kNoObjectGiven, // No object was given to the initial Inspect() call.
0036       kValidObjectGiven // The address points to an actual object.
0037    };
0038 private:
0039    class TParentBuf;
0040    TParentBuf* fParent; // current inspection "path"
0041    EObjectPointerState fObjectPointerState; // whether the address is valid or only an offset
0042    UInt_t fNestedTransient;
0043 
0044    TMemberInspector(const TMemberInspector &) = delete;
0045    TMemberInspector &operator=(const TMemberInspector &) = delete;
0046 
0047 public:
0048    TMemberInspector();
0049    virtual ~TMemberInspector();
0050 
0051    EObjectPointerState GetObjectValidity() const { return fObjectPointerState; }
0052    void SetObjectValidity(EObjectPointerState val) { fObjectPointerState = val; }
0053    virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr);
0054    virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t /* isTransient */) { Inspect(cl,parent,name,addr); }
0055 
0056    const char* GetParent() const;
0057    Ssiz_t GetParentLen() const;
0058    void AddToParent(const char* name);
0059    void RemoveFromParent(Ssiz_t startingAt);
0060 
0061    virtual Bool_t IsTreatingNonAccessibleTypes() {return kTRUE;}
0062 
0063    template <class T>
0064    void InspectMember(const T& obj, const char* name, Bool_t isTransient) {
0065       Ssiz_t len = GetParentLen();
0066       AddToParent(name);
0067       obj.IsA()->CallShowMembers(&obj, *this, isTransient);
0068       RemoveFromParent(len);
0069    }
0070 
0071    void InspectMember(const TObject& obj, const char* name, Bool_t isTransient);
0072    void InspectMember(const char* topclassname, const void* pobj, const char* name,
0073                       Bool_t transient);
0074    void InspectMember(TClass* cl, const void* pobj, const char* name,
0075                       Bool_t isTransient);
0076 
0077    void GenericShowMembers(const char *topClassName, const void *obj,
0078                            Bool_t transientMember);
0079 
0080    void DecrementNestedTransient() { --fNestedTransient; }
0081    void IncrementNestedTransient() { ++fNestedTransient; }
0082    bool IsNestedTransient() { return fNestedTransient != 0; }
0083 
0084    ClassDef(TMemberInspector,0)  //ABC for inspecting class data members
0085 };
0086 
0087 #endif