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");
183 printf(
"Key: %s\n",key->
String().Data());
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];
264 TString s = r->fName;
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);
371 if (r->fProto)
delete r->fProto;
382 ::Warning(
"TClassTable::Add(TProtoClass*)",
"Called for existing class without a prior call add the dictionary function.");
405 for (
const TClassAlt *
a = fgAlternate[slot];
a;
a =
a->fNext.get()) {
406 if (strcmp(alternate,
a->fName)==0) {
407 if (strcmp(normName,
a->fNormName) != 0) {
408 fprintf(stderr,
"Error in TClassTable::AddAlternate: " 409 "Second registration of %s with a different normalized name (old: '%s', new: '%s')\n",
410 alternate,
a->fNormName, normName);
416 fgAlternate[slot] =
new TClassAlt(alternate,normName,fgAlternate[slot]);
423 if (!gClassTable || !fgTable)
return kFALSE;
428 for (TClassRec *
r = fgTable[slot];
r;
r =
r->fNext)
432 for (
const TClassAlt *
a = fgAlternate[slot];
a;
a =
a->fNext.get()) {
433 if (strcmp(cname,
a->fName)==0) {
434 normname =
a->fNormName;
448 if (!gClassTable || !fgTable)
return;
454 for (r = fgTable[slot];
r; r = r->fNext) {
455 if (!strcmp(r->fName, cname)) {
457 prev->fNext = r->fNext;
459 fgTable[slot] = r->fNext;
460 fgIdMap->Remove(r->fInfo->name());
480 for (TClassRec *
r = fgTable[slot];
r;
r =
r->fNext)
481 if (strcmp(cname,
r->
fName)==0)
return r;
483 if (!insert)
return 0;
485 fgTable[slot] =
new TClassRec(fgTable[slot]);
488 return fgTable[slot];
500 if (!fgTable)
return 0;
504 std::string normalized;
507 return FindElementImpl(normalized.c_str(), insert);
515 TClassRec *
r = FindElement(cname);
516 if (r)
return r->fId;
525 TClassRec *
r = FindElement(cname);
526 if (r)
return r->fBits;
537 ::Info(
"GetDict",
"searches for %s", cname);
541 TClassRec *
r = FindElement(cname);
542 if (r)
return r->fDict;
553 ::Info(
"GetDict",
"searches for %s at 0x%lx", info.name(), (
Long_t)&info);
557 TClassRec *
r = fgIdMap->Find(info.name());
558 if (r)
return r->fDict;
569 ::Info(
"GetDict",
"searches for %s", cname);
573 TClassRec *
r = FindElementImpl(cname,
kFALSE);
574 if (r)
return r->fDict;
585 ::Info(
"GetDict",
"searches for %s", cname);
589 TClassRec *
r = FindElement(cname);
590 if (r)
return r->fProto;
601 ::Info(
"GetDict",
"searches for %s", cname);
605 TClassRec *
r = FindElementImpl(cname,
kFALSE);
606 if (r)
return r->fProto;
617 return strcmp((*(TClassRec **)a)->fName, (*(TClassRec **)b)->fName);
628 if (fgCursor < fgTally) {
629 TClassRec *
r = fgSortedTable[fgCursor++];
641 if (fgTally == 0 || !fgTable)
646 int n = 0, ninit = 0;
648 Printf(
"\nDefined classes");
649 Printf(
"class version bits initialized");
650 Printf(
"================================================================");
652 for (
UInt_t i = 0; i < last; i++) {
653 TClassRec *
r = fgSortedTable[i];
657 if (
gROOT->GetListOfClasses()->FindObject(r->fName)) {
659 Printf(
"%-35s %6d %7d Yes", r->fName, r->fId, r->fBits);
661 Printf(
"%-35s %6d %7d No", r->fName, r->fId, r->fBits);
663 Printf(
"----------------------------------------------------------------");
664 Printf(
"Total classes: %4d initialized: %4d", n, ninit);
665 Printf(
"================================================================\n");
674 delete [] fgSortedTable;
675 fgSortedTable =
new TClassRec* [fgTally];
678 for (
UInt_t i = 0; i < fgSize; i++)
679 for (TClassRec *
r = fgTable[i];
r;
r =
r->fNext)
680 fgSortedTable[j++] =
r;
682 ::qsort(fgSortedTable, fgTally,
sizeof(TClassRec *), ::
ClassComp);
693 for (
UInt_t i = 0; i < fgSize; i++)
696 delete [] fgTable; fgTable = 0;
697 delete [] fgSortedTable; fgSortedTable = 0;
698 delete fgIdMap; fgIdMap = 0;
709 const std::type_info& info,
741 if (cname && cname!=(
void*)-1) {
743 if (r) r->fId = newid;
748 if (cname!=(
void*)-1)
749 Error(
"ResetClassVersion",
"Version number of %s can not be changed after first usage!",
753 Error(
"SetClassVersion",
"The class version (for %s) must be positive (value %d is ignored)",cl->
GetName(),newid);
755 if (cname==(
void*)-1) {
783 if ((pcname=
gROOT->GetListOfClasses()->FindObject(cname))) {
806 TString classname(name);
807 Ssiz_t loc = classname.Index(
"<");
808 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
virtual const char * GetName() const
Returns name of object.
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
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).
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
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).
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,...)
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.
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.
void Print(Option_t *option="") const
Print the class table.
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.
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).
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.
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.
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
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
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
R__EXTERN TInterpreter * gCling
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