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;
53 static_assert(
sizeof(ClassMap_t)<=
sizeof(
fSubTypes),
"ClassMap size is to large for array");
92 if ( !
fClass )
return nullptr;
108 DynamicType* ptr = (DynamicType*)obj;
109 const std::type_info* typ = &
typeid(*ptr);
111 if ( typ ==
fType ) {
114 for(
auto& slot :
fLasts) {
115 auto last = ToPair(slot);
116 if ( last && typ == last->first ) {
123 if ( last ==
nullptr ) {
134 UChar_t expected_value = next + 1;
136 fNextLastSlot.compare_exchange_strong(expected_value, next + 1);
140 return last ? last->second :
nullptr;
148 bool needToWait =
kTRUE;
162 void* returnValue =
nullptr;
165 auto found =
map->find(type);
166 if(found !=
map->end()) {
167 returnValue = &(*found);
188 auto ret =
map->emplace(type,cls);
191 (*
ret.first).second = cls;
195 return &(*(
ret.first));
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char).
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
#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 ~TIsAProxy()
Standard destructor.
TClass * operator()(const void *obj) override
IsA callback.
Atomic_t< UChar_t > fNextLastSlot
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
void SetClass(TClass *cl) override
Set class pointer This method is not thread safe.
TIsAProxy(const TIsAProxy &)=delete
externTVirtualRWMutex * gCoreMutex