Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:12:34

0001 // @(#)root/meta: $Id$
0002 // Author: Markus Frank 20/05/2005
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2006, 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 #ifndef ROOT_TVirtualRefProxy
0012 #define ROOT_TVirtualRefProxy
0013 
0014 // Framework include files
0015 #include "RtypesCore.h"
0016 
0017 // Forward declarations
0018 class TClass;
0019 class TFormLeafInfoReference;
0020 
0021 //______________________________________________________________________________
0022 //
0023 //   Abstract proxy definition to follow reference objects.
0024 //
0025 //
0026 //   Generic Mechanism for Object References
0027 //   =======================================
0028 //
0029 //   References are a well known mechanism to support persistency
0030 //   of entities, which in C++ typically are represented as
0031 //   pointers. The generic mechanism allows clients to supply
0032 //   hooks to the ROOT framework in interactive mode in order to
0033 //   dereference these objects and access the objects pointed to by
0034 //   the reference objects.
0035 //
0036 //   Implementations are supplied for ROOT own reference mechanism
0037 //   based on instances of the TRef and the TRefArray classes.
0038 //
0039 //   To support generality this mechanism was implemented using a
0040 //   proxy mechanism, which shields the concrete implementation of the
0041 //   reference classes from ROOT. Hence, this mechanism also works for
0042 //   references as they are supported by the POOL persistency framework
0043 //   and by frameworks like Gaudi.
0044 //
0045 //   To enable reference support a concrete sub-class instance of
0046 //   the TVirtualRefProxy base class must be attached to the TClass
0047 //   instance representing the reference itself. Please see the
0048 //   header- and implementation file TRefProxy.h/cxx for details.
0049 //   For ROOT's own references this is done simply by a call like:
0050 //
0051 //        #include "TROOT.h"
0052 //        #include "TClass.h"
0053 //        #include "TRefProxy.h"
0054 //
0055 //        ...
0056 //        gROOT->GetClass("TRef")->AdoptReferenceProxy(new TRefProxy());
0057 //
0058 //      - GetObject() must return the pointer to the referenced
0059 //        object. TTreeFormula then figures out how to access the
0060 //        value to be plotted.
0061 //        Hence, the actual work is done inside a call to:
0062 //
0063 //        void* TRefProxy::GetObject(TFormLeafInfoReference* info, void* data, int)
0064 //        {
0065 //          if ( data )  {
0066 //            TRef*      ref    = (TRef*)((char*)data + info->GetOffset());
0067 //            // Dereference TRef and return pointer to object
0068 //            void* obj = ref->GetObject();
0069 //            if ( obj )  {         return obj;      }
0070 //
0071 //            ... else handle error or implement failover ....
0072 //
0073 //
0074 //   The type of the referenced object must either be known at compilation
0075 //      time or it must be possible to guess it reading the first TTree entry.
0076 //      In this case the following conditions must be met:
0077 //      - GetValueClass() must return the TClass to the referenced
0078 //        objects (or a base class)
0079 //
0080 //______________________________________________________________________________
0081 class TVirtualRefProxy  {
0082 public:
0083    // Virtual Destructor
0084    virtual ~TVirtualRefProxy() {};
0085 
0086    // Release the reference proxy (virtual destructor)
0087    virtual void Release() = 0;
0088 
0089    // Clone the reference proxy (virtual constructor)
0090    virtual TVirtualRefProxy* Clone() const = 0;
0091 
0092    // Setter of reference class (executed when the proxy is adopted)
0093    // Setup the reference when it is adopted by the TClass structure
0094    //
0095    // classptr [IN]    Pointer to the reference class.
0096    virtual void SetClass(TClass *classptr) = 0;
0097 
0098    // Getter of reference class.
0099    // The function returns the class description of the reference class
0100    // ie. in the case of TRef TRef::Class
0101    virtual TClass * GetClass() const = 0;
0102 
0103    // Access to the target class.
0104    // In the event the value class cannot be specified from the reference
0105    // itself, because the object behind the reference requires a cast,
0106    // the return value must be NULL.
0107    //
0108    // data   [IN]   Resolved pointer to the referenced object
0109    virtual TClass* GetValueClass(void* data) const = 0;
0110 
0111    // Update (and propagate) cached information
0112    virtual Bool_t Update() = 0;
0113 
0114    // Flag to indicate if this is a container reference
0115    virtual Bool_t HasCounter()  const = 0;
0116 
0117    // Access to container size (if container reference (ie TRefArray) etc)
0118    //
0119    // info    [IN]   Pointer to the structure called by TTree::Draw
0120    //                to extract the required object information.
0121    // data    [IN]   Pointer to the reference object
0122    //
0123    //  return value: The prepared pointer to the reference.
0124    virtual Int_t  GetCounterValue(TFormLeafInfoReference* info, void *data) = 0;
0125 
0126    // Prepare reused reference object (e.g. ZERO data pointers)
0127    // Because TTree::Draw reuses objects some reference implementations
0128    // require setup. For example the pointer to the object the reference points to
0129    // needs to be ZEROed.
0130    //
0131    // data   [IN]   Pointer to the reference object
0132    //
0133    // return value: The prepared pointer to the reference.
0134    virtual void* GetPreparedReference(void* data) = 0;
0135 
0136    // Access referenced object(-data)
0137    //
0138    // info     [IN]   Pointer to the structure called by TTree::Draw
0139    //                 to extract the required object information.
0140    // data     [IN]   Pointer to the referenced object
0141    // instance [IN]   Item number if ref collection
0142    //
0143    // return value: Pointer to the requested information
0144    virtual void* GetObject(TFormLeafInfoReference* info, void* data, int instance) = 0;
0145 };
0146 #endif // ROOT_TVirtualRefProxy