62 TClassRec(TClassRec *next) :
63 fName(0), fId(0), fDict(0), fInfo(0), fProto(0), fNext(next)
77 const std::type_info *fInfo;
84 TClassAlt(
const char*alternate,
const char *normName, TClassAlt *next) :
85 fName(alternate), fNormName(normName), fNext(next)
93 const char *fNormName;
94 std::unique_ptr<TClassAlt> fNext;
98 class TMapTypeToClassRec {
99#if defined R__USE_STD_MAP
103 typedef std::map<std::string, TClassRec*>
IdMap_t;
104 typedef IdMap_t::key_type key_type;
105 typedef IdMap_t::const_iterator const_iterator;
106 typedef IdMap_t::size_type size_type;
109 typedef TClassRec* mapped_type;
111 typedef IdMap_t::mapped_type mapped_type;
118 void Add(
const key_type &key, mapped_type &obj) {
122 mapped_type
Find(
const key_type &key)
const {
124 IdMap_t::const_iterator iter = fMap.find(key);
126 if (iter != fMap.end()) cl = iter->second;
130 void Remove(
const key_type &key) { fMap.erase(key); }
133 Info(
"TMapTypeToClassRec::Print",
"printing the typeinfo map in TClassTable");
134 for (const_iterator iter = fMap.begin(); iter != fMap.end(); ++iter) {
135 printf(
"Key: %40s 0x%lx\n", iter->first.c_str(), (
unsigned long)iter->second);
142#ifdef R__COMPLETE_MEM_TERMINATION
143 ~TMapTypeToClassRec() {
152 void Add(
const char *key, TClassRec *&obj)
157 fMap.Add(realkey, (
TObject*)obj);
160 TClassRec *
Find(
const char *key)
const {
162 const TPair *
a = (
const TPair *)fMap.FindObject(key);
163 if (
a)
return (TClassRec*)
a->Value();
167 void Remove(
const char *key) {
170 TObject *actual = fMap.Remove(&realkey);
176 Info(
"TMapTypeToClassRec::Print",
"printing the typeinfo map in TClassTable");
181 TClassRec *data = (TClassRec*)fMap.GetValue(key);
183 printf(
" class: %s %d\n",data->fName,data->fId);
185 printf(
" no class: \n");
194 auto p =
reinterpret_cast<const unsigned char*
>(
name );
197 while (*p) slot = slot<<1 ^ *p++;
205 static std::vector<std::unique_ptr<TClassRec>> delayedAddClass;
206 return delayedAddClass;
211 static std::vector<std::pair<const char *, const char *>> delayedAddClassAlternate;
212 return delayedAddClassAlternate;
287 int n = 0, ninit = 0, nl = 0;
289 int nch = strlen(option);
292 Printf(
"\nDefined classes");
293 Printf(
"class version bits initialized");
294 Printf(
"================================================================");
300 if (nch && strcmp(option,
r->fName) &&
s.Index(re) ==
kNPOS)
continue;
308 Printf(
"----------------------------------------------------------------");
309 Printf(
"Listed Classes: %4d Total classes: %4d initialized: %4d",nl,
n, ninit);
310 Printf(
"================================================================\n");
326 if (
r)
return r->fName;
336namespace ROOT {
class TForNamespace {}; }
348 if (!cname || *cname == 0)
349 ::Fatal(
"TClassTable::Add()",
"Failed to deduce type for '%s'", info.name());
353 if (
r->fName &&
r->fInfo) {
354 if ( strcmp(
r->fInfo->name(),
typeid(ROOT::TForNamespace).name())==0
355 && strcmp(info.name(),
typeid(ROOT::TForNamespace).name())==0 ) {
362 ::Warning(
"TClassTable::Add",
"class %s already in TClassTable", cname);
382 if (!
r->fName)
r->fName =
StrDup(cname);
403 const char *cname =
proto->GetName();
408 if (
r->fProto)
delete r->fProto;
419 ::Warning(
"TClassTable::Add(TProtoClass*)",
"Called for existing class without a prior call add the dictionary function.");
443 if (strcmp(alternate,
a->fName)==0) {
444 if (strcmp(normName,
a->fNormName) != 0) {
445 fprintf(stderr,
"Error in TClassTable::AddAlternate: "
446 "Second registration of %s with a different normalized name (old: '%s', new: '%s')\n",
447 alternate,
a->fNormName, normName);
465 for (TClassRec *
r =
fgTable[slot];
r;
r =
r->fNext)
466 if (strcmp(cname,
r->fName)==0)
return kTRUE;
470 if (strcmp(cname,
a->fName)==0) {
471 normname =
a->fNormName;
492 if (!strcmp(
r->fName, cname)) {
494 prev->fNext =
r->fNext;
517 for (TClassRec *
r =
fgTable[slot];
r;
r =
r->fNext)
518 if (strcmp(cname,
r->fName)==0)
return r;
520 if (!insert)
return 0;
541 std::string normalized;
553 if (
r)
return r->fId;
574 ::Info(
"GetDict",
"searches for %s", cname);
579 if (
r)
return r->fDict;
592 ::Info(
"GetDict",
"searches for %s at 0x%lx", info.name(), (
Long_t)&info);
596 TClassRec *
r =
fgIdMap->Find(info.name());
597 if (
r)
return r->fDict;
610 ::Info(
"GetDict",
"searches for %s", cname);
615 if (
r)
return r->fDict;
626 ::Info(
"GetDict",
"searches for %s", cname);
632 ::Info(
"GetDict",
"searches for %s", cname);
637 if (
r)
return r->fProto;
648 ::Info(
"GetDict",
"searches for %s", cname);
658 if (
r)
return r->fProto;
669 return strcmp((*(TClassRec **)
a)->fName, (*(TClassRec **)
b)->fName);
698 int n = 0, ninit = 0;
700 Printf(
"\nDefined classes");
701 Printf(
"class version bits initialized");
702 Printf(
"================================================================");
704 for (
UInt_t i = 0; i < last; i++) {
709 if (
gROOT->GetListOfClasses()->FindObject(
r->fName)) {
715 Printf(
"----------------------------------------------------------------");
716 Printf(
"Total classes: %4d initialized: %4d",
n, ninit);
717 Printf(
"================================================================\n");
761 const std::type_info& info,
766 auto r = std::unique_ptr<TClassRec>(
new TClassRec(
nullptr));
807 if (cname && cname!=(
void*)-1) {
809 if (
r)
r->fId = newid;
814 if (cname!=(
void*)-1)
815 Error(
"ResetClassVersion",
"Version number of %s can not be changed after first usage!",
819 Error(
"SetClassVersion",
"The class version (for %s) must be positive (value %d is ignored)",cl->
GetName(),newid);
821 if (cname==(
void*)-1) {
849 if ((pcname=
gROOT->GetListOfClasses()->FindObject(cname))) {
874 if (loc >= 1) classname.
Remove(loc);
TClass *(* DictFuncPtr_t)()
TClassTable * gClassTable
static int ClassComp(const void *a, const void *b)
ROOT::TMapTypeToTClass IdMap_t
void Info(const char *location, const char *msgfmt,...)
void Error(const char *location, const char *msgfmt,...)
R__EXTERN TInterpreter * gCling
void Printf(const char *fmt,...)
char * StrDup(const char *str)
Duplicate the string str.
This class registers for all classes their name, id and dictionary function in a hash table.
static void PrintTable()
Print the class table.
static Int_t GetPragmaBits(const char *name)
Returns the pragma bits as specified in the LinkDef.h file.
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
static Version_t GetID(const char *cname)
Returns the ID of a class.
ROOT::TMapTypeToClassRec IdMap_t
static void SortTable()
Sort the class table by ascending class ID's.
static TProtoClass * GetProtoNorm(const char *cname)
Given the class normalized name returns the TClassProto object for the class.
static DictFuncPtr_t GetDictNorm(const char *cname)
Given the normalized class name returns the Dictionary() function of a class (uses hash of name).
static void AddAlternate(const char *normname, const char *alternate)
static ROOT::TClassAlt ** fgAlternate
static ROOT::TClassRec * FindElementImpl(const char *cname, Bool_t insert)
Find a class by name in the class table (using hash of name).
static void Terminate()
Deletes the class table (this static class function calls the dtor).
void Print(Option_t *option="") const
Print the class table.
static TProtoClass * GetProto(const char *cname)
Given the class name returns the TClassProto object for the class.
TClassTable()
TClassTable is a singleton (i.e. only one can exist per application).
static char * Next()
Returns next class from sorted class table.
static char * At(UInt_t index)
Returns class at index from sorted class table.
static Bool_t Check(const char *cname, std::string &normname)
static void Remove(const char *cname)
Remove a class from the class table.
static ROOT::TClassRec ** fgSortedTable
static ROOT::TClassRec ** fgTable
static Bool_t CheckClassTableInit()
Return true fs the table exist.
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).
~TClassTable()
TClassTable singleton is deleted in Terminate().
static ROOT::TClassRec * FindElement(const char *cname, Bool_t insert=kFALSE)
Find a class by name in the class table (using hash of name).
TClass instances represent classes, structs and namespaces in the ROOT type system.
void SetUnloaded()
Call this method to indicate that the shared library containing this class's code has been removed (u...
void SetClassVersion(Version_t version)
Private function.
std::atomic< Bool_t > fVersionUsed
saved remember if fOffsetStreamer has been set.
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.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void RegisterTClassUpdate(TClass *oldcl, DictFuncPtr_t dict)=0
virtual void Add(TObject *obj)
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
The TNamed class is the base class for all named ROOT classes.
virtual const char * GetName() const
Returns name of object.
Collectable string class.
Mother of all ROOT objects.
UInt_t fBits
bit field status word
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Class used by TMap to store (key,value) pairs.
Persistent version of a TClass.
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Regular expression class.
const char * Data() const
TString & Remove(Ssiz_t pos)
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
void Add(RHist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, const RHist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
R__EXTERN TROOT * gROOTLocal
void Print(std::ostream &os, const OptionType &opt)
std::vector< std::pair< const char *, const char * > > & GetDelayedAddClassAlternate()
std::vector< std::unique_ptr< TClassRec > > & GetDelayedAddClass()
void AddClassAlternate(const char *normName, const char *alternate)
Global function called by GenerateInitInstance.
void RemoveClass(const char *cname)
Global function called by the dtor of a class's init class (see the ClassImp macro).
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).
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....
static UInt_t ClassTableHash(const char *name, UInt_t size)
void ResetClassVersion(TClass *, const char *, Short_t)
Global function to update the version number.
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
static constexpr double s
UInt_t Find(std::list< std::pair< const Node< T > *, Float_t > > &nlist, const Node< T > *node, const T &event, UInt_t nfind)