1 // @(#)root/meta:$Id$ 2 // Author: Markus Frank 20/05/2005 3 4 /************************************************************************* 5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 6 * All rights reserved. * 7 * * 8 * For the licensing terms see $ROOTSYS/LICENSE. * 9 * For the list of contributors see $ROOTSYS/README/CREDITS. * 10 *************************************************************************/ 11 12 #ifndef ROOT_TIsAProxy 13 #define ROOT_TIsAProxy 14 15 #ifndef ROOT_TVirtualIsAProxy 16 #include "TVirtualIsAProxy.h" 17 #endif 18 #ifndef ROOT_Rtypes 19 #include "Rtypes.h" 20 #endif 21 22 23 class TClass; 24 25 ////////////////////////////////////////////////////////////////////////// 26 // // 27 // TIsAProxy implementation class. // 28 // // 29 ////////////////////////////////////////////////////////////////////////// 30 class TIsAProxy : public TVirtualIsAProxy { 31 32 private: 33 const type_info *fType; //Actual typeid of the proxy 34 const type_info *fLastType; //Last used subtype 35 TClass *fClass; //Actual TClass 36 TClass *fLastClass; //Last used TClass 37 Char_t fSubTypes[72]; //map of known sub-types 38 Bool_t fVirtual; //Flag if class is virtual 39 void *fContext; //Optional user contex 40 Bool_t fInit; //Initialization flag 41 42 protected: 43 TIsAProxy(const TIsAProxy&); 44 TIsAProxy& operator=(const TIsAProxy&); 45 46 public: 47 // Standard initializing constructor 48 TIsAProxy(const type_info &typ, void *ctxt = 0); 49 // Standard destructor 50 virtual ~TIsAProxy(); 51 // Callbacl to set the class 52 virtual void SetClass(TClass *cl); 53 // IsA callback 54 virtual TClass* operator()(const void *obj); 55 }; 56 57 ////////////////////////////////////////////////////////////////////////// 58 // // 59 // TInstrumentedIsAProxy implementation class. // 60 // // 61 ////////////////////////////////////////////////////////////////////////// 62 template <class T> class TInstrumentedIsAProxy : public TVirtualIsAProxy { 63 64 private: 65 TClass *fClass; //Actual TClass 66 67 protected: 68 TInstrumentedIsAProxy(const TInstrumentedIsAProxy& iip) : 69 TVirtualIsAProxy(iip), fClass(iip.fClass) { } 70 TInstrumentedIsAProxy& operator=(const TInstrumentedIsAProxy& iip) 71 {if(this!=&iip) {TVirtualIsAProxy::operator=(iip); fClass=iip.fClass;} 72 return *this;} 73 74 public: 75 // Standard initializing constructor 76 TInstrumentedIsAProxy(TClass *cl) : fClass(cl) {} 77 // Standard destructor 78 virtual ~TInstrumentedIsAProxy() {} 79 // Callbacl to set the class 80 virtual void SetClass(TClass *cl) { fClass = cl; } 81 // IsA callback 82 virtual TClass* operator()(const void *obj) { 83 return obj==0 ? fClass : ((T*)obj)->IsA(); 84 } 85 }; 86 87 #endif // ROOT_TIsAProxy 88