Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 09:38:08

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 // clang++ <v20 (-Wshadow) complains about shadowing TError.h global variable kUnset. Let's silence warning:
0035 #if defined(__clang__) && __clang_major__ < 20
0036 #pragma clang diagnostic push
0037 #pragma clang diagnostic ignored "-Wshadow"
0038 #endif
0039       kUnset, // No Inspect() call has been seen yet.
0040 #if defined(__clang__) && __clang_major__ < 20
0041 #pragma clang diagnostic pop
0042 #endif
0043       kNoObjectGiven, // No object was given to the initial Inspect() call.
0044       kValidObjectGiven // The address points to an actual object.
0045    };
0046 private:
0047    class TParentBuf;
0048    TParentBuf* fParent; // current inspection "path"
0049    EObjectPointerState fObjectPointerState; // whether the address is valid or only an offset
0050    UInt_t fNestedTransient;
0051 
0052    TMemberInspector(const TMemberInspector &) = delete;
0053    TMemberInspector &operator=(const TMemberInspector &) = delete;
0054 
0055 public:
0056    TMemberInspector();
0057    virtual ~TMemberInspector();
0058 
0059    EObjectPointerState GetObjectValidity() const { return fObjectPointerState; }
0060    void SetObjectValidity(EObjectPointerState val) { fObjectPointerState = val; }
0061    virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr);
0062    virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t /* isTransient */) { Inspect(cl,parent,name,addr); }
0063 
0064    const char* GetParent() const;
0065    Ssiz_t GetParentLen() const;
0066    void AddToParent(const char* name);
0067    void RemoveFromParent(Ssiz_t startingAt);
0068 
0069    virtual Bool_t IsTreatingNonAccessibleTypes() {return kTRUE;}
0070 
0071    template <class T>
0072    void InspectMember(const T& obj, const char* name, Bool_t isTransient) {
0073       Ssiz_t len = GetParentLen();
0074       AddToParent(name);
0075       obj.IsA()->CallShowMembers(&obj, *this, isTransient);
0076       RemoveFromParent(len);
0077    }
0078 
0079    void InspectMember(const TObject& obj, const char* name, Bool_t isTransient);
0080    void InspectMember(const char* topclassname, const void* pobj, const char* name,
0081                       Bool_t transient);
0082    void InspectMember(TClass* cl, const void* pobj, const char* name,
0083                       Bool_t isTransient);
0084 
0085    void GenericShowMembers(const char *topClassName, const void *obj,
0086                            Bool_t transientMember);
0087 
0088    void DecrementNestedTransient() { --fNestedTransient; }
0089    void IncrementNestedTransient() { ++fNestedTransient; }
0090    bool IsNestedTransient() { return fNestedTransient != 0; }
0091 
0092    ClassDef(TMemberInspector,0)  //ABC for inspecting class data members
0093 };
0094 
0095 #endif