TIsAProxy.h

Go to the documentation of this file.
00001 // @(#)root/meta:$Id: TIsAProxy.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Markus Frank 20/05/2005
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TIsAProxy
00013 #define ROOT_TIsAProxy
00014 
00015 #ifndef ROOT_TVirtualIsAProxy
00016 #include "TVirtualIsAProxy.h"
00017 #endif
00018 #ifndef ROOT_Rtypes
00019 #include "Rtypes.h"
00020 #endif
00021 
00022 
00023 class TClass;
00024 
00025 //////////////////////////////////////////////////////////////////////////
00026 //                                                                      //
00027 // TIsAProxy implementation class.                                      //
00028 //                                                                      //
00029 //////////////////////////////////////////////////////////////////////////
00030 class TIsAProxy  : public TVirtualIsAProxy {
00031 
00032 private:
00033    const type_info   *fType;         //Actual typeid of the proxy
00034    const type_info   *fLastType;     //Last used subtype
00035    TClass            *fClass;        //Actual TClass
00036    TClass            *fLastClass;    //Last used TClass
00037    Char_t             fSubTypes[72]; //map of known sub-types
00038    Bool_t             fVirtual;      //Flag if class is virtual
00039    void              *fContext;      //Optional user contex
00040    Bool_t             fInit;         //Initialization flag
00041 
00042 protected:
00043    TIsAProxy(const TIsAProxy&);
00044    TIsAProxy& operator=(const TIsAProxy&);
00045 
00046 public:
00047    // Standard initializing constructor
00048    TIsAProxy(const type_info &typ, void *ctxt = 0);
00049    // Standard destructor
00050    virtual ~TIsAProxy();
00051    // Callbacl to set the class
00052    virtual void SetClass(TClass *cl);
00053    // IsA callback
00054    virtual TClass* operator()(const void *obj);
00055 };
00056 
00057 //////////////////////////////////////////////////////////////////////////
00058 //                                                                      //
00059 // TInstrumentedIsAProxy implementation class.                          //
00060 //                                                                      //
00061 //////////////////////////////////////////////////////////////////////////
00062 template <class T> class TInstrumentedIsAProxy : public TVirtualIsAProxy {
00063 
00064 private:
00065    TClass *fClass;        //Actual TClass
00066 
00067 protected:
00068    TInstrumentedIsAProxy(const TInstrumentedIsAProxy& iip) : 
00069      TVirtualIsAProxy(iip), fClass(iip.fClass) { }
00070    TInstrumentedIsAProxy& operator=(const TInstrumentedIsAProxy& iip)
00071      {if(this!=&iip) {TVirtualIsAProxy::operator=(iip); fClass=iip.fClass;}
00072      return *this;}
00073 
00074 public:
00075    // Standard initializing constructor
00076    TInstrumentedIsAProxy(TClass *cl) : fClass(cl)      {}
00077    // Standard destructor
00078    virtual ~TInstrumentedIsAProxy()                    {}
00079    // Callbacl to set the class
00080    virtual void SetClass(TClass *cl)                   { fClass = cl; }
00081    // IsA callback
00082    virtual TClass* operator()(const void *obj) {
00083       return obj==0 ? fClass : ((T*)obj)->IsA();
00084    }
00085 };
00086 
00087 #endif // ROOT_TIsAProxy

Generated on Tue Jul 5 14:11:40 2011 for ROOT_528-00b_version by  doxygen 1.5.1