Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TMemberInspector.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 
0043    TMemberInspector(const TMemberInspector &) = delete;
0044    TMemberInspector &operator=(const TMemberInspector &) = delete;
0045 
0046 public:
0047    TMemberInspector();
0048    virtual ~TMemberInspector();
0049 
0050    EObjectPointerState GetObjectValidity() const { return fObjectPointerState; }
0051    void SetObjectValidity(EObjectPointerState val) { fObjectPointerState = val; }
0052    virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr);
0053    virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t /* isTransient */) { Inspect(cl,parent,name,addr); }
0054 
0055    const char* GetParent() const;
0056    Ssiz_t GetParentLen() const;
0057    void AddToParent(const char* name);
0058    void RemoveFromParent(Ssiz_t startingAt);
0059 
0060    virtual Bool_t IsTreatingNonAccessibleTypes() {return kTRUE;}
0061 
0062    template <class T>
0063    void InspectMember(const T& obj, const char* name, Bool_t isTransient) {
0064       Ssiz_t len = GetParentLen();
0065       AddToParent(name);
0066       obj.IsA()->CallShowMembers(&obj, *this, isTransient);
0067       RemoveFromParent(len);
0068    }
0069 
0070    void InspectMember(const TObject& obj, const char* name, Bool_t isTransient);
0071    void InspectMember(const char* topclassname, const void* pobj, const char* name,
0072                       Bool_t transient);
0073    void InspectMember(TClass* cl, const void* pobj, const char* name,
0074                       Bool_t isTransient);
0075 
0076    void GenericShowMembers(const char *topClassName, const void *obj,
0077                            Bool_t transientMember);
0078 
0079    ClassDef(TMemberInspector,0)  //ABC for inspecting class data members
0080 };
0081 
0082 #endif