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;
49 : fType(&typ),
fClass(nullptr),
50 fSubTypesReaders(0), fSubTypesWriteLockTaken(
kFALSE),
53 static_assert(
sizeof(ClassMap_t)<=
sizeof(
fSubTypes),
"ClassMap size is to large for array");
92 if ( !
fClass )
return nullptr;
106 DynamicType* ptr = (DynamicType*)obj;
107 const std::type_info* typ = &
typeid(*ptr);
109 if ( typ ==
fType ) {
112 for(
auto& slot :
fLasts) {
113 auto last = ToPair(slot);
114 if ( last && typ == last->first ) {
121 if ( last ==
nullptr ) {
132 UChar_t expected_value = next + 1;
134 fNextLastSlot.compare_exchange_strong(expected_value, next + 1);
138 return last ? last->second :
nullptr;
146 bool needToWait =
kTRUE;
160 void* returnValue =
nullptr;
163 auto found = map->find(
type);
164 if(found != map->end()) {
165 returnValue = &(*found);
186 auto ret = map->emplace(
type,cls);
189 (*ret.first).
second = cls;
193 return &(*(ret.first));
#define R__WRITE_LOCKGUARD(mutex)
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.
Atomic_t< UChar_t > fNextLastSlot
virtual TClass * operator()(const void *obj)
IsA callback.
const std::type_info * fType
Atomic_t< Bool_t > fSubTypesWriteLockTaken
Atomic_t< void * > fLasts[fgMaxLastSlot]
void * FindSubType(const std::type_info *) const
See if we have already cached the TClass that correspond to this std::type_info.
static constexpr UInt_t fgMaxLastSlot
TIsAProxy(const TIsAProxy &)=delete
R__EXTERN TVirtualRWMutex * gCoreMutex
static constexpr double second