Logo ROOT  
Reference Guide
TIsAProxy.h
Go to the documentation of this file.
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 #include "TVirtualIsAProxy.h"
16 #include "RtypesCore.h"
17 #include <atomic>
18 #include <typeinfo>
19 
20 class TClass;
21 
22 //////////////////////////////////////////////////////////////////////////
23 // //
24 // TIsAProxy implementation class. //
25 // //
26 //////////////////////////////////////////////////////////////////////////
27 class TIsAProxy : public TVirtualIsAProxy {
28 private:
29  template <typename T> using Atomic_t = std::atomic<T>;
30 
31  const std::type_info *fType; //Actual typeid of the proxy
32  Atomic_t<TClass*> fClass; //Actual TClass
33  Atomic_t<void*> fLast; //points into fSubTypes map for last used values
34  Char_t fSubTypes[72];//map of known sub-types
35  mutable Atomic_t<UInt_t> fSubTypesReaders; //number of readers of fSubTypes
36  Atomic_t<Bool_t> fSubTypesWriteLockTaken; //True if there is a writer
37  Bool_t fVirtual; //Flag if class is virtual
38  Atomic_t<Bool_t> fInit; //Initialization flag
39 
40  void* FindSubType(const std::type_info*) const;
41  void* CacheSubType(const std::type_info*, TClass*);
42 protected:
43  TIsAProxy(const TIsAProxy&) = delete;
44  TIsAProxy& operator=(const TIsAProxy&) = delete;
45 
46 public:
47  // Standard initializing constructor
48  TIsAProxy(const std::type_info &typ);
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:
69  TVirtualIsAProxy(iip), fClass(iip.fClass) { }
71  {if(this!=&iip) {TVirtualIsAProxy::operator=(iip); fClass=iip.fClass;}
72  return *this;}
73 
74 public:
75  // Standard initializing constructor
77  // Standard destructor
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 : ((const T*)obj)->IsA();
84  }
85 };
86 
87 #endif // ROOT_TIsAProxy
TIsAProxy::~TIsAProxy
virtual ~TIsAProxy()
Standard destructor.
Definition: TIsAProxy.cxx:60
TIsAProxy
TIsAProxy implementation class.
Definition: TIsAProxy.h:27
TIsAProxy::operator=
TIsAProxy & operator=(const TIsAProxy &)=delete
TIsAProxy::TIsAProxy
TIsAProxy(const TIsAProxy &)=delete
TIsAProxy::operator()
virtual TClass * operator()(const void *obj)
IsA callback.
Definition: TIsAProxy.cxx:81
TInstrumentedIsAProxy::fClass
TClass * fClass
Definition: TIsAProxy.h:65
operator=
Binding & operator=(OUT(*fun)(void))
Definition: TRInterface_Binding.h:11
TIsAProxy::SetClass
virtual void SetClass(TClass *cl)
Set class pointer This method is not thread safe.
Definition: TIsAProxy.cxx:71
TInstrumentedIsAProxy
Definition: TIsAProxy.h:62
TIsAProxy::fSubTypes
Char_t fSubTypes[72]
Definition: TIsAProxy.h:34
TIsAProxy::fInit
Atomic_t< Bool_t > fInit
Definition: TIsAProxy.h:38
TVirtualIsAProxy.h
bool
TInstrumentedIsAProxy::operator()
virtual TClass * operator()(const void *obj)
Definition: TIsAProxy.h:82
TIsAProxy::fLast
Atomic_t< void * > fLast
Definition: TIsAProxy.h:33
TInstrumentedIsAProxy::SetClass
virtual void SetClass(TClass *cl)
Definition: TIsAProxy.h:80
TIsAProxy::fClass
Atomic_t< TClass * > fClass
Definition: TIsAProxy.h:32
TIsAProxy::fType
const std::type_info * fType
Definition: TIsAProxy.h:31
TInstrumentedIsAProxy::TInstrumentedIsAProxy
TInstrumentedIsAProxy(const TInstrumentedIsAProxy &iip)
Definition: TIsAProxy.h:68
RtypesCore.h
TInstrumentedIsAProxy::operator=
TInstrumentedIsAProxy & operator=(const TInstrumentedIsAProxy &iip)
Definition: TIsAProxy.h:70
TClass
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
TIsAProxy::fSubTypesReaders
Atomic_t< UInt_t > fSubTypesReaders
Definition: TIsAProxy.h:35
TInstrumentedIsAProxy::~TInstrumentedIsAProxy
virtual ~TInstrumentedIsAProxy()
Definition: TIsAProxy.h:78
TIsAProxy::Atomic_t
std::atomic< T > Atomic_t
Definition: TIsAProxy.h:29
TIsAProxy::fVirtual
Bool_t fVirtual
Definition: TIsAProxy.h:37
ROOT::Math::Chebyshev::T
double T(double x)
Definition: ChebyshevPol.h:34
TVirtualIsAProxy
Definition: TVirtualIsAProxy.h:27
TIsAProxy::fSubTypesWriteLockTaken
Atomic_t< Bool_t > fSubTypesWriteLockTaken
Definition: TIsAProxy.h:36
Char_t
char Char_t
Definition: RtypesCore.h:33
TIsAProxy::CacheSubType
void * CacheSubType(const std::type_info *, TClass *)
Record the TClass found for a std::type_info, so that we can retrieved it faster.
Definition: TIsAProxy.cxx:158
TInstrumentedIsAProxy::TInstrumentedIsAProxy
TInstrumentedIsAProxy(TClass *cl)
Definition: TIsAProxy.h:76
TIsAProxy::FindSubType
void * FindSubType(const std::type_info *) const
See if we have already cached the TClass that correspond to this std::type_info.
Definition: TIsAProxy.cxx:128