61 TClassRec(TClassRec *next) :
62 fName(0), fId(0), fDict(0), fInfo(0), fProto(0), fNext(next)
76 const std::type_info *fInfo;
83 TClassAlt(
const char*alternate,
const char *normName, TClassAlt *next) :
84 fName(alternate), fNormName(normName), fNext(next)
92 const char *fNormName;
93 std::unique_ptr<TClassAlt> fNext;
96 #define R__USE_STD_MAP 97 class TMapTypeToClassRec {
98 #if defined R__USE_STD_MAP 103 typedef std::map<string, TClassRec*>
IdMap_t;
105 typedef std::map<std::string, TClassRec*>
IdMap_t;
107 typedef IdMap_t::key_type key_type;
108 typedef IdMap_t::const_iterator const_iterator;
109 typedef IdMap_t::size_type size_type;
112 typedef TClassRec* mapped_type;
114 typedef IdMap_t::mapped_type mapped_type;
121 void Add(
const key_type &key, mapped_type &obj) {
125 mapped_type
Find(
const key_type &key)
const {
127 IdMap_t::const_iterator iter = fMap.find(key);
129 if (iter != fMap.end()) cl = iter->second;
133 void Remove(
const key_type &key) { fMap.erase(key); }
136 Info(
"TMapTypeToClassRec::Print",
"printing the typeinfo map in TClassTable");
137 for (const_iterator iter = fMap.begin(); iter != fMap.end(); iter++) {
138 printf(
"Key: %40s 0x%lx\n", iter->first.c_str(), (
unsigned long)iter->second);
145 #ifdef R__COMPLETE_MEM_TERMINATION 146 ~TMapTypeToClassRec() {
155 void Add(
const char *key, TClassRec *&obj)
163 TClassRec *
Find(
const char *key)
const {
166 if (a)
return (TClassRec*) a->
Value();
170 void Remove(
const char *key) {
179 Info(
"TMapTypeToClassRec::Print",
"printing the typeinfo map in TClassTable");
184 TClassRec *data = (TClassRec*)fMap.
GetValue(key);
186 printf(
" class: %s %d\n",data->fName,data->fId);
188 printf(
" no class: \n");
197 auto p =
reinterpret_cast<const unsigned char*
>(
name );
200 while (*p) slot = slot<<1 ^ *p++;
212 if (gClassTable)
return;
215 fgTable =
new TClassRec* [fgSize];
216 fgAlternate =
new TClassAlt* [fgSize];
218 memset(fgTable, 0, fgSize*
sizeof(TClassRec*));
219 memset(fgAlternate, 0, fgSize*
sizeof(TClassAlt*));
229 if (gClassTable !=
this)
return;
231 for (
UInt_t i = 0; i < fgSize; i++) {
234 delete [] fgTable; fgTable = 0;
235 delete [] fgSortedTable; fgSortedTable = 0;
236 delete fgIdMap; fgIdMap = 0;
247 if (fgTally == 0 || !fgTable)
252 int n = 0, ninit = 0, nl = 0;
254 int nch = strlen(option);
257 Printf(
"\nDefined classes");
258 Printf(
"class version bits initialized");
259 Printf(
"================================================================");
260 for (
UInt_t i = 0; i < fgTally; i++) {
261 TClassRec *
r = fgSortedTable[i];
265 if (nch && strcmp(option,r->fName) && s.
Index(re) ==
kNPOS)
continue;
269 Printf(
"%-35s %6d %7d Yes", r->fName, r->fId, r->fBits);
271 Printf(
"%-35s %6d %7d No", r->fName, r->fId, r->fBits);
273 Printf(
"----------------------------------------------------------------");
274 Printf(
"Listed Classes: %4d Total classes: %4d initialized: %4d",nl, n, ninit);
275 Printf(
"================================================================\n");
289 if (index < fgTally) {
290 TClassRec *
r = fgSortedTable[index];
291 if (r)
return r->fName;
301 namespace ROOT {
class TForNamespace {}; }
314 TClassRec *
r = FindElementImpl(cname,
kTRUE);
315 if (r->fName && r->fInfo) {
316 if ( strcmp(r->fInfo->name(),
typeid(ROOT::TForNamespace).
name())==0
317 && strcmp(info.name(),
typeid(ROOT::TForNamespace).
name())==0 ) {
325 ::Warning(
"TClassTable::Add",
"class %s already in TClassTable", cname);
345 if (!r->fName) r->fName =
StrDup(cname);
347 r->fBits = pragmabits;
351 fgIdMap->Add(info.name(),
r);
366 const char *cname = proto->
GetName();
369 TClassRec *
r = FindElementImpl(cname,
kTRUE);
381 ::Warning(
"TClassTable::Add(TProtoClass*)",
"Called for existing class without a prior call add the dictionary function.");
404 for (
const TClassAlt *
a = fgAlternate[slot];
a;
a =
a->fNext.get()) {
405 if (strcmp(alternate,
a->fName)==0) {
406 if (strcmp(normName,
a->fNormName) != 0) {
407 fprintf(stderr,
"Error in TClassTable::AddAlternate: " 408 "Second registration of %s with a different normalized name (old: '%s', new: '%s')\n",
409 alternate,
a->fNormName, normName);
415 fgAlternate[slot] =
new TClassAlt(alternate,normName,fgAlternate[slot]);
422 if (!gClassTable || !fgTable)
return kFALSE;
427 for (TClassRec *
r = fgTable[slot];
r;
r =
r->fNext)
431 for (
const TClassAlt *
a = fgAlternate[slot];
a;
a =
a->fNext.get()) {
432 if (strcmp(cname,
a->fName)==0) {
433 normname =
a->fNormName;
447 if (!gClassTable || !fgTable)
return;
453 for (r = fgTable[slot];
r; r = r->fNext) {
454 if (!strcmp(r->fName, cname)) {
456 prev->fNext = r->fNext;
458 fgTable[slot] = r->fNext;
459 fgIdMap->Remove(r->fInfo->name());
479 for (TClassRec *
r = fgTable[slot];
r;
r =
r->fNext)
480 if (strcmp(cname,
r->
fName)==0)
return r;
482 if (!insert)
return 0;
484 fgTable[slot] =
new TClassRec(fgTable[slot]);
487 return fgTable[slot];
499 if (!fgTable)
return 0;
503 std::string normalized;
506 return FindElementImpl(normalized.c_str(), insert);
514 TClassRec *
r = FindElement(cname);
515 if (r)
return r->fId;
524 TClassRec *
r = FindElement(cname);
525 if (r)
return r->fBits;
536 ::Info(
"GetDict",
"searches for %s", cname);
540 TClassRec *
r = FindElement(cname);
541 if (r)
return r->fDict;
552 ::Info(
"GetDict",
"searches for %s at 0x%lx", info.name(), (
Long_t)&info);
556 TClassRec *
r = fgIdMap->Find(info.name());
557 if (r)
return r->fDict;
568 ::Info(
"GetDict",
"searches for %s", cname);
572 TClassRec *
r = FindElementImpl(cname,
kFALSE);
573 if (r)
return r->fDict;
584 ::Info(
"GetDict",
"searches for %s", cname);
588 TClassRec *
r = FindElement(cname);
589 if (r)
return r->fProto;
600 ::Info(
"GetDict",
"searches for %s", cname);
604 TClassRec *
r = FindElementImpl(cname,
kFALSE);
605 if (r)
return r->fProto;
616 return strcmp((*(TClassRec **)a)->fName, (*(TClassRec **)b)->fName);
627 if (fgCursor < fgTally) {
628 TClassRec *
r = fgSortedTable[fgCursor++];
640 if (fgTally == 0 || !fgTable)
645 int n = 0, ninit = 0;
647 Printf(
"\nDefined classes");
648 Printf(
"class version bits initialized");
649 Printf(
"================================================================");
651 for (
UInt_t i = 0; i < last; i++) {
652 TClassRec *
r = fgSortedTable[i];
656 if (
gROOT->GetListOfClasses()->FindObject(r->fName)) {
658 Printf(
"%-35s %6d %7d Yes", r->fName, r->fId, r->fBits);
660 Printf(
"%-35s %6d %7d No", r->fName, r->fId, r->fBits);
662 Printf(
"----------------------------------------------------------------");
663 Printf(
"Total classes: %4d initialized: %4d", n, ninit);
664 Printf(
"================================================================\n");
673 delete [] fgSortedTable;
674 fgSortedTable =
new TClassRec* [fgTally];
677 for (
UInt_t i = 0; i < fgSize; i++)
678 for (TClassRec *
r = fgTable[i];
r;
r =
r->fNext)
679 fgSortedTable[j++] =
r;
681 ::qsort(fgSortedTable, fgTally,
sizeof(TClassRec *), ::
ClassComp);
692 for (
UInt_t i = 0; i < fgSize; i++)
695 delete [] fgTable; fgTable = 0;
696 delete [] fgSortedTable; fgSortedTable = 0;
697 delete fgIdMap; fgIdMap = 0;
708 const std::type_info& info,
740 if (cname && cname!=(
void*)-1) {
742 if (r) r->fId = newid;
747 if (cname!=(
void*)-1)
748 Error(
"ResetClassVersion",
"Version number of %s can not be changed after first usage!",
752 Error(
"SetClassVersion",
"The class version (for %s) must be positive (value %d is ignored)",cl->
GetName(),newid);
754 if (cname==(
void*)-1) {
782 if ((pcname=
gROOT->GetListOfClasses()->FindObject(cname))) {
807 if (loc >= 1) classname.
Remove(loc);
void AddClass(const char *cname, Version_t id, const std::type_info &info, DictFuncPtr_t dict, Int_t pragmabits)
Global function called by the ctor of a class's init class (see the ClassImp macro).
static ROOT::TClassRec ** fgSortedTable
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
static Bool_t Check(const char *cname, std::string &normname)
Collectable string class.
static int ClassComp(const void *a, const void *b)
static Version_t GetID(const char *cname)
Returns the ID of a class.
static TProtoClass * GetProtoNorm(const char *cname)
Given the class normalized name returns the TClassProto object for the class.
static void SortTable()
Sort the class table by ascending class ID's.
static TProtoClass * GetProto(const char *cname)
Given the class name returns the TClassProto object for the class.
void SetClassVersion(Version_t version)
Private function.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Persistent version of a TClass.
Regular expression class.
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
ROOT::TMapTypeToClassRec IdMap_t
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
This class registers for all classes their name, id and dictionary function in a hash table...
virtual void RegisterTClassUpdate(TClass *oldcl, DictFuncPtr_t dict)=0
TClassTable()
TClassTable is a singleton (i.e. only one can exist per application).
static void Add(const char *cname, Version_t id, const std::type_info &info, DictFuncPtr_t dict, Int_t pragmabits)
Add a class to the class table (this is a static function).
const char * Data() const
The TNamed class is the base class for all named ROOT classes.
void AddClassAlternate(const char *normName, const char *alternate)
Global function called by GenerateInitInstance.
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, THist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
void Info(const char *location, const char *msgfmt,...)
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
std::atomic< Bool_t > fVersionUsed
saved remember if fOffsetStreamer has been set.
static ROOT::TClassRec ** fgTable
TClass *(* DictFuncPtr_t)()
TClassTable * gClassTable
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
R__EXTERN TROOT * gROOTLocal
void ResetClassVersion(TClass *, const char *, Short_t)
Global function to update the version number.
void RemoveClass(const char *cname)
Global function called by the dtor of a class's init class (see the ClassImp macro).
static void AddAlternate(const char *normname, const char *alternate)
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
TObject * Remove(TObject *key)
Remove the (key,value) pair with key from the map.
void SetUnloaded()
Call this method to indicate that the shared library containing this class's code has been removed (u...
static void Remove(const char *cname)
Remove a class from the class table.
virtual const char * GetName() const
Returns name of object.
static Int_t GetPragmaBits(const char *name)
Returns the pragma bits as specified in the LinkDef.h file.
The ROOT global object gROOT contains a list of all defined classes.
ROOT::TMapTypeToTClass IdMap_t
void Warning(const char *location, const char *msgfmt,...)
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
char * StrDup(const char *str)
Duplicate the string str.
static void Terminate()
Deletes the class table (this static class function calls the dtor).
TString & Remove(Ssiz_t pos)
Class used by TMap to store (key,value) pairs.
static ROOT::TClassRec * FindElement(const char *cname, Bool_t insert=kFALSE)
Find a class by name in the class table (using hash of name).
static char * Next()
Returns next class from sorted class table.
void Print(std::ostream &os, const OptionType &opt)
~TClassTable()
TClassTable singleton is deleted in Terminate().
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
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.
void Print(Option_t *option="") const
Print the class table.
UInt_t Find(std::list< std::pair< const Node< T > *, Float_t > > &nlist, const Node< T > *node, const T &event, UInt_t nfind)
Mother of all ROOT objects.
static void PrintTable()
Print the class table.
virtual void Add(TObject *obj)
static ROOT::TClassRec * FindElementImpl(const char *cname, Bool_t insert)
Find a class by name in the class table (using hash of name).
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
R__EXTERN TInterpreter * gCling
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
TNamed * RegisterClassTemplate(const char *name, const char *file, Int_t line)
Global function to register the implementation file and line of a class template (i.e.
static char * At(UInt_t index)
Returns class at index from sorted class table.
static DictFuncPtr_t GetDictNorm(const char *cname)
Given the normalized class name returns the Dictionary() function of a class (uses hash of name)...
static UInt_t ClassTableHash(const char *name, UInt_t size)
void Error(ErrorHandler_t func, int code, const char *va_(fmt),...)
Write error message and call a handler, if required.
static ROOT::TClassAlt ** fgAlternate