29 virtual ~DynamicType() {}
32 typedef std::map<const void*, TClass*> ClassMap_t;
33 inline ClassMap_t *GetMap(
const void* p)
35 return (ClassMap_t*)p;
38 inline ClassMap_t::value_type* ToPair(
void*p)
40 return (ClassMap_t::value_type*)p;
48 :
fType(&typ), fClass(nullptr), fLast(nullptr),
49 fSubTypesReaders(0), fSubTypesWriteLockTaken(
kFALSE),
52 static_assert(
sizeof(ClassMap_t)<=
sizeof(
fSubTypes),
"ClassMap size is to large for array");
86 TClass* expected =
nullptr;
87 fClass.compare_exchange_strong(expected,cls);
89 if ( !
fClass.load() )
return nullptr;
103 DynamicType* ptr = (DynamicType*)obj;
104 const std::type_info* typ = &
typeid(*ptr);
106 if ( typ ==
fType ) {
109 auto last = ToPair(
fLast.load());
110 if ( last && typ == last->first ) {
115 if ( last ==
nullptr || last->second ==
nullptr ) {
122 return last ==
nullptr?
nullptr: last->second;
130 bool needToWait =
kTRUE;
144 void* returnValue =
nullptr;
147 auto found = map->find(
type);
148 if(found != map->end()) {
149 returnValue = &(*found);
170 auto ret = map->emplace(
type,cls);
173 (*ret.first).
second = cls;
177 return &(*(ret.first));
TClass instances represent classes, structs and namespaces in the ROOT type system.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Atomic_t< UInt_t > fSubTypesReaders
void * CacheSubType(const std::type_info *, TClass *)
Record the TClass found for a std::type_info, so that we can retrieved it faster.
virtual void SetClass(TClass *cl)
Set class pointer This method is not thread safe.
virtual ~TIsAProxy()
Standard destructor.
virtual TClass * operator()(const void *obj)
IsA callback.
const std::type_info * fType
Atomic_t< Bool_t > fSubTypesWriteLockTaken
void * FindSubType(const std::type_info *) const
See if we have already cached the TClass that correspond to this std::type_info.
Atomic_t< TClass * > fClass
TIsAProxy(const TIsAProxy &)=delete
static constexpr double second