Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TClass.cxx
Go to the documentation of this file.
1// @(#)root/meta:$Id: 7109cb45f1219c2aae6be19906ae5a63e31972ef $
2// Author: Rene Brun 07/01/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/** \class TClass
13TClass instances represent classes, structs and namespaces in the ROOT type system.
14
15TClass instances are created starting from different sources of information:
161. TStreamerInfo instances saved in a ROOT file which is opened. This is called in jargon an *emulated TClass*.
172. From TProtoClass instances saved in a ROOT pcm file created by the dictionary generator and the dictionary itself.
183. From a lookup in the AST built by cling.
19
20If a TClass instance is built through the mechanisms 1. and 2., it does not contain information about methods of the
21class/struct/namespace it represents. Conversely, if built through 3. or 1., it does not carry the information which is necessary
22to ROOT to perform I/O of instances of the class/struct it represents.
23The mechanisms 1., 2. and 3. are not mutually exclusive: it can happen that during the execution of the program, all
24the three are triggered, modifying the state of the TClass instance.
25
26In order to retrieve a TClass instance from the type system, a query can be executed as follows through the static
27TClass::GetClass method:
28
29~~~ {.cpp}
30auto myClassTClass_0 = TClass::GetClass("myClass");
31auto myClassTClass_1 = TClass::GetClass<myClass>();
32auto myClassTClass_2 = TClass::GetClass(myClassTypeInfo);
33~~~
34
35The name of classes is crucial for ROOT. A careful procedure of *name normalization* is carried out for
36each and every class. A *normalized name* is a valid C++ class name.
37In order to access the name of a class within the ROOT type system, the method TClass::GetName() can be used.
38*/
39
40//*-*x7.5 macros/layout_class
41
42#include "TClass.h"
43
44#include "strlcpy.h"
45#include "TBaseClass.h"
46#include "TBrowser.h"
47#include "TBuffer.h"
48#include "TClassGenerator.h"
49#include "TClassEdit.h"
50#include "TClassMenuItem.h"
51#include "TClassRef.h"
52#include "TClassTable.h"
53#include "TDataMember.h"
54#include "TDataType.h"
55#include "TDatime.h"
56#include "TEnum.h"
57#include "TEnv.h"
58#include "TError.h"
59#include "TExMap.h"
60#include "TFunctionTemplate.h"
61#include "THashList.h"
62#include "TInterpreter.h"
63#include "TMemberInspector.h"
64#include "TMethod.h"
65#include "TMethodArg.h"
66#include "TMethodCall.h"
67#include "TObjArray.h"
68#include "TObjString.h"
69#include "TProtoClass.h"
70#include "TROOT.h"
71#include "TRealData.h"
72#include "TCheckHashRecursiveRemoveConsistency.h" // Private header
73#include "TStreamer.h"
74#include "TStreamerElement.h"
77#include "TVirtualIsAProxy.h"
78#include "TVirtualRefProxy.h"
79#include "TVirtualMutex.h"
80#include "TVirtualPad.h"
81#include "THashTable.h"
82#include "TSchemaRuleSet.h"
83#include "TGenericClassInfo.h"
84#include "TIsAProxy.h"
85#include "TSchemaRule.h"
86#include "TSystem.h"
87#include "TThreadSlots.h"
88#include "ThreadLocalStorage.h"
89
90#include <cstdio>
91#include <cctype>
92#include <set>
93#include <iostream>
94#include <sstream>
95#include <string>
96#include <map>
97#include <mutex>
98#include <typeinfo>
99#include <cmath>
100#include <cassert>
101#include <vector>
102#include <memory>
103
104#include "TSpinLockGuard.h"
105
106#ifdef WIN32
107#include <io.h>
108#include "Windows4Root.h"
109#include <Psapi.h>
110#define RTLD_DEFAULT ((void *)::GetModuleHandle(NULL))
111#define dlsym(library, function_name) ::GetProcAddress((HMODULE)library, function_name)
112#else
113#include <dlfcn.h>
114#endif
115
116#include "TListOfDataMembers.h"
117#include "TListOfFunctions.h"
119#include "TListOfEnums.h"
120#include "TListOfEnumsWithLock.h"
121#include "TViewPubDataMembers.h"
122#include "TViewPubFunctions.h"
123#include "TArray.h"
124#include "TClonesArray.h"
125#include "TRef.h"
126#include "TRefArray.h"
127#include "ROOT/BitUtils.hxx"
128
129using std::multimap, std::make_pair, std::string;
130
131// Mutex to protect CINT and META operations
132// (exported to be used for similar cases in related classes)
133
135
136namespace {
137
138 static constexpr const char kUndeterminedClassInfoName[] = "<NOT YET DETERMINED FROM fClassInfo>";
139
140 class TMmallocDescTemp {
141 private:
142 void *fSave;
143 public:
144 TMmallocDescTemp(void *value = nullptr) :
146 ~TMmallocDescTemp() { ROOT::Internal::gMmallocDesc = fSave; }
147 };
148
149 // When a new class is created, we need to be able to find
150 // if there are any existing classes that have the same name
151 // after any typedefs are expanded. (This only really affects
152 // template arguments.) To avoid having to search through all classes
153 // in that case, we keep a hash table mapping from the fully
154 // typedef-expanded names to the original class names.
155 // An entry is made in the table only if they are actually different.
156 //
157 // In these objects, the TObjString base holds the typedef-expanded
158 // name (the hash key), and fOrigName holds the original class name
159 // (the value to which the key maps).
160 //
161 class TNameMapNode : public TObjString {
162 public:
163 TString fOrigName;
164
165 TNameMapNode(const char *typedf, const char *orig) :
166 TObjString (typedf),
167 fOrigName (orig)
168 {
169 }
170 };
171
172}
173
174std::atomic<Int_t> TClass::fgClassCount;
175
176static bool IsFromRootCling() {
177 // rootcling also uses TCling for generating the dictionary ROOT files.
178 const static bool foundSymbol = dlsym(RTLD_DEFAULT, "usedToIdentifyRootClingByDlSym");
179 return foundSymbol;
180}
181
182// Implementation of the TDeclNameRegistry
183
184////////////////////////////////////////////////////////////////////////////////
185/// TDeclNameRegistry class constructor.
186
188{
189 // MSVC doesn't support fSpinLock=ATOMIC_FLAG_INIT; in the class definition
190 std::atomic_flag_clear( &fSpinLock );
191}
192
193////////////////////////////////////////////////////////////////////////////////
194/// Extract this part of the name
195/// 1. Templates `ns::%ns2::,,,::%THISPART<...`
196/// 2. Namespaces,classes `ns::%ns2::,,,::%THISPART`
197
199{
200 // Sanity check
201 auto strLen = name ? strlen(name) : 0;
202 if (strLen == 0) return;
203 // find <. If none, put end of string
204 const char* endCharPtr = strchr(name, '<');
205 endCharPtr = !endCharPtr ? &name[strLen] : endCharPtr;
206 // find last : before the <. If not found, put begin of string
207 const char* beginCharPtr = endCharPtr;
208 while (beginCharPtr!=name){
209 if (*beginCharPtr==':'){
210 beginCharPtr++;
211 break;
212 }
213 beginCharPtr--;
214 }
215 beginCharPtr = beginCharPtr!=endCharPtr ? beginCharPtr : name;
216 std::string s(beginCharPtr, endCharPtr);
217 if (fVerbLevel>1)
218 printf("TDeclNameRegistry::AddQualifiedName Adding key %s for class/namespace %s\n", s.c_str(), name);
219 ROOT::Internal::TSpinLockGuard slg(fSpinLock);
220 fClassNamesSet.insert(s);
221}
222
223////////////////////////////////////////////////////////////////////////////////
224
226{
227 Bool_t found = false;
228 {
229 ROOT::Internal::TSpinLockGuard slg(fSpinLock);
230 found = fClassNamesSet.find(name) != fClassNamesSet.end();
231 }
232 return found;
233}
234
235////////////////////////////////////////////////////////////////////////////////
236
238{
239 if (fVerbLevel > 1) {
240 printf("TDeclNameRegistry Destructor. List of %lu names:\n",
241 (long unsigned int)fClassNamesSet.size());
242 for (auto const & key: fClassNamesSet) {
243 printf(" - %s\n", key.c_str());
244 }
245 }
246}
247
248////////////////////////////////////////////////////////////////////////////////
249
253
254////////////////////////////////////////////////////////////////////////////////
255
263
264// Initialise the global member of TClass
266
267//Intent of why/how TClass::New() is called
268//[Not a static data member because MacOS does not support static thread local data member ... who knows why]
270 TTHREAD_TLS(TClass::ENewType) fgCallingNew = TClass::kRealNew;
271 return fgCallingNew;
272}
273
275{
278
280 fCurrentValue(TClass__GetCallingNew()),
281 fOldValue(fCurrentValue)
282 {
283 fCurrentValue = newvalue;
284 }
285
287 {
288 fCurrentValue = fOldValue;
289 }
290};
291
292void TClass::RegisterAddressInRepository(const char * /*where*/, void *location, const TClass *what) const
293{
294 // Register the object for special handling in the destructor.
295
296 Version_t version = what->GetClassVersion();
297// if (!fObjectVersionRepository.count(location)) {
298// Info(where, "Registering address %p of class '%s' version %d", location, what->GetName(), version);
299// } else {
300// Warning(where, "Registering address %p again of class '%s' version %d", location, what->GetName(), version);
301// }
302 {
304 fObjectVersionRepository.insert(RepoCont_t::value_type(location, version));
305 }
306#if 0
307 // This code could be used to prevent an address to be registered twice.
308 std::pair<RepoCont_t::iterator, Bool_t> tmp = fObjectVersionRepository.insert(RepoCont_t::value_type>(location, version));
309 if (!tmp.second) {
310 Warning(where, "Reregistering an object of class '%s' version %d at address %p", what->GetName(), version, p);
311 fObjectVersionRepository.erase(tmp.first);
312 tmp = fObjectVersionRepository.insert(RepoCont_t::value_type>(location, version));
313 if (!tmp.second) {
314 Warning(where, "Failed to reregister an object of class '%s' version %d at address %p", what->GetName(), version, location);
315 }
316 }
317#endif
318}
319
320void TClass::UnregisterAddressInRepository(const char * /*where*/, void *location, const TClass *what) const
321{
322 // Remove an address from the repository of address/object.
323
325 RepoCont_t::iterator cur = fObjectVersionRepository.find(location);
326 for (; cur != fObjectVersionRepository.end();) {
327 RepoCont_t::iterator tmp = cur++;
328 if ((tmp->first == location) && (tmp->second == what->GetClassVersion())) {
329 // -- We still have an address, version match.
330 // Info(where, "Unregistering address %p of class '%s' version %d", location, what->GetName(), what->GetClassVersion());
331 fObjectVersionRepository.erase(tmp);
332 } else {
333 // -- No address, version match, we've reached the end.
334 break;
335 }
336 }
337}
338
339void TClass::MoveAddressInRepository(const char * /*where*/, void *oldadd, void *newadd, const TClass *what) const
340{
341 // Register in the repository that an object has moved.
342
343 // Move not only the object itself but also any base classes or sub-objects.
344 size_t objsize = what->Size();
345 long delta = (char*)newadd - (char*)oldadd;
347 RepoCont_t::iterator cur = fObjectVersionRepository.find(oldadd);
348 for (; cur != fObjectVersionRepository.end();) {
349 RepoCont_t::iterator tmp = cur++;
350 if (oldadd <= tmp->first && tmp->first < ( ((char*)oldadd) + objsize) ) {
351 // The location is within the object, let's move it.
352
353 fObjectVersionRepository.insert(RepoCont_t::value_type(((char*)tmp->first)+delta, tmp->second));
354 fObjectVersionRepository.erase(tmp);
355
356 } else {
357 // -- No address, version match, we've reached the end.
358 break;
359 }
360 }
361}
362
363//______________________________________________________________________________
364//______________________________________________________________________________
365namespace ROOT {
366#define R__USE_STD_MAP
368#if defined R__USE_STD_MAP
369 // This wrapper class allow to avoid putting #include <map> in the
370 // TROOT.h header file.
371 public:
372 typedef std::map<std::string,TClass*> IdMap_t;
376#ifdef R__WIN32
377 // Window's std::map does NOT defined mapped_type
378 typedef TClass* mapped_type;
379#else
381#endif
382
383 private:
385
386 public:
387 void Add(const key_type &key, mapped_type &obj)
388 {
389 // Add the <key,obj> pair to the map.
390 fMap[key] = obj;
391 }
392 mapped_type Find(const key_type &key) const
393 {
394 // Find the type corresponding to the key.
395 IdMap_t::const_iterator iter = fMap.find(key);
396 mapped_type cl = nullptr;
397 if (iter != fMap.end()) cl = iter->second;
398 return cl;
399 }
400 void Remove(const key_type &key) {
401 // Remove the type corresponding to the key.
402 fMap.erase(key);
403 }
404#else
405 private:
406 TMap fMap;
407
408 public:
409#ifdef R__COMPLETE_MEM_TERMINATION
411 TIter next(&fMap);
412 TObjString *key;
413 while((key = (TObjString*)next())) {
414 delete key;
415 }
416 }
417#endif
418 void Add(const char *key, TClass *&obj) {
419 TObjString *realkey = new TObjString(key);
420 fMap.Add(realkey, obj);
421 }
422 TClass* Find(const char *key) const {
423 const TPair *a = (const TPair *)fMap.FindObject(key);
424 if (a) return (TClass*) a->Value();
425 return 0;
426 }
427 void Remove(const char *key) {
428 TObjString realkey(key);
429 TObject *actual = fMap.Remove(&realkey);
430 delete actual;
431 }
432#endif
433 };
434
436 // Wrapper class for the multimap of DeclId_t and TClass.
437 public:
438 typedef multimap<TDictionary::DeclId_t, TClass*> DeclIdMap_t;
442 typedef std::pair <const_iterator, const_iterator> equal_range;
444
445 private:
447
448 public:
449 void Add(const key_type &key, mapped_type obj)
450 {
451 // Add the <key,obj> pair to the map.
452 std::pair<const key_type, mapped_type> pair = make_pair(key, obj);
453 fMap.insert(pair);
454 }
456 {
457 return fMap.count(key);
458 }
459 equal_range Find(const key_type &key) const
460 {
461 // Find the type corresponding to the key.
462 return fMap.equal_range(key);
463 }
464 void Remove(const key_type &key) {
465 // Remove the type corresponding to the key.
466 fMap.erase(key);
467 }
468 };
469}
470
472
473#ifdef R__COMPLETE_MEM_TERMINATION
474 static IdMap_t gIdMapObject;
475 return &gIdMapObject;
476#else
477 static IdMap_t *gIdMap = new IdMap_t;
478 return gIdMap;
479#endif
480}
481
483
484#ifdef R__COMPLETE_MEM_TERMINATION
485 static DeclIdMap_t gDeclIdMapObject;
486 return &gDeclIdMapObject;
487#else
488 static DeclIdMap_t *gDeclIdMap = new DeclIdMap_t;
489 return gDeclIdMap;
490#endif
491}
492
493
494namespace {
495
496////////////////////////////////////////////////////////////////////////////////
497/// Check whether c is a character that can be part of an identifier.
498bool isIdentifierChar(char c) {
499 return isalnum(c) || c == '_';
500}
501
502////////////////////////////////////////////////////////////////////////////////
503/// Count the number of occurrences of needle in typename haystack.
504
505static int CountStringOccurrences(const TString &needle, const TString &haystack) {
506 Ssiz_t currStart = 0;
507 int numOccurrences = 0;
508 Ssiz_t posFound = haystack.Index(needle, currStart);
509 while (posFound != TString::kNPOS) {
510 // Ensure it's neither FooNeedle nor NeedleFoo, but Needle is surrounded
511 // by delimiters:
512 auto hasDelimLeft = [&]() {
513 return posFound == 0
514 || !isIdentifierChar(haystack[posFound - 1]);
515 };
516 auto hasDelimRight = [&]() {
517 return posFound + needle.Length() == haystack.Length()
518 || !isIdentifierChar(haystack[posFound + needle.Length()]);
519 };
520
521 if (hasDelimLeft() && hasDelimRight())
522 ++numOccurrences;
523 currStart = posFound + needle.Length();
524 posFound = haystack.Index(needle, currStart);
525 }
526 return numOccurrences;
527}
528
529////////////////////////////////////////////////////////////////////////////////
530/// Whether an existing typeinfo value should be replaced because the new one
531/// has "less" Double32_t.
532
533static bool ShouldReplaceDouble32TypeInfo(TClass *newCl, TClass *existingCl) {
534
535 // If old and new names match, no need to replace.
536 if (!strcmp(newCl->GetName(), existingCl->GetName()))
537 return false;
538
539 int numExistingDouble32 = CountStringOccurrences("Double32_t", existingCl->GetName());
540 int numExistingFloat16 = CountStringOccurrences("Float16_t", existingCl->GetName());
541
542 // If the existing class has no I/O types then it should not be replaced.
543 if (numExistingDouble32 + numExistingFloat16 == 0)
544 return false;
545
546 int numNewDouble32 = CountStringOccurrences("Double32_t", newCl->GetName());
547 int numNewFloat16 = CountStringOccurrences("Float16_t", newCl->GetName());
548
549 // If old has more I/O types, replace!
550 return numExistingDouble32 + numExistingFloat16 > numNewDouble32 + numNewFloat16;
551}
552}
553
554////////////////////////////////////////////////////////////////////////////////
555/// static: Add a class to the list and map of classes.
556
558{
559 if (!cl) return;
560
562 gROOT->GetListOfClasses()->Add(cl);
563 if (cl->GetTypeInfo()) {
564 bool shouldAddTypeInfo = true;
565 if (TClass* existingCl = GetIdMap()->Find(cl->GetTypeInfo()->name()))
566 shouldAddTypeInfo = ShouldReplaceDouble32TypeInfo(cl, existingCl);
567 if (shouldAddTypeInfo)
568 GetIdMap()->Add(cl->GetTypeInfo()->name(),cl);
569 }
570 if (cl->fClassInfo) {
571 GetDeclIdMap()->Add((void*)(cl->fClassInfo), cl);
572 }
573}
574
575////////////////////////////////////////////////////////////////////////////////
576/// static: Add a TClass* to the map of classes.
577
579{
580 if (!cl || !id) return;
581 GetDeclIdMap()->Add(id, cl);
582}
583
584////////////////////////////////////////////////////////////////////////////////
585/// static: Remove a class from the list and map of classes
586
588{
589 if (!oldcl) return;
590
592 gROOT->GetListOfClasses()->Remove(oldcl);
593 if (oldcl->GetTypeInfo()) {
594 if (TClass* existingCl = GetIdMap()->Find(oldcl->GetTypeInfo()->name()))
595 if (existingCl == oldcl)
596 GetIdMap()->Remove(oldcl->GetTypeInfo()->name());
597 }
598 if (oldcl->fClassInfo) {
599 //GetDeclIdMap()->Remove((void*)(oldcl->fClassInfo));
600 }
601}
602
603////////////////////////////////////////////////////////////////////////////////
604
606{
607 if (!id) return;
608 GetDeclIdMap()->Remove(id);
609}
610
611////////////////////////////////////////////////////////////////////////////////
612/// Indirect call to the implementation of ShowMember allowing [forward]
613/// declaration with out a full definition of the TClass class.
614
615void ROOT::Class_ShowMembers(TClass *cl, const void *obj, TMemberInspector&insp)
616{
617 gInterpreter->InspectMembers(insp, obj, cl, kFALSE);
618}
619
620//______________________________________________________________________________
621//______________________________________________________________________________
622
625public:
626 TDumpMembers(bool noAddr): fNoAddr(noAddr) { }
627
629 void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t isTransient) override;
630};
631
632////////////////////////////////////////////////////////////////////////////////
633/// Print value of member mname.
634///
635/// This method is called by the ShowMembers() method for each
636/// data member when object.Dump() is invoked.
637///
638/// - cl is the pointer to the current class
639/// - pname is the parent name (in case of composed objects)
640/// - mname is the data member name
641/// - add is the data member address
642
643void TDumpMembers::Inspect(TClass *cl, const char *pname, const char *mname, const void *add, Bool_t /* isTransient */)
644{
645 const Int_t kvalue = 30;
646#ifdef R__B64
647 const Int_t ktitle = 50;
648#else
649 const Int_t ktitle = 42;
650#endif
651 const Int_t kline = 1024;
652 Int_t cdate = 0;
653 Int_t ctime = 0;
654 UInt_t *cdatime = nullptr;
655 char line[kline];
656
657 TDataType *membertype;
658 EDataType memberDataType = kNoType_t;
659 const char *memberName;
660 const char *memberFullTypeName;
661 const char *memberTitle;
662 Bool_t isapointer;
663 Bool_t isbasic;
664 Bool_t isarray;
665
666 if (TDataMember *member = cl->GetDataMember(mname)) {
667 if (member->GetDataType()) {
668 memberDataType = (EDataType)member->GetDataType()->GetType();
669 }
670 memberName = member->GetName();
671 memberFullTypeName = member->GetFullTypeName();
672 memberTitle = member->GetTitle();
673 isapointer = member->IsaPointer();
674 isbasic = member->IsBasic();
675 membertype = member->GetDataType();
676 isarray = member->GetArrayDim();
677 } else if (!cl->IsLoaded()) {
678 // The class is not loaded, hence it is 'emulated' and the main source of
679 // information is the StreamerInfo.
681 if (!info) return;
682 const char *cursor = mname;
683 while ( (*cursor)=='*' ) ++cursor;
684 TString elname( cursor );
685 Ssiz_t pos = elname.Index("[");
686 if ( pos != kNPOS ) {
687 elname.Remove( pos );
688 }
689 TStreamerElement *element = (TStreamerElement*)info->GetElements()->FindObject(elname.Data());
690 if (!element) return;
691 memberFullTypeName = element->GetTypeName();
692
693 memberDataType = (EDataType)element->GetType();
694
695 memberName = element->GetName();
696 memberTitle = element->GetTitle();
697 isapointer = element->IsaPointer() || element->GetType() == TVirtualStreamerInfo::kCharStar;
698 membertype = gROOT->GetType(memberFullTypeName);
699
700 isbasic = membertype !=nullptr;
701 isarray = element->GetArrayDim();
702 } else {
703 return;
704 }
705
706
707 Bool_t isdate = kFALSE;
708 if (strcmp(memberName,"fDatime") == 0 && memberDataType == kUInt_t) {
709 isdate = kTRUE;
710 }
711 Bool_t isbits = kFALSE;
712 if (strcmp(memberName,"fBits") == 0 && memberDataType == kUInt_t) {
713 isbits = kTRUE;
714 }
715 TClass * dataClass = TClass::GetClass(memberFullTypeName);
716 Bool_t isTString = (dataClass == TString::Class());
717 static TClassRef stdClass("std::string");
718 Bool_t isStdString = (dataClass == stdClass);
719
720 Int_t i;
721 for (i = 0;i < kline; i++) line[i] = ' ';
722 line[kline-1] = 0;
723 snprintf(line,kline,"%s%s ",pname,mname);
724 i = strlen(line); line[i] = ' ';
725
726 // Encode data value or pointer value
727 char *pointer = (char*)add;
728 char **ppointer = (char**)(pointer);
729
730 if (isapointer) {
731 char **p3pointer = (char**)(*ppointer);
732 if (!p3pointer)
733 snprintf(&line[kvalue],kline-kvalue,"->0");
734 else if (!isbasic) {
735 if (!fNoAddr) {
736 snprintf(&line[kvalue],kline-kvalue,"->%zx ", (size_t)p3pointer);
737 }
738 } else if (membertype) {
739 if (!strcmp(membertype->GetTypeName(), "char")) {
740 i = strlen(*ppointer);
741 if (kvalue+i > kline) i=kline-1-kvalue;
742 Bool_t isPrintable = kTRUE;
743 for (Int_t j = 0; j < i; j++) {
744 if (!std::isprint((*ppointer)[j])) {
745 isPrintable = kFALSE;
746 break;
747 }
748 }
749 if (isPrintable) {
750 strncpy(line + kvalue, *ppointer, i);
751 line[kvalue+i] = 0;
752 } else {
753 line[kvalue] = 0;
754 }
755 } else {
756 line[kvalue] = '-';
757 line[kvalue+1] = '>';
758 strncpy(&line[kvalue+2], membertype->AsString(p3pointer), std::min(kline-1-kvalue-2,(int)strlen(membertype->AsString(p3pointer))));
759 }
760 } else if (!strcmp(memberFullTypeName, "char*") ||
761 !strcmp(memberFullTypeName, "const char*")) {
762 i = strlen(*ppointer);
763 if (kvalue+i >= kline) i=kline-1-kvalue;
764 Bool_t isPrintable = kTRUE;
765 for (Int_t j = 0; j < i; j++) {
766 if (!std::isprint((*ppointer)[j])) {
767 isPrintable = kFALSE;
768 break;
769 }
770 }
771 if (isPrintable) {
772 strncpy(line + kvalue, *ppointer, kline - 1 - kvalue);
773 line[kvalue+i] = 0;
774 } else {
775 line[kvalue] = 0;
776 }
777 } else {
778 if (!fNoAddr) {
779 snprintf(&line[kvalue],kline-kvalue,"->%zx ", (size_t)p3pointer);
780 }
781 }
782 } else if (membertype) {
783 if (isdate) {
784 cdatime = (UInt_t*)pointer;
785 TDatime::GetDateTime(cdatime[0],cdate,ctime);
786 snprintf(&line[kvalue],kline-kvalue,"%d/%d",cdate,ctime);
787 } else if (isbits) {
788 snprintf(&line[kvalue],kline-kvalue,"0x%08x", *(UInt_t*)pointer);
789 } else {
790 strncpy(&line[kvalue], membertype->AsString(pointer), std::min(kline-1-kvalue,(int)strlen(membertype->AsString(pointer))));
791 }
792 } else {
793 if (isStdString) {
794 std::string *str = (std::string*)pointer;
795 snprintf(&line[kvalue],kline-kvalue,"%s",str->c_str());
796 } else if (isTString) {
797 TString *str = (TString*)pointer;
798 snprintf(&line[kvalue],kline-kvalue,"%s",str->Data());
799 } else {
800 if (!fNoAddr) {
801 snprintf(&line[kvalue],kline-kvalue,"->%zx ", (size_t)pointer);
802 }
803 }
804 }
805 // Encode data member title
806 if (isdate == kFALSE && strcmp(memberFullTypeName, "char*") && strcmp(memberFullTypeName, "const char*")) {
807 i = strlen(&line[0]); line[i] = ' ';
808 assert(250 > ktitle);
809 strlcpy(&line[ktitle],memberTitle,250-ktitle+1); // strlcpy copy 'size-1' characters.
810 }
811 if (isarray) {
812 // Should iterate over the element
813 strncat(line, " ...", kline-strlen(line)-1);
814 }
815 Printf("%s", line);
816}
817
819
820//______________________________________________________________________________
821
823
824private:
827
828public:
829 TBuildRealData(void *obj, TClass *cl) {
830 // Main constructor.
831 fRealDataObject = obj;
832 fRealDataClass = cl;
833 }
835 void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t isTransient) override;
836
837};
838
839////////////////////////////////////////////////////////////////////////////////
840/// This method is called from ShowMembers() via BuildRealdata().
841
842void TBuildRealData::Inspect(TClass* cl, const char* pname, const char* mname, const void* add, Bool_t isTransient)
843{
844 TDataMember* dm = cl->GetDataMember(mname);
845 if (!dm) {
846 return;
847 }
848
849 Bool_t isTransientMember = kFALSE;
850
851 if (!dm->IsPersistent()) {
852 // For the DataModelEvolution we need access to the transient member.
853 // so we now record them in the list of RealData.
854 isTransientMember = kTRUE;
855 isTransient = kTRUE;
856 }
857
858 TString rname( pname );
859 // Take into account cases like TPaveStats->TPaveText->TPave->TBox.
860 // Check that member is in a derived class or an object in the class.
861 if (cl != fRealDataClass) {
862 if (!fRealDataClass->InheritsFrom(cl)) {
863 Ssiz_t dot = rname.Index('.');
864 if (dot == kNPOS) {
865 return;
866 }
867 rname[dot] = '\0';
868 if (!fRealDataClass->GetDataMember(rname)) {
869 //could be a data member in a base class like in this example
870 // class Event : public Data {
871 // class Data : public TObject {
872 // EventHeader fEvtHdr;
873 // class EventHeader {
874 // Int_t fEvtNum;
875 // Int_t fRun;
876 // Int_t fDate;
877 // EventVertex fVertex;
878 // class EventVertex {
879 // EventTime fTime;
880 // class EventTime {
881 // Int_t fSec;
882 // Int_t fNanoSec;
883 if (!fRealDataClass->GetBaseDataMember(rname)) {
884 return;
885 }
886 }
887 rname[dot] = '.';
888 }
889 }
890
891 Longptr_t offset = Longptr_t(((Longptr_t) add) - ((Longptr_t) fRealDataObject));
892
893 if (TClassEdit::IsStdArray(dm->GetTypeName())){ // We tackle the std array case
894 TString rdName;
895 TRealData::GetName(rdName,dm);
896 rname += rdName;
897 TRealData* rd = new TRealData(rname.Data(), offset, dm);
898 if (isTransientMember || IsNestedTransient())
900 fRealDataClass->GetListOfRealData()->Add(rd);
901 return;
902 }
903
904 rname += mname;
905
906 if (dm->IsaPointer()) {
907 // Data member is a pointer.
908 TRealData* rd = new TRealData(rname, offset, dm);
909 if (isTransientMember || IsNestedTransient())
911 fRealDataClass->GetListOfRealData()->Add(rd);
912 } else {
913 // Data Member is a basic data type.
914 TRealData* rd = new TRealData(rname, offset, dm);
915 if (isTransientMember || IsNestedTransient())
917 if (!dm->IsBasic()) {
918 rd->SetIsObject(kTRUE);
919
920 // Make sure that BuildReadData is called for any abstract
921 // bases classes involved in this object, i.e for all the
922 // classes composing this object (base classes, type of
923 // embedded object and same for their data members).
924 //
925 TClass* dmclass = TClass::GetClass(dm->GetTypeName(), kTRUE, isTransient);
926 if (!dmclass) {
927 dmclass = TClass::GetClass(dm->GetTrueTypeName(), kTRUE, isTransient);
928 }
929 if (dmclass) {
930 if ((dmclass != cl) && !dm->IsaPointer()) {
931 if (dmclass->GetCollectionProxy()) {
932 TClass* valcl = dmclass->GetCollectionProxy()->GetValueClass();
933 // We create the real data for the content of the collection to help the case
934 // of split branches in a TTree (where the node for the data member itself
935 // might have been elided). However, in some cases, like transient members
936 // and/or classes, the content might not be create-able. An example is the
937 // case of a map<A,B> where either A or B does not have default constructor
938 // and thus the compilation of the default constructor for pair<A,B> will
939 // fail (noisily) [This could also apply to any template instance, where it
940 // might have a default constructor definition that can not be compiled due
941 // to the template parameter]
942 if (valcl) {
943 Bool_t wantBuild = kTRUE;
944 if (valcl->Property() & kIsAbstract) wantBuild = kFALSE;
945 if ( (isTransient)
947 && (!valcl->IsLoaded()) ) {
948 // Case where the collection dictionary was not requested and
949 // the content's dictionary was also not requested.
950 // [This is a super set of what we need, but we can't really detect it :(]
951 wantBuild = kFALSE;
952 }
953
954 if (wantBuild) valcl->BuildRealData(nullptr, isTransient);
955 }
956 } else {
957 void* addrForRecursion = nullptr;
958 if (GetObjectValidity() == kValidObjectGiven)
959 addrForRecursion = const_cast<void*>(add);
960
961 dmclass->BuildRealData(addrForRecursion, isTransient);
962 }
963 }
964 }
965 }
966 fRealDataClass->GetListOfRealData()->Add(rd);
967 }
968}
969
970//______________________________________________________________________________
971//______________________________________________________________________________
972//______________________________________________________________________________
973
974////////////////////////////////////////////////////////////////////////////////
975
977public:
980
982 {
983 // main constructor.
984 fBrowser = b; fCount = 0;
985 }
986 ~TAutoInspector() override {}
988 void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t isTransient) override;
990};
991
992////////////////////////////////////////////////////////////////////////////////
993/// This method is called from ShowMembers() via AutoBrowse().
994
995void TAutoInspector::Inspect(TClass *cl, const char *tit, const char *name,
996 const void *addr, Bool_t /* isTransient */)
997{
998 if(tit && strchr(tit,'.')) return ;
999 if (fCount && !fBrowser) return;
1000
1001 TString ts;
1002
1003 if (!cl) return;
1004 //if (*(cl->GetName()) == 'T') return;
1005 if (*name == '*') name++;
1006 int ln = strcspn(name,"[ ");
1007 TString iname(name,ln);
1008
1009 ClassInfo_t *classInfo = cl->GetClassInfo();
1010 if (!classInfo) return;
1011
1012 // Browse data members
1014 TString mname;
1015
1016 int found=0;
1017 while (gCling->DataMemberInfo_Next(m)) { // MemberLoop
1018 mname = gCling->DataMemberInfo_Name(m);
1019 mname.ReplaceAll("*","");
1020 if ((found = (iname==mname))) break;
1021 }
1022 assert(found);
1023
1024 // we skip: non static members and non objects
1025 // - the member G__virtualinfo inserted by the CINT RTTI system
1026
1027 //Long_t prop = m.Property() | m.Type()->Property();
1029 if (prop & kIsStatic) return;
1030 if (prop & kIsFundamental) return;
1031 if (prop & kIsEnum) return;
1032 if (mname == "G__virtualinfo") return;
1033
1034 int size = sizeof(void*);
1035
1036 int nmax = 1;
1037 if (prop & kIsArray) {
1038 for (int dim = 0; dim < gCling->DataMemberInfo_ArrayDim(m); dim++) nmax *= gCling->DataMemberInfo_MaxIndex(m,dim);
1039 }
1040
1043 TClass * clm = TClass::GetClass(clmName.c_str());
1044 R__ASSERT(clm);
1045 if (!(prop & kIsPointer)) {
1046 size = clm->Size();
1048 }
1049
1050
1053
1054 for(int i=0; i<nmax; i++) {
1055
1056 char *ptr = (char*)addr + i*size;
1057
1058 void *obj = (prop & kIsPointer) ? *((void**)ptr) : (TObject*)ptr;
1059
1060 if (!obj) continue;
1061
1062 fCount++;
1063 if (!fBrowser) return;
1064
1065 TString bwname;
1066 TClass *actualClass = clm->GetActualClass(obj);
1067 if (clm->IsTObject()) {
1068 TObject *tobj = (TObject*)clm->DynamicCast(TObject::Class(),obj);
1069 bwname = tobj->GetName();
1070 } else {
1071 bwname = actualClass->GetName();
1072 bwname += "::";
1073 bwname += mname;
1074 }
1075
1076 if (!clm->IsTObject() ||
1077 bwname.Length()==0 ||
1078 strcmp(bwname.Data(),actualClass->GetName())==0) {
1079 bwname = name;
1080 int l = strcspn(bwname.Data(),"[ ");
1081 if (l<bwname.Length() && bwname[l]=='[') {
1082 char cbuf[13]; snprintf(cbuf,13,"[%02d]",i);
1083 ts.Replace(0,999,bwname,l);
1084 ts += cbuf;
1085 bwname = (const char*)ts;
1086 }
1087 }
1088
1089 if (proxy==nullptr) {
1090
1091 fBrowser->Add(obj,clm,bwname);
1092
1093 } else {
1094 TClass *valueCl = proxy->GetValueClass();
1095
1096 if (valueCl==nullptr) {
1097
1098 fBrowser->Add( obj, clm, bwname );
1099
1100 } else {
1101 TVirtualCollectionProxy::TPushPop env(proxy, obj);
1102 TClass *actualCl = nullptr;
1103
1104 int sz = proxy->Size();
1105
1106 char fmt[] = {"#%09d"};
1107 fmt[3] = '0'+(int)log10(double(sz))+1;
1108 char buf[20];
1109 for (int ii=0;ii<sz;ii++) {
1110 void *p = proxy->At(ii);
1111
1112 if (proxy->HasPointers()) {
1113 p = *((void**)p);
1114 if(!p) continue;
1115 actualCl = valueCl->GetActualClass(p);
1116 p = actualCl->DynamicCast(valueCl,p,0);
1117 }
1118 fCount++;
1119 snprintf(buf,20,fmt,ii);
1120 ts = bwname;
1121 ts += buf;
1122 fBrowser->Add( p, actualCl, ts );
1123 }
1124 }
1125 }
1126 }
1127}
1128
1129//______________________________________________________________________________
1130//______________________________________________________________________________
1131//______________________________________________________________________________
1132
1133
1134////////////////////////////////////////////////////////////////////////////////
1135/// Internal, default constructor.
1136///
1137/// \note Use `TClass::GetClass("ClassName")` to get access to a TClass object for a certain class!
1138
1140 TDictionary(),
1142{
1143 // Default ctor.
1144
1146 {
1147 TMmallocDescTemp setreset;
1148 fStreamerInfo = new TObjArray(1, -2);
1149 }
1150 fDeclFileLine = -2; // -2 for standalone TClass (checked in dtor)
1151}
1152
1153////////////////////////////////////////////////////////////////////////////////
1154/// Create a TClass object. This object contains the full dictionary
1155/// of a class. It has list to baseclasses, datamembers and methods.
1156/// Use this ctor to create a standalone TClass object. Only useful
1157/// to get a temporary TClass interface to an interpreted class. Used by TTabCom.
1158///
1159/// \note Use `TClass::GetClass("ClassName")` to get access to a TClass object for a certain class!
1160
1161TClass::TClass(const char *name, Bool_t silent) :
1163 fIsSyntheticPair(kFALSE), fHasCustomStreamerMember(kFALSE)
1164{
1166
1167 if (!gROOT)
1168 ::Fatal("TClass::TClass", "ROOT system not initialized");
1169
1170 {
1171 TMmallocDescTemp setreset;
1172 fStreamerInfo = new TObjArray(1, -2);
1173 }
1174 fDeclFileLine = -2; // -2 for standalone TClass (checked in dtor)
1175
1177 if (!gInterpreter)
1178 ::Fatal("TClass::TClass", "gInterpreter not initialized");
1179
1180 gInterpreter->SetClassInfo(this); // sets fClassInfo pointer
1181 if (!silent && !fClassInfo && !TClassEdit::IsArtificial(name))
1182 ::Warning("TClass::TClass", "no dictionary for class %s is available", name);
1184
1186 fConversionStreamerInfo = nullptr;
1187}
1188
1189////////////////////////////////////////////////////////////////////////////////
1190/// Internal constructor.
1191///
1192/// \note Use `TClass::GetClass("ClassName")` to get access to a TClass object for a certain class!
1193
1194TClass::TClass(const char *name, Version_t cversion, Bool_t silent) :
1196 fIsSyntheticPair(kFALSE), fHasCustomStreamerMember(kFALSE)
1197{
1199 Init(name, cversion, nullptr, nullptr, nullptr, nullptr, -1, -1, nullptr, silent);
1200}
1201
1202////////////////////////////////////////////////////////////////////////////////
1203/// Internal constructor, mimicing the case of a class fwd declared in the interpreter.
1204///
1205/// \note Use `TClass::GetClass("ClassName")` to get access to a TClass object for a certain class!
1206
1207TClass::TClass(const char *name, Version_t cversion, EState theState, Bool_t silent) :
1209 fIsSyntheticPair(kFALSE), fHasCustomStreamerMember(kFALSE),
1210 fState(theState)
1211{
1213
1214 // Treat the case in which a TClass instance is created for a namespace
1215 if (theState == kNamespaceForMeta){
1217 theState = kForwardDeclared; // it immediately decays in kForwardDeclared
1218 }
1219
1220 if (theState != kForwardDeclared && theState != kEmulated)
1221 ::Fatal("TClass::TClass",
1222 "A TClass entry cannot be initialized in a state different from kForwardDeclared or kEmulated.");
1223 Init(name, cversion, nullptr, nullptr, nullptr, nullptr, -1, -1, nullptr, silent);
1224}
1225
1226////////////////////////////////////////////////////////////////////////////////
1227/// Internal constructor.
1228///
1229/// Create a TClass object. This object contains the full dictionary
1230/// of a class. It has list to baseclasses, datamembers and methods.
1231/// Use this ctor to create a standalone TClass object. Most useful
1232/// to get a TClass interface to an interpreted class. Used by TTabCom.
1233///
1234/// This copies the ClassInfo (i.e. does *not* take ownership of it).
1235///
1236/// \note Use `TClass::GetClass("class")` to get access to a TClass object for a certain class!
1237
1238TClass::TClass(ClassInfo_t *classInfo, Version_t cversion,
1239 const char *dfil, const char *ifil, Int_t dl, Int_t il, Bool_t silent) :
1240 TDictionary(""),
1241 fIsSyntheticPair(kFALSE), fHasCustomStreamerMember(kFALSE)
1242{
1244
1245 if (!gROOT)
1246 ::Fatal("TClass::TClass", "ROOT system not initialized");
1247
1248 fDeclFileLine = -2; // -2 for standalone TClass (checked in dtor)
1249
1251 if (!gInterpreter)
1252 ::Fatal("TClass::TClass", "gInterpreter not initialized");
1253
1254 if (!classInfo || !gInterpreter->ClassInfo_IsValid(classInfo)) {
1255 MakeZombie();
1256 fState = kNoInfo;
1257 } else {
1258 fName = gInterpreter->ClassInfo_FullName(classInfo);
1259
1261 Init(fName, cversion, nullptr, nullptr, dfil, ifil, dl, il, classInfo, silent);
1262 }
1264
1265 fConversionStreamerInfo = nullptr;
1266}
1267
1268
1269////////////////////////////////////////////////////////////////////////////////
1270/// Internal constructor.
1271///
1272/// \note Use `TClass::GetClass("class")` to get access to a TClass object for a certain class!
1273
1274TClass::TClass(const char *name, Version_t cversion,
1275 const char *dfil, const char *ifil, Int_t dl, Int_t il, Bool_t silent) :
1277 fIsSyntheticPair(kFALSE), fHasCustomStreamerMember(kFALSE)
1278{
1280 Init(name,cversion, nullptr, nullptr, dfil, ifil, dl, il, nullptr, silent);
1281}
1282
1283////////////////////////////////////////////////////////////////////////////////
1284/// Internal constructor.
1285///
1286/// \note Use `TClass::GetClass("class")` to get access to a TClass object for a certain class!
1287
1288TClass::TClass(const char *name, Version_t cversion,
1289 const std::type_info &info, TVirtualIsAProxy *isa,
1290 const char *dfil, const char *ifil, Int_t dl, Int_t il,
1291 Bool_t silent) :
1293 fIsSyntheticPair(kFALSE), fHasCustomStreamerMember(kFALSE),
1294 fState(kHasTClassInit)
1295{
1297 // use info
1298 Init(name, cversion, &info, isa, dfil, ifil, dl, il, nullptr, silent);
1299}
1300
1301////////////////////////////////////////////////////////////////////////////////
1302/// we found at least one equivalent.
1303/// let's force a reload
1304
1306{
1307 TClass::RemoveClass(oldcl);
1308
1309 if (oldcl->CanIgnoreTObjectStreamer()) {
1311 }
1312
1314 TIter next(oldcl->GetStreamerInfos());
1315 while ((info = (TVirtualStreamerInfo*)next())) {
1316 info->Clear("build");
1317 info->SetClass(this);
1318 if (IsSyntheticPair()) {
1319 // Some pair's StreamerInfo were inappropriately marked as versioned
1320 info->SetClassVersion(1);
1321 // There is already a TStreamerInfo put there by the synthetic
1322 // creation.
1323 fStreamerInfo->Add(info);
1324 } else {
1326 }
1327 }
1328 oldcl->fStreamerInfo->Clear();
1329
1330 oldcl->ReplaceWith(this);
1331 delete oldcl;
1332}
1333
1334////////////////////////////////////////////////////////////////////////////////
1335/// Initialize a TClass object. This object contains the full dictionary
1336/// of a class. It has list to baseclasses, datamembers and methods.
1337/// The caller of this function should be holding the ROOT Write lock.
1338
1339void TClass::Init(const char *name, Version_t cversion,
1340 const std::type_info *typeinfo, TVirtualIsAProxy *isa,
1341 const char *dfil, const char *ifil, Int_t dl, Int_t il,
1342 ClassInfo_t *givenInfo,
1343 Bool_t silent)
1344{
1345 if (!gROOT)
1346 ::Fatal("TClass::TClass", "ROOT system not initialized");
1347 if (!name || !name[0]) {
1348 ::Error("TClass::Init", "The name parameter is invalid (null or empty)");
1349 MakeZombie();
1350 return;
1351 }
1352 // Always strip the default STL template arguments (from any template argument or the class name)
1354 fName = name; // We can assume that the artificial class name is already normalized.
1355 else
1357
1358 fClassVersion = cversion;
1359 fDeclFileName = dfil ? dfil : "";
1360 fImplFileName = ifil ? ifil : "";
1361 fDeclFileLine = dl;
1362 fImplFileLine = il;
1363 fTypeInfo = typeinfo;
1364 fIsA = isa;
1365 if ( fIsA ) fIsA->SetClass(this);
1366 // See also TCling::GenerateTClass() which will update fClassVersion after creation!
1367 fStreamerInfo = new TObjArray(fClassVersion+2+10,-1); // +10 to read new data by old
1368 fProperty = -1;
1369 fClassProperty = 0;
1370 const bool ispair = TClassEdit::IsStdPair(fName);
1371 if (ispair)
1373
1375
1376 TClass *oldcl = (TClass*)gROOT->GetListOfClasses()->FindObject(fName.Data());
1377
1379
1380 if (oldcl && oldcl->TestBit(kLoading)) {
1381 // Do not recreate a class while it is already being created!
1382
1383 // We can no longer reproduce this case, to check whether we are, we use
1384 // this code:
1385 // Fatal("Init","A bad replacement for %s was requested\n",name);
1386 return;
1387 }
1388
1389 TClass **persistentRef = nullptr;
1390 if (oldcl) {
1391
1392 persistentRef = oldcl->fPersistentRef.exchange(nullptr);
1393
1394 // The code from here is also in ForceReload.
1395 TClass::RemoveClass(oldcl);
1396 // move the StreamerInfo immediately so that there are
1397 // properly updated!
1398
1399 if (oldcl->CanIgnoreTObjectStreamer()) {
1401 }
1403
1404 TIter next(oldcl->GetStreamerInfos());
1405 while ((info = (TVirtualStreamerInfo*)next())) {
1406 // We need to force a call to BuildOld
1407 info->Clear("build");
1408 info->SetClass(this);
1410 }
1411 oldcl->fStreamerInfo->Clear();
1412 // The code diverges here from ForceReload.
1413
1414 // Move the Schema Rules too.
1415 fSchemaRules = oldcl->fSchemaRules;
1416 oldcl->fSchemaRules = nullptr;
1417
1418 // Move the TFunctions.
1420 if (fFuncTemplate)
1421 fFuncTemplate->fClass = this;
1422 oldcl->fFuncTemplate = nullptr;
1423 fMethod.store( oldcl->fMethod );
1424 if (fMethod)
1425 (*fMethod).fClass = this;
1426 oldcl->fMethod = nullptr;
1427
1428 }
1429
1431 // Advertise ourself as the loading class for this class name
1432 TClass::AddClass(this);
1433
1435
1436 if (!gInterpreter)
1437 ::Fatal("TClass::Init", "gInterpreter not initialized");
1438
1439 if (givenInfo) {
1440 bool invalid = !gInterpreter->ClassInfo_IsValid(givenInfo);
1441 bool notloaded = !gInterpreter->ClassInfo_IsLoaded(givenInfo);
1442 auto property = gInterpreter->ClassInfo_Property(givenInfo);
1443
1444 if (invalid || (notloaded && (property & kIsNamespace)) ||
1447 MakeZombie();
1448 fState = kNoInfo;
1449 TClass::RemoveClass(this);
1450 return;
1451 }
1452 }
1453
1454 if (!invalid) {
1455 fClassInfo = gInterpreter->ClassInfo_Factory(givenInfo);
1456 fCanLoadClassInfo = false; // avoids calls to LoadClassInfo() if info is already loaded
1457 if (fState <= kEmulated)
1459 }
1460 }
1461
1462 // We need to check if the class it is not fwd declared for the cases where we
1463 // created a TClass directly in the kForwardDeclared state. Indeed in those cases
1464 // fClassInfo will always be nullptr.
1466
1467 if (fState == kHasTClassInit) {
1468 // If the TClass is being generated from a ROOT dictionary,
1469 // even though we do not seem to have a CINT dictionary for
1470 // the class, we will will try to load it anyway UNLESS
1471 // the class is an STL container (or string).
1472 // This is because we do not expect the CINT dictionary
1473 // to be present for all STL classes (and we can handle
1474 // the lack of CINT dictionary in that cases).
1475 // However, the cling the dictionary no longer carries
1476 // an instantiation with it, unless we request the loading
1477 // here *or* the user explicitly instantiate the template
1478 // we would not have a ClassInfo for the template
1479 // instantiation.
1481 // Here we check and grab the info from the rootpcm.
1483 if (proto)
1484 proto->FillTClass(this);
1485 }
1486 ClassInfo_t *checkedInfo = nullptr;
1487 if (!fHasRootPcmInfo &&
1488 gInterpreter->CheckClassInfo(fName, /* autoload = */ kTRUE, /* isClassOrNamespaceOnly = */ kFALSE,
1489 /* classInfo = */ &checkedInfo)) {
1490 // Pass along the class info that CheckClassInfo may have found, so that
1491 // SetClassInfo (which takes its ownership) does not repeat the lookup.
1492 gInterpreter->SetClassInfo(this, kFALSE, silent, checkedInfo); // sets fClassInfo pointer
1493 if (fClassInfo) {
1494 // This should be moved out of GetCheckSum itself however the last time
1495 // we tried this cause problem, in particular in the end-of-process operation.
1496 // fCheckSum = GetCheckSum(kLatestCheckSum);
1497 } else {
1498 if (!fClassInfo) {
1499 if (IsZombie()) {
1500 TClass::RemoveClass(this);
1501 return;
1502 }
1503 }
1504 }
1505 }
1506 }
1507 if (!silent && (!fClassInfo && !fCanLoadClassInfo) && !isStl && !TClassEdit::IsArtificial(fName) &&
1509 if (fState == kHasTClassInit) {
1510 if (fImplFileLine == -1 && fClassVersion == 0) {
1511 // We have a 'transient' class with a ClassDefInline and apparently no interpreter
1512 // information. Since it is transient, it is more than likely that the lack
1513 // will be harmles.
1514 } else {
1515 ::Error("TClass::Init", "no interpreter information for class %s is available even though it has a TClass "
1516 "initialization routine.",
1517 fName.Data());
1518 }
1519 } else {
1520 const bool ispairbase = TClassEdit::IsStdPairBase(fName.Data()) && !IsFromRootCling();
1521 if (!ispairbase)
1522 ::Warning("TClass::Init", "no dictionary for class %s is available", fName.Data());
1523 }
1524 }
1525
1526 fgClassCount++;
1528
1529 // Make the typedef-expanded -> original hash table entries.
1530 // There may be several entries for any given key.
1531 // We only make entries if the typedef-expanded name
1532 // is different from the original name.
1533 TString resolvedThis;
1534 if (!givenInfo && strchr (name, '<')) {
1535 if ( fName != name) {
1536 if (!fgClassTypedefHash) {
1537 fgClassTypedefHash = new THashTable (100, 5);
1539 }
1540
1541 fgClassTypedefHash->Add (new TNameMapNode (name, fName));
1543
1544 }
1545 resolvedThis = TClassEdit::ResolveTypedef (name, kTRUE);
1546 if (resolvedThis != name) {
1547 if (!fgClassTypedefHash) {
1548 fgClassTypedefHash = new THashTable (100, 5);
1550 }
1551
1552 fgClassTypedefHash->Add (new TNameMapNode (resolvedThis, fName));
1554 }
1555
1556 }
1557
1558 //In case a class with the same name had been created by TVirtualStreamerInfo
1559 //we must delete the old class, importing only the StreamerInfo structure
1560 //from the old dummy class.
1561 if (oldcl) {
1562
1563 oldcl->ReplaceWith(this);
1564 delete oldcl;
1565
1566 } else if (!givenInfo && resolvedThis.Length() > 0 && fgClassTypedefHash) {
1567
1568 // Check for existing equivalent.
1569
1570 if (resolvedThis != fName) {
1571 oldcl = (TClass*)gROOT->GetListOfClasses()->FindObject(resolvedThis);
1572 if (oldcl && oldcl != this) {
1573 persistentRef = oldcl->fPersistentRef.exchange(nullptr);
1574 ForceReload (oldcl);
1575 }
1576 }
1577 TIter next( fgClassTypedefHash->GetListForObject(resolvedThis) );
1578 while ( TNameMapNode* htmp = static_cast<TNameMapNode*> (next()) ) {
1579 if (resolvedThis != htmp->String()) continue;
1580 oldcl = (TClass*)gROOT->GetListOfClasses()->FindObject(htmp->fOrigName); // gROOT->GetClass (htmp->fOrigName, kFALSE);
1581 if (oldcl && oldcl != this) {
1582 persistentRef = oldcl->fPersistentRef.exchange(nullptr);
1583 ForceReload (oldcl);
1584 }
1585 }
1586 }
1587 if (fClassInfo) {
1589 if ( fDeclFileName == nullptr || fDeclFileName[0] == '\0' ) {
1590 fDeclFileName = kUndeterminedClassInfoName;
1591 // Missing interface:
1592 // fDeclFileLine = gInterpreter->ClassInfo_FileLine( fClassInfo );
1593
1594 // But really do not want to set ImplFileLine as it is currently the
1595 // marker of being 'loaded' or not (reminder loaded == has a TClass bootstrap).
1596 }
1597 }
1598
1599 if (persistentRef) {
1600 fPersistentRef = persistentRef;
1601 } else {
1602 fPersistentRef = new TClass*;
1603 }
1604 *fPersistentRef = this;
1605
1606 if ( isStl || !strncmp(GetName(),"stdext::hash_",13) || !strncmp(GetName(),"__gnu_cxx::hash_",16) ) {
1607 if (fState != kHasTClassInit) {
1608 // If we have a TClass compiled initialization, we can safely assume that
1609 // there will also be a collection proxy.
1611 if (fCollectionProxy) {
1613
1614 // Numeric Collections have implicit conversions:
1616
1617 } else if (!silent) {
1618 Warning("Init","Collection proxy for %s was not properly initialized!",GetName());
1619 }
1620 if (fStreamer==nullptr) {
1622 }
1623 }
1624 } else if (TClassEdit::IsStdPair(GetName())) {
1625 // std::pairs have implicit conversions
1627 }
1629 auto &registry = GetReadRulesRegistry(ruletype);
1630 auto rulesiter = registry.find(GetName());
1631 if (rulesiter != registry.end()) {
1632 auto rset = GetSchemaRules(kTRUE);
1633 for (const auto &helper : rulesiter->second) {
1634 auto rule = new ROOT::TSchemaRule(ruletype, GetName(), helper);
1635 TString errmsg;
1636 if (!rset->AddRule(rule, ROOT::Detail::TSchemaRuleSet::kCheckAll, &errmsg)) {
1637 Warning(
1638 "Init",
1639 "The rule for class: \"%s\": version, \"%s\" and data members: \"%s\" has been skipped because %s.",
1640 GetName(), helper.fVersion.c_str(), helper.fTarget.c_str(), errmsg.Data());
1641 delete rule;
1642 }
1643 }
1644 }
1645 }
1646
1648}
1649
1650////////////////////////////////////////////////////////////////////////////////
1651/// TClass dtor. Deletes all list that might have been created.
1652
1654{
1656
1657 // Remove from the typedef hashtables.
1659 TString resolvedThis = TClassEdit::ResolveTypedef (GetName(), kTRUE);
1660 TIter next (fgClassTypedefHash->GetListForObject (resolvedThis));
1661 while ( TNameMapNode* htmp = static_cast<TNameMapNode*> (next()) ) {
1662 if (resolvedThis == htmp->String() && htmp->fOrigName == GetName()) {
1663 fgClassTypedefHash->Remove (htmp);
1664 delete htmp;
1665 break;
1666 }
1667 }
1668 }
1669
1670 // Not owning lists, don't call Delete()
1671 // But this still need to be done first because the TList destructor
1672 // does access the object contained (via GetObject()->TestBit(kCanDelete))
1673 delete fStreamer; fStreamer =nullptr;
1674 delete fAllPubData; fAllPubData =nullptr;
1675 delete fAllPubMethod; fAllPubMethod=nullptr;
1676
1677 delete fPersistentRef.load();
1678
1679 if (fBase.load())
1680 (*fBase).Delete();
1681 delete fBase.load(); fBase = nullptr;
1682
1683 if (fData.load())
1684 (*fData).Delete();
1685 delete fData.load(); fData = nullptr;
1686
1687 if (fUsingData.load())
1688 (*fUsingData).Delete();
1689 delete fUsingData.load(); fUsingData = nullptr;
1690
1691 if (fEnums.load())
1692 (*fEnums).Delete();
1693 delete fEnums.load(); fEnums = nullptr;
1694
1695 if (fFuncTemplate)
1697 delete fFuncTemplate; fFuncTemplate = nullptr;
1698
1699 if (fMethod.load())
1700 (*fMethod).Delete();
1701 delete fMethod.load(); fMethod=nullptr;
1702
1703 if (fRealData)
1704 fRealData->Delete();
1705 delete fRealData; fRealData=nullptr;
1706
1707 if (fStreamerInfo)
1709 delete fStreamerInfo; fStreamerInfo = nullptr;
1710
1711 if (fDeclFileLine >= -1)
1712 TClass::RemoveClass(this);
1713
1715 fClassInfo=nullptr;
1716
1717 if (fClassMenuList)
1719 delete fClassMenuList; fClassMenuList=nullptr;
1720
1722
1723 if ( fIsA ) delete fIsA;
1724
1725 if ( fRefProxy ) fRefProxy->Release();
1726 fRefProxy = nullptr;
1727
1728 delete fStreamer;
1729 delete fCollectionProxy;
1730 delete fIsAMethod.load();
1731 delete fSchemaRules;
1732 if (fConversionStreamerInfo.load()) {
1733 std::map<std::string, TObjArray*>::iterator it;
1734 std::map<std::string, TObjArray*>::iterator end = (*fConversionStreamerInfo).end();
1735 for( it = (*fConversionStreamerInfo).begin(); it != end; ++it ) {
1736 delete it->second;
1737 }
1738 delete fConversionStreamerInfo.load();
1739 }
1740}
1741
1742////////////////////////////////////////////////////////////////////////////////
1743
1744namespace {
1745 Int_t ReadRulesContent(FILE *f)
1746 {
1747 // Read a class.rules file which contains one rule per line with comment
1748 // starting with a #
1749 // Returns the number of rules loaded.
1750 // Returns -1 in case of error.
1751
1752 R__ASSERT(f!=nullptr);
1753 TString rule(1024);
1754 int c, state = 0;
1755 Int_t count = 0;
1756
1757 while ((c = fgetc(f)) != EOF) {
1758 if (c == 13) // ignore CR
1759 continue;
1760 if (c == '\n') {
1761 if (state != 3) {
1762 state = 0;
1763 if (rule.Length() > 0) {
1764 if (TClass::AddRule(rule)) {
1765 ++count;
1766 }
1767 rule.Clear();
1768 }
1769 }
1770 continue;
1771 }
1772 switch (state) {
1773 case 0: // start of line
1774 switch (c) {
1775 case ' ':
1776 case '\t':
1777 break;
1778 case '#':
1779 state = 1;
1780 break;
1781 default:
1782 state = 2;
1783 break;
1784 }
1785 break;
1786
1787 case 1: // comment
1788 break;
1789
1790 case 2: // rule
1791 switch (c) {
1792 case '\\':
1793 state = 3; // Continuation request
1794 default:
1795 break;
1796 }
1797 break;
1798 }
1799 switch (state) {
1800 case 2:
1801 rule.Append(c);
1802 break;
1803 }
1804 }
1805 return count;
1806 }
1807}
1808
1809////////////////////////////////////////////////////////////////////////////////
1810/// Read the class.rules files from the default location:.
1811/// $ROOTSYS/etc/class.rules (or ROOTETCDIR/class.rules)
1812
1814{
1815 static const char *suffix = "class.rules";
1816 TString sname = suffix;
1818
1819 Int_t res = -1;
1820
1821 FILE * f = fopen(sname,"r");
1822 if (f != nullptr) {
1823 res = ReadRulesContent(f);
1824 fclose(f);
1825 } else {
1826 ::Error("TClass::ReadRules()", "Cannot find rules file %s", sname.Data());
1827 }
1828 return res;
1829}
1830
1831////////////////////////////////////////////////////////////////////////////////
1832/// Read a class.rules file which contains one rule per line with comment
1833/// starting with a #
1834/// - Returns the number of rules loaded.
1835/// - Returns -1 in case of error.
1836
1838{
1839 if (!filename || !filename[0]) {
1840 ::Error("TClass::ReadRules", "no file name specified");
1841 return -1;
1842 }
1843
1844 FILE * f = fopen(filename,"r");
1845 if (f == nullptr) {
1846 ::Error("TClass::ReadRules","Failed to open %s\n",filename);
1847 return -1;
1848 }
1849 Int_t count = ReadRulesContent(f);
1850
1851 fclose(f);
1852 return count;
1853
1854}
1855
1856////////////////////////////////////////////////////////////////////////////////
1857/// Add a schema evolution customization rule.
1858/// The syntax of the rule can be either the short form:
1859/// ~~~ {.cpp}
1860/// [type=Read] classname membername [attributes=... ] [version=[...] ] [checksum=[...] ] [oldtype=...] [code={...}]
1861/// ~~~
1862/// or the long form
1863/// ~~~ {.cpp}
1864/// [type=Read] sourceClass=classname [targetclass=newClassname] [ source="type membername; [type2 membername2]" ]
1865/// [target="membername3;membername4"] [attributes=... ] [version=...] [checksum=...] [code={...}|functionname]
1866/// ~~~
1867///
1868/// For example to set HepMC::GenVertex::m_event to _not_ owned the object it is pointing to:
1869/// HepMC::GenVertex m_event attributes=NotOwner
1870///
1871/// Semantic of the tags:
1872/// - type : the type of the rule, valid values: Read, ReadRaw, Write, WriteRaw, the default is 'Read'.
1873/// - sourceClass : the name of the class as it is on the rule file
1874/// - targetClass : the name of the class as it is in the current code ; defaults to the value of sourceClass
1875/// - source : the types and names of the data members from the class on file that are needed, the list is separated by semi-colons ';'
1876/// - oldtype: in the short form only, indicates the type on disk of the data member.
1877/// - target : the names of the data members updated by this rule, the list is separated by semi-colons ';'
1878/// - attributes : list of possible qualifiers among: Owner, NotOwner
1879/// - version : list of the version of the class layout that this rule applies to. The syntax can be [1,4,5] or [2-] or [1-3] or [-3]
1880/// - checksum : comma delimited list of the checksums of the class layout that this rule applies to.
1881/// - code={...} : code to be executed for the rule or name of the function implementing it.
1882
1883Bool_t TClass::AddRule( const char *rule )
1884{
1885 ROOT::TSchemaRule *ruleobj = new ROOT::TSchemaRule();
1886 if (! ruleobj->SetFromRule( rule ) ) {
1887 delete ruleobj;
1888 return kFALSE;
1889 }
1890
1892
1893 TClass *cl = TClass::GetClass( ruleobj->GetTargetClass() );
1894 if (!cl) {
1895 // Create an empty emulated class for now.
1896 cl = gInterpreter->GenerateTClass(ruleobj->GetTargetClass(), /* emulation = */ kTRUE, /*silent = */ kTRUE);
1897 }
1899
1900 TString errmsg;
1901 if( !rset->AddRule( ruleobj, ROOT::Detail::TSchemaRuleSet::kCheckConflict, &errmsg ) ) {
1902 ::Warning( "TClass::AddRule", "The rule for class: \"%s\": version, \"%s\" and data members: \"%s\" has been skipped because it conflicts with one of the other rules (%s).",
1903 ruleobj->GetTargetClass(), ruleobj->GetVersion(), ruleobj->GetTargetString(), errmsg.Data() );
1904 delete ruleobj;
1905 return kFALSE;
1906 }
1907 return kTRUE;
1908}
1909
1910////////////////////////////////////////////////////////////////////////////////
1911/// Adopt a new set of Data Model Evolution rules.
1912
1914{
1916
1917 delete fSchemaRules;
1918 fSchemaRules = rules;
1919 fSchemaRules->SetClass( this );
1920}
1921
1922////////////////////////////////////////////////////////////////////////////////
1923/// Return the registry for the unassigned read rules.
1924
1926{
1928 static SchemaHelperMap_t gReadRulesRegistry;
1929 return gReadRulesRegistry;
1930 } else {
1931 static SchemaHelperMap_t gReadRawRulesRegistry;
1932 return gReadRawRulesRegistry;
1933 }
1934}
1935
1936////////////////////////////////////////////////////////////////////////////////
1937/// Return the set of the schema rules if any.
1938
1943
1944////////////////////////////////////////////////////////////////////////////////
1945/// Return the set of the schema rules if any.
1946/// If create is true, create an empty set
1947
1949{
1950 if (create && fSchemaRules == nullptr) {
1952 fSchemaRules->SetClass( this );
1953 }
1954 return fSchemaRules;
1955}
1956
1957////////////////////////////////////////////////////////////////////////////////
1958
1959void TClass::AddImplFile(const char* filename, int line) {
1960 // Currently reset the implementation file and line.
1961 // In the close future, it will actually add this file and line
1962 // to a "list" of implementation files.
1963
1966}
1967
1968////////////////////////////////////////////////////////////////////////////////
1969/// Browse external object inherited from TObject.
1970/// It passes through inheritance tree and calls TBrowser::Add
1971/// in appropriate cases. Static function.
1972
1974{
1975 if (!obj) return 0;
1976
1977 TAutoInspector insp(b);
1978 obj->ShowMembers(insp);
1979 return insp.fCount;
1980}
1981
1982////////////////////////////////////////////////////////////////////////////////
1983/// Browse objects of of the class described by this TClass object.
1984
1985Int_t TClass::Browse(void *obj, TBrowser *b) const
1986{
1987 if (!obj) return 0;
1988
1989 TClass *actual = GetActualClass(obj);
1990 if (IsTObject()) {
1991 // Call TObject::Browse.
1992
1993 if (!fIsOffsetStreamerSet) {
1995 }
1996 TObject* realTObject = (TObject*)((size_t)obj + fOffsetStreamer);
1997 realTObject->Browse(b);
1998 return 1;
1999 } else if (actual != this) {
2000 return actual->Browse(obj, b);
2001 } else if (GetCollectionProxy()) {
2002
2003 // do something useful.
2004
2005 } else {
2006 if (fBrowse) {
2007 fBrowse(obj, b);
2008 return 1;
2009 } else {
2010 TAutoInspector insp(b);
2011 CallShowMembers(obj,insp,kFALSE);
2012 return insp.fCount;
2013 }
2014 }
2015
2016 return 0;
2017}
2018
2019////////////////////////////////////////////////////////////////////////////////
2020/// This method is called by a browser to get the class information.
2021
2023{
2024 if (!HasInterpreterInfo()) return;
2025
2026 if (b) {
2027 if (!fRealData) BuildRealData();
2028
2029 b->Add(GetListOfDataMembers(), "Data Members");
2030 b->Add(GetListOfRealData(), "Real Data Members");
2031 b->Add(GetListOfMethods(), "Methods");
2032 b->Add(GetListOfBases(), "Base Classes");
2033 }
2034}
2035
2036////////////////////////////////////////////////////////////////////////////////
2037/// Build a full list of persistent data members.
2038/// Scans the list of all data members in the class itself and also
2039/// in all base classes. For each persistent data member, inserts a
2040/// TRealData object in the list fRealData.
2041///
2042
2043void TClass::BuildRealData(void* pointer, Bool_t isTransient)
2044{
2045
2047
2048 // Only do this once.
2049 if (fRealData) {
2050 return;
2051 }
2052
2053 if (fClassVersion == 0) {
2054 isTransient = kTRUE;
2055 }
2056
2057 // When called via TMapFile (e.g. Update()) make sure that the dictionary
2058 // gets allocated on the heap and not in the mapped file.
2059 TMmallocDescTemp setreset;
2060
2061 // Handle emulated classes and STL containers specially.
2063 // We are an emulated class or an STL container.
2064 fRealData = new TList;
2065 BuildEmulatedRealData("", 0, this, isTransient);
2066 return;
2067 }
2068
2069 // return early on string
2070 static TClassRef clRefString("std::string");
2071 if (clRefString == this) {
2072 return;
2073 }
2074
2075 // Complain about stl classes ending up here (unique_ptr etc) - except for
2076 // pair where we will build .first, .second just fine
2077 // and those for which the user explicitly requested a dictionary.
2078 if (!isTransient && GetState() != kHasTClassInit
2081 Error("BuildRealData", "Inspection for %s not supported!", GetName());
2082 }
2083
2084 // The following statement will recursively call
2085 // all the subclasses of this class.
2086 fRealData = new TList;
2087 TBuildRealData brd(pointer, this);
2088
2089 // CallShowMember will force a call to InheritsFrom, which indirectly
2090 // calls TClass::GetClass. It forces the loading of new typedefs in
2091 // case some of them were not yet loaded.
2092 if ( ! CallShowMembers(pointer, brd, isTransient) ) {
2093 if ( isTransient ) {
2094 // This is a transient data member, so it is probably fine to not have
2095 // access to its content. However let's no mark it as definitively setup,
2096 // since another class might use this class for a persistent data member and
2097 // in this case we really want the error message.
2098 delete fRealData;
2099 fRealData = nullptr;
2100 } else {
2101 Error("BuildRealData", "Cannot find any ShowMembers function for %s!", GetName());
2102 }
2103 }
2104
2105 // Take this opportunity to build the real data for base classes.
2106 // In case one base class is abstract, it would not be possible later
2107 // to create the list of real data for this abstract class.
2108 TBaseClass* base = nullptr;
2109 TIter next(GetListOfBases());
2110 while ((base = (TBaseClass*) next())) {
2111 if (base->IsSTLContainer()) {
2112 continue;
2113 }
2114 TClass* c = base->GetClassPointer();
2115 if (c) {
2116 c->BuildRealData(nullptr, isTransient);
2117 }
2118 }
2119}
2120
2121////////////////////////////////////////////////////////////////////////////////
2122/// Build the list of real data for an emulated class
2123
2125{
2127
2129 if (Property() & kIsAbstract) {
2131 } else {
2132 info = GetStreamerInfoImpl(fClassVersion, isTransient);
2133 }
2134 if (!info) {
2135 // This class is abstract, but we don't yet have a SteamerInfo for it ...
2136 Error("BuildEmulatedRealData","Missing StreamerInfo for %s",GetName());
2137 // Humm .. no information ... let's bail out
2138 return;
2139 }
2140
2141 TIter next(info->GetElements());
2142 TStreamerElement *element;
2143 while ((element = (TStreamerElement*)next())) {
2144 Int_t etype = element->GetType();
2145 Longptr_t eoffset = element->GetOffset();
2146 TClass *cle = element->GetClassPointer();
2147 if (element->IsBase() || etype == TVirtualStreamerInfo::kBase) {
2148 //base class are skipped in this loop, they will be added at the end.
2149 continue;
2150 } else if (etype == TVirtualStreamerInfo::kTObject ||
2153 etype == TVirtualStreamerInfo::kAny) {
2154 //member class
2155 TString rdname; rdname.Form("%s%s",name,element->GetFullName());
2156 TRealData *rd = new TRealData(rdname,offset+eoffset,nullptr);
2157 if (gDebug > 0) printf(" Class: %s, adding TRealData=%s, offset=%ld\n",cl->GetName(),rd->GetName(),rd->GetThisOffset());
2158 cl->GetListOfRealData()->Add(rd);
2159 // Now we a dot
2160 rdname.Form("%s%s.",name,element->GetFullName());
2161 if (cle) cle->BuildEmulatedRealData(rdname,offset+eoffset,cl, isTransient);
2162 } else {
2163 //others
2164 TString rdname; rdname.Form("%s%s",name,element->GetFullName());
2165 TRealData *rd = new TRealData(rdname,offset+eoffset,nullptr);
2166 if (gDebug > 0) printf(" Class: %s, adding TRealData=%s, offset=%ld\n",cl->GetName(),rd->GetName(),rd->GetThisOffset());
2167 cl->GetListOfRealData()->Add(rd);
2168 }
2169 //if (fClassInfo==0 && element->IsBase()) {
2170 // if (fBase==0) fBase = new TList;
2171 // TClass *base = element->GetClassPointer();
2172 // fBase->Add(new TBaseClass(this, cl, eoffset));
2173 //}
2174 }
2175 // The base classes must added last on the list of real data (to help with ambiguous data member names)
2176 next.Reset();
2177 while ((element = (TStreamerElement*)next())) {
2178 Int_t etype = element->GetType();
2179 if (element->IsBase() || etype == TVirtualStreamerInfo::kBase) {
2180 //base class
2181 Longptr_t eoffset = element->GetOffset();
2182 TClass *cle = element->GetClassPointer();
2183 if (cle) cle->BuildEmulatedRealData(name,offset+eoffset,cl, isTransient);
2184 }
2185 }
2186}
2187
2188
2189////////////////////////////////////////////////////////////////////////////////
2190/// Calculate the offset between an object of this class to
2191/// its base class TObject. The pointer can be adjusted by
2192/// that offset to access any virtual method of TObject like
2193/// Streamer() and ShowMembers().
2194
2196{
2199 // When called via TMapFile (e.g. Update()) make sure that the dictionary
2200 // gets allocated on the heap and not in the mapped file.
2201
2202 TMmallocDescTemp setreset;
2204 if (fStreamerType == kTObject) {
2206 }
2208 }
2209}
2210
2211
2212////////////////////////////////////////////////////////////////////////////////
2213/// Call ShowMembers() on the obj of this class type, passing insp and parent.
2214/// isATObject is -1 if unknown, 0 if it is not a TObject, and 1 if it is a TObject.
2215/// The function returns whether it was able to call ShowMembers().
2216
2217Bool_t TClass::CallShowMembers(const void* obj, TMemberInspector &insp, Bool_t isTransient) const
2218{
2219 if (fShowMembers) {
2220 // This should always works since 'pointer' should be pointing
2221 // to an object of the actual type of this TClass object.
2222 fShowMembers(obj, insp, isTransient);
2223 return kTRUE;
2224 } else {
2225
2227 if (fClassInfo) {
2228
2229 if (strcmp(GetName(), "string") == 0) {
2230 // For std::string we know that we do not have a ShowMembers
2231 // function and that it's okay.
2232 return kTRUE;
2233 }
2234 // Since we do have some dictionary information, let's
2235 // call the interpreter's ShowMember.
2236 // This works with Cling to support interpreted classes.
2237 gInterpreter->InspectMembers(insp, obj, this, isTransient);
2238 return kTRUE;
2239
2240 } else if (TVirtualStreamerInfo* sinfo = GetStreamerInfo()) {
2241 sinfo->CallShowMembers(obj, insp, isTransient);
2242 return kTRUE;
2243 } // isATObject
2244 } // fShowMembers is set
2245
2246 return kFALSE;
2247}
2248
2249////////////////////////////////////////////////////////////////////////////////
2250/// Do a ShowMembers() traversal of all members and base classes' members
2251/// using the reflection information from the interpreter. Works also for
2252/// interpreted objects.
2253
2254void TClass::InterpretedShowMembers(void* obj, TMemberInspector &insp, Bool_t isTransient)
2255{
2256 return gInterpreter->InspectMembers(insp, obj, this, isTransient);
2257}
2258
2260{
2261 if (fCanSplit >= 0) {
2262 return ! ( fCanSplit & 0x2 );
2263 }
2264
2266
2267 if (GetCollectionProxy() != nullptr) {
2268 // A collection can never affect its derived class 'splittability'
2269 return kTRUE;
2270 }
2271
2272 if (this == TRef::Class()) { fCanSplit = 2; return kFALSE; }
2273 if (this == TRefArray::Class()) { fCanSplit = 2; return kFALSE; }
2274 if (this == TArray::Class()) { fCanSplit = 2; return kFALSE; }
2275 if (this == TClonesArray::Class()) { fCanSplit = 1; return kTRUE; }
2276 if (this == TCollection::Class()) { fCanSplit = 2; return kFALSE; }
2277
2278 // TTree is not always available (for example in rootcling), so we need
2279 // to grab it silently.
2280 auto refTreeClass( TClass::GetClass("TTree",kTRUE,kTRUE) );
2281 if (this == refTreeClass) { fCanSplit = 2; return kFALSE; }
2282
2283 if (!HasDataMemberInfo()) {
2284 TVirtualStreamerInfo *sinfo = ((TClass *)this)->GetCurrentStreamerInfo();
2285 if (sinfo==nullptr) sinfo = GetStreamerInfo();
2286 TIter next(sinfo->GetElements());
2287 TStreamerElement *element;
2288 while ((element = (TStreamerElement*)next())) {
2289 if (element->IsA() == TStreamerBase::Class()) {
2290 TClass *clbase = element->GetClassPointer();
2291 if (!clbase) {
2292 // If there is a missing base class, we can't split the immediate
2293 // derived class.
2294 fCanSplit = 0;
2295 return kFALSE;
2296 } else if (!clbase->CanSplitBaseAllow()) {
2297 fCanSplit = 2;
2298 return kFALSE;
2299 }
2300 }
2301 }
2302 }
2303
2304 // If we don't have data member info there is no more information
2305 // we can find out.
2306 if (!HasDataMemberInfo()) return kTRUE;
2307
2308 TObjLink *lnk = GetListOfBases() ? fBase.load()->FirstLink() : nullptr;
2309
2310 // Look at inheritance tree
2311 while (lnk) {
2312 TBaseClass *base = (TBaseClass*) lnk->GetObject();
2313 TClass *c = base->GetClassPointer();
2314 if(!c) {
2315 // If there is a missing base class, we can't split the immediate
2316 // derived class.
2317 fCanSplit = 0;
2318 return kFALSE;
2319 } else if (!c->CanSplitBaseAllow()) {
2320 fCanSplit = 2;
2321 return kFALSE;
2322 }
2323 lnk = lnk->Next();
2324 }
2325 return kTRUE;
2326}
2327
2328////////////////////////////////////////////////////////////////////////////////
2329/// Return true if the data member of this TClass can be saved separately.
2330
2332{
2333 // Note: add the possibility to set it for the class and the derived class.
2334 // save the info in TVirtualStreamerInfo
2335 // deal with the info in MakeProject
2336 if (fCanSplit >= 0) {
2337 // The user explicitly set the value
2338 return (fCanSplit & 0x1) == 1;
2339 }
2340
2342 TClass *This = const_cast<TClass*>(this);
2343
2344 if (this == TObject::Class()) { This->fCanSplit = 1; return kTRUE; }
2345 if (fName == "TClonesArray") { This->fCanSplit = 1; return kTRUE; }
2346 if (fRefProxy) { This->fCanSplit = 0; return kFALSE; }
2347 if (fName.BeginsWith("TVectorT<")) { This->fCanSplit = 0; return kFALSE; }
2348 if (fName.BeginsWith("TMatrixT<")) { This->fCanSplit = 0; return kFALSE; }
2349 if (fName == "string") { This->fCanSplit = 0; return kFALSE; }
2350 if (fName == "std::string") { This->fCanSplit = 0; return kFALSE; }
2351
2352 if (GetCollectionProxy()!=nullptr) {
2353 // For STL collection we need to look inside.
2354
2355 // However we do not split collections of collections
2356 // nor collections of strings
2357 // nor collections of pointers (unless explicit request (see TBranchSTL)).
2358
2359 if (GetCollectionProxy()->HasPointers()) { This->fCanSplit = 0; return kFALSE; }
2360
2361 TClass *valueClass = GetCollectionProxy()->GetValueClass();
2362 if (valueClass == nullptr) { This->fCanSplit = 0; return kFALSE; }
2363 static TClassRef stdStringClass("std::string");
2364 if (valueClass==TString::Class() || valueClass==stdStringClass)
2365 { This->fCanSplit = 0; return kFALSE; }
2366 if (!valueClass->CanSplit()) { This->fCanSplit = 0; return kFALSE; }
2367 if (valueClass->GetCollectionProxy() != nullptr) { This->fCanSplit = 0; return kFALSE; }
2368
2369 This->fCanSplit = 1;
2370 return kTRUE;
2371
2372 }
2373
2374 if (GetStreamer() != nullptr || fStreamerFunc != nullptr) {
2375
2376 // We have an external custom streamer provided by the user, we must not
2377 // split it.
2378 This->fCanSplit = 0;
2379 return kFALSE;
2380
2381 } else if ( fHasCustomStreamerMember ) {
2382
2383 // We have a custom member function streamer or
2384 // an older (not StreamerInfo based) automatic streamer.
2385 This->fCanSplit = 0;
2386 return kFALSE;
2387 }
2388
2389 if (Size()==1) {
2390 // 'Empty' class there is nothing to split!.
2391 This->fCanSplit = 0;
2392 return kFALSE;
2393 }
2394
2395
2396 if ( !This->CanSplitBaseAllow() ) {
2397 return kFALSE;
2398 }
2399
2400 This->fCanSplit = 1;
2401 return kTRUE;
2402}
2403
2404////////////////////////////////////////////////////////////////////////////////
2405/// Return the C++ property of this class, eg. is abstract, has virtual base
2406/// class, see EClassProperty in TDictionary.h
2407
2409{
2410 if (fProperty == -1) Property();
2411 return fClassProperty;
2412}
2413
2414////////////////////////////////////////////////////////////////////////////////
2415/// Create a Clone of this TClass object using a different name but using the same 'dictionary'.
2416/// This effectively creates a hard alias for the class name.
2417
2418TObject *TClass::Clone(const char *new_name) const
2419{
2420 if (new_name == nullptr || new_name[0]=='\0' || fName == new_name) {
2421 Error("Clone","The name of the class must be changed when cloning a TClass object.");
2422 return nullptr;
2423 }
2424
2425 // Need to lock access to TROOT::GetListOfClasses so the cloning happens atomically
2427 // Temporarily remove the original from the list of classes.
2428 TClass::RemoveClass(const_cast<TClass*>(this));
2429
2430 TClass *copy;
2431 if (fTypeInfo) {
2432 copy = new TClass(GetName(),
2434 *fTypeInfo,
2435 new TIsAProxy(*fTypeInfo),
2439 GetImplFileLine());
2440 } else {
2441 copy = new TClass(GetName(),
2446 GetImplFileLine());
2447 }
2448 copy->fShowMembers = fShowMembers;
2449 // Remove the copy before renaming it
2450 TClass::RemoveClass(copy);
2451 copy->fName = new_name;
2452 TClass::AddClass(copy);
2453
2454 copy->SetNew(fNew);
2455 copy->SetNewArray(fNewArray);
2456 copy->SetDelete(fDelete);
2462 if (fStreamer) {
2464 }
2465 // If IsZombie is true, something went wrong and we will not be
2466 // able to properly copy the collection proxy
2467 if (fCollectionProxy && !copy->IsZombie()) {
2469 }
2470 copy->SetClassSize(fSizeof);
2471 if (fRefProxy) {
2473 }
2474 TClass::AddClass(const_cast<TClass*>(this));
2475 return copy;
2476}
2477
2478////////////////////////////////////////////////////////////////////////////////
2479/// Replaces the collection proxy for this class. The provided object is cloned
2480/// and the copy is then owned by `TClass`.
2481
2483{
2484// // This code was used too quickly test the STL Emulation layer
2485// Int_t k = TClassEdit::IsSTLCont(GetName());
2486// if (k==1||k==-1) return;
2487
2488 delete fCollectionProxy;
2489 fCollectionProxy = orig.Generate();
2490}
2491
2492////////////////////////////////////////////////////////////////////////////////
2493/// Draw detailed class inheritance structure.
2494/// If a class B inherits from a class A, the description of B is drawn
2495/// on the right side of the description of A.
2496/// Member functions overridden by B are shown in class A with a blue line
2497/// erasing the corresponding member function
2498
2500{
2501 if (!HasInterpreterInfo()) return;
2502
2504
2505 // Should we create a new canvas?
2506 TString opt = option;
2507 if (!ctxt.GetSaved() || !opt.Contains("same")) {
2508 TVirtualPad *padclass = (TVirtualPad*)(gROOT->GetListOfCanvases())->FindObject("R__class");
2509 if (!padclass) {
2510 gROOT->ProcessLine("new TCanvas(\"R__class\",\"class\",20,20,1000,750);");
2511 } else {
2512 padclass->cd();
2513 }
2514 }
2515
2516 if (gPad)
2518}
2519
2520////////////////////////////////////////////////////////////////////////////////
2521/// Dump contents of object on stdout.
2522/// Using the information in the object dictionary
2523/// each data member is interpreted.
2524/// If a data member is a pointer, the pointer value is printed
2525/// 'obj' is assume to point to an object of the class describe by this TClass
2526///
2527/// The following output is the Dump of a TArrow object:
2528/// ~~~ {.cpp}
2529/// fAngle 0 Arrow opening angle (degrees)
2530/// fArrowSize 0.2 Arrow Size
2531/// fOption.*fData
2532/// fX1 0.1 X of 1st point
2533/// fY1 0.15 Y of 1st point
2534/// fX2 0.67 X of 2nd point
2535/// fY2 0.83 Y of 2nd point
2536/// fUniqueID 0 object unique identifier
2537/// fBits 50331648 bit field status word
2538/// fLineColor 1 line color
2539/// fLineStyle 1 line style
2540/// fLineWidth 1 line width
2541/// fFillColor 19 fill area color
2542/// fFillStyle 1001 fill area style
2543/// ~~~
2544///
2545/// If noAddr is true, printout of all pointer values is skipped.
2546
2547void TClass::Dump(const void *obj, Bool_t noAddr /*=kFALSE*/) const
2548{
2549
2550 Longptr_t prObj = noAddr ? 0 : (Longptr_t)obj;
2551 if (IsTObject()) {
2552 if (!fIsOffsetStreamerSet) {
2554 }
2555 TObject *tobj = (TObject*)((Longptr_t)obj + fOffsetStreamer);
2556
2557
2558 if (sizeof(this) == 4)
2559 Printf("==> Dumping object at: 0x%08lx, name=%s, class=%s\n",prObj,tobj->GetName(),GetName());
2560 else
2561 Printf("==> Dumping object at: 0x%016lx, name=%s, class=%s\n",prObj,tobj->GetName(),GetName());
2562 } else {
2563
2564 if (sizeof(this) == 4)
2565 Printf("==> Dumping object at: 0x%08lx, class=%s\n",prObj,GetName());
2566 else
2567 Printf("==> Dumping object at: 0x%016lx, class=%s\n",prObj,GetName());
2568 }
2569
2570 TDumpMembers dm(noAddr);
2571 if (!CallShowMembers(obj, dm, kFALSE)) {
2572 Info("Dump", "No ShowMembers function, dumping disabled");
2573 }
2574}
2575
2576////////////////////////////////////////////////////////////////////////////////
2577/// Introduce an escape character (@) in front of a special chars.
2578/// You need to use the result immediately before it is being overwritten.
2579
2580char *TClass::EscapeChars(const char *text) const
2581{
2582 static const UInt_t maxsize = 255;
2583 static char name[maxsize+2]; //One extra if last char needs to be escaped
2584
2585 UInt_t nch = text ? strlen(text) : 0;
2586 UInt_t icur = 0;
2587 for (UInt_t i = 0; i < nch && icur < maxsize; ++i, ++icur) {
2588 if (text[i] == '\"' || text[i] == '[' || text[i] == '~' ||
2589 text[i] == ']' || text[i] == '&' || text[i] == '#' ||
2590 text[i] == '!' || text[i] == '^' || text[i] == '<' ||
2591 text[i] == '?' || text[i] == '>') {
2592 name[icur] = '@';
2593 ++icur;
2594 }
2595 name[icur] = text[i];
2596 }
2597 name[icur] = 0;
2598 return name;
2599}
2600
2601////////////////////////////////////////////////////////////////////////////////
2602/// Return a pointer to the real class of the object.
2603/// This is equivalent to object->IsA() when the class has a ClassDef.
2604/// It is REQUIRED that object is coming from a proper pointer to the
2605/// class represented by 'this'.
2606/// Example: Special case:
2607/// ~~~ {.cpp}
2608/// class MyClass : public AnotherClass, public TObject
2609/// ~~~
2610/// then on return, one must do:
2611/// ~~~ {.cpp}
2612/// TObject *obj = (TObject*)((void*)myobject)directory->Get("some object of MyClass");
2613/// MyClass::Class()->GetActualClass(obj); // this would be wrong!!!
2614/// ~~~
2615/// Also if the class represented by 'this' and NONE of its parents classes
2616/// have a virtual ptr table, the result will be 'this' and NOT the actual
2617/// class.
2618
2619TClass *TClass::GetActualClass(const void *object) const
2620{
2621 if (!object)
2622 return (TClass*)this;
2623 if (fIsA) {
2624 return (*fIsA)(object); // ROOT::IsA((ThisClass*)object);
2625 } else if (fGlobalIsA) {
2626 return fGlobalIsA(this,object);
2627 } else {
2628 if (IsTObject()) {
2629
2630 if (!fIsOffsetStreamerSet) {
2632 }
2633 TObject* realTObject = (TObject*)((size_t)object + fOffsetStreamer);
2634
2635 return realTObject->IsA();
2636 }
2637
2638 if (HasInterpreterInfo()) {
2639
2640 TVirtualIsAProxy *isa = nullptr;
2642 isa = (TVirtualIsAProxy*)gROOT->ProcessLineFast(TString::Format("new ::TInstrumentedIsAProxy<%s>(0);",GetName()));
2643 }
2644 else {
2645 isa = (TVirtualIsAProxy*)gROOT->ProcessLineFast(TString::Format("new ::TIsAProxy(typeid(%s));",GetName()));
2646 }
2647 if (isa) {
2649 const_cast<TClass*>(this)->fIsA = isa;
2650 }
2651 if (fIsA) {
2652 return (*fIsA)(object); // ROOT::IsA((ThisClass*)object);
2653 }
2654 }
2656 if (sinfo) {
2657 return sinfo->GetActualClass(object);
2658 }
2659 return (TClass*)this;
2660 }
2661}
2662
2663////////////////////////////////////////////////////////////////////////////////
2664/// Return pointer to the base class "classname". Returns 0 in case
2665/// "classname" is not a base class. Takes care of multiple inheritance.
2666
2667TClass *TClass::GetBaseClass(const char *classname)
2668{
2669 // check if class name itself is equal to classname
2670 if (strcmp(GetName(), classname) == 0) return this;
2671
2672 if (!HasDataMemberInfo()) return nullptr;
2673
2674 // Make sure we deal with possible aliases, we could also have normalized
2675 // the name.
2676 TClass *search = TClass::GetClass(classname,kTRUE,kTRUE);
2677
2678 if (search) return GetBaseClass(search);
2679 else return nullptr;
2680}
2681
2682////////////////////////////////////////////////////////////////////////////////
2683/// Return pointer to the base class "cl". Returns 0 in case "cl"
2684/// is not a base class. Takes care of multiple inheritance.
2685
2687{
2688 // check if class name itself is equal to classname
2689 if (cl == this) return this;
2690
2691 if (!HasDataMemberInfo()) return nullptr;
2692
2693 TObjLink *lnk = GetListOfBases() ? fBase.load()->FirstLink() : nullptr;
2694
2695 // otherwise look at inheritance tree
2696 while (lnk) {
2697 TClass *c, *c1;
2698 TBaseClass *base = (TBaseClass*) lnk->GetObject();
2699 c = base->GetClassPointer();
2700 if (c) {
2701 if (cl == c) return c;
2702 c1 = c->GetBaseClass(cl);
2703 if (c1) return c1;
2704 }
2705 lnk = lnk->Next();
2706 }
2707 return nullptr;
2708}
2709
2710////////////////////////////////////////////////////////////////////////////////
2711/// Return data member offset to the base class "cl".
2712/// - Returns -1 in case "cl" is not a base class.
2713/// - Returns -2 if cl is a base class, but we can't find the offset
2714/// because it's virtual.
2715/// Takes care of multiple inheritance.
2716
2718{
2719 // check if class name itself is equal to classname
2720 if (cl == this) return 0;
2721
2722 if (!fBase.load()) {
2724 // If the information was not provided by the root pcm files and
2725 // if we can not find the ClassInfo, we have to fall back to the
2726 // StreamerInfo
2727 if (!fClassInfo) {
2729 if (!sinfo) return -1;
2730 TStreamerElement *element;
2731 Int_t offset = 0;
2732
2733 TObjArray &elems = *(sinfo->GetElements());
2734 Int_t size = elems.GetLast()+1;
2735 for(Int_t i=0; i<size; i++) {
2736 element = (TStreamerElement*)elems[i];
2737 if (element->IsBase()) {
2738 if (element->IsA() == TStreamerBase::Class()) {
2739 TStreamerBase *base = (TStreamerBase*)element;
2740 TClass *baseclass = base->GetClassPointer();
2741 if (!baseclass) return -1;
2742 Int_t subOffset = baseclass->GetBaseClassOffsetRecurse(cl);
2743 if (subOffset == -2) return -2;
2744 auto align = baseclass->GetClassAlignment();
2746 offset = ROOT::Internal::AlignUp((size_t)offset, align);
2747 } else {
2748 Error("GetBaseClassOffsetRecurse", "Can not determine alignment for base class %s (got %zu)\n",
2749 baseclass->GetName(), align);
2750 }
2751 if (subOffset != -1) return offset+subOffset;
2752 offset += baseclass->Size();
2753 } else if (element->IsA() == TStreamerSTL::Class()) {
2754 TStreamerSTL *base = (TStreamerSTL*)element;
2755 TClass *baseclass = base->GetClassPointer();
2756 if (!baseclass) return -1;
2757 Int_t subOffset = baseclass->GetBaseClassOffsetRecurse(cl);
2758 if (subOffset == -2) return -2;
2759 auto align = baseclass->GetClassAlignment();
2761 offset = ROOT::Internal::AlignUp((size_t)offset, align);
2762 } else {
2763 Error("GetBaseClassOffsetRecurse", "Can not determine alignment for base class %s (got %zu)\n",
2764 baseclass->GetName(), align);
2765 }
2766 if (subOffset != -1) return offset+subOffset;
2767 offset += baseclass->Size();
2768
2769 } else {
2770 Error("GetBaseClassOffsetRecurse","Unexpected element type for base class: %s\n",element->IsA()->GetName());
2771 }
2772 }
2773 }
2774 return -1;
2775 }
2776 }
2777
2778 TClass *c;
2779 Int_t off;
2780 TBaseClass *inh;
2781 TObjLink *lnk = nullptr;
2782 if (fBase.load() == nullptr)
2783 lnk = GetListOfBases()->FirstLink();
2784 else
2785 lnk = fBase.load()->FirstLink();
2786
2787 // otherwise look at inheritance tree
2788 while (lnk) {
2789 inh = (TBaseClass *)lnk->GetObject();
2790 //use option load=kFALSE to avoid a warning like:
2791 //"Warning in <TClass::TClass>: no dictionary for class TRefCnt is available"
2792 //We can not afford to not have the class if it exist, so we
2793 //use kTRUE.
2794 c = inh->GetClassPointer(kTRUE); // kFALSE);
2795 if (c) {
2796 if (cl == c) {
2797 if ((inh->Property() & kIsVirtualBase) != 0)
2798 return -2;
2799 return inh->GetDelta();
2800 }
2801 off = c->GetBaseClassOffsetRecurse(cl);
2802 if (off == -2) return -2;
2803 if (off != -1) {
2804 return off + inh->GetDelta();
2805 }
2806 }
2807 lnk = lnk->Next();
2808 }
2809 return -1;
2810}
2811
2812////////////////////////////////////////////////////////////////////////////////
2813/// - Return data member offset to the base class "cl".
2814/// - Returns -1 in case "cl" is not a base class.
2815/// Takes care of multiple inheritance.
2816
2817Int_t TClass::GetBaseClassOffset(const TClass *toBase, void *address, bool isDerivedObject)
2818{
2819 // Warning("GetBaseClassOffset","Requires the use of fClassInfo for %s to %s",GetName(),toBase->GetName());
2820
2821 if (this == toBase) return 0;
2822
2823 if ((!address /* || !has_virtual_base */) &&
2825 // At least of the ClassInfo have not been loaded in memory yet and
2826 // since there is no virtual base class (or we don't have enough so it
2827 // would not make a difference) we can use the 'static' information
2829 if (offset != -2) {
2830 return offset;
2831 }
2832 return offset;
2833 }
2834
2835 ClassInfo_t* derived = GetClassInfo();
2836 ClassInfo_t* base = toBase->GetClassInfo();
2837 if(derived && base) {
2838 // TClingClassInfo::GetBaseOffset takes the lock.
2839 return gCling->ClassInfo_GetBaseOffset(derived, base, address, isDerivedObject);
2840 }
2841 else {
2843 if (offset != -2) {
2844 return offset;
2845 }
2846 }
2847 return -1;
2848}
2849
2850////////////////////////////////////////////////////////////////////////////////
2851/// Return pointer to (base) class that contains datamember.
2852
2853TClass *TClass::GetBaseDataMember(const char *datamember)
2854{
2855 if (!HasDataMemberInfo()) return nullptr;
2856
2857 // Check if data member exists in class itself
2858 TDataMember *dm = GetDataMember(datamember);
2859 if (dm) return this;
2860
2861 // if datamember not found in class, search in next base classes
2862 TBaseClass *inh;
2863 TIter next(GetListOfBases());
2864 while ((inh = (TBaseClass *) next())) {
2865 TClass *c = inh->GetClassPointer();
2866 if (c) {
2867 TClass *cdm = c->GetBaseDataMember(datamember);
2868 if (cdm) return cdm;
2869 }
2870 }
2871
2872 return nullptr;
2873}
2874
2875namespace {
2876 // A local Helper class used to keep 2 pointer (the collection proxy
2877 // and the class streamer) in the thread local storage.
2878
2879 struct TClassLocalStorage {
2880 TClassLocalStorage() : fCollectionProxy(nullptr), fStreamer(nullptr) {};
2881
2882 TVirtualCollectionProxy *fCollectionProxy;
2883 TClassStreamer *fStreamer;
2884
2885 static TClassLocalStorage *GetStorage(const TClass *cl)
2886 {
2887 // Return the thread storage for the TClass.
2888
2889 void **thread_ptr = (*gThreadTsd)(nullptr,ROOT::kClassThreadSlot);
2890 if (thread_ptr) {
2891 if (*thread_ptr==nullptr) *thread_ptr = new TExMap();
2892 TExMap *lmap = (TExMap*)(*thread_ptr);
2893 ULong_t hash = TString::Hash(&cl, sizeof(void*));
2894 ULongptr_t local = 0;
2895 UInt_t slot;
2896 if ((local = (ULongptr_t)lmap->GetValue(hash, (Longptr_t)cl, slot)) != 0) {
2897 } else {
2898 local = (ULongptr_t) new TClassLocalStorage();
2899 lmap->AddAt(slot, hash, (Longptr_t)cl, local);
2900 }
2901 return (TClassLocalStorage*)local;
2902 }
2903 return nullptr;
2904 }
2905 };
2906}
2907
2908////////////////////////////////////////////////////////////////////////////////
2909/// Return the 'type' of the STL the TClass is representing.
2910/// and return ROOT::kNotSTL if it is not representing an STL collection.
2911
2913{
2914 auto proxy = GetCollectionProxy();
2915 if (proxy) return (ROOT::ESTLType)proxy->GetCollectionType();
2916 return ROOT::kNotSTL;
2917}
2918
2919
2920////////////////////////////////////////////////////////////////////////////////
2921/// Return the proxy describing the collection (if any).
2922
2924{
2925 // Use assert, so that this line (slow because of the TClassEdit) is completely
2926 // removed in optimized code.
2927 //assert(TestBit(kLoading) || !TClassEdit::IsSTLCont(fName) || fCollectionProxy || 0 == "The TClass for the STL collection has no collection proxy!");
2929 TClassLocalStorage *local = TClassLocalStorage::GetStorage(this);
2930 if (local == nullptr) return fCollectionProxy;
2931 if (local->fCollectionProxy==nullptr) local->fCollectionProxy = fCollectionProxy->Generate();
2932 return local->fCollectionProxy;
2933 }
2934 return fCollectionProxy;
2935}
2936
2937////////////////////////////////////////////////////////////////////////////////
2938/// Return the Streamer Class allowing streaming (if any).
2939
2941{
2942 if (gThreadTsd && fStreamer) {
2943 TClassLocalStorage *local = TClassLocalStorage::GetStorage(this);
2944 if (local==nullptr) return fStreamer;
2945 if (local->fStreamer==nullptr) {
2946 local->fStreamer = fStreamer->Generate();
2947 const std::type_info &orig = ( typeid(*fStreamer) );
2948 if (!local->fStreamer) {
2949 Warning("GetStreamer","For %s, the TClassStreamer (%s) passed's call to Generate failed!",GetName(),orig.name());
2950 } else {
2951 const std::type_info &copy = ( typeid(*local->fStreamer) );
2952 if (strcmp(orig.name(),copy.name())!=0) {
2953 Warning("GetStreamer","For %s, the TClassStreamer passed does not properly implement the Generate method (%s vs %s)\n",GetName(),orig.name(),copy.name());
2954 }
2955 }
2956 }
2957 return local->fStreamer;
2958 }
2959 return fStreamer;
2960}
2961
2962////////////////////////////////////////////////////////////////////////////////
2963/// Get a wrapper/accessor function around this class custom streamer (member function).
2964
2969
2970////////////////////////////////////////////////////////////////////////////////
2971/// Get a wrapper/accessor function around this class custom conversion streamer (member function).
2972
2977
2978////////////////////////////////////////////////////////////////////////////////
2979/// Return the proxy implementing the IsA functionality.
2980
2982{
2983 return fIsA;
2984}
2985
2986////////////////////////////////////////////////////////////////////////////////
2987/// Static method returning pointer to TClass of the specified class name.
2988/// If load is true, an attempt is made to obtain the class by loading
2989/// the appropriate shared library (directed by the rootmap file).
2990/// If silent is 'true', do not warn about missing dictionary for the class.
2991/// (typically used for classes that are used only for transient members)
2992/// Returns `nullptr` in case class is not found.
2993///
2994/// To completely disallow auto-parsing during TClass::GetClass, you can either
2995/// set the shell environment variable `ROOT_DISABLE_TCLASS_GET_CLASS_AUTOPARSING`
2996/// (to anything) or set the `rootrc` key `Root.TClass.GetClass.AutoParsing` to
2997/// `false`.
2998
2999TClass *TClass::GetClass(const char *name, Bool_t load, Bool_t silent)
3000{
3001 return TClass::GetClass(name, load, silent, 0, 0);
3002}
3003
3004TClass *TClass::GetClass(const char *name, Bool_t load, Bool_t silent, size_t hint_pair_offset, size_t hint_pair_size)
3005{
3006 if (!name || !name[0]) return nullptr;
3007
3008 if (strstr(name, "(anonymous)")) return nullptr;
3009 if (strstr(name, "(unnamed)")) return nullptr;
3010 if (strncmp(name,"class ",6)==0) name += 6;
3011 if (strncmp(name,"struct ",7)==0) name += 7;
3012
3013 if (!gROOT->GetListOfClasses()) return nullptr;
3014
3015 // FindObject will take the read lock before actually getting the
3016 // TClass pointer so we will need not get a partially initialized
3017 // object.
3018 TClass *cl = (TClass*)gROOT->GetListOfClasses()->FindObject(name);
3019
3020 // Early return to release the lock without having to execute the
3021 // long-ish normalization.
3022 if (cl && (cl->IsLoaded() || cl->TestBit(kUnloading)))
3023 return cl;
3024
3026
3027 // Now that we got the write lock, another thread may have constructed the
3028 // TClass while we were waiting, so we need to do the checks again.
3029
3030 cl = (TClass*)gROOT->GetListOfClasses()->FindObject(name);
3031 if (cl) {
3032 if (cl->IsLoaded() || cl->TestBit(kUnloading))
3033 return cl;
3034
3035 // We could speed-up some of the search by adding (the equivalent of)
3036 //
3037 // if (cl->GetState() == kInterpreter) return cl
3038 //
3039 // In this case, if a ROOT dictionary was available when the TClass
3040 // was first requested it would have been used and if a ROOT dictionary is
3041 // loaded later on TClassTable::Add will take care of updating the TClass.
3042 // So as far as ROOT dictionary are concerned, if the current TClass is
3043 // in interpreted state, we are sure there is nothing to load.
3044 //
3045 // However (see TROOT::LoadClass), the TClass can also be loaded/provided
3046 // by a user provided TClassGenerator. We have no way of knowing whether
3047 // those do (or even can) behave the same way as the ROOT dictionary and
3048 // have the 'dictionary is now available for use' step informs the existing
3049 // TClass that their dictionary is now available.
3050
3051 //we may pass here in case of a dummy class created by TVirtualStreamerInfo
3052 load = kTRUE;
3053 }
3054
3056 // If there is a @ symbol (followed by a version number) then this is a synthetic class name created
3057 // from an already normalized name for the purpose of supporting schema evolution.
3058 // There is no dictionary or interpreter information about this kind of class, the only
3059 // (undesirable) side-effect of doing the search would be a waste of CPU time and potential
3060 // auto-loading or auto-parsing based on the scope of the name.
3061 return cl;
3062 }
3063
3064 // To avoid spurious auto parsing, let's check if the name as-is is
3065 // known in the TClassTable.
3067 // The name is normalized, so the result of the first search is
3068 // authoritative.
3069 if (!cl && !load)
3070 return nullptr;
3071
3072 TClass *loadedcl = (dict)();
3073 if (loadedcl) {
3074 loadedcl->PostLoadCheck();
3075 return loadedcl;
3076 }
3077
3078 // We should really not fall through to here, but if we do, let's just
3079 // continue as before ...
3080 }
3081
3082 bool disableAutoParsing = gInterpreter->IsAutoParsingSuspended();
3083 // We could get the user choice from:
3084 // - TClass::SetGetClassAutoParsing
3085 static const bool requestDisableAutoParsing =
3086 !gEnv->GetValue("Root.TClass.GetClass.AutoParsing", true) ||
3087 gSystem->Getenv("ROOT_DISABLE_TCLASS_GET_CLASS_AUTOPARSING") != nullptr;
3088 if (requestDisableAutoParsing)
3089 disableAutoParsing = true;
3090 TInterpreter::SuspendAutoParsing autoparseFence(gInterpreter, disableAutoParsing);
3091
3092 // Note: this variable does not always holds the fully normalized name
3093 // as there is information from a not yet loaded library or from header
3094 // not yet parsed that may be needed to fully normalize the name.
3095 std::string normalizedName;
3096 Bool_t nameChanged = kFALSE;
3097
3098 if (!cl) {
3099 // First look at known types but without triggering any loads
3100 {
3101 THashTable *typeTable = dynamic_cast<THashTable *>(gROOT->GetListOfTypes());
3102 TDataType *type = (TDataType *)typeTable->THashTable::FindObject(name);
3103 if (type) {
3104 if (type->GetType() > 0)
3105 // This is a numerical type
3106 return nullptr;
3107 // This is a typedef
3108 normalizedName = type->GetTypeName();
3109 nameChanged = kTRUE;
3110 }
3111 }
3112 {
3114 TClassEdit::GetNormalizedName(normalizedName, name);
3115 }
3116 // Try the normalized name.
3117 if (normalizedName != name) {
3118 cl = (TClass*)gROOT->GetListOfClasses()->FindObject(normalizedName.c_str());
3119
3120 if (cl) {
3121 if (cl->IsLoaded() || cl->TestBit(kUnloading))
3122 return cl;
3123
3124 //we may pass here in case of a dummy class created by TVirtualStreamerInfo
3125 load = kTRUE;
3126 }
3127 nameChanged = kTRUE;
3128 }
3129 } else {
3130 normalizedName = cl->GetName(); // Use the fact that all TClass names are normalized.
3131 }
3132
3133 if (!load)
3134 return nullptr;
3135
3136 // We want to avoid auto-parsing due to intentionally missing dictionary for std::pair.
3137 // However, we don't need this special treatement in rootcling (there is no auto-parsing)
3138 // and we want to make that the TClass for the pair goes through the regular creation
3139 // mechanism (i.e. in rootcling they should be in kInterpreted state and never in
3140 // kEmulated state) so that they have proper interpreter (ClassInfo) information which
3141 // will be used to create the TProtoClass (if one is requested for the pair).
3142 const bool ispair = TClassEdit::IsStdPair(normalizedName) && !IsFromRootCling();
3143 const bool ispairbase = TClassEdit::IsStdPairBase(normalizedName) && !IsFromRootCling();
3144
3145 auto loadClass = [](const char *requestedname) -> TClass* {
3146 DictFuncPtr_t dict = TClassTable::GetDictNorm(requestedname);
3147 if (dict) {
3148 TClass *loadedcl = (dict)();
3149 if (loadedcl) {
3150 loadedcl->PostLoadCheck();
3151 return loadedcl;
3152 }
3153 }
3154 return nullptr;
3155 };
3156
3157 // Check with the changed name first.
3158 if (nameChanged) {
3159 if(TClass *loadedcl = loadClass(normalizedName.c_str()))
3160 return loadedcl;
3161 }
3162 if (gInterpreter->AutoLoad(normalizedName.c_str(),kTRUE)) {
3163 // Check if we just loaded the necessary dictionary.
3164 if (TClass *loadedcl = loadClass(normalizedName.c_str()))
3165 return loadedcl;
3166
3167 // At this point more information has been loaded. This
3168 // information might be pertinent to the normalization of the name.
3169 // For example it might contain or be a typedef for which we don't
3170 // have a forward declaration (eg. typedef to instance of class
3171 // template with default parameters). So let's redo the normalization
3172 // as the new information (eg. typedef in TROOT::GetListOfTypes) might
3173 // lead to a different value.
3174 {
3176 std::string normalizedNameAfterAutoLoad;
3177 TClassEdit::GetNormalizedName(normalizedNameAfterAutoLoad, name);
3178 nameChanged = normalizedNameAfterAutoLoad != normalizedName;
3179 normalizedName = normalizedNameAfterAutoLoad;
3180 }
3181 if (nameChanged) {
3182 // Try to load with an attempt to autoload with the new name
3183 if (TClass *loadedcl = LoadClassDefault(normalizedName.c_str(), silent))
3184 return loadedcl;
3185 }
3186 }
3187
3188 // If name is known to be an enum, we don't need to try to load it.
3189 if (TEnum::GetEnum(normalizedName.c_str(), TEnum::kNone))
3190 return nullptr;
3191
3192 // Maybe this was a typedef: let's try to see if this is the case
3193 if (!ispair && !ispairbase) {
3194 if (TDataType* theDataType = gROOT->GetType(normalizedName.c_str())){
3195 // We have a typedef: we get the name of the underlying type
3196 auto underlyingTypeName = theDataType->GetTypeName();
3197 // We see if we can bootstrap a class with it
3198 if (TClass *loadedcl = LoadClassDefault(underlyingTypeName, silent))
3199 return loadedcl;
3200 }
3201 }
3202
3203 // See if the TClassGenerator can produce the TClass we need.
3204 if (TClass *loadedcl = LoadClassCustom(normalizedName.c_str(), silent))
3205 return loadedcl;
3206
3207 // We have not been able to find a loaded TClass, return the Emulated
3208 // TClass if we have one.
3209 if (cl)
3210 return cl;
3211
3212 if (ispair) {
3213 if (hint_pair_offset && hint_pair_size) {
3214 auto pairinfo = TVirtualStreamerInfo::Factory()->GenerateInfoForPair(normalizedName, silent, hint_pair_offset, hint_pair_size);
3215 // Fall-through to allow TClass to be created when known by the interpreter
3216 // This is used in the case where TStreamerInfo can not handle them.
3217 if (pairinfo)
3218 return pairinfo->GetClass();
3219 } else {
3220 // Check if we have an STL container that might provide it.
3221 static constexpr size_t slen = std::char_traits<char>::length("pair");
3222 static const char *associativeContainer[] = { "map", "unordered_map", "multimap",
3223 "unordered_multimap", "set", "unordered_set", "multiset", "unordered_multiset" };
3224 for(auto contname : associativeContainer) {
3225 std::string collname = contname;
3226 collname.append( normalizedName.c_str() + slen );
3227 TClass *collcl = TClass::GetClass(collname.c_str(), false, silent);
3228 if (!collcl)
3229 collcl = LoadClassDefault(collname.c_str(), silent);
3230 if (collcl) {
3231 auto p = collcl->GetCollectionProxy();
3232 if (p)
3233 cl = p->GetValueClass();
3234 if (cl)
3235 return cl;
3236 }
3237 }
3238 }
3239 } else if (TClassEdit::IsSTLCont( normalizedName.c_str() ))
3240 {
3241 return gInterpreter->GenerateTClass(normalizedName.c_str(), kTRUE, silent);
3242 }
3243
3244 // Check the interpreter only after autoparsing the template if any.
3245 if (!ispairbase) {
3246 std::string::size_type posLess = normalizedName.find('<');
3247 if (posLess != std::string::npos) {
3248 gCling->AutoParse(normalizedName.substr(0, posLess).c_str());
3249 }
3250 }
3251
3252 //last attempt. Look in CINT list of all (compiled+interpreted) classes
3253 if (gDebug>0){
3254 printf("TClass::GetClass: Header Parsing - The representation of %s was not found in the type system. A lookup in the interpreter is about to be tried: this can cause parsing. This can be avoided selecting %s in the linkdef/selection file.\n",normalizedName.c_str(), normalizedName.c_str());
3255 }
3256 if (normalizedName.length()) {
3257 auto cci = gInterpreter->CheckClassInfo(normalizedName.c_str(), kTRUE /* autoload */,
3258 kTRUE /*Only class, structs and ns*/);
3259
3260 // We could have an interpreted class with an inline ClassDef, in this case we do not
3261 // want to create an 'interpreted' TClass but we want the one triggered via the call to
3262 // the Dictionary member. If we go ahead and generate the 'interpreted' version it will
3263 // replace if/when there is a call to IsA on an object of this type.
3264
3266 auto ci = gInterpreter->ClassInfo_Factory(normalizedName.c_str());
3267 auto funcDecl = gInterpreter->GetFunctionWithPrototype(ci, "Dictionary", "", false, ROOT::kExactMatch);
3268 auto method = gInterpreter->MethodInfo_Factory(funcDecl);
3269 typedef void (*tcling_callfunc_Wrapper_t)(void *, int, void **, void *);
3270 auto funcPtr = (tcling_callfunc_Wrapper_t)gInterpreter->MethodInfo_InterfaceMethod(method);
3271
3272 TClass *res = nullptr;
3273 if (funcPtr)
3274 funcPtr(nullptr, 0, nullptr, &res);
3275 // else
3276 // We could fallback to the interpreted case ...
3277 // For now just 'fail' (return nullptr)
3278
3279 gInterpreter->MethodInfo_Delete(method);
3280 gInterpreter->ClassInfo_Delete(ci);
3281
3282 return res;
3283 } else if (cci) {
3284 // Get the normalized name based on the decl (currently the only way
3285 // to get the part to add or drop the default arguments as requested by the user)
3286 std::string alternative;
3287 gInterpreter->GetInterpreterTypeName(normalizedName.c_str(), alternative, kTRUE);
3288 if (alternative.empty())
3289 return nullptr;
3290 const char *altname = alternative.c_str();
3291 if (strncmp(altname, "std::", 5) == 0) {
3292 // For namespace (for example std::__1), GetInterpreterTypeName does
3293 // not strip std::, so we must do it explicitly here.
3294 altname += 5;
3295 }
3296 if (altname != normalizedName && strcmp(altname, name) != 0) {
3297 // altname now contains the full name of the class including a possible
3298 // namespace if there has been a using namespace statement.
3299
3300 // At least in the case C<string [2]> (normalized) vs C<string[2]> (altname)
3301 // the TClassEdit normalization and the TMetaUtils normalization leads to
3302 // two different space layout. To avoid an infinite recursion, we also
3303 // add the test on (altname != name)
3304
3305 return GetClass(altname, load);
3306 }
3307
3308 TClass *ncl = gInterpreter->GenerateTClass(normalizedName.c_str(), /* emulation = */ kFALSE, silent);
3309 if (!ncl->IsZombie()) {
3310 return ncl;
3311 }
3312 delete ncl;
3313 }
3314 }
3315 return nullptr;
3316}
3317
3318////////////////////////////////////////////////////////////////////////////////
3319/// Return pointer to class with name.
3320
3321TClass *TClass::GetClass(const std::type_info& typeinfo, Bool_t load, Bool_t /* silent */, size_t hint_pair_offset, size_t hint_pair_size)
3322{
3323 if (!gROOT->GetListOfClasses())
3324 return nullptr;
3325
3326 //protect access to TROOT::GetIdMap
3328
3329 TClass* cl = GetIdMap()->Find(typeinfo.name());
3330
3331 if (cl && cl->IsLoaded()) return cl;
3332
3334
3335 // Now that we got the write lock, another thread may have constructed the
3336 // TClass while we were waiting, so we need to do the checks again.
3337
3338 cl = GetIdMap()->Find(typeinfo.name());
3339
3340 if (cl) {
3341 if (cl->IsLoaded()) return cl;
3342 //we may pass here in case of a dummy class created by TVirtualStreamerInfo
3343 load = kTRUE;
3344 } else {
3345 // Note we might need support for typedefs and simple types!
3346
3347 // TDataType *objType = GetType(name, load);
3348 //if (objType) {
3349 // const char *typdfName = objType->GetTypeName();
3350 // if (typdfName && strcmp(typdfName, name)) {
3351 // cl = GetClass(typdfName, load);
3352 // return cl;
3353 // }
3354 // }
3355 }
3356
3357 if (!load) return nullptr;
3358
3359 DictFuncPtr_t dict = TClassTable::GetDict(typeinfo);
3360 if (dict) {
3361 cl = (dict)();
3362 if (cl) cl->PostLoadCheck();
3363 return cl;
3364 }
3365 if (cl) return cl;
3366
3367 TIter next(gROOT->GetListOfClassGenerators());
3368 TClassGenerator *gen;
3369 while( (gen = (TClassGenerator*) next()) ) {
3370 cl = gen->GetClass(typeinfo,load);
3371 if (cl) {
3372 cl->PostLoadCheck();
3373 return cl;
3374 }
3375 }
3376
3377 // try AutoLoading the typeinfo
3378 int autoload_old = gCling->SetClassAutoLoading(1);
3379 if (!autoload_old) {
3380 // Re-disable, we just meant to test
3382 }
3383 if (autoload_old && gInterpreter->AutoLoad(typeinfo,kTRUE)) {
3384 // Disable autoload to avoid potential infinite recursion
3386 cl = GetClass(typeinfo, load, hint_pair_offset, hint_pair_size);
3387 if (cl) {
3388 return cl;
3389 }
3390 }
3391
3392 if (hint_pair_offset) {
3393 int err = 0;
3394 char* demangled_name = TClassEdit::DemangleTypeIdName(typeinfo, err);
3395 if (!err) {
3396 cl = TClass::GetClass(demangled_name, load, kTRUE, hint_pair_offset, hint_pair_size);
3397 free(demangled_name);
3398 if (cl)
3399 return cl;
3400 }
3401 }
3402
3403 // last attempt. Look in the interpreter list of all (compiled+interpreted)
3404 // classes
3405 cl = gInterpreter->GetClass(typeinfo, load);
3406
3407 return cl; // Can be zero.
3408}
3409
3410////////////////////////////////////////////////////////////////////////////////
3411/// Static method returning pointer to TClass of the specified ClassInfo.
3412/// If load is true an attempt is made to obtain the class by loading
3413/// the appropriate shared library (directed by the rootmap file).
3414/// If silent is 'true', do not warn about missing dictionary for the class.
3415/// (typically used for class that are used only for transient members)
3416/// Returns 0 in case class is not found.
3417
3418TClass *TClass::GetClass(ClassInfo_t *info, Bool_t load, Bool_t silent)
3419{
3420 if (!info || !gCling->ClassInfo_IsValid(info)) return nullptr;
3421 if (!gROOT->GetListOfClasses()) return nullptr;
3422
3423 // Technically we need the write lock only for the call to ClassInfo_FullName
3424 // and GenerateTClass but FindObject will take the read lock (and LoadClass will
3425 // take the write lock). Since taking/releasing the lock is expensive, let just
3426 // take the write guard and keep it.
3428
3429 // Get the normalized name.
3431
3432 TClass *cl = (TClass*)gROOT->GetListOfClasses()->FindObject(name);
3433
3434 if (cl) {
3435 if (cl->IsLoaded()) return cl;
3436
3437 //we may pass here in case of a dummy class created by TVirtualStreamerInfo
3438 load = kTRUE;
3439
3440 }
3441
3442 if (!load) return nullptr;
3443
3444 TClass *loadedcl = nullptr;
3445 if (cl) loadedcl = gROOT->LoadClass(cl->GetName(),silent);
3446 else loadedcl = gROOT->LoadClass(name,silent);
3447
3448 if (loadedcl) return loadedcl;
3449
3450 if (cl) return cl; // If we found the class but we already have a dummy class use it.
3451
3452 // We did not find a proper TClass but we do know (we have a valid
3453 // ClassInfo) that the class is known to the interpreter.
3454 TClass *ncl = gInterpreter->GenerateTClass(info, silent);
3455 if (!ncl->IsZombie()) {
3456 return ncl;
3457 } else {
3458 delete ncl;
3459 return nullptr;
3460 }
3461}
3462
3463////////////////////////////////////////////////////////////////////////////////
3464
3468
3469////////////////////////////////////////////////////////////////////////////////
3470
3471Bool_t TClass::GetClass(DeclId_t id, std::vector<TClass*> &classes)
3472{
3473 if (!gROOT->GetListOfClasses()) return 0;
3474
3475 DeclIdMap_t* map = GetDeclIdMap();
3476 // Get all the TClass pointer that have the same DeclId.
3477 DeclIdMap_t::equal_range iter = map->Find(id);
3478 if (iter.first == iter.second) return false;
3479 std::vector<TClass*>::iterator vectIt = classes.begin();
3480 for (DeclIdMap_t::const_iterator it = iter.first; it != iter.second; ++it)
3481 vectIt = classes.insert(vectIt, it->second);
3482 return true;
3483}
3484
3485////////////////////////////////////////////////////////////////////////////////
3486/// Return a pointer to the dictionary loading function generated by
3487/// rootcint
3488
3490{
3492}
3493
3494////////////////////////////////////////////////////////////////////////////////
3495/// Return a pointer to the dictionary loading function generated by
3496/// rootcint
3497
3498DictFuncPtr_t TClass::GetDict (const std::type_info& info)
3499{
3500 return TClassTable::GetDict(info);
3501}
3502
3503////////////////////////////////////////////////////////////////////////////////
3504/// Return pointer to datamember object with name "datamember".
3505
3506TDataMember *TClass::GetDataMember(const char *datamember) const
3507{
3508 if ((!(fData.load() && (*fData).IsLoaded()) && !HasInterpreterInfo())
3509 || datamember == nullptr) return nullptr;
3510
3511 // Strip off leading *'s and trailing [
3512 const char *start_name = datamember;
3513 while (*start_name == '*') ++start_name;
3514
3515 // Empty name are 'legal', they represent anonymous unions.
3516 // if (*start_name == 0) return 0;
3517
3518 if (const char *s = strchr(start_name, '[')){
3519 UInt_t len = s-start_name;
3520 TString name(start_name,len);
3521 return (TDataMember *)((TClass*)this)->GetListOfDataMembers(kFALSE)->FindObject(name.Data());
3522 } else {
3523 return (TDataMember *)((TClass*)this)->GetListOfDataMembers(kFALSE)->FindObject(start_name);
3524 }
3525}
3526
3527////////////////////////////////////////////////////////////////////////////////
3528/// Return name of the file containing the declaration of this class.
3529
3530const char *TClass::GetDeclFileName() const
3531{
3532 if (fDeclFileName == kUndeterminedClassInfoName)
3533 return gInterpreter->ClassInfo_FileName( fClassInfo );
3534 return fDeclFileName;
3535}
3536
3537////////////////////////////////////////////////////////////////////////////////
3538/// return offset for member name. name can be a data member in
3539/// the class itself, one of its base classes, or one member in
3540/// one of the aggregated classes.
3541///
3542/// In case of an emulated class, the list of emulated TRealData is built
3543
3545{
3546 TRealData *rd = GetRealData(name);
3547 if (rd) return rd->GetThisOffset();
3548 if (strchr(name,'[')==nullptr) {
3549 // If this is a simple name there is a chance to find it in the
3550 // StreamerInfo even if we did not find it in the RealData.
3551 // For example an array name would be fArray[3] in RealData but
3552 // just fArray in the streamerInfo.
3553 TVirtualStreamerInfo *info = const_cast<TClass*>(this)->GetCurrentStreamerInfo();
3554 if (info) {
3555 return info->GetOffset(name);
3556 }
3557 }
3559}
3560
3561////////////////////////////////////////////////////////////////////////////////
3562/// Return pointer to TRealData element with name "name".
3563///
3564/// Name can be a data member in the class itself,
3565/// one of its base classes, or a member in
3566/// one of the aggregated classes.
3567///
3568/// In case of an emulated class, the list of emulated TRealData is built.
3569
3571{
3572 if (!fRealData) {
3573 const_cast<TClass*>(this)->BuildRealData();
3574 }
3575
3576 if (!fRealData) {
3577 return nullptr;
3578 }
3579
3580 if (!name) {
3581 return nullptr;
3582 }
3583
3584 // First try just the whole name.
3586 if (rd) {
3587 return rd;
3588 }
3589
3590 std::string givenName(name);
3591
3592 // Try ignoring the array dimensions.
3593 std::string::size_type firstBracket = givenName.find_first_of("[");
3594 std::string nameNoDim(givenName.substr(0, firstBracket));
3595 TObjLink *lnk = fRealData->FirstLink();
3596 while (lnk) {
3597 TObject *obj = lnk->GetObject();
3598 std::string objName(obj->GetName());
3599 std::string::size_type pos = objName.find_first_of("[");
3600 if (pos != std::string::npos) {
3601 objName.erase(pos);
3602 }
3603 if (objName == nameNoDim) {
3604 return static_cast<TRealData *>(obj);
3605 }
3606 lnk = lnk->Next();
3607 }
3608
3609 // Now try it as a pointer.
3610 std::ostringstream ptrname;
3611 ptrname << "*" << givenName;
3612 rd = (TRealData*) fRealData->FindObject(ptrname.str().c_str());
3613 if (rd) {
3614 return rd;
3615 }
3616
3617 // Check for a dot in the name.
3618 std::string::size_type firstDot = givenName.find_first_of(".");
3619 if (firstDot == std::string::npos) {
3620 // -- Not found, a simple name, all done.
3621 return nullptr;
3622 }
3623
3624 //
3625 // At this point the name has a dot in it, so it is the name
3626 // of some contained sub-object.
3627 //
3628
3629 // May be a pointer like in TH1: fXaxis.fLabels (in TRealdata is named fXaxis.*fLabels)
3630 std::string::size_type lastDot = givenName.find_last_of(".");
3631 std::ostringstream starname;
3632 starname << givenName.substr(0, lastDot) << ".*" << givenName.substr(lastDot + 1);
3633 rd = (TRealData*) fRealData->FindObject(starname.str().c_str());
3634 if (rd) {
3635 return rd;
3636 }
3637
3638 // Last attempt in case a member has been changed from
3639 // a static array to a pointer, for example the member
3640 // was arr[20] and is now *arr.
3641 //
3642 // Note: In principle, one could also take into account
3643 // the opposite situation where a member like *arr has
3644 // been converted to arr[20].
3645 //
3646 // FIXME: What about checking after the first dot as well?
3647 //
3648 std::string::size_type bracket = starname.str().find_first_of("[");
3649 if (bracket != std::string::npos) {
3650 rd = (TRealData*) fRealData->FindObject(starname.str().substr(0, bracket).c_str());
3651 if (rd) {
3652 return rd;
3653 }
3654 }
3655
3656 // Strip the first component, it may be the name of
3657 // the branch (old TBranchElement code), and try again.
3658 std::string firstDotName(givenName.substr(firstDot + 1));
3659
3660 rd = GetRealData(firstDotName.c_str());
3661 if (rd)
3662 return rd;
3663
3664 // Not found;
3665 return nullptr;
3666}
3667
3668////////////////////////////////////////////////////////////////////////////////
3669
3671{
3672 if (!gInterpreter || !HasInterpreterInfo()) return nullptr;
3673
3674 // The following
3676
3678}
3679
3680////////////////////////////////////////////////////////////////////////////////
3681/// Get the list of shared libraries containing the code for class cls.
3682/// The first library in the list is the one containing the class, the
3683/// others are the libraries the first one depends on. Returns 0
3684/// in case the library is not found.
3685
3687{
3688 if (!gInterpreter) return nullptr;
3689
3690 if (fSharedLibs.IsNull())
3691 fSharedLibs = gInterpreter->GetClassSharedLibs(fName);
3692
3693 return !fSharedLibs.IsNull() ? fSharedLibs.Data() : nullptr;
3694}
3695
3696////////////////////////////////////////////////////////////////////////////////
3697/// Return list containing the TBaseClass(es) of a class.
3698
3700{
3701 if (!fBase.load()) {
3702 if (fCanLoadClassInfo) {
3703 if (fState == kHasTClassInit) {
3704
3706 if (!fHasRootPcmInfo) {
3707 // The bases are in our ProtoClass; we don't need the class info.
3709 if (proto && proto->FillTClass(this))
3710 return fBase;
3711 }
3712 }
3713 // We test again on fCanLoadClassInfo has another thread may have executed it.
3715 LoadClassInfo();
3716 }
3717 }
3718 if (!fClassInfo)
3719 return nullptr;
3720
3721 if (!gInterpreter)
3722 Fatal("GetListOfBases", "gInterpreter not initialized");
3723
3725 if (!fBase.load()) {
3726 gInterpreter->CreateListOfBaseClasses(this);
3727 }
3728 }
3729 return fBase;
3730}
3731
3732////////////////////////////////////////////////////////////////////////////////
3733/// Return a list containing the TEnums of a class.
3734///
3735/// The list returned is safe to use from multiple thread without explicitly
3736/// taking the ROOT global lock.
3737///
3738/// In the case the TClass represents a namespace, the returned list will
3739/// implicit take the ROOT global lock upon any access (see TListOfEnumsWithLock)
3740///
3741/// In the case the TClass represents a class or struct and requestListLoading
3742/// is true, the list is immutable (and thus safe to access from multiple thread
3743/// without taking the global lock at all).
3744///
3745/// In the case the TClass represents a class or struct and requestListLoading
3746/// is false, the list is mutable and thus we return a TListOfEnumsWithLock
3747/// which will implicit take the ROOT global lock upon any access.
3748
3749TList *TClass::GetListOfEnums(Bool_t requestListLoading /* = kTRUE */)
3750{
3751 auto temp = fEnums.load();
3752 if (temp) {
3753 if (requestListLoading) {
3754 if (fProperty == -1) Property();
3755 if (! ((kIsClass | kIsStruct | kIsUnion) & fProperty) ) {
3757 temp->Load();
3758 } else if ( temp->IsA() == TListOfEnumsWithLock::Class() ) {
3759 // We have a class for which the list was not loaded fully at
3760 // first use.
3762 temp->Load();
3763 }
3764 }
3765 return temp;
3766 }
3767
3768 if (!requestListLoading) {
3769 if (fProperty == -1) Property();
3771 if (fEnums.load()) {
3772 return fEnums.load();
3773 }
3774
3775 if (IsFromRootCling()) // rootcling is single thread (this save some space in the rootpcm).
3776 fEnums = new TListOfEnums(this);
3777 else
3778 fEnums = new TListOfEnumsWithLock(this);
3779 return fEnums;
3780 }
3781
3783 if (fEnums.load()) {
3784 (*fEnums).Load();
3785 return fEnums.load();
3786 }
3787 if (fProperty == -1) Property();
3788 if ( (kIsClass | kIsStruct | kIsUnion) & fProperty) {
3789 // For this case, the list will be immutable
3790 temp = new TListOfEnums(this);
3791 } else {
3792 //namespaces can have enums added to them
3793 temp = new TListOfEnumsWithLock(this);
3794 }
3795 temp->Load();
3796 fEnums = temp;
3797 return temp;
3798}
3799
3800////////////////////////////////////////////////////////////////////////////////
3801/// Create the list containing the TDataMembers (of actual data members or members
3802/// pulled in through using declarations) of a class.
3803
3804TList *TClass::CreateListOfDataMembers(std::atomic<TListOfDataMembers*> &data, TDictionary::EMemberSelection selection, bool load)
3805{
3807
3808 if (!data) {
3810 // The members are in our ProtoClass; we don't need the class info.
3812 if (proto && proto->FillTClass(this))
3813 return data;
3814 }
3815
3816 data = new TListOfDataMembers(this, selection);
3817 }
3818 if (IsClassStructOrUnion()) {
3819 // If the we have a class or struct or union, the order
3820 // of data members is the list is essential since it determines their
3821 // order on file. So we must always load. Also, the list is fixed
3822 // since the language does not allow to add members.
3823 if (!(*data).IsLoaded())
3824 (*data).Load();
3825
3826 } else if (load) (*data).Load();
3827 return data;
3828}
3829
3830////////////////////////////////////////////////////////////////////////////////
3831/// Return list containing the TDataMembers of a class.
3832
3834{
3835 // Fast path, no lock? Classes load at creation time.
3836 if (IsClassStructOrUnion()) {
3837 auto data = fData.load();
3838 if (data && data->IsLoaded())
3839 return data;
3840 } else if (!load && fData)
3841 return fData;
3842
3844}
3845
3846////////////////////////////////////////////////////////////////////////////////
3847/// Return list containing the TDataMembers of using declarations of a class.
3848
3850{
3851 // Fast path, no lock? Classes load at creation time.
3852 if ((!load || IsClassStructOrUnion()) && fUsingData)
3853 return fUsingData;
3854
3856}
3857
3858////////////////////////////////////////////////////////////////////////////////
3859/// Return TListOfFunctionTemplates for a class.
3860
3862{
3864
3866 if (load) fFuncTemplate->Load();
3867 return fFuncTemplate;
3868}
3869
3870////////////////////////////////////////////////////////////////////////////////
3871/// Return list containing the TMethods of a class.
3872/// If load is true, the list is populated with all the defined function
3873/// and currently instantiated function template.
3874
3876{
3878
3879 if (!fMethod.load()) GetMethodList();
3880 if (load) {
3881 if (gDebug>0) Info("GetListOfMethods","Header Parsing - Asking for all the methods of class %s: this can involve parsing.",GetName());
3882 (*fMethod).Load();
3883 }
3884 return fMethod;
3885}
3886
3887////////////////////////////////////////////////////////////////////////////////
3888/// Return the collection of functions named "name".
3889
3891{
3892 return const_cast<TClass*>(this)->GetMethodList()->GetListForObject(name);
3893}
3894
3895
3896////////////////////////////////////////////////////////////////////////////////
3897/// Returns a list of all public methods of this class and its base classes.
3898/// Refers to a subset of the methods in GetListOfMethods() so don't do
3899/// GetListOfAllPublicMethods()->Delete().
3900/// Algorithm used to get the list is:
3901/// - put all methods of the class in the list (also protected and private
3902/// ones).
3903/// - loop over all base classes and add only those methods not already in the
3904/// list (also protected and private ones).
3905/// - once finished, loop over resulting list and remove all private and
3906/// protected methods.
3907
3909{
3911
3913 if (load) {
3914 if (gDebug>0) Info("GetListOfAllPublicMethods","Header Parsing - Asking for all the methods of class %s: this can involve parsing.",GetName());
3916 }
3917 return fAllPubMethod;
3918}
3919
3920////////////////////////////////////////////////////////////////////////////////
3921/// Returns a list of all public data members of this class and its base
3922/// classes. Refers to a subset of the data members in GetListOfDatamembers()
3923/// so don't do GetListOfAllPublicDataMembers()->Delete().
3924
3926{
3928
3930 if (load) fAllPubData->Load();
3931 return fAllPubData;
3932}
3933
3934////////////////////////////////////////////////////////////////////////////////
3935/// Returns list of methods accessible by context menu.
3936
3938{
3939 if (!HasInterpreterInfo()) return;
3940
3941 // get the base class
3942 TIter nextBase(GetListOfBases(), kIterBackward);
3943 TBaseClass *baseClass;
3944 while ((baseClass = (TBaseClass *) nextBase())) {
3945 TClass *base = baseClass->GetClassPointer();
3946 if (base) base->GetMenuItems(list);
3947 }
3948
3949 // remove methods redefined in this class with no menu
3950 TMethod *method, *m;
3952 while ((method = (TMethod*)next())) {
3953 m = (TMethod*)list->FindObject(method->GetName());
3954 if (method->IsMenuItem() != kMenuNoMenu) {
3955 if (!m)
3956 list->AddFirst(method);
3957 } else {
3958 if (m && m->GetNargs() == method->GetNargs())
3959 list->Remove(m);
3960 }
3961 }
3962}
3963
3964////////////////////////////////////////////////////////////////////////////////
3965/// Check whether a class has a dictionary or not.
3966/// This is equivalent to ask if a class is coming from a bootstrapping
3967/// procedure initiated during the loading of a library.
3968
3970{
3971 return IsLoaded();
3972}
3973
3974////////////////////////////////////////////////////////////////////////////////
3975/// Check whether a class has a dictionary or ROOT can load one.
3976/// This is equivalent to ask HasDictionary() or whether a library is known
3977/// where it can be loaded from, or whether a Dictionary function is
3978/// available because the class's dictionary library was already loaded.
3979
3981{
3982 if (TClass* cl = (TClass*)gROOT->GetListOfClasses()->FindObject(clname))
3983 return cl->IsLoaded();
3984 return gClassTable->GetDict(clname) || gInterpreter->GetClassSharedLibs(clname);
3985}
3986
3987////////////////////////////////////////////////////////////////////////////////
3988/// Verify the base classes always.
3989
3991{
3992 TList* lb = GetListOfBases();
3993 if (!lb) return;
3994 TIter nextBase(lb);
3995 TBaseClass* base = nullptr;
3996 while ((base = (TBaseClass*)nextBase())) {
3997 TClass* baseCl = base->GetClassPointer();
3998 if (baseCl) {
3999 baseCl->GetMissingDictionariesWithRecursionCheck(result, visited, recurse);
4000 }
4001 }
4002}
4003
4004////////////////////////////////////////////////////////////////////////////////
4005/// Verify the Data Members.
4006
4008{
4010 if (!ldm) return ;
4011 TIter nextMemb(ldm);
4012 TDataMember * dm = nullptr;
4013 while ((dm = (TDataMember*)nextMemb())) {
4014 // If it is a transient
4015 if(!dm->IsPersistent()) {
4016 continue;
4017 }
4018 if (dm->Property() & kIsStatic) {
4019 continue;
4020 }
4021 // If it is a built-in data type.
4022 TClass* dmTClass = nullptr;
4023 if (dm->GetDataType()) {
4024 // We have a basic datatype.
4025 dmTClass = nullptr;
4026 // Otherwise get the string representing the type.
4027 } else if (dm->GetTypeName()) {
4028 dmTClass = TClass::GetClass(dm->GetTypeName());
4029 }
4030 if (dmTClass) {
4031 dmTClass->GetMissingDictionariesWithRecursionCheck(result, visited, recurse);
4032 }
4033 }
4034}
4035
4037{
4038 // Pair is a special case and we have to check its elements for missing dictionaries
4039 // Pair is a transparent container so we should always look at its.
4040
4042 for (int i = 0; i < 2; i++) {
4043 TClass* pairElement = ((TStreamerElement*)SI->GetElements()->At(i))->GetClass();
4044 if (pairElement) {
4045 pairElement->GetMissingDictionariesWithRecursionCheck(result, visited, recurse);
4046 }
4047 }
4048}
4049
4050////////////////////////////////////////////////////////////////////////////////
4051/// From the second level of recursion onwards it is different state check.
4052
4054{
4055 if (result.FindObject(this) || visited.FindObject(this)) return;
4056
4057 static TClassRef sCIString("string");
4058 if (this == sCIString) return;
4059
4060 TClassEdit::TSplitType splitType(fName);
4061 if (splitType.IsTemplate()) {
4062 // We now treat special cases:
4063 // - pair
4064 // - unique_ptr
4065 // - array
4066 // - tuple
4067
4068 // Small helper to get the TClass instance from a classname and recursively
4069 // investigate it
4070 auto checkDicts = [&](const string &clName){
4071 auto cl = TClass::GetClass(clName.c_str());
4072 if (!cl) {
4073 // We try to remove * and const from the type name if any
4074 const auto clNameShortType = TClassEdit::ShortType(clName.c_str(), 1);
4075 cl = TClass::GetClass(clNameShortType.c_str());
4076 }
4077 if (cl) {
4078 cl->GetMissingDictionariesWithRecursionCheck(result, visited, recurse);
4079 }
4080 };
4081
4082 const auto &elements = splitType.fElements;
4083 const auto &templName = elements[0];
4084
4085 // Special treatment for pair.
4086 if (templName == "pair") {
4088 return;
4089 }
4090
4091 // Special treatment of unique_ptr or array
4092 // They are treated together since they have 1 single template argument
4093 // which is interesting when checking for missing dictionaries.
4094 if (templName == "unique_ptr" || templName == "array") {
4095 checkDicts(elements[1]);
4096 return;
4097 }
4098
4099 // Special treatment of tuple
4100 // This type must be treated separately since it can have N template
4101 // arguments which are interesting, unlike unique_ptr or array.
4102 if (templName == "tuple") {
4103 // -1 because the elements end with a list of the "stars", i.e. number of
4104 // * after the type name
4105 const auto nTemplArgs = elements.size() - 1;
4106 // loop starts at 1 because the first element is the template name
4107 for (auto iTemplArg = 1U; iTemplArg < nTemplArgs; ++iTemplArg) {
4108 checkDicts(elements[iTemplArg]);
4109 }
4110 return;
4111 }
4112 } // this is not a template
4113
4114 if (!HasDictionary()) {
4115 result.Add(this);
4116 }
4117
4118 visited.Add(this);
4119 //Check whether a custom streamer
4121 if (GetCollectionProxy()) {
4122 // We need to look at the collection's content
4123 // The collection has different kind of elements the check would be required.
4124 TClass* t = nullptr;
4125 if ((t = GetCollectionProxy()->GetValueClass())) {
4127 }
4128 } else {
4129 if (recurse) {
4130 GetMissingDictionariesForMembers(result, visited, recurse);
4131 }
4133 }
4134 }
4135}
4136
4137////////////////////////////////////////////////////////////////////////////////
4138/// Get the classes that have a missing dictionary starting from this one.
4139/// - With recurse = false the classes checked for missing dictionaries are:
4140/// the class itself, all base classes, direct data members,
4141/// and for collection proxies the container's
4142/// elements without iterating over the element's data members;
4143/// - With recurse = true the classes checked for missing dictionaries are:
4144/// the class itself, all base classes, recursing on the data members,
4145/// and for the collection proxies recursion on the elements of the
4146/// collection and iterating over the element's data members.
4147
4149{
4150 // Top level recursion it different from the following levels of recursion.
4151
4152 if (result.FindObject(this)) return;
4153
4154 static TClassRef sCIString("string");
4155 if (this == sCIString) return;
4156
4157 THashTable visited;
4158
4161 return;
4162 }
4163
4164 if (strncmp(fName, "unique_ptr<", 11) == 0 || strncmp(fName, "array<", 6) == 0 || strncmp(fName, "tuple<", 6) == 0) {
4166 return;
4167 }
4168
4169 if (!HasDictionary()) {
4170 result.Add(this);
4171 }
4172
4173 visited.Add(this);
4174
4175 //Check whether a custom streamer
4177 if (GetCollectionProxy()) {
4178 // We need to look at the collection's content
4179 // The collection has different kind of elements the check would be required.
4180 TClass* t = nullptr;
4181 if ((t = GetCollectionProxy()->GetValueClass())) {
4183 }
4184 } else {
4185 GetMissingDictionariesForMembers(result, visited, recurse);
4187 }
4188 }
4189}
4190
4191////////////////////////////////////////////////////////////////////////////////
4192/// Return kTRUE if the class has elements.
4193
4194Bool_t TClass::IsFolder(void *obj) const
4195{
4196 return Browse(obj,(TBrowser*)nullptr);
4197}
4198
4199//______________________________________________________________________________
4200//______________________________________________________________________________
4201void TClass::ReplaceWith(TClass *newcl) const
4202{
4203 // Inform the other objects to replace this object by the new TClass (newcl)
4204
4206 //we must update the class pointers pointing to 'this' in all TStreamerElements
4207 TIter nextClass(gROOT->GetListOfClasses());
4208 TClass *acl;
4210
4211 // Since we are in the process of replacing a TClass by a TClass
4212 // coming from a dictionary, there is no point in loading any
4213 // libraries during this search.
4215 while ((acl = (TClass*)nextClass())) {
4216 if (acl == newcl) continue;
4217
4218 TIter nextInfo(acl->GetStreamerInfos());
4219 while ((info = (TVirtualStreamerInfo*)nextInfo())) {
4220
4221 info->Update(this, newcl);
4222 }
4223 }
4224
4225 gInterpreter->UnRegisterTClassUpdate(this);
4226}
4227
4228////////////////////////////////////////////////////////////////////////////////
4229/// Make sure that the current ClassInfo is up to date.
4230
4232{
4233 Warning("ResetClassInfo(Long_t tagnum)","Call to deprecated interface (does nothing)");
4234}
4235
4236////////////////////////////////////////////////////////////////////////////////
4237/// Make sure that the current ClassInfo is up to date.
4238
4240{
4242
4244
4245 if (fClassInfo) {
4247 gInterpreter->ClassInfo_Delete(fClassInfo);
4248 fClassInfo = nullptr;
4249 }
4250 // We can not check at this point whether after the unload there will
4251 // still be interpreter information about this class (as v5 was doing),
4252 // instead this function must only be called if the definition is (about)
4253 // to be unloaded.
4254
4255 ResetCaches();
4256
4257 // We got here because the definition Decl is about to be unloaded.
4259 if (fStreamerInfo->GetEntries() != 0) {
4261 } else {
4263 }
4264 } else {
4265 // if the ClassInfo was loaded for a class with a TClass Init and it
4266 // gets unloaded, should we guess it can be reloaded?
4268 }
4269}
4270
4271////////////////////////////////////////////////////////////////////////////////
4272/// To clean out all caches.
4273
4275{
4276 R__ASSERT(!TestBit(kLoading) && "Resetting the caches does not make sense during loading!" );
4277
4278 // Not owning lists, don't call Delete(), but unload
4279 if (fData.load())
4280 (*fData).Unload();
4281 if (fUsingData.load())
4282 (*fUsingData).Unload();
4283 if (fEnums.load())
4284 (*fEnums).Unload();
4285 if (fMethod.load())
4286 (*fMethod).Unload();
4287
4288 delete fAllPubData; fAllPubData = nullptr;
4289
4290 if (fBase.load())
4291 (*fBase).Delete();
4292 delete fBase.load(); fBase = nullptr;
4293
4294 if (fRealData)
4295 fRealData->Delete();
4296 delete fRealData; fRealData=nullptr;
4297}
4298
4299////////////////////////////////////////////////////////////////////////////////
4300/// Resets the menu list to it's standard value.
4301
4310
4311////////////////////////////////////////////////////////////////////////////////
4312/// The ls function lists the contents of a class on stdout. Ls output
4313/// is typically much less verbose then Dump().
4314/// If options contains 'streamerinfo', run ls on the list of streamerInfos
4315/// and the list of conversion streamerInfos.
4316
4317void TClass::ls(Option_t *options) const
4318{
4319 TNamed::ls(options);
4320 if (options==nullptr || options[0]==0) return;
4321
4322 if (strstr(options,"streamerinfo")!=nullptr) {
4323 GetStreamerInfos()->ls(options);
4324
4325 if (fConversionStreamerInfo.load()) {
4326 std::map<std::string, TObjArray*>::iterator it;
4327 std::map<std::string, TObjArray*>::iterator end = (*fConversionStreamerInfo).end();
4328 for( it = (*fConversionStreamerInfo).begin(); it != end; ++it ) {
4329 it->second->ls(options);
4330 }
4331 }
4332 }
4333}
4334
4335////////////////////////////////////////////////////////////////////////////////
4336/// Makes a customizable version of the popup menu list, i.e. makes a list
4337/// of TClassMenuItem objects of methods accessible by context menu.
4338/// The standard (and different) way consists in having just one element
4339/// in this list, corresponding to the whole standard list.
4340/// Once the customizable version is done, one can remove or add elements.
4341
4343{
4345 TClassMenuItem *menuItem;
4346
4347 // Make sure fClassMenuList is initialized and empty.
4348 GetMenuList()->Delete();
4349
4350 TList* methodList = new TList;
4351 GetMenuItems(methodList);
4352
4353 TMethod *method;
4354 TMethodArg *methodArg;
4355 TClass *classPtr = nullptr;
4356 TIter next(methodList);
4357
4358 while ((method = (TMethod*) next())) {
4359 // if go to a mother class method, add separator
4360 if (classPtr != method->GetClass()) {
4361 menuItem = new TClassMenuItem(TClassMenuItem::kPopupSeparator, this);
4362 fClassMenuList->AddLast(menuItem);
4363 classPtr = method->GetClass();
4364 }
4365 // Build the signature of the method
4366 TString sig;
4367 TList* margsList = method->GetListOfMethodArgs();
4368 TIter nextarg(margsList);
4369 while ((methodArg = (TMethodArg*)nextarg())) {
4370 sig = sig+","+methodArg->GetFullTypeName();
4371 }
4372 if (sig.Length()!=0) sig.Remove(0,1); // remove first comma
4374 method->GetName(), method->GetName(),nullptr,
4375 sig.Data(),-1,TClassMenuItem::kIsSelf);
4376 if (method->IsMenuItem() == kMenuToggle) menuItem->SetToggle();
4377 fClassMenuList->Add(menuItem);
4378 }
4379 delete methodList;
4380}
4381
4382////////////////////////////////////////////////////////////////////////////////
4383/// Return kTRUE if an object of this class can be relocated to a new address
4384/// with a raw memory copy, i.e. without running a move or copy constructor --
4385/// trivial relocatability in the C++26 sense ([class.prop]), as answered by the
4386/// interpreter. Every trivially copyable class is trivially relocatable, but not
4387/// every trivially relocatable class is trivially copyable: e.g. a polymorphic
4388/// class whose bases and members are all trivially relocatable qualifies too.
4389///
4390/// A kTRUE answer rules out both a resource being freed twice or from the wrong
4391/// address (the failure mode of root-project/root#20882) and a non-trivial copy
4392/// constructor being skipped. It is still not a proof that a raw memory copy
4393/// preserves the class' semantics:
4394/// ~~~ {.cpp}
4395/// struct Foo { Foo *ptr = this; };
4396/// ~~~
4397/// is trivially copyable, hence trivially relocatable, yet a raw memory copy
4398/// leaves `ptr` pointing at the old location -- and nothing observable here
4399/// would reveal that. Such a class is relocated the way it always has been.
4400///
4401/// An emulated class, described only by a TStreamerInfo, gets the conservative
4402/// answer since its members can be anything -- e.g. the std::string of an
4403/// emulated pair<string,double>.
4404
4406{
4407 const Long_t classProperty = ClassProperty();
4408 // No kClassIsValid means no interpreter information at all (emulated class,
4409 // forward declaration, ...), so assume the worst.
4410 if (!(classProperty & kClassIsValid))
4411 return kFALSE;
4412 return (classProperty & kClassIsTriviallyRelocatable) != 0;
4413}
4414
4415////////////////////////////////////////////////////////////////////////////////
4416/// Register the fact that an object was moved from the memory location
4417/// 'arenaFrom' to the memory location 'arenaTo'.
4418
4419void TClass::Move(void *arenaFrom, void *arenaTo) const
4420{
4421 // If/when we have access to a copy constructor (or better to a move
4422 // constructor), this function should also perform the data move.
4423 // For now we just information the repository.
4424
4425 // This only records the new address; a caller that relocated the data with a
4426 // raw memory copy silently corrupts the types that do not support it, so warn
4427 // about those rather than let it surface later as an obscure crash (typically
4428 // an invalid free). A caller that did run a real move or copy constructor can
4429 // ignore the message -- we have no way to tell the two apart here. The in-tree
4430 // callers, in TEmulatedCollectionProxy::Expand, already avoid the memcpy for
4431 // these types, so this is aimed at external users of this public method.
4432 if (!IsTriviallyRelocatable()) {
4433 // Keyed by name rather than by 'this': a TClass can be deleted and another
4434 // one allocated at the same address, which would silence the message.
4435 static std::mutex sMoveDiagMutex;
4436 static std::set<std::string> sMoveDiagDone;
4437 bool firstTime = false;
4438 {
4439 std::lock_guard<std::mutex> guard(sMoveDiagMutex);
4440 firstTime = sMoveDiagDone.emplace(GetName()).second;
4441 }
4442 if (firstTime)
4443 Error("Move",
4444 "Objects of type %s are not trivially relocatable, i.e. can not be relocated with a raw memory copy. "
4445 "TClass::Move does not move the data itself (here from %p to %p), so if the caller relocated it that "
4446 "way the objects are now corrupted.",
4447 GetName(), arenaFrom, arenaTo);
4448 }
4449
4450 if ((GetState() <= kEmulated) && !fCollectionProxy) {
4451 MoveAddressInRepository("TClass::Move",arenaFrom,arenaTo,this);
4452 }
4453}
4454
4455////////////////////////////////////////////////////////////////////////////////
4456/// Return the list of menu items associated with the class.
4457
4459 if (!fClassMenuList) {
4460 fClassMenuList = new TList();
4462 }
4463 return fClassMenuList;
4464}
4465
4466////////////////////////////////////////////////////////////////////////////////
4467/// Return (create an empty one if needed) the list of functions.
4468/// The major difference with GetListOfMethod is that this returns
4469/// the internal type of fMethod and thus can not be made public.
4470/// It also never 'loads' the content of the list.
4471
4473{
4474 if (!fMethod.load()) {
4475 std::unique_ptr<TListOfFunctions> temp{ new TListOfFunctions(this) };
4476 TListOfFunctions* expected = nullptr;
4477 if(fMethod.compare_exchange_strong(expected, temp.get()) ) {
4478 temp.release();
4479 }
4480 }
4481 return fMethod;
4482}
4483
4484
4485////////////////////////////////////////////////////////////////////////////////
4486/// Return pointer to method without looking at parameters.
4487/// Does not look in (possible) base classes.
4488/// Has the side effect of loading all the TMethod object in the list
4489/// of the class.
4490
4491TMethod *TClass::GetMethodAny(const char *method)
4492{
4493 if (!HasInterpreterInfo()) return nullptr;
4494 return (TMethod*) GetMethodList()->FindObject(method);
4495}
4496
4497////////////////////////////////////////////////////////////////////////////////
4498/// Return pointer to method without looking at parameters.
4499/// Does look in all base classes.
4500
4502{
4503 if (!HasInterpreterInfo()) return nullptr;
4504
4505 TMethod* m = GetMethodAny(method);
4506 if (m) return m;
4507
4508 TBaseClass *base;
4509 TIter nextb(GetListOfBases());
4510 while ((base = (TBaseClass *) nextb())) {
4511 TClass *c = base->GetClassPointer();
4512 if (c) {
4513 m = c->GetMethodAllAny(method);
4514 if (m) return m;
4515 }
4516 }
4517
4518 return nullptr;
4519}
4520
4521////////////////////////////////////////////////////////////////////////////////
4522/// Find the best method (if there is one) matching the parameters.
4523/// The params string must contain argument values, like "3189, \"aap\", 1.3".
4524/// The function invokes GetClassMethod to search for a possible method
4525/// in the class itself or in its base classes. Returns 0 in case method
4526/// is not found.
4527
4528TMethod *TClass::GetMethod(const char *method, const char *params,
4529 Bool_t objectIsConst /* = kFALSE */)
4530{
4532 if (!fClassInfo) return nullptr;
4533
4534 if (!gInterpreter)
4535 Fatal("GetMethod", "gInterpreter not initialized");
4536
4537 TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithValues(fClassInfo,
4538 method, params,
4539 objectIsConst);
4540
4541 if (!decl) return nullptr;
4542
4543 // search recursively in this class or its base classes
4545 if (f) return f;
4546
4547 Error("GetMethod",
4548 "\nDid not find matching TMethod <%s> with \"%s\" %sfor %s",
4549 method,params,objectIsConst ? "const " : "", GetName());
4550 return nullptr;
4551}
4552
4553
4554////////////////////////////////////////////////////////////////////////////////
4555/// Find a method with decl id in this class or its bases.
4556
4558 if (TFunction* method = GetMethodList()->Get(declId))
4559 return static_cast<TMethod *>(method);
4560
4561 for (auto item : *GetListOfBases())
4562 if (auto base = static_cast<TBaseClass *>(item)->GetClassPointer())
4563 if (TFunction* method = base->FindClassOrBaseMethodWithId(declId))
4564 return static_cast<TMethod *>(method);
4565
4566 return nullptr;
4567}
4568
4569////////////////////////////////////////////////////////////////////////////////
4570/// Find the method with a given prototype. The proto string must be of the
4571/// form: "char*,int,double". Returns 0 in case method is not found.
4572
4573TMethod *TClass::GetMethodWithPrototype(const char *method, const char *proto,
4574 Bool_t objectIsConst /* = kFALSE */,
4575 ROOT::EFunctionMatchMode mode /* = ROOT::kConversionMatch */)
4576{
4578 if (!fClassInfo) return nullptr;
4579
4580 if (!gInterpreter)
4581 Fatal("GetMethodWithPrototype", "gInterpreter not initialized");
4582
4583 TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithPrototype(fClassInfo,
4584 method, proto,
4585 objectIsConst, mode);
4586
4587 if (!decl) return nullptr;
4589 if (f) return f;
4590 Error("GetMethodWithPrototype",
4591 "\nDid not find matching TMethod <%s> with \"%s\" %sfor %s",
4592 method,proto,objectIsConst ? "const " : "", GetName());
4593 return nullptr;
4594}
4595
4596////////////////////////////////////////////////////////////////////////////////
4597/// Look for a method in this class that has the interface function
4598/// address faddr.
4599
4601{
4602 if (!HasInterpreterInfo()) return nullptr;
4603
4604 TMethod *m;
4605 TIter next(GetListOfMethods());
4606 while ((m = (TMethod *) next())) {
4607 if (faddr == (Longptr_t)m->InterfaceMethod())
4608 return m;
4609 }
4610 return nullptr;
4611}
4612
4613////////////////////////////////////////////////////////////////////////////////
4614/// Look for a method in this class that has the name and matches the parameters.
4615/// The params string must contain argument values, like "3189, \"aap\", 1.3".
4616/// Returns 0 in case method is not found.
4617/// See TClass::GetMethod to also search the base classes.
4618
4619TMethod *TClass::GetClassMethod(const char *name, const char* params,
4620 Bool_t objectIsConst /* = kFALSE */)
4621{
4623 if (!fClassInfo) return nullptr;
4624
4625 if (!gInterpreter)
4626 Fatal("GetClassMethod", "gInterpreter not initialized");
4627
4628 TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithValues(fClassInfo,
4629 name, params,
4630 objectIsConst);
4631
4632 if (!decl) return nullptr;
4633
4634 TFunction *f = GetMethodList()->Get(decl);
4635
4636 return (TMethod*)f; // Could be zero if the decl is actually in a base class.
4637}
4638
4639////////////////////////////////////////////////////////////////////////////////
4640/// Find the method with a given prototype. The proto string must be of the
4641/// form: "char*,int,double". Returns 0 in case method is not found.
4642/// See TClass::GetMethodWithPrototype to also search the base classes.
4643
4644TMethod *TClass::GetClassMethodWithPrototype(const char *name, const char* proto,
4645 Bool_t objectIsConst /* = kFALSE */,
4646 ROOT::EFunctionMatchMode mode /* = ROOT::kConversionMatch */)
4647{
4649 if (!fClassInfo) return nullptr;
4650
4651 if (!gInterpreter)
4652 Fatal("GetClassMethodWithPrototype", "gInterpreter not initialized");
4653
4654 TInterpreter::DeclId_t decl = gInterpreter->GetFunctionWithPrototype(fClassInfo,
4655 name, proto,
4656 objectIsConst,
4657 mode);
4658
4659 if (!decl) return nullptr;
4660
4661 TFunction *f = GetMethodList()->Get(decl);
4662
4663 return (TMethod*)f; // Could be zero if the decl is actually in a base class.
4664}
4665
4666////////////////////////////////////////////////////////////////////////////////
4667/// Return the number of data members of this class
4668/// Note that in case the list of data members is not yet created, it will be done
4669/// by GetListOfDataMembers().
4670
4672{
4673 if (!HasDataMemberInfo()) return 0;
4674
4676 if (lm)
4677 return lm->GetSize();
4678 else
4679 return 0;
4680}
4681
4682////////////////////////////////////////////////////////////////////////////////
4683/// Return the number of methods of this class
4684/// Note that in case the list of methods is not yet created, it will be done
4685/// by GetListOfMethods().
4686/// This will also load/populate the list of methods, to get 'just' the
4687/// number of currently loaded methods use:
4688/// cl->GetListOfMethods(false)->GetSize();
4689
4691{
4692 if (!HasInterpreterInfo()) return 0;
4693
4694 TList *lm = GetListOfMethods();
4695 if (lm)
4696 return lm->GetSize();
4697 else
4698 return 0;
4699}
4700
4701////////////////////////////////////////////////////////////////////////////////
4702/// returns a pointer to the TVirtualStreamerInfo object for version
4703/// If the object does not exist, it is created
4704///
4705/// Note: There are two special version numbers:
4706///
4707/// - 0: Use the class version from the currently loaded class library.
4708/// - -1: Assume no class library loaded (emulated class).
4709///
4710/// Warning: If we create a new streamer info, whether or not the build
4711/// optimizes is controlled externally to us by a global variable!
4712/// Don't call us unless you have set that variable properly
4713/// with TStreamer::Optimize()!
4714///
4715
4716TVirtualStreamerInfo* TClass::GetStreamerInfo(Int_t version /* = 0 */, Bool_t isTransient /* = false */) const
4717{
4719
4720 // Version 0 is special, it means the currently loaded version.
4721 // We need to set it at the beginning to be able to guess it correctly.
4722
4723 if (version == 0)
4724 version = fClassVersion;
4725
4726 // If the StreamerInfo is assigned to the fLastReadInfo, we are
4727 // guaranteed it was built and compiled.
4728 if (sinfo && sinfo->GetClassVersion() == version)
4729 return sinfo;
4730
4731 // Note that the access to fClassVersion above is technically not thread-safe with a low probably of problems.
4732 // fClassVersion is not an atomic and is modified TClass::SetClassVersion (called from RootClassVersion via
4733 // ROOT::ResetClassVersion) and is 'somewhat' protected by the atomic fVersionUsed.
4734 // However, direct access to fClassVersion should be replaced by calls to GetClassVersion to set fVersionUsed.
4735 // Even with such a change the code here and in these functions need to be reviewed as a cursory look seem
4736 // to indicates they are not yet properly protection against mutli-thread access.
4737 //
4738 // However, the use of these functions is rare and mostly done at library loading time which should
4739 // in almost all cases preceeds the possibility of GetStreamerInfo being called from multiple thread
4740 // on that same TClass object.
4741 //
4742 // Summary: need careful review but risk of problem is extremely low.
4743
4745
4746 return GetStreamerInfoImpl(version, isTransient);
4747};
4748
4749// Implementation of/for TStreamerInfo::GetStreamerInfo.
4750// This routine assumes the global lock has been taken.
4752{
4753 // Warning: version may be -1 for an emulated class, or -2 if the
4754 // user requested the emulated streamerInfo for an abstract
4755 // base class, even though we have a dictionary for it.
4756
4757 if ((version < -1) || (version >= (fStreamerInfo->GetSize()-1))) {
4758 Error("GetStreamerInfo", "class: %s, attempting to access a wrong version: %d", GetName(), version);
4759 // FIXME: Shouldn't we go to -1 here, or better just abort?
4760 version = fClassVersion;
4761 }
4762
4764
4765 if (!sinfo && (version != fClassVersion)) {
4766 // When the requested version does not exist we return
4767 // the TVirtualStreamerInfo for the currently loaded class version.
4768 // FIXME: This arguably makes no sense, we should warn and return nothing instead.
4769 // Note: This is done for STL collections
4770 // Note: fClassVersion could be -1 here (for an emulated class).
4771 // This is also the code path take for unversioned classes.
4773 }
4774
4775 if (!sinfo) {
4776 // We just were not able to find a streamer info, we have to make a new one.
4777 TMmallocDescTemp setreset;
4778 sinfo = TVirtualStreamerInfo::Factory()->NewInfo(const_cast<TClass*>(this));
4780 if (gDebug > 0) {
4781 printf("Creating StreamerInfo for class: %s, version: %d\n", GetName(), fClassVersion);
4782 }
4784 // If we do not have a StreamerInfo for this version and we do not
4785 // have dictionary information nor a proxy, there is nothing to build!
4786 sinfo->Build(silent);
4787 }
4788 } else {
4789 if (!sinfo->IsCompiled()) {
4790 // Streamer info has not been compiled, but exists.
4791 // Therefore it was read in from a file and we have to do schema evolution?
4792 // Or it didn't have a dictionary before, but does now?
4793 sinfo->BuildOld();
4794 }
4795 }
4796
4797 // Cache the current info if we now have it.
4798 if (version == fClassVersion)
4799 fCurrentInfo = sinfo;
4800
4801 // If the compilation succeeded, remember this StreamerInfo.
4802 if (sinfo->IsCompiled())
4803 fLastReadInfo = sinfo;
4804
4805 return sinfo;
4806}
4807
4808////////////////////////////////////////////////////////////////////////////////
4809/// For the case where the requestor class is emulated and this class is abstract,
4810/// returns a pointer to the TVirtualStreamerInfo object for version with an emulated
4811/// representation whether or not the class is loaded.
4812///
4813/// If the object does not exist, it is created
4814///
4815/// Note: There are two special version numbers:
4816///
4817/// - 0: Use the class version from the currently loaded class library.
4818/// - -1: Assume no class library loaded (emulated class).
4819///
4820/// Warning: If we create a new streamer info, whether or not the build
4821/// optimizes is controlled externally to us by a global variable!
4822/// Don't call us unless you have set that variable properly
4823/// with TStreamer::Optimize()!
4824///
4825
4827{
4828 TVirtualStreamerInfo *sinfo = nullptr;
4829
4830 TString newname(GetName());
4831 newname += "@@emulated";
4832
4834
4835 TClass *emulated = TClass::GetClass(newname);
4836
4837 if (emulated)
4838 sinfo = emulated->GetStreamerInfo(version);
4839
4840 if (!sinfo) {
4841 // The emulated version of the streamerInfo is explicitly requested and has
4842 // not been built yet.
4843
4844 sinfo = (TVirtualStreamerInfo*) fStreamerInfo->At(version);
4845
4846 if (!sinfo && (version != fClassVersion)) {
4847 // When the requested version does not exist we return
4848 // the TVirtualStreamerInfo for the currently loaded class version.
4849 // FIXME: This arguably makes no sense, we should warn and return nothing instead.
4851 }
4852
4853 if (!sinfo) {
4854 // Let's take the first available StreamerInfo as a start
4855 Int_t ninfos = fStreamerInfo->GetEntriesFast() - 1;
4856 for (Int_t i = -1; sinfo == nullptr && i < ninfos; ++i)
4858 }
4859
4860 if (sinfo) {
4861 sinfo = dynamic_cast<TVirtualStreamerInfo *>(sinfo->Clone());
4862 if (sinfo) {
4863 sinfo->SetClass(nullptr);
4864 sinfo->SetName(newname);
4865 sinfo->BuildCheck();
4866 sinfo->BuildOld();
4867 sinfo->GetClass()->AddRule(TString::Format("sourceClass=%s targetClass=%s",GetName(),newname.Data()));
4868 } else {
4869 Error("GetStreamerInfoAbstractEmulated", "could not create TVirtualStreamerInfo");
4870 }
4871 }
4872 }
4873 return sinfo;
4874}
4875
4876////////////////////////////////////////////////////////////////////////////////
4877/// For the case where the requestor class is emulated and this class is abstract,
4878/// returns a pointer to the TVirtualStreamerInfo object for version with an emulated
4879/// representation whether or not the class is loaded.
4880///
4881/// If the object does not exist, it is created
4882///
4883/// Warning: If we create a new streamer info, whether or not the build
4884/// optimizes is controlled externally to us by a global variable!
4885/// Don't call us unless you have set that variable properly
4886/// with TStreamer::Optimize()!
4887///
4888
4890{
4891 TVirtualStreamerInfo *sinfo = nullptr;
4892
4893 TString newname(GetName());
4894 newname += "@@emulated";
4895
4897
4898 TClass *emulated = TClass::GetClass(newname);
4899
4900 if (emulated)
4901 sinfo = emulated->FindStreamerInfo(checksum);
4902
4903 if (!sinfo) {
4904 // The emulated version of the streamerInfo is explicitly requested and has
4905 // not been built yet.
4906
4907 sinfo = (TVirtualStreamerInfo*) FindStreamerInfo(checksum);
4908
4909 if (!sinfo && (checksum != fCheckSum)) {
4910 // When the requested version does not exist we return
4911 // the TVirtualStreamerInfo for the currently loaded class version.
4912 // FIXME: This arguably makes no sense, we should warn and return nothing instead.
4914 }
4915
4916 if (!sinfo) {
4917 // Let's take the first available StreamerInfo as a start
4918 Int_t ninfos = fStreamerInfo->GetEntriesFast() - 1;
4919 for (Int_t i = -1; sinfo == nullptr && i < ninfos; ++i)
4921 }
4922
4923 if (sinfo) {
4924 sinfo = dynamic_cast<TVirtualStreamerInfo*>( sinfo->Clone() );
4925 if (sinfo) {
4926 sinfo->SetClass(nullptr);
4927 sinfo->SetName( newname );
4928 sinfo->BuildCheck();
4929 sinfo->BuildOld();
4930 sinfo->GetClass()->AddRule(TString::Format("sourceClass=%s targetClass=%s",GetName(),newname.Data()));
4931 } else {
4932 Error("GetStreamerInfoAbstractEmulated", "could not create TVirtualStreamerInfo");
4933 }
4934 }
4935 }
4936 return sinfo;
4937}
4938
4939////////////////////////////////////////////////////////////////////////////////
4940/// When the class kIgnoreTObjectStreamer bit is set, the automatically
4941/// generated Streamer will not call TObject::Streamer.
4942/// This option saves the TObject space overhead on the file.
4943/// However, the information (fBits, fUniqueID) of TObject is lost.
4944///
4945/// Note that to be effective for objects streamed object-wise this function
4946/// must be called for the class deriving directly from TObject, eg, assuming
4947/// that BigTrack derives from Track and Track derives from TObject, one must do:
4948/// ~~~ {.cpp}
4949/// Track::Class()->IgnoreTObjectStreamer();
4950/// ~~~
4951/// and not:
4952/// ~~~ {.cpp}
4953/// BigTrack::Class()->IgnoreTObjectStreamer();
4954/// ~~~
4955/// To be effective for object streamed member-wise or split in a TTree,
4956/// this function must be called for the most derived class (i.e. BigTrack).
4957
4959{
4960 // We need to tak the lock since we are test and then setting fBits
4961 // and TStreamerInfo::fBits (and the StreamerInfo state in general)
4962 // which can also be modified by another thread.
4964
4965 if ( doIgnore && TestBit(kIgnoreTObjectStreamer)) return;
4966 if (!doIgnore && !TestBit(kIgnoreTObjectStreamer)) return;
4968 if (sinfo) {
4969 if (sinfo->IsCompiled()) {
4970 // -- Warn the user that what they are doing cannot work.
4971 // Note: The reason is that TVirtualStreamerInfo::Build() examines
4972 // the kIgnoreTObjectStreamer bit and sets the TStreamerElement
4973 // type for the TObject base class streamer element it creates
4974 // to -1 as a flag. Later on the TStreamerInfo::Compile()
4975 // member function sees the flag and does not insert the base
4976 // class element into the compiled streamer info. None of this
4977 // machinery works correctly if we are called after the streamer
4978 // info has already been built and compiled.
4979 Error("IgnoreTObjectStreamer","Must be called before the creation of StreamerInfo");
4980 return;
4981 }
4982 }
4983 if (doIgnore) SetBit (kIgnoreTObjectStreamer);
4985}
4986
4987////////////////////////////////////////////////////////////////////////////////
4988/// Return kTRUE if this class inherits from a class with name "classname".
4989/// note that the function returns kTRUE in case classname is the class itself
4990
4991Bool_t TClass::InheritsFrom(const char *classname) const
4992{
4993 if (strcmp(GetName(), classname) == 0) return kTRUE;
4994
4995 return InheritsFrom(TClass::GetClass(classname,kTRUE,kTRUE));
4996}
4997
4998////////////////////////////////////////////////////////////////////////////////
4999/// Return kTRUE if this class inherits from class cl.
5000/// note that the function returns KTRUE in case cl is the class itself
5001
5003{
5004 if (!cl) return kFALSE;
5005 if (cl == this) return kTRUE;
5006
5007 if (!HasDataMemberInfo()) {
5008 TVirtualStreamerInfo *sinfo = ((TClass *)this)->GetCurrentStreamerInfo();
5009 if (sinfo==nullptr) sinfo = GetStreamerInfo();
5010 TIter next(sinfo->GetElements());
5011 TStreamerElement *element;
5012 while ((element = (TStreamerElement*)next())) {
5013 if (element->IsA() == TStreamerBase::Class()) {
5014 TClass *clbase = element->GetClassPointer();
5015 if (!clbase) return kFALSE; //missing class
5016 if (clbase->InheritsFrom(cl)) return kTRUE;
5017 }
5018 }
5019 return kFALSE;
5020 }
5021 // cast const away (only for member fBase which can be set in GetListOfBases())
5022 if (((TClass *)this)->GetBaseClass(cl)) return kTRUE;
5023 return kFALSE;
5024}
5025
5026////////////////////////////////////////////////////////////////////////////////
5027/// Cast obj of this class type up to baseclass cl if up is true.
5028/// Cast obj of this class type down from baseclass cl if up is false.
5029/// If this class is not a baseclass of cl return 0, else the pointer
5030/// to the cl part of this (up) or to this (down).
5031
5032void *TClass::DynamicCast(const TClass *cl, void *obj, Bool_t up)
5033{
5034 if (cl == this) return obj;
5035
5036 if (!HasDataMemberInfo()) return nullptr;
5037
5038 Int_t off;
5039 if ((off = GetBaseClassOffset(cl, obj)) != -1) {
5040 if (up)
5041 return (void*)((Longptr_t)obj+off);
5042 else
5043 return (void*)((Longptr_t)obj-off);
5044 }
5045 return nullptr;
5046}
5047
5048////////////////////////////////////////////////////////////////////////////////
5049/// Cast obj of this class type up to baseclass cl if up is true.
5050/// Cast obj of this class type down from baseclass cl if up is false.
5051/// If this class is not a baseclass of cl return 0, else the pointer
5052/// to the cl part of this (up) or to this (down).
5053
5054const void *TClass::DynamicCast(const TClass *cl, const void *obj, Bool_t up)
5055{
5056 return DynamicCast(cl,const_cast<void*>(obj),up);
5057}
5058
5059////////////////////////////////////////////////////////////////////////////////
5060/// Return a pointer to a newly allocated object of this class.
5061///
5062/// If quiet is true, do not issue a message via Error in case
5063/// of problems, just return `nullptr`.
5064///
5065/// This method is also used by the I/O subsystem to allocate the right amount
5066/// of memory for the objects. If a default constructor is not defined for a
5067/// certain class, some options are available.
5068/// The simplest is to define the default I/O constructor, for example
5069/// ~~~{.cpp}
5070/// class myClass {
5071/// public:
5072/// myClass() = delete;
5073/// myClass(TRootIOCtor *) {/* do something */}
5074/// // more code...
5075/// };
5076/// ~~~
5077///
5078/// Moreover, the constructor called by TClass::New can be customized by
5079/// using a rootcling pragma as follows:
5080/// ~~~ {.cpp}
5081/// #pragma link C++ ioctortype UserClass;
5082/// ~~~
5083/// `TClass::New` will then look for a constructor (for a class `MyClass` in the
5084/// following example) in the following order, constructing the object using the
5085/// first one in the list that exists and is declared public:
5086/// ~~~ {.cpp}
5087/// MyClass(UserClass*);
5088/// MyClass(TRootIOCtor*);
5089/// MyClass(); // Or a constructor with all its arguments defaulted.
5090/// ~~~
5091///
5092/// When more than one `pragma ioctortype` is specified, the priority order is
5093/// defined as the definition order; the earliest definitions have higher priority.
5094/// For example with:
5095/// ~~~ {.cpp}
5096/// #pragma link C++ ioctortype UserClass1;
5097/// #pragma link C++ ioctortype UserClass2;
5098/// ~~~
5099/// ROOT looks for constructors with the following order:
5100/// ~~~ {.cpp}
5101/// MyClass(UserClass1*);
5102/// MyClass(UserClass2*);
5103/// MyClass(TRootIOCtor*);
5104/// MyClass(); // Or a constructor with all its arguments defaulted.
5105/// ~~~
5106
5107void *TClass::New(ENewType defConstructor, Bool_t quiet) const
5108{
5109 auto obj = NewObject(defConstructor, quiet);
5110 if (obj.GetPtr() && obj.GetAllocator()) {
5111 // Register the object for special handling in the destructor.
5112 RegisterAddressInRepository("TClass::New", obj.GetPtr(), this);
5113 }
5114 return obj.GetPtr();
5115}
5116
5117// See TClass:New
5118// returns a TClass::ObjectPtr which remembers if the object was allocated
5119// via a TStreamerInfo.
5120
5122{
5123 ObjectPtr p;
5124
5125 if (fNew) {
5126 // We have the new operator wrapper function,
5127 // so there is a dictionary and it was generated
5128 // by rootcint, so there should be a default
5129 // constructor we can call through the wrapper.
5130 {
5131 TClass__GetCallingNewRAII callingNew(defConstructor);
5132 p = fNew(nullptr);
5133 }
5134 if (!p && !quiet) {
5135 //Error("New", "cannot create object of class %s version %d", GetName(), fClassVersion);
5136 Error("New", "cannot create object of class %s", GetName());
5137 }
5138 } else if (HasInterpreterInfo()) {
5139 // We have the dictionary but do not have the
5140 // constructor wrapper, so the dictionary was
5141 // not generated by rootcint. Let's try to
5142 // create the object by having the interpreter
5143 // call the new operator, hopefully the class
5144 // library is loaded and there will be a default
5145 // constructor we can call.
5146 // [This is very unlikely to work, but who knows!]
5147 {
5148 TClass__GetCallingNewRAII callingNew(defConstructor);
5150 }
5151 if (!p && !quiet) {
5152 //Error("New", "cannot create object of class %s version %d", GetName(), fClassVersion);
5153 Error("New", "cannot create object of class %s", GetName());
5154 }
5155 } else if (!HasInterpreterInfo() && fCollectionProxy) {
5156 // There is no dictionary at all, so this is an emulated
5157 // class; however we do have the services of a collection proxy,
5158 // so this is an emulated STL class.
5159 {
5160 TClass__GetCallingNewRAII callingNew(defConstructor);
5162 }
5163 if (!p && !quiet) {
5164 //Error("New", "cannot create object of class %s version %d", GetName(), fClassVersion);
5165 Error("New", "cannot create object of class %s", GetName());
5166 }
5167 } else if (!HasInterpreterInfo() && !fCollectionProxy) {
5168 // There is no dictionary at all and we do not have
5169 // the services of a collection proxy available, so
5170 // use the streamer info to approximate calling a
5171 // constructor (basically we just make sure that the
5172 // pointer data members are null, unless they are marked
5173 // as preallocated with the "->" comment, in which case
5174 // we default-construct an object to point at).
5175
5176 // Do not register any TObject's that we create
5177 // as a result of creating this object.
5178 // FIXME: Why do we do this?
5179 // FIXME: Partial Answer: Is this because we may never actually deregister them???
5180
5181 Bool_t statsave = GetObjectStat();
5182 if(statsave) {
5184 }
5186 if (!sinfo) {
5187 if (!quiet)
5188 Error("New", "Cannot construct class '%s' version %d, no streamer info available!", GetName(), fClassVersion);
5189 return nullptr;
5190 }
5191
5192 {
5193 TClass__GetCallingNewRAII callingNew(defConstructor);
5194 p = { sinfo->New(), sinfo};
5195 }
5196
5197 // FIXME: Mistake? See note above at the GetObjectStat() call.
5198 // Allow TObject's to be registered again.
5199 if(statsave) {
5200 SetObjectStat(statsave);
5201 }
5202
5203 if (!p) {
5204 Error("New", "Failed to construct class '%s' using streamer info", GetName());
5205 }
5206
5207 return p;
5208 } else {
5209 Fatal("New", "This cannot happen!");
5210 }
5211
5212 return p;
5213}
5214
5215////////////////////////////////////////////////////////////////////////////////
5216/// Return a pointer to a newly allocated object of this class.
5217/// The class must have a default constructor. For meaning of
5218/// defConstructor, see TClass::IsCallingNew().
5219
5220void *TClass::New(void *arena, ENewType defConstructor) const
5221{
5222 auto obj = NewObject(arena, defConstructor);
5223 if (obj.GetPtr() && obj.GetAllocator()) {
5224 // Register the object for special handling in the destructor.
5225 RegisterAddressInRepository("TClass::New with placement", obj.GetPtr(), this);
5226 }
5227 return obj.GetPtr();
5228}
5229
5230////////////////////////////////////////////////////////////////////////////////
5231/// Return a pointer to a newly allocated object of this class.
5232/// The class must have a default constructor. For meaning of
5233/// defConstructor, see TClass::IsCallingNew().
5234
5235TClass::ObjectPtr TClass::NewObject(void *arena, ENewType defConstructor) const
5236{
5237 ObjectPtr p;
5238
5239 if (fNew) {
5240 // We have the new operator wrapper function,
5241 // so there is a dictionary and it was generated
5242 // by rootcint, so there should be a default
5243 // constructor we can call through the wrapper.
5244 {
5245 TClass__GetCallingNewRAII callingNew(defConstructor);
5246 p = fNew(arena);
5247 }
5248 if (!p) {
5249 Error("New with placement", "cannot create object of class %s version %d at address %p", GetName(), fClassVersion, arena);
5250 }
5251 } else if (HasInterpreterInfo()) {
5252 // We have the dictionary but do not have the
5253 // constructor wrapper, so the dictionary was
5254 // not generated by rootcint. Let's try to
5255 // create the object by having the interpreter
5256 // call the new operator, hopefully the class
5257 // library is loaded and there will be a default
5258 // constructor we can call.
5259 // [This is very unlikely to work, but who knows!]
5260 {
5261 TClass__GetCallingNewRAII callingNew(defConstructor);
5262 p = gCling->ClassInfo_New(GetClassInfo(),arena);
5263 }
5264 if (!p) {
5265 Error("New with placement", "cannot create object of class %s version %d at address %p", GetName(), fClassVersion, arena);
5266 }
5267 } else if (!HasInterpreterInfo() && fCollectionProxy) {
5268 // There is no dictionary at all, so this is an emulated
5269 // class; however we do have the services of a collection proxy,
5270 // so this is an emulated STL class.
5271 {
5272 TClass__GetCallingNewRAII callingNew(defConstructor);
5273 p = fCollectionProxy->NewObject(arena);
5274 }
5275 } else if (!HasInterpreterInfo() && !fCollectionProxy) {
5276 // There is no dictionary at all and we do not have
5277 // the services of a collection proxy available, so
5278 // use the streamer info to approximate calling a
5279 // constructor (basically we just make sure that the
5280 // pointer data members are null, unless they are marked
5281 // as preallocated with the "->" comment, in which case
5282 // we default-construct an object to point at).
5283
5284 // ???BUG??? ???WHY???
5285 // Do not register any TObject's that we create
5286 // as a result of creating this object.
5287 Bool_t statsave = GetObjectStat();
5288 if(statsave) {
5290 }
5291
5293 if (!sinfo) {
5294 Error("New with placement", "Cannot construct class '%s' version %d at address %p, no streamer info available!", GetName(), fClassVersion, arena);
5295 return nullptr;
5296 }
5297
5298 {
5299 TClass__GetCallingNewRAII callingNew(defConstructor);
5300 p = { sinfo->New(arena), sinfo };
5301 }
5302
5303 // ???BUG???
5304 // Allow TObject's to be registered again.
5305 if(statsave) {
5306 SetObjectStat(statsave);
5307 }
5308
5309 } else {
5310 Error("New with placement", "This cannot happen!");
5311 }
5312
5313 return p;
5314}
5315
5316////////////////////////////////////////////////////////////////////////////////
5317/// Return a pointer to a newly allocated array of objects
5318/// of this class.
5319/// The class must have a default constructor. For meaning of
5320/// defConstructor, see TClass::IsCallingNew().
5321
5322void *TClass::NewArray(Long_t nElements, ENewType defConstructor) const
5323{
5324 auto obj = NewObjectArray(nElements, defConstructor);
5325 if (obj.GetPtr() && obj.GetAllocator()) {
5326 // Register the object for special handling in the destructor.
5327 RegisterAddressInRepository("TClass::NewArray", obj.GetPtr(), this);
5328 }
5329 return obj.GetPtr();
5330}
5331
5332////////////////////////////////////////////////////////////////////////////////
5333/// Return a pointer to a newly allocated array of objects
5334/// of this class.
5335/// The class must have a default constructor. For meaning of
5336/// defConstructor, see TClass::IsCallingNew().
5337
5339{
5340 ObjectPtr p;
5341
5342 if (fNewArray) {
5343 // We have the new operator wrapper function,
5344 // so there is a dictionary and it was generated
5345 // by rootcint, so there should be a default
5346 // constructor we can call through the wrapper.
5347 {
5348 TClass__GetCallingNewRAII callingNew(defConstructor);
5349 p = fNewArray(nElements, nullptr);
5350 }
5351 if (!p) {
5352 Error("NewArray", "cannot create object of class %s version %d", GetName(), fClassVersion);
5353 }
5354 } else if (HasInterpreterInfo()) {
5355 // We have the dictionary but do not have the
5356 // constructor wrapper, so the dictionary was
5357 // not generated by rootcint. Let's try to
5358 // create the object by having the interpreter
5359 // call the new operator, hopefully the class
5360 // library is loaded and there will be a default
5361 // constructor we can call.
5362 // [This is very unlikely to work, but who knows!]
5363 {
5364 TClass__GetCallingNewRAII callingNew(defConstructor);
5365 p = gCling->ClassInfo_New(GetClassInfo(),nElements);
5366 }
5367 if (!p) {
5368 Error("NewArray", "cannot create object of class %s version %d", GetName(), fClassVersion);
5369 }
5370 } else if (!HasInterpreterInfo() && fCollectionProxy) {
5371 // There is no dictionary at all, so this is an emulated
5372 // class; however we do have the services of a collection proxy,
5373 // so this is an emulated STL class.
5374 {
5375 TClass__GetCallingNewRAII callingNew(defConstructor);
5376 p = fCollectionProxy->NewObjectArray(nElements);
5377 }
5378 } else if (!HasInterpreterInfo() && !fCollectionProxy) {
5379 // There is no dictionary at all and we do not have
5380 // the services of a collection proxy available, so
5381 // use the streamer info to approximate calling a
5382 // constructor (basically we just make sure that the
5383 // pointer data members are null, unless they are marked
5384 // as preallocated with the "->" comment, in which case
5385 // we default-construct an object to point at).
5386
5387 // ???BUG??? ???WHY???
5388 // Do not register any TObject's that we create
5389 // as a result of creating this object.
5390 Bool_t statsave = GetObjectStat();
5391 if(statsave) {
5393 }
5394
5396 if (!sinfo) {
5397 Error("NewArray", "Cannot construct class '%s' version %d, no streamer info available!", GetName(), fClassVersion);
5398 return nullptr;
5399 }
5400
5401 {
5402 TClass__GetCallingNewRAII callingNew(defConstructor);
5403 p = { sinfo->NewArray(nElements), sinfo };
5404 }
5405
5406 // ???BUG???
5407 // Allow TObject's to be registered again.
5408 if(statsave) {
5409 SetObjectStat(statsave);
5410 }
5411
5412 } else {
5413 Error("NewArray", "This cannot happen!");
5414 }
5415
5416 return p;
5417}
5418
5419////////////////////////////////////////////////////////////////////////////////
5420/// Return a pointer to a newly allocated object of this class.
5421/// The class must have a default constructor. For meaning of
5422/// defConstructor, see TClass::IsCallingNew().
5423
5424void *TClass::NewArray(Long_t nElements, void *arena, ENewType defConstructor) const
5425{
5426 auto obj = NewObjectArray(nElements, arena, defConstructor);
5427 if (obj.GetPtr() && obj.GetAllocator()) {
5428 // Register the object for special handling in the destructor.
5429 RegisterAddressInRepository("TClass::NewArray with placement", obj.GetPtr(), this);
5430 }
5431 return obj.GetPtr();
5432}
5433
5434////////////////////////////////////////////////////////////////////////////////
5435/// Return a pointer to a newly allocated object of this class.
5436/// The class must have a default constructor. For meaning of
5437/// defConstructor, see TClass::IsCallingNew().
5438
5439TClass::ObjectPtr TClass::NewObjectArray(Long_t nElements, void *arena, ENewType defConstructor) const
5440{
5441 ObjectPtr p;
5442
5443 if (fNewArray) {
5444 // We have the new operator wrapper function,
5445 // so there is a dictionary and it was generated
5446 // by rootcint, so there should be a default
5447 // constructor we can call through the wrapper.
5448 {
5449 TClass__GetCallingNewRAII callingNew(defConstructor);
5450 p = fNewArray(nElements, arena);
5451 }
5452 if (!p) {
5453 Error("NewArray with placement", "cannot create object of class %s version %d at address %p", GetName(), fClassVersion, arena);
5454 }
5455 } else if (HasInterpreterInfo()) {
5456 // We have the dictionary but do not have the constructor wrapper,
5457 // so the dictionary was not generated by rootcint (it was made either
5458 // by cint or by some external mechanism). Let's try to create the
5459 // object by having the interpreter call the new operator, either the
5460 // class library is loaded and there is a default constructor we can
5461 // call, or the class is interpreted and we will call the default
5462 // constructor that way, or no default constructor is available and
5463 // we fail.
5464 {
5465 TClass__GetCallingNewRAII callingNew(defConstructor);
5466 p = gCling->ClassInfo_New(GetClassInfo(),nElements, arena);
5467 }
5468 if (!p) {
5469 Error("NewArray with placement", "cannot create object of class %s version %d at address %p", GetName(), fClassVersion, arena);
5470 }
5471 } else if (!HasInterpreterInfo() && fCollectionProxy) {
5472 // There is no dictionary at all, so this is an emulated
5473 // class; however we do have the services of a collection proxy,
5474 // so this is an emulated STL class.
5475 {
5476 TClass__GetCallingNewRAII callingNew(defConstructor);
5477 p = fCollectionProxy->NewObjectArray(nElements, arena);
5478 }
5479 } else if (!HasInterpreterInfo() && !fCollectionProxy) {
5480 // There is no dictionary at all and we do not have
5481 // the services of a collection proxy available, so
5482 // use the streamer info to approximate calling a
5483 // constructor (basically we just make sure that the
5484 // pointer data members are null, unless they are marked
5485 // as preallocated with the "->" comment, in which case
5486 // we default-construct an object to point at).
5487
5488 // ???BUG??? ???WHY???
5489 // Do not register any TObject's that we create
5490 // as a result of creating this object.
5491 Bool_t statsave = GetObjectStat();
5492 if(statsave) {
5494 }
5495
5497 if (!sinfo) {
5498 Error("NewArray with placement", "Cannot construct class '%s' version %d at address %p, no streamer info available!", GetName(), fClassVersion, arena);
5499 return nullptr;
5500 }
5501
5502 {
5503 TClass__GetCallingNewRAII callingNew(defConstructor);
5504 p = { sinfo->NewArray(nElements, arena), sinfo };
5505 }
5506
5507 // ???BUG???
5508 // Allow TObject's to be registered again.
5509 if(statsave) {
5510 SetObjectStat(statsave);
5511 }
5512
5514 // We always register emulated objects, we need to always
5515 // use the streamer info to destroy them.
5516 }
5517
5518 return p;
5519 } else {
5520 Error("NewArray with placement", "This cannot happen!");
5521 }
5522
5523 return p;
5524}
5525
5526////////////////////////////////////////////////////////////////////////////////
5527/// Explicitly call destructor for object.
5528
5529void TClass::Destructor(void *obj, Bool_t dtorOnly)
5530{
5531 // Do nothing if passed a null pointer.
5532 if (obj == nullptr) return;
5533
5534 void* p = obj;
5535
5536 if (dtorOnly && fDestructor) {
5537 // We have the destructor wrapper, use it.
5538 fDestructor(p);
5539 } else if ((!dtorOnly) && fDelete) {
5540 // We have the delete wrapper, use it.
5541 fDelete(p);
5542 } else if (HasInterpreterInfo()) {
5543 // We have the dictionary but do not have the
5544 // destruct/delete wrapper, so the dictionary was
5545 // not generated by rootcint (it could have been
5546 // created by cint or by some external mechanism).
5547 // Let's have the interpreter call the destructor,
5548 // either the code will be in a loaded library,
5549 // or it will be interpreted, otherwise we fail
5550 // because there is no destructor code at all.
5551 if (dtorOnly) {
5553 } else {
5555 }
5556 } else if (!HasInterpreterInfo() && fCollectionProxy) {
5557 // There is no dictionary at all, so this is an emulated
5558 // class; however we do have the services of a collection proxy,
5559 // so this is an emulated STL class.
5560 GetCollectionProxy()->Destructor(p, dtorOnly);
5561 } else if (!HasInterpreterInfo() && !fCollectionProxy) {
5562 // There is no dictionary at all and we do not have
5563 // the services of a collection proxy available, so
5564 // use the streamer info to approximate calling a
5565 // destructor.
5566
5567 Bool_t inRepo = kTRUE;
5568 Bool_t currentVersion = kFALSE;
5569
5570 // Was this object allocated through TClass?
5571 Version_t objVer = -1;
5572 {
5574 RepoCont_t::iterator iter = fObjectVersionRepository.find(p);
5575 if (iter == fObjectVersionRepository.end()) {
5576 // No, it wasn't, skip special version handling.
5577 //Error("Destructor2", "Attempt to delete unregistered object of class '%s' at address %p!", GetName(), p);
5578 inRepo = kFALSE;
5579 } else {
5580 //objVer = iter->second;
5581 for (; (iter != fObjectVersionRepository.end()) && (iter->first == p); ++iter) {
5582 objVer = iter->second;
5583 if (objVer == fClassVersion) {
5584 currentVersion = kTRUE;
5585 break;
5586 }
5587 }
5588 }
5589 }
5590
5591 if (!inRepo || currentVersion) {
5592 // The object was allocated using code for the same class version
5593 // as is loaded now. We may proceed without worry.
5595 if (si) {
5596 si->Destructor(p, dtorOnly);
5597 } else {
5598 Error("Destructor", "No streamer info available for class '%s' version %d at address %p, cannot destruct emulated object!", GetName(), fClassVersion, p);
5599 Error("Destructor", "length of fStreamerInfo is %d", fStreamerInfo->GetSize());
5601 for (Int_t v = 0; v < fStreamerInfo->GetSize(); ++v, ++i) {
5602 Error("Destructor", "fStreamerInfo->At(%d): %p", i, fStreamerInfo->At(i));
5603 if (fStreamerInfo->At(i) != nullptr) {
5604 Error("Destructor", "Doing Dump() ...");
5606 }
5607 }
5608 }
5609 } else {
5610 // The loaded class version is not the same as the version of the code
5611 // which was used to allocate this object. The best we can do is use
5612 // the TVirtualStreamerInfo to try to free up some of the allocated memory.
5614 if (si) {
5615 si->Destructor(p, dtorOnly);
5616 } else {
5617 Error("Destructor", "No streamer info available for class '%s' version %d, cannot destruct object at addr: %p", GetName(), objVer, p);
5618 Error("Destructor", "length of fStreamerInfo is %d", fStreamerInfo->GetSize());
5620 for (Int_t v = 0; v < fStreamerInfo->GetSize(); ++v, ++i) {
5621 Error("Destructor2", "fStreamerInfo->At(%d): %p", i, fStreamerInfo->At(i));
5622 if (fStreamerInfo->At(i) != nullptr) {
5623 // Do some debugging output.
5624 Error("Destructor2", "Doing Dump() ...");
5626 }
5627 }
5628 }
5629 }
5630
5631 if (inRepo && p) {
5632 UnregisterAddressInRepository("TClass::Destructor",p,this);
5633 }
5634 } else {
5635 Error("Destructor", "This cannot happen! (class %s)", GetName());
5636 }
5637}
5638
5639////////////////////////////////////////////////////////////////////////////////
5640/// Explicitly call destructor for object.
5641
5643{
5644 // Do nothing if passed a null pointer.
5645 if (obj.GetPtr() == nullptr)
5646 return;
5647
5648 if (obj.GetAllocator()) {
5649 obj.GetAllocator()->Destructor(obj.GetPtr(), dtorOnly);
5650 } else {
5651 Destructor(obj.GetPtr(), dtorOnly);
5652 }
5653}
5654
5655////////////////////////////////////////////////////////////////////////////////
5656/// Explicitly call operator delete[] for an array.
5657
5658void TClass::DeleteArray(void *ary, Bool_t dtorOnly)
5659{
5660 // Do nothing if passed a null pointer.
5661 if (ary == nullptr) return;
5662
5663 // Make a copy of the address.
5664 void* p = ary;
5665
5666 if (fDeleteArray) {
5667 if (dtorOnly) {
5668 Error("DeleteArray", "Destructor only is not supported!");
5669 } else {
5670 // We have the array delete wrapper, use it.
5671 fDeleteArray(ary);
5672 }
5673 } else if (HasInterpreterInfo()) {
5674 // We have the dictionary but do not have the
5675 // array delete wrapper, so the dictionary was
5676 // not generated by rootcint. Let's try to
5677 // delete the array by having the interpreter
5678 // call the array delete operator, hopefully
5679 // the class library is loaded and there will be
5680 // a destructor we can call.
5681 gCling->ClassInfo_DeleteArray(GetClassInfo(),ary, dtorOnly);
5682 } else if (!HasInterpreterInfo() && fCollectionProxy) {
5683 // There is no dictionary at all, so this is an emulated
5684 // class; however we do have the services of a collection proxy,
5685 // so this is an emulated STL class.
5686 GetCollectionProxy()->DeleteArray(ary, dtorOnly);
5687 } else if (!HasInterpreterInfo() && !fCollectionProxy) {
5688 // There is no dictionary at all and we do not have
5689 // the services of a collection proxy available, so
5690 // use the streamer info to approximate calling the
5691 // array destructor.
5692
5693 Bool_t inRepo = kTRUE;
5694 Bool_t currentVersion = kFALSE;
5695
5696 // Was this array object allocated through TClass?
5697 Version_t objVer = -1;
5698 {
5700 RepoCont_t::iterator iter = fObjectVersionRepository.find(p);
5701 if (iter == fObjectVersionRepository.end()) {
5702 // No, it wasn't, we cannot know what to do.
5703 //Error("DeleteArray", "Attempt to delete unregistered array object, element type '%s', at address %p!", GetName(), p);
5704 inRepo = kFALSE;
5705 } else {
5706 for (; (iter != fObjectVersionRepository.end()) && (iter->first == p); ++iter) {
5707 objVer = iter->second;
5708 if (objVer == fClassVersion) {
5709 currentVersion = kTRUE;
5710 break;
5711 }
5712 }
5713 }
5714 }
5715
5716 if (!inRepo || currentVersion) {
5717 // The object was allocated using code for the same class version
5718 // as is loaded now. We may proceed without worry.
5720 if (si) {
5721 si->DeleteArray(ary, dtorOnly);
5722 } else {
5723 Error("DeleteArray", "No streamer info available for class '%s' version %d at address %p, cannot destruct object!", GetName(), fClassVersion, ary);
5724 Error("DeleteArray", "length of fStreamerInfo is %d", fStreamerInfo->GetSize());
5726 for (Int_t v = 0; v < fStreamerInfo->GetSize(); ++v, ++i) {
5727 Error("DeleteArray", "fStreamerInfo->At(%d): %p", v, fStreamerInfo->At(i));
5728 if (fStreamerInfo->At(i)) {
5729 Error("DeleteArray", "Doing Dump() ...");
5731 }
5732 }
5733 }
5734 } else {
5735 // The loaded class version is not the same as the version of the code
5736 // which was used to allocate this array. The best we can do is use
5737 // the TVirtualStreamerInfo to try to free up some of the allocated memory.
5739 if (si) {
5740 si->DeleteArray(ary, dtorOnly);
5741 } else {
5742 Error("DeleteArray", "No streamer info available for class '%s' version %d at address %p, cannot destruct object!", GetName(), objVer, ary);
5743 Error("DeleteArray", "length of fStreamerInfo is %d", fStreamerInfo->GetSize());
5745 for (Int_t v = 0; v < fStreamerInfo->GetSize(); ++v, ++i) {
5746 Error("DeleteArray", "fStreamerInfo->At(%d): %p", v, fStreamerInfo->At(i));
5747 if (fStreamerInfo->At(i)) {
5748 // Print some debugging info.
5749 Error("DeleteArray", "Doing Dump() ...");
5751 }
5752 }
5753 }
5754 }
5755
5756 // Deregister the object for special handling in the destructor.
5757 if (inRepo && p) {
5758 UnregisterAddressInRepository("TClass::DeleteArray",p,this);
5759 }
5760 } else {
5761 Error("DeleteArray", "This cannot happen! (class '%s')", GetName());
5762 }
5763}
5764
5765////////////////////////////////////////////////////////////////////////////////
5766/// Explicitly call operator delete[] for an array.
5767
5769{
5770 // Do nothing if passed a null pointer.
5771 if (obj.GetPtr() == nullptr) return;
5772
5773 if (obj.GetAllocator()) {
5774 obj.GetAllocator()->DeleteArray(obj.GetPtr(), dtorOnly);
5775 } else {
5776 DeleteArray(obj.GetPtr(), dtorOnly);
5777 }
5778}
5779
5780////////////////////////////////////////////////////////////////////////////////
5781/// Set the splitability of this class:
5782/// - -1: Use the default calculation
5783/// - 0: Disallow splitting
5784/// - 1: Always allow splitting.
5785/// - 2: Disallow splitting of the class and splitting of any it's derived classes.
5786
5788{
5789 fCanSplit = splitmode;
5790}
5791
5792////////////////////////////////////////////////////////////////////////////////
5793/// Private function. Set the class version for the 'class' represented by
5794/// this TClass object. See the public interface:
5795/// ROOT::ResetClassVersion
5796/// defined in TClassTable.cxx
5797///
5798/// Note on class version numbers:
5799/// - If no class number has been specified, TClass::GetVersion will return -1
5800/// - The Class Version 0 request the whole object to be transient
5801/// - The Class Version 1, unless specified via ClassDef indicates that the
5802/// I/O should use the TClass checksum to distinguish the layout of the class
5803
5805{
5806 fClassVersion = version;
5807 fCurrentInfo = nullptr;
5808}
5809
5810////////////////////////////////////////////////////////////////////////////////
5811/// Determine and set pointer to current TVirtualStreamerInfo
5812
5821
5822////////////////////////////////////////////////////////////////////////////////
5823/// Set pointer to current TVirtualStreamerInfo
5824
5829
5830////////////////////////////////////////////////////////////////////////////////
5831/// Return the alignment requirement (in bytes) for objects of this class.
5832///
5833/// Returns (size_t)-1 if the class info is invalid, 0 for a forward-declared
5834/// class, an enum, a namespace or or a class with no definition. For all other
5835/// cases the actual alignment obtained from the dictionary or the clang ASTRecordLayout,
5836/// or the StreamerInfo (in that order of priority) is returned.
5837///
5838/// Returns `0` when the alignment cannot be determined.
5839
5841{
5842 auto alignment = fAlignment.load(std::memory_order_relaxed);
5843 if (alignment != 0)
5844 return alignment;
5846 return 0;
5847 if (HasInterpreterInfo()) {
5848 if (Property() & (kIsNamespace | kIsEnum))
5849 return 0;
5851 if (alignment != 0)
5852 fAlignment.store(alignment, std::memory_order_relaxed);
5853 return alignment;
5854 }
5855 if (fCollectionProxy) {
5856 // If the collection proxy has a dictionary, it will have return earlier,
5857 // so we know that the collection proxy is emulated.
5859 Fatal("TClass::GetClassAlignment", "Cannot determine alignment for collection proxy of class %s.", GetName());
5860 return 0;
5861 }
5862 return alignof(std::vector<char>);
5863 }
5864 assert(GetStreamerInfo() && GetStreamerInfo()->GetClassAlignment() != 0);
5866}
5867
5868////////////////////////////////////////////////////////////////////////////////
5869/// Return size of object of this class.
5870
5872{
5873 auto size = fSizeof.load(std::memory_order_relaxed);
5874 if (size != -1) return size;
5876 if (HasInterpreterInfo()) {
5878 if (size >= 0)
5879 fSizeof.store(size, std::memory_order_relaxed);
5880 return size;
5881 }
5882 return GetStreamerInfo()->GetSize();
5883}
5884
5885////////////////////////////////////////////////////////////////////////////////
5886/// Load class description from I/O buffer and return class object.
5887
5889{
5890 UInt_t maxsize = 256;
5891 char *s = new char[maxsize];
5892
5893 Int_t pos = b.Length();
5894
5895 b.ReadString(s, maxsize); // Reads at most maxsize - 1 characters, plus null at end.
5896 while (strlen(s) == (maxsize - 1)) {
5897 // The classname is too large, try again with a large buffer.
5898 b.SetBufferOffset(pos);
5899 maxsize = 2*maxsize;
5900 delete [] s;
5901 s = new char[maxsize];
5902 b.ReadString(s, maxsize); // Reads at most maxsize - 1 characters, plus null at end.
5903 }
5904
5905 TClass *cl = TClass::GetClass(s, kTRUE);
5906 if (!cl)
5907 ::Error("TClass::Load", "dictionary of class %s not found", s);
5908
5909 delete [] s;
5910 return cl;
5911}
5912
5913////////////////////////////////////////////////////////////////////////////////
5914/// Helper function used by TClass::GetClass().
5915/// This function attempts to load the dictionary for 'classname'
5916/// either from the TClassTable or from the list of generator.
5917/// If silent is 'true', do not warn about missing dictionary for the class.
5918/// (typically used for class that are used only for transient members)
5919///
5920/// The 'requestedname' is expected to be already normalized.
5921
5922TClass *TClass::LoadClass(const char *requestedname, Bool_t silent)
5923{
5924 // This function does not (and should not) attempt to check in the
5925 // list of loaded classes or in the typedef.
5926
5928
5929 TClass *result = LoadClassDefault(requestedname, silent);
5930
5931 if (result) return result;
5932 else return LoadClassCustom(requestedname,silent);
5933}
5934
5935////////////////////////////////////////////////////////////////////////////////
5936/// Helper function used by TClass::GetClass().
5937/// This function attempts to load the dictionary for 'classname' from
5938/// the TClassTable or the autoloader.
5939/// If silent is 'true', do not warn about missing dictionary for the class.
5940/// (typically used for class that are used only for transient members)
5941///
5942/// The 'requestedname' is expected to be already normalized.
5943
5944TClass *TClass::LoadClassDefault(const char *requestedname, Bool_t /* silent */)
5945{
5946 // This function does not (and should not) attempt to check in the
5947 // list of loaded classes or in the typedef.
5948
5949 DictFuncPtr_t dict = TClassTable::GetDictNorm(requestedname);
5950
5951 if (!dict) {
5952 if (gInterpreter->AutoLoad(requestedname, kTRUE)) {
5953 dict = TClassTable::GetDictNorm(requestedname);
5954 }
5955 }
5956
5957 if (dict) {
5958 TClass *ncl = (dict)();
5959 if (ncl) ncl->PostLoadCheck();
5960 return ncl;
5961 }
5962 return nullptr;
5963}
5964
5965////////////////////////////////////////////////////////////////////////////////
5966/// Helper function used by TClass::GetClass().
5967/// This function attempts to load the dictionary for 'classname'
5968/// from the list of generator.
5969/// If silent is 'true', do not warn about missing dictionary for the class.
5970/// (typically used for class that are used only for transient members)
5971///
5972/// The 'requestedname' is expected to be already normalized.
5973
5974TClass *TClass::LoadClassCustom(const char *requestedname, Bool_t silent)
5975{
5976 // This function does not (and should not) attempt to check in the
5977 // list of loaded classes or in the typedef.
5978
5979 TIter next(gROOT->GetListOfClassGenerators());
5980 TClassGenerator *gen;
5981 while ((gen = (TClassGenerator*) next())) {
5982 TClass *cl = gen->GetClass(requestedname, kTRUE, silent);
5983 if (cl) {
5984 cl->PostLoadCheck();
5985 return cl;
5986 }
5987 }
5988 return nullptr;
5989}
5990
5991////////////////////////////////////////////////////////////////////////////////
5992/// Try to load the ClassInfo if available. This function may require parsing
5993/// the header file and/or loading data from the clang pcm. If further calls to
5994/// this function cannot affect the value of fClassInfo, fCanLoadClassInfo is set
5995/// to false.
5996
5998{
6000
6001 // Return if another thread already loaded the info
6002 // while we were waiting for the lock
6004 return;
6005
6006 bool autoParse = !gInterpreter->IsAutoParsingSuspended();
6007
6008 if (autoParse && !fClassInfo)
6009 gInterpreter->AutoParse(GetName());
6010
6011 if (!fClassInfo) // Could be indirectly set by the parsing
6012 gInterpreter->SetClassInfo(const_cast<TClass *>(this));
6013
6014 if (autoParse && !fClassInfo) {
6015 if (fImplFileLine == -1 && fClassVersion == 0) {
6016 // We have a 'transient' class with a ClassDefInline and apparently no interpreter
6017 // information. Since it is transient, it is more than likely that the lack
6018 // will be harmles.
6019 } else {
6020 ::Error("TClass::LoadClassInfo", "no interpreter information for class %s is available"
6021 " even though it has a TClass initialization routine.",
6022 fName.Data());
6023 }
6024 }
6025
6026 // Keep trying to load the ClassInfo, since we have no ClassInfo yet,
6027 // we will get an update even when there is an explicit load. So whether
6028 // or not the autoparsing is on, we will need to keep trying to load
6029 // the ClassInfo.
6031}
6032
6033////////////////////////////////////////////////////////////////////////////////
6034/// Store class description on I/O buffer.
6035
6037{
6038 b.WriteString(GetName());
6039}
6040
6041////////////////////////////////////////////////////////////////////////////////
6042/// Global function called by a class' static Dictionary() method
6043/// (see the ClassDef macro).
6044
6046 const std::type_info &info, TVirtualIsAProxy *isa,
6047 const char *dfil, const char *ifil,
6048 Int_t dl, Int_t il)
6049{
6050 // When called via TMapFile (e.g. Update()) make sure that the dictionary
6051 // gets allocated on the heap and not in the mapped file.
6052 TMmallocDescTemp setreset;
6053 return new TClass(cname, id, info, isa, dfil, ifil, dl, il);
6054}
6055
6056////////////////////////////////////////////////////////////////////////////////
6057/// Global function called by a class' static Dictionary() method
6058/// (see the ClassDef macro).
6059
6061 const char *dfil, const char *ifil,
6062 Int_t dl, Int_t il)
6063{
6064 // When called via TMapFile (e.g. Update()) make sure that the dictionary
6065 // gets allocated on the heap and not in the mapped file.
6066 TMmallocDescTemp setreset;
6067 return new TClass(cname, id, dfil, ifil, dl, il);
6068}
6069
6070////////////////////////////////////////////////////////////////////////////////
6071/// Static method returning the defConstructor flag passed to TClass::New().
6072/// New type is either:
6073/// - TClass::kRealNew - when called via plain new
6074/// - TClass::kClassNew - when called via TClass::New()
6075/// - TClass::kDummyNew - when called via TClass::New() but object is a dummy,
6076/// in which case the object ctor might take short cuts
6077
6082
6083////////////////////////////////////////////////////////////////////////////////
6084/// Return true if the shared library of this class is currently in the a
6085/// process's memory. Return false, after the shared library has been
6086/// unloaded or if this is an 'emulated' class created from a file's StreamerInfo.
6087
6089{
6090 return fState == kHasTClassInit;
6091}
6092
6093////////////////////////////////////////////////////////////////////////////////
6094/// Returns true if this class inherits from TObject and if the start of
6095/// the TObject parts is at the very beginning of the objects.
6096/// Concretely this means that the following code is proper for this class:
6097/// ~~~ {.cpp}
6098/// ThisClass *ptr;
6099/// void *void_ptr = (void)ptr;
6100/// TObject *obj = (TObject*)void_ptr;
6101/// ~~~
6102/// This code would be wrong if 'ThisClass' did not inherit 'first' from
6103/// TObject.
6104
6106{
6107 if (fProperty==(-1)) Property();
6108 return TestBit(kStartWithTObject);
6109}
6110
6111////////////////////////////////////////////////////////////////////////////////
6112/// Return kTRUE is the class inherits from TObject.
6113
6115{
6116 if (fProperty==(-1)) Property();
6117 return TestBit(kIsTObject);
6118}
6119
6120////////////////////////////////////////////////////////////////////////////////
6121/// Return kTRUE is the class is Foreign (the class does not have a Streamer method).
6122
6124{
6125 if (fProperty==(-1)) Property();
6126 // If the property are not set and the class is a pair, hard code that
6127 // it is a unversioned/Foreign class.
6128 return TestBit(kIsForeign);
6129}
6130
6131////////////////////////////////////////////////////////////////////////////////
6132/// Do the initialization that can only be done after the CINT dictionary has
6133/// been fully populated and can not be delayed efficiently.
6134
6136{
6137 // In the case of a Foreign class (loaded class without a Streamer function)
6138 // we reset fClassVersion to be -1 so that the current TVirtualStreamerInfo will not
6139 // be confused with a previously loaded streamerInfo.
6140
6141 if (IsLoaded() && HasInterpreterInfo() && fClassVersion==1 /*&& fStreamerInfo
6142 && fStreamerInfo->At(1)*/ && IsForeign() )
6143 {
6144 SetClassVersion(-1);
6145 }
6146 // Note: We are careful to check the class version first because checking
6147 // for foreign can trigger an AutoParse.
6148 else if (IsLoaded() && HasDataMemberInfo() && fStreamerInfo && ((fClassVersion > 1) || !IsForeign()))
6149 {
6151
6153 // Here we need to check whether this TVirtualStreamerInfo (which presumably has been
6154 // loaded from a file) is consistent with the definition in the library we just loaded.
6155 // BuildCheck is not appropriate here since it check a streamerinfo against the
6156 // 'current streamerinfo' which, at time point, would be the same as 'info'!
6157 if (info && GetListOfDataMembers() && !GetCollectionProxy()
6158 && (info->GetCheckSum()!=GetCheckSum() && !info->CompareContent(this,nullptr,kFALSE,kFALSE, nullptr) && !(MatchLegacyCheckSum(info->GetCheckSum()))))
6159 {
6160 Bool_t warn = ! TestBit(kWarned);
6161 if (warn && info->GetOldVersion()<=2) {
6162 // Names of STL base classes was modified in vers==3. Allocators removed
6163 //
6164 TIter nextBC(GetListOfBases());
6165 TBaseClass *bc;
6166 while ((bc=(TBaseClass*)nextBC()))
6167 {if (TClassEdit::IsSTLCont(bc->GetName())) warn = kFALSE;}
6168 }
6169
6170 if (warn) {
6171 if (info->GetOnFileClassVersion()==1 && fClassVersion>1) {
6172 Warning("PostLoadCheck","\n\
6173 The class %s transitioned from not having a specified class version\n\
6174 to having a specified class version (the current class version is %d).\n\
6175 However too many different non-versioned layouts of the class have\n\
6176 already been loaded so far. To work around this problem you can\n\
6177 load fewer 'old' file in the same ROOT session or load the C++ library\n\
6178 describing the class %s before opening the files or increase the version\n\
6179 number of the class for example ClassDef(%s,%d).\n\
6180 Do not try to write objects with the current class definition,\n\
6181 the files might not be readable.\n",
6183 } else {
6184 Warning("PostLoadCheck","\n\
6185 The StreamerInfo version %d for the class %s which was read\n\
6186 from a file previously opened has the same version as the active class\n\
6187 but a different checksum. You should update the version to ClassDef(%s,%d).\n\
6188 Do not try to write objects with the current class definition,\n\
6189 the files will not be readable.\n"
6191 }
6192 info->CompareContent(this,nullptr,kTRUE,kTRUE,nullptr);
6193 SetBit(kWarned);
6194 }
6195 }
6196 }
6197 if (fCollectionProxy) {
6198 // Update the related pair's TClass if it has already been created.
6199 std::vector<std::string> inside;
6200 int nested = 0;
6201 const auto num = TClassEdit::GetSplit(GetName(), inside, nested);
6202 std::string pairname;
6203 if (num >= 4) {
6204 switch (TClassEdit::STLKind(inside[0])) {
6205 case ROOT::kSTLmap:
6206 case ROOT::kSTLmultimap:
6209 pairname = "pair<" + inside[1] + "," + inside[2];
6210 pairname += (pairname.back() == '>') ? " >" : ">";
6211 break;
6212 default:
6213 break;
6214 }
6215 }
6216 if (!pairname.empty()) {
6217 auto pcl = TClass::GetClass(pairname.c_str(), false, false);
6218 if ( pcl && !pcl->IsLoaded() && !pcl->IsSyntheticPair() )
6219 {
6221
6223 TIter nextClass(gROOT->GetListOfClasses());
6224 while (auto acl = (TClass*)nextClass()) {
6225 if (acl == this) continue;
6226 if (acl->fCollectionProxy && acl->fCollectionProxy->GetValueClass() == pcl) {
6227 acl->fCollectionProxy->Reset();
6228 }
6229 }
6230
6231 TIter next(pcl->GetStreamerInfos());
6232 while (auto info = (TVirtualStreamerInfo*)next()) {
6233 if (info->IsBuilt()) {
6234 info->Clear("build");
6235 info->BuildOld();
6236 }
6237 }
6239 }
6240 }
6241 }
6242}
6243
6244////////////////////////////////////////////////////////////////////////////////
6245/// Returns the properties of the TClass as a bit field stored as a `Long_t` value.
6246///
6247/// The bit values used for the return value are defined in the enum EProperty (in TDictionary.h)
6248///
6249/// Also sets `TObject::fBits` and `fStreamerType` to cache information about the
6250/// class. The bits stored in `TObject::fBits` are
6251/// ~~~ {.cpp}
6252/// kIsTObject : the class inherits from TObject
6253/// kStartWithTObject: TObject is the left-most class in the inheritance tree
6254/// kIsForeign : the class doe not have a Streamer method
6255/// ~~~
6256/// The value of `fStreamerType` are
6257/// ~~~ {.cpp}
6258/// kTObject : the class inherits from TObject
6259/// kForeign : the class does not have a Streamer method
6260/// kInstrumented: the class does have a Streamer method
6261/// kExternal: the class has a free standing way of streaming itself
6262/// kEmulatedStreamer: the class is missing its shared library.
6263/// ~~~
6264///
6265/// Implementation note: the data member fProperty has the value -1
6266/// until it is initialized.
6267
6269{
6270 // Check if we can return without taking the lock,
6271 // this is valid since fProperty is atomic and set as
6272 // the last operation before return.
6273 if (fProperty!=(-1)) return fProperty;
6274
6276
6277 // Check if another thread set fProperty while we
6278 // were waiting.
6279 if (fProperty!=(-1)) return fProperty;
6280
6281 // Avoid asking about the class when it is still building
6282 if (TestBit(kLoading)) return fProperty;
6283
6285 // We have no interpreter information but we already set the streamer type
6286 // so we have already been here and have no new information, then let's
6287 // give up. See the code at this end of this routine (else branch of the
6288 // `if (HasInterpreterInfo()` for the path we took before.
6289 return 0;
6290 }
6291
6292 // When called via TMapFile (e.g. Update()) make sure that the dictionary
6293 // gets allocated on the heap and not in the mapped file.
6294 TMmallocDescTemp setreset;
6295
6296 TClass *kl = const_cast<TClass*>(this);
6297
6298 Int_t streamerType = TClass::kDefault;
6299
6301 kl->SetBit(kIsTObject);
6302
6303 // Is it DIRECT inheritance from TObject?
6305 if (delta==0) kl->SetBit(kStartWithTObject);
6306
6307 streamerType = kTObject;
6308 }
6309
6310 if (HasInterpreterInfo()) {
6311
6312 // This code used to use ClassInfo_Has|IsValidMethod but since v6
6313 // they return true if the routine is defined in the class or any of
6314 // its parent. We explicitly want to know whether the function is
6315 // defined locally.
6316 if (!const_cast<TClass*>(this)->GetClassMethodWithPrototype("Streamer","TBuffer&",kFALSE)) {
6317
6318 kl->SetBit(kIsForeign);
6319 streamerType = kForeign;
6320
6321 } else if (streamerType == TClass::kDefault) {
6322 if (kl->fConvStreamerFunc) {
6323 streamerType = kInstrumented;
6324 } else if (kl->fStreamerFunc) {
6325 streamerType = kInstrumented;
6326 } else {
6327 // We have an automatic streamer using the StreamerInfo .. no need to go through the
6328 // Streamer method function itself.
6329 streamerType = kInstrumented;
6330 }
6331 }
6332
6333 if (fStreamer) {
6334 streamerType = kExternal;
6335 }
6336
6337 if (const_cast<TClass *>(this)->GetClassMethodWithPrototype("Hash", "", kTRUE)) {
6339 }
6340
6341 kl->SetStreamerImpl(streamerType);
6342
6343 if (GetClassInfo()) {
6344 // In the case where the TClass for one of ROOT's core class
6345 // (eg TClonesArray for map<int,TClonesArray*>) is requested
6346 // during the execution of rootcling, we could end up in a situation
6347 // where we should have the information (since TClonesArray has
6348 // a dictionary as part of libCore) but do not because the user
6349 // only include a forward declaration of TClonesArray and we do not
6350 // forcefully load the header file either (because the autoparsing
6351 // is intentionally disabled).
6353 // Must set this last since other threads may read fProperty
6354 // and think all test bits have been properly set.
6356 }
6357
6358 } else {
6359
6360 if (fStreamer) {
6361 streamerType = kExternal;
6362 }
6363
6364 streamerType |= kEmulatedStreamer;
6365
6366 kl->SetStreamerImpl(streamerType);
6367 // fProperty was *not* set so that it can be forced to be recalculated
6368 // next time.
6369 return 0;
6370 }
6371
6372 return fProperty;
6373}
6374
6375////////////////////////////////////////////////////////////////////////////////
6376/// Internal routine to set calculate the class properties that can only be
6377/// known at run-time, for example whether the Hash member function and the
6378/// destructor are consistent.
6379
6381{
6382 // For now, no need to lock this routines as fRuntimeProperties is
6383 // the only atomic set here and this is done at the end
6384 // and there is no downside if the execution is done twice.
6385
6386 // Note SetRuntimeProperties is set to const as it is technically
6387 // thread-safe.
6388
6389 UChar_t properties = static_cast<UChar_t>(ERuntimeProperties::kSet);
6390
6392 properties |= static_cast<UChar_t>(ERuntimeProperties::kConsistentHash);
6393
6394 const_cast<TClass *>(this)->fRuntimeProperties = properties;
6395}
6396
6397////////////////////////////////////////////////////////////////////////////////
6398/// Internal routine to set fStreamerImpl based on the value of
6399/// fStreamerType.
6400
6402{
6403 fStreamerType = StreamerType;
6404 switch (fStreamerType) {
6408 case kInstrumented: {
6412 break;
6413 }
6414
6415 case kEmulatedStreamer: // intentional fall through
6416 case kForeign|kEmulatedStreamer: // intentional fall through
6421 default:
6422 Error("SetStreamerImpl","Unexpected value of fStreamerType: %d",fStreamerType);
6423 }
6424}
6425
6426
6427////////////////////////////////////////////////////////////////////////////////
6428/// Create the collection proxy object (and the streamer object) from
6429/// using the information in the TCollectionProxyInfo.
6430
6432{
6434
6435 delete fCollectionProxy;
6436
6437 // We can not use GetStreamerInfo() instead of TVirtualStreamerInfo::Factory()
6438 // because GetStreamerInfo call TStreamerInfo::Build which need to have fCollectionProxy
6439 // set correctly.
6440
6443
6444 AdoptStreamer(TVirtualStreamerInfo::Factory()->GenExplicitClassStreamer(info,this));
6445
6447 // Numeric Collections have implicit conversions:
6449 }
6450 fCanSplit = -1;
6451}
6452
6453////////////////////////////////////////////////////////////////////////////////
6454/// Change (i.e. set) the title of the TNamed.
6455
6456void TClass::SetContextMenuTitle(const char *title)
6457{
6458 fContextMenuTitle = title;
6459}
6460
6461////////////////////////////////////////////////////////////////////////////////
6462/// This function installs a global IsA function for this class.
6463/// The global IsA function will be used if there is no local IsA function (fIsA)
6464///
6465/// A global IsA function has the signature:
6466///
6467/// ~~~ {.cpp}
6468/// TClass *func( TClass *cl, const void *obj);
6469/// ~~~
6470///
6471/// 'cl' is a pointer to the TClass object that corresponds to the
6472/// 'pointer type' used to retrieve the value 'obj'
6473///
6474/// For example with:
6475/// ~~~ {.cpp}
6476/// TNamed * m = new TNamed("example","test");
6477/// TObject* o = m
6478/// ~~~
6479/// and
6480/// the global IsA function would be called with TObject::Class() as
6481/// the first parameter and the exact numerical value in the pointer
6482/// 'o'.
6483///
6484/// In other word, inside the global IsA function. it is safe to C-style
6485/// cast the value of 'obj' into a pointer to the class described by 'cl'.
6486
6488{
6489 fGlobalIsA = func;
6490}
6491
6492////////////////////////////////////////////////////////////////////////////////
6493/// Call this method to indicate that the shared library containing this
6494/// class's code has been removed (unloaded) from the process's memory
6495/// The caller of this calss should be holding the ROOT Write lock.
6496
6498{
6499 if (TestBit(kUnloaded) && !TestBit(kUnloading)) {
6500 // Don't redo the work.
6501 return;
6502 }
6504
6505 //R__ASSERT(fState == kLoaded);
6506 if (fState != kLoaded) {
6507 Fatal("SetUnloaded","The TClass for %s is being unloaded when in state %d\n",
6508 GetName(),(int)fState);
6509 }
6510
6512
6513 // Make sure SetClassInfo, re-calculated the state.
6515
6516 delete fIsA; fIsA = nullptr;
6517 // Disable the autoloader while calling SetClassInfo, to prevent
6518 // the library from being reloaded!
6519 {
6522 gInterpreter->SetClassInfo(this,kTRUE);
6523 }
6524 fDeclFileName = nullptr;
6525 fDeclFileLine = 0;
6526 fImplFileName = nullptr;
6527 fImplFileLine = 0;
6528 fTypeInfo = nullptr;
6529
6530 if (fMethod.load()) {
6531 (*fMethod).Unload();
6532 }
6533 if (fData.load()) {
6534 (*fData).Unload();
6535 }
6536 if (fUsingData.load()) {
6537 (*fUsingData).Unload();
6538 }
6539 if (fEnums.load()) {
6540 (*fEnums).Unload();
6541 }
6542
6543 if (fState <= kForwardDeclared && !fStreamerInfo->IsEmpty()) {
6544 fState = kEmulated;
6545 }
6546
6549}
6550
6551////////////////////////////////////////////////////////////////////////////////
6552/// Info is a string describing the names and types of attributes
6553/// written by the class Streamer function.
6554/// If info is an empty string (when called by TObject::StreamerInfo)
6555/// the default Streamer info string is build. This corresponds to
6556/// the case of an automatically generated Streamer.
6557/// In case of user defined Streamer function, it is the user responsibility
6558/// to implement a StreamerInfo function (override TObject::StreamerInfo).
6559/// The user must call IsA()->SetStreamerInfo(info) from this function.
6560
6561TVirtualStreamerInfo *TClass::SetStreamerInfo(Int_t /*version*/, const char * /*info*/)
6562{
6563 // info is specified, nothing to do, except that we should verify
6564 // that it contains a valid descriptor.
6565
6566/*
6567 TDataMember *dm;
6568 Int_t nch = info ? strlen(info) : 0;
6569 Bool_t update = kTRUE;
6570 if (nch != 0) {
6571 //decode strings like "TObject;TAttLine;fA;fB;Int_t i,j,k;"
6572 char *save, *temp, *blank, *colon, *comma;
6573 save = new char[10000];
6574 temp = save;
6575 strlcpy(temp,info,10000);
6576 //remove heading and trailing blanks
6577 while (*temp == ' ') temp++;
6578 while (save[nch-1] == ' ') {nch--; save[nch] = 0;}
6579 if (nch == 0) {delete [] save; return;}
6580 if (save[nch-1] != ';') {save[nch] = ';'; save[nch+1] = 0;}
6581 //remove blanks around , or ;
6582 while ((blank = strstr(temp,"; "))) strcpy(blank+1,blank+2);
6583 while ((blank = strstr(temp," ;"))) strcpy(blank, blank+1);
6584 while ((blank = strstr(temp,", "))) strcpy(blank+1,blank+2);
6585 while ((blank = strstr(temp," ,"))) strcpy(blank, blank+1);
6586 while ((blank = strstr(temp," "))) strcpy(blank, blank+1);
6587 //loop on tokens separated by ;
6588 char *final = new char[1000];
6589 char token[100];
6590 while ((colon=strchr(temp,';'))) {
6591 *colon = 0;
6592 strlcpy(token,temp,100);
6593 blank = strchr(token,' ');
6594 if (blank) {
6595 *blank = 0;
6596 if (!gROOT->GetType(token)) {
6597 Error("SetStreamerInfo","Illegal type: %s in %s",token,info);
6598 return;
6599 }
6600 while (blank) {
6601 strlcat(final,token,1000);
6602 strlcat(final," ",1000);
6603 comma = strchr(blank+1,','); if (comma) *comma=0;
6604 strlcat(final,blank+1,1000);
6605 strlcat(final,";",1000);
6606 blank = comma;
6607 }
6608
6609 } else {
6610 if (TClass::GetClass(token,update)) {
6611 //a class name
6612 strlcat(final,token,1000); strlcat(final,";",1000);
6613 } else {
6614 //a data member name
6615 dm = (TDataMember*)GetListOfDataMembers()->FindObject(token);
6616 if (dm) {
6617 strlcat(final,dm->GetFullTypeName(),1000);
6618 strlcat(final," ",1000);
6619 strlcat(final,token,1000); strlcat(final,";",1000);
6620 } else {
6621 Error("SetStreamerInfo","Illegal name: %s in %s",token,info);
6622 return;
6623 }
6624 }
6625 update = kFALSE;
6626 }
6627 temp = colon+1;
6628 if (*temp == 0) break;
6629 }
6630 //// fStreamerInfo = final;
6631 delete [] final;
6632 delete [] save;
6633 return;
6634 }
6635
6636 //info is empty. Let's build the default Streamer descriptor
6637
6638 char *temp = new char[10000];
6639 temp[0] = 0;
6640 char local[100];
6641
6642 //add list of base classes
6643 TIter nextb(GetListOfBases());
6644 TBaseClass *base;
6645 while ((base = (TBaseClass*) nextb())) {
6646 snprintf(local,100,"%s;",base->GetName());
6647 strlcat(temp,local,10000);
6648 }
6649
6650 //add list of data members and types
6651 TIter nextd(GetListOfDataMembers());
6652 while ((dm = (TDataMember *) nextd())) {
6653 if (dm->IsEnum()) continue;
6654 if (!dm->IsPersistent()) continue;
6655 Long_t property = dm->Property();
6656 if (property & kIsStatic) continue;
6657 TClass *acl = TClass::GetClass(dm->GetTypeName(),update);
6658 update = kFALSE;
6659 if (acl) {
6660 if (acl->GetClassVersion() == 0) continue;
6661 }
6662
6663 // dm->GetArrayIndex() returns an empty string if it does not
6664 // applies
6665 const char * index = dm->GetArrayIndex();
6666 if (strlen(index)==0)
6667 snprintf(local,100,"%s %s;",dm->GetFullTypeName(),dm->GetName());
6668 else
6669 snprintf(local,100,"%s %s[%s];",dm->GetFullTypeName(),dm->GetName(),index);
6670 strlcat(temp,local,10000);
6671 }
6672 //fStreamerInfo = temp;
6673 delete [] temp;
6674*/
6675 return nullptr;
6676}
6677
6678////////////////////////////////////////////////////////////////////////////////
6679/// Return true if the checksum passed as argument is one of the checksum
6680/// value produced by the older checksum calculation algorithm.
6681
6683{
6684 for(UInt_t i = 1; i < kLatestCheckSum; ++i) {
6685 if ( checksum == GetCheckSum( (ECheckSum) i ) ) return kTRUE;
6686 }
6687 return kFALSE;
6688}
6689
6690////////////////////////////////////////////////////////////////////////////////
6691/// Call GetCheckSum with validity check.
6692
6694{
6695 bool isvalid;
6696 return GetCheckSum(code,isvalid);
6697}
6698
6699////////////////////////////////////////////////////////////////////////////////
6700/// Return GetCheckSum(kCurrentCheckSum,isvalid);
6701
6703{
6704 return GetCheckSum(kCurrentCheckSum,isvalid);
6705}
6706
6707////////////////////////////////////////////////////////////////////////////////
6708/// Compute and/or return the class check sum.
6709///
6710/// isvalid is set to false, if the function is unable to calculate the
6711/// checksum.
6712///
6713/// The class ckecksum is used by the automatic schema evolution algorithm
6714/// to uniquely identify a class version.
6715/// The check sum is built from the names/types of base classes and
6716/// data members.
6717/// Original algorithm from Victor Perevovchikov (perev@bnl.gov).
6718///
6719/// The valid range of code is determined by ECheckSum.
6720///
6721/// - kNoEnum: data members of type enum are not counted in the checksum
6722/// - kNoRange: return the checksum of data members and base classes, not including the ranges and array size found in comments.
6723/// - kWithTypeDef: use the sugared type name in the calculation.
6724///
6725/// This is needed for backward compatibility.
6726///
6727/// WARNING: this function must be kept in sync with TStreamerInfo::GetCheckSum.
6728/// They are both used to handle backward compatibility and should both return the same values.
6729/// TStreamerInfo uses the information in TStreamerElement while TClass uses the information
6730/// from TClass::GetListOfBases and TClass::GetListOfDataMembers.
6731
6733{
6734 // fCheckSum is an atomic variable. Also once it has
6735 // transition from a zero Value it never changes. If two
6736 // thread reach past this if statement and calculated the
6737 // 'kLastestCheckSum', they will by definition obtain the
6738 // same value, so technically we could simply have:
6739 // if (fCheckSum && code == kCurrentCheckSum) return fCheckSum;
6740 // However save a little bit of barrier time by calling load()
6741 // only once.
6742
6743 isvalid = kTRUE;
6744
6745 UInt_t currentChecksum = fCheckSum.load();
6746 if (currentChecksum && code == kCurrentCheckSum) return currentChecksum;
6747
6749
6750 // kCurrentCheckSum (0) is the default parameter value and should be kept
6751 // for backward compatibility, too be able to use the inequality checks,
6752 // we need to set the code to the largest value.
6753 if (code == kCurrentCheckSum) code = kLatestCheckSum;
6754
6755 UInt_t id = 0;
6756
6757 int il;
6758 TString name = GetName();
6759 TString type;
6760 il = name.Length();
6761 for (int i=0; i<il; i++) id = id*3+name[i];
6762
6763 // Here we skip he base classes in case this is a pair or STL collection,
6764 // otherwise, on some STL implementations, it can happen that pair has
6765 // base classes which are an internal implementation detail.
6766 TList *tlb = ((TClass*)this)->GetListOfBases();
6767 if (tlb && !GetCollectionProxy() && !TClassEdit::IsStdPair(GetName())) {
6768 // Loop over bases if not a proxied collection or a pair
6769
6770 TIter nextBase(tlb);
6771
6772 TBaseClass *tbc=nullptr;
6773 while((tbc=(TBaseClass*)nextBase())) {
6774 name = tbc->GetName();
6776 if (isSTL)
6778 il = name.Length();
6779 for (int i=0; i<il; i++) id = id*3+name[i];
6780 if (code > kNoBaseCheckSum && !isSTL) {
6781 if (tbc->GetClassPointer() == nullptr) {
6782 Error("GetCheckSum","Calculating the checksum for (%s) requires the base class (%s) meta information to be available!",
6783 GetName(),tbc->GetName());
6784 isvalid = kFALSE;
6785 return 0;
6786 } else
6787 id = id*3 + tbc->GetClassPointer()->GetCheckSum();
6788 }
6789 }/*EndBaseLoop*/
6790 }
6791 TList *tlm = ((TClass*)this)->GetListOfDataMembers();
6792 if (tlm) { // Loop over members
6793 TIter nextMemb(tlm);
6794 TDataMember *tdm=nullptr;
6795 Long_t prop = 0;
6796 while((tdm=(TDataMember*)nextMemb())) {
6797 if (!tdm->IsPersistent()) continue;
6798 // combine properties
6799 prop = (tdm->Property());
6800 TDataType* tdt = tdm->GetDataType();
6801 if (tdt) prop |= tdt->Property();
6802
6803 if ( prop&kIsStatic) continue;
6804 name = tdm->GetName(); il = name.Length();
6805 if ( (code > kNoEnum) && code != kReflex && code != kReflexNoComment && prop&kIsEnum)
6806 id = id*3 + 1;
6807
6808 int i;
6809 for (i=0; i<il; i++) id = id*3+name[i];
6810
6811 if (code > kWithTypeDef || code == kReflexNoComment) {
6812 type = tdm->GetTrueTypeName();
6813 // GetTrueTypeName uses GetFullyQualifiedName which already drops
6814 // the default template parameter, so we no longer need to do this.
6815 //if (TClassEdit::IsSTLCont(type))
6816 // type = TClassEdit::ShortType( type, TClassEdit::kDropStlDefault );
6817 if (code == kReflex || code == kReflexNoComment) {
6818 if (prop&kIsEnum) {
6819 type = "int";
6820 } else {
6821 type.ReplaceAll("ULong64_t","unsigned long long");
6822 type.ReplaceAll("Long64_t","long long");
6823 type.ReplaceAll("<signed char","<char");
6824 type.ReplaceAll(",signed char",",char");
6825 if (type=="signed char") type = "char";
6826 }
6827 }
6828 } else {
6829 type = tdm->GetFullTypeName();
6830 // GetFullTypeName uses GetFullyQualifiedName which already drops
6831 // the default template parameter, so we no longer need to do this.
6832 //if (TClassEdit::IsSTLCont(type))
6833 // type = TClassEdit::ShortType( type, TClassEdit::kDropStlDefault );
6834 }
6835
6836 il = type.Length();
6837 for (i=0; i<il; i++) id = id*3+type[i];
6838
6839 int dim = tdm->GetArrayDim();
6840 if (prop&kIsArray) {
6841 for (int ii=0;ii<dim;ii++) id = id*3+tdm->GetMaxIndex(ii);
6842 }
6843 if (code > kNoRange) {
6844 const char *left;
6845 if (code > TClass::kNoRangeCheck)
6847 else
6848 left = strstr(tdm->GetTitle(),"[");
6849 if (left) {
6850 const char *right = strstr(left,"]");
6851 if (right) {
6852 ++left;
6853 while (left != right) {
6854 id = id*3 + *left;
6855 ++left;
6856 }
6857 }
6858 }
6859 }
6860 }/*EndMembLoop*/
6861 }
6862 // This should be moved to Initialization time however the last time
6863 // we tried this cause problem, in particular in the end-of-process operation.
6864 if (code==kLatestCheckSum) fCheckSum = id;
6865 return id;
6866}
6867
6868////////////////////////////////////////////////////////////////////////////////
6869/// Adopt the Reference proxy pointer to indicate that this class
6870/// represents a reference.
6871/// When a new proxy is adopted, the old one is deleted.
6872
6874{
6876
6877 if ( fRefProxy ) {
6878 fRefProxy->Release();
6879 }
6880 fRefProxy = proxy;
6881 if ( fRefProxy ) {
6882 fRefProxy->SetClass(this);
6883 }
6884 fCanSplit = -1;
6885}
6886
6887////////////////////////////////////////////////////////////////////////////////
6888/// Adopt the TMemberStreamer pointer to by p and use it to Stream non basic
6889/// member name.
6890/// Returns false if the member streamer could not be adopted (which happens if this class had its StreamerInfo
6891/// compiled already).
6892/// This function transfers ownership of the `strm` pointer to the TClass, so it should not be used anymore on the
6893/// caller side. In particular, if `AdoptMemberStreamer` returns false `strm` has been deleted and becomes invalid.
6895{
6896 // Too late to add member streamers!
6897 if (fLastReadInfo && (*fLastReadInfo).IsCompiled()) {
6898 Error("AdoptMemberStreamer",
6899 "Cannot adopt member streamer for %s::%s: StreamerInfo for the class is already compiled.", GetName(),
6900 name);
6901 delete p;
6902 return false;
6903 }
6904
6905 if (fRealData) {
6906
6908
6909 TIter next(fRealData);
6910 TRealData *rd;
6911 while ((rd = (TRealData*)next())) {
6912 if (strcmp(rd->GetName(),name) == 0) {
6913 // If there is a TStreamerElement that took a pointer to the
6914 // streamer we should inform it!
6915 rd->AdoptStreamer(p);
6916 return true;
6917 }
6918 }
6919 }
6920
6921 Error("AdoptMemberStreamer", "Cannot adopt member streamer for %s::%s", GetName(), name);
6922 delete p;
6923 return false;
6924}
6925
6926////////////////////////////////////////////////////////////////////////////////
6927/// Install a new member streamer (p will be copied).
6928
6933
6934////////////////////////////////////////////////////////////////////////////////
6935/// Function called by the Streamer functions to deserialize information
6936/// from buffer b into object at p.
6937/// This function assumes that the class version and the byte count information
6938/// have been read.
6939/// - version is the version number of the class
6940/// - start is the starting position in the buffer b
6941/// - count is the number of bytes for this object in the buffer
6942
6943Int_t TClass::ReadBuffer(TBuffer &b, void *pointer, Int_t version, UInt_t start, UInt_t count)
6944{
6945 return b.ReadClassBuffer(this,pointer,version,start,count);
6946}
6947
6948////////////////////////////////////////////////////////////////////////////////
6949/// Function called by the Streamer functions to deserialize information
6950/// from buffer b into object at p.
6951
6953{
6954 return b.ReadClassBuffer(this,pointer);
6955}
6956
6957////////////////////////////////////////////////////////////////////////////////
6958/// Function called by the Streamer functions to serialize object at p
6959/// to buffer b. The optional argument info may be specified to give an
6960/// alternative StreamerInfo instead of using the default StreamerInfo
6961/// automatically built from the class definition.
6962/// For more information, see class TVirtualStreamerInfo.
6963
6964Int_t TClass::WriteBuffer(TBuffer &b, void *pointer, const char * /*info*/)
6965{
6966 b.WriteClassBuffer(this,pointer);
6967 return 0;
6968}
6969
6970////////////////////////////////////////////////////////////////////////////////
6971///There is special streamer for the class
6972
6973void TClass::StreamerExternal(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class)
6974{
6975 // case kExternal:
6976 // case kExternal|kEmulatedStreamer:
6977
6978 TClassStreamer *streamer = gThreadTsd ? pThis->GetStreamer() : pThis->fStreamer;
6979 streamer->Stream(b,object,onfile_class);
6980}
6981
6982////////////////////////////////////////////////////////////////////////////////
6983/// Case of TObjects
6984
6985void TClass::StreamerTObject(const TClass* pThis, void *object, TBuffer &b, const TClass * /* onfile_class */)
6986{
6987 // case kTObject:
6988
6989 if (!pThis->fIsOffsetStreamerSet) {
6990 pThis->CalculateStreamerOffset();
6991 }
6992 TObject *tobj = (TObject*)((Longptr_t)object + pThis->fOffsetStreamer);
6993 tobj->Streamer(b);
6994}
6995
6996////////////////////////////////////////////////////////////////////////////////
6997/// Case of TObjects when fIsOffsetStreamerSet is known to have been set.
6998
6999void TClass::StreamerTObjectInitialized(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
7000{
7001 if (R__likely(onfile_class == nullptr || pThis == onfile_class)) {
7002 TObject *tobj = (TObject *)((Longptr_t)object + pThis->fOffsetStreamer);
7003 tobj->Streamer(b);
7004 } else {
7005 // This is the case where we are reading an object of a derived class
7006 // but the class is not the same as the one we are streaming.
7007 // We need to call the Streamer of the base class.
7008 StreamerTObjectEmulated(pThis, object, b, onfile_class);
7009 }
7010}
7011
7012////////////////////////////////////////////////////////////////////////////////
7013/// Case of TObjects when we do not have the library defining the class.
7014
7015void TClass::StreamerTObjectEmulated(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class)
7016{
7017 // case kTObject|kEmulatedStreamer :
7018 if (b.IsReading()) {
7019 b.ReadClassEmulated(pThis, object, onfile_class);
7020 } else {
7021 b.WriteClassBuffer(pThis, object);
7022 }
7023}
7024
7025////////////////////////////////////////////////////////////////////////////////
7026/// Case of instrumented class with a library
7027
7028void TClass::StreamerInstrumented(const TClass* pThis, void *object, TBuffer &b, const TClass * /* onfile_class */)
7029{
7030 // case kInstrumented:
7031 pThis->fStreamerFunc(b,object);
7032}
7033
7034////////////////////////////////////////////////////////////////////////////////
7035/// Case of instrumented class with a library
7036
7037void TClass::ConvStreamerInstrumented(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class)
7038{
7039 // case kInstrumented:
7040 pThis->fConvStreamerFunc(b,object,onfile_class);
7041}
7042
7043////////////////////////////////////////////////////////////////////////////////
7044/// Case of where we should directly use the StreamerInfo.
7045/// - case kForeign:
7046/// - case kForeign|kEmulatedStreamer:
7047/// - case kInstrumented|kEmulatedStreamer:
7048/// - case kEmulatedStreamer:
7049
7050void TClass::StreamerStreamerInfo(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class)
7051{
7052 if (b.IsReading()) {
7053 b.ReadClassBuffer(pThis, object, onfile_class);
7054 //ReadBuffer (b, object);
7055 } else {
7056 //WriteBuffer(b, object);
7057 b.WriteClassBuffer(pThis, object);
7058 }
7059}
7060
7061////////////////////////////////////////////////////////////////////////////////
7062/// Default streaming in cases where either we have no way to know what to do
7063/// or if Property() has not yet been called.
7064
7065void TClass::StreamerDefault(const TClass* pThis, void *object, TBuffer &b, const TClass *onfile_class)
7066{
7067 if (pThis->fProperty==(-1)) {
7068 pThis->Property();
7069 }
7070
7071 // We could get here because after this thread started StreamerDefault
7072 // *and* before check fProperty, another thread might have call Property
7073 // and this fProperty when we read it, is not -1 and fStreamerImpl is
7074 // supposed to be set properly (no longer pointing to the default).
7075 if (pThis->fStreamerImpl.load() == &TClass::StreamerDefault) {
7076 pThis->Fatal("StreamerDefault", "fStreamerImpl not properly initialized (%d)", pThis->fStreamerType);
7077 } else {
7078 (*pThis->fStreamerImpl)(pThis,object,b,onfile_class);
7079 }
7080}
7081
7082////////////////////////////////////////////////////////////////////////////////
7083/// Adopt a TClassStreamer object. Ownership is transferred to this TClass
7084/// object.
7085
7087{
7088// // This code can be used to quickly test the STL Emulation layer
7089// Int_t k = TClassEdit::IsSTLCont(GetName());
7090// if (k==1||k==-1) { delete str; return; }
7091
7093
7094 if (fStreamer) delete fStreamer;
7095 if (str) {
7097 fStreamer = str;
7099 } else if (fStreamer) {
7100 // Case where there was a custom streamer and it is hereby removed,
7101 // we need to reset fStreamerType
7102 fStreamer = str;
7104 if (fProperty != -1) {
7105 fProperty = -1;
7106 Property();
7107 }
7108 }
7109}
7110
7111////////////////////////////////////////////////////////////////////////////////
7112/// Set a wrapper/accessor function around this class custom streamer.
7113
7115{
7117 if (fProperty != -1 && !fConvStreamerFunc &&
7118 ( (fStreamerFunc == nullptr && strm != nullptr) || (fStreamerFunc != nullptr && strm == nullptr) ) )
7119 {
7120 fStreamerFunc = strm;
7121
7122 // Since initialization has already been done, make sure to tweak it
7123 // for the new state.
7127 }
7128 } else {
7129 fStreamerFunc = strm;
7130 }
7131 fCanSplit = -1;
7132}
7133
7134////////////////////////////////////////////////////////////////////////////////
7135/// Set a wrapper/accessor function around this class custom conversion streamer.
7136
7138{
7140 if (fProperty != -1 &&
7141 ( (fConvStreamerFunc == nullptr && strm != nullptr) || (fConvStreamerFunc != nullptr && strm == nullptr) ) )
7142 {
7143 fConvStreamerFunc = strm;
7144
7145 // Since initialization has already been done, make sure to tweak it
7146 // for the new state.
7150 }
7151 } else {
7152 fConvStreamerFunc = strm;
7153 }
7154 fCanSplit = -1;
7155}
7156
7157
7158////////////////////////////////////////////////////////////////////////////////
7159/// Install a new wrapper around 'Browse'.
7160
7162{
7163 fBrowse = newBrowse;
7164}
7165
7166////////////////////////////////////////////////////////////////////////////////
7167/// Install a new wrapper around 'Merge'.
7168
7170{
7171 fMerge = newMerge;
7172}
7173
7174////////////////////////////////////////////////////////////////////////////////
7175/// Install a new wrapper around 'ResetAfterMerge'.
7176
7181
7182////////////////////////////////////////////////////////////////////////////////
7183/// Install a new wrapper around 'new'.
7184
7186{
7187 fNew = newFunc;
7188}
7189
7190////////////////////////////////////////////////////////////////////////////////
7191/// Install a new wrapper around 'new []'.
7192
7194{
7195 fNewArray = newArrayFunc;
7196}
7197
7198////////////////////////////////////////////////////////////////////////////////
7199/// Install a new wrapper around 'delete'.
7200
7202{
7203 fDelete = deleteFunc;
7204}
7205
7206////////////////////////////////////////////////////////////////////////////////
7207/// Install a new wrapper around 'delete []'.
7208
7210{
7211 fDeleteArray = deleteArrayFunc;
7212}
7213
7214////////////////////////////////////////////////////////////////////////////////
7215/// Install a new wrapper around the destructor.
7216
7218{
7219 fDestructor = destructorFunc;
7220}
7221
7222////////////////////////////////////////////////////////////////////////////////
7223/// Install a new wrapper around the directory auto add function.
7224/// The function autoAddFunc has the signature void (*)(void *obj, TDirectory dir)
7225/// and should register 'obj' to the directory if dir is not null
7226/// and unregister 'obj' from its current directory if dir is null
7227
7229{
7230 fDirAutoAdd = autoAddFunc;
7231}
7232
7233////////////////////////////////////////////////////////////////////////////////
7234/// Find the TVirtualStreamerInfo in the StreamerInfos corresponding to checksum
7235
7237{
7239 if (guess && guess->GetCheckSum() == checksum) {
7240 return guess;
7241 } else {
7242 if (fCheckSum == checksum)
7243 return GetStreamerInfo(0, isTransient);
7244
7246
7247 Int_t ninfos = fStreamerInfo->GetEntriesFast()-1;
7248 for (Int_t i=-1;i<ninfos;++i) {
7249 // TClass::fStreamerInfos has a lower bound not equal to 0,
7250 // so we have to use At and should not use UncheckedAt
7252 if (info && info->GetCheckSum() == checksum) {
7253 // R__ASSERT(i==info->GetClassVersion() || (i==-1&&info->GetClassVersion()==1));
7254 info->BuildOld();
7255 if (info->IsCompiled()) fLastReadInfo = info;
7256 return info;
7257 }
7258 }
7259 return nullptr;
7260 }
7261}
7262
7263////////////////////////////////////////////////////////////////////////////////
7264/// Find the TVirtualStreamerInfo in the StreamerInfos corresponding to checksum
7265
7267{
7269 Int_t ninfos = arr->GetEntriesFast()-1;
7270 for (Int_t i=-1;i<ninfos;i++) {
7271 // TClass::fStreamerInfos has a lower bound not equal to 0,
7272 // so we have to use At and should not use UncheckedAt
7274 if (!info) continue;
7275 if (info->GetCheckSum() == checksum) {
7276 R__ASSERT(i==info->GetClassVersion() || (i==-1&&info->GetClassVersion()==1));
7277 return info;
7278 }
7279 }
7280 return nullptr;
7281}
7282
7283////////////////////////////////////////////////////////////////////////////////
7284/// Return a Conversion StreamerInfo from the class 'classname' for version number 'version' to this class, if any.
7285
7286TVirtualStreamerInfo *TClass::GetConversionStreamerInfo( const char* classname, Int_t version ) const
7287{
7288 TClass *cl = TClass::GetClass( classname );
7289 if( !cl )
7290 return nullptr;
7291 return GetConversionStreamerInfo( cl, version );
7292}
7293
7294////////////////////////////////////////////////////////////////////////////////
7295/// Return a Conversion StreamerInfo from the class represented by cl for version number 'version' to this class, if any.
7296
7298{
7299 //----------------------------------------------------------------------------
7300 // Check if the classname was specified correctly
7301 /////////////////////////////////////////////////////////////////////////////
7302
7303 if( !cl )
7304 return nullptr;
7305
7306 if( cl == this )
7307 return GetStreamerInfo( version );
7308
7309 //----------------------------------------------------------------------------
7310 // Check if we already have it
7311 /////////////////////////////////////////////////////////////////////////////
7312
7313 TObjArray* arr = nullptr;
7314 if (fConversionStreamerInfo.load()) {
7315 std::map<std::string, TObjArray*>::iterator it;
7317
7318 it = (*fConversionStreamerInfo).find( cl->GetName() );
7319
7320 if( it != (*fConversionStreamerInfo).end() ) {
7321 arr = it->second;
7322 }
7323
7324 if( arr && version >= -1 && version < arr->GetSize() && arr->At( version ) )
7325 return (TVirtualStreamerInfo*) arr->At( version );
7326 }
7327
7329
7330 //----------------------------------------------------------------------------
7331 // We don't have the streamer info so find it in other class
7332 /////////////////////////////////////////////////////////////////////////////
7333
7334 const TObjArray *clSI = cl->GetStreamerInfos();
7335 TVirtualStreamerInfo* info = nullptr;
7336 if( version >= -1 && version < clSI->GetSize() )
7337 info = (TVirtualStreamerInfo*)clSI->At( version );
7338
7339 if (!info && cl->GetCollectionProxy()) {
7340 info = cl->GetStreamerInfo(); // instantiate the StreamerInfo for STL collections.
7341 }
7342
7343 if( !info )
7344 return nullptr;
7345
7346 //----------------------------------------------------------------------------
7347 // We have the right info so we need to clone it to create new object with
7348 // non artificial streamer elements and we should build it for current class
7349 /////////////////////////////////////////////////////////////////////////////
7350
7351 info = (TVirtualStreamerInfo*)info->Clone();
7352
7353 // When cloning the StreamerInfo we record (and thus restore)
7354 // the absolute value of the version, let's restore the sign.
7355 if (version == -1)
7356 info->SetClassVersion(-1);
7357
7358 if( !info->BuildFor( this ) ) {
7359 delete info;
7360 return nullptr;
7361 }
7362
7363 if (!info->IsCompiled()) {
7364 // Streamer info has not been compiled, but exists.
7365 // Therefore it was read in from a file and we have to do schema evolution?
7366 // Or it didn't have a dictionary before, but does now?
7367 info->BuildOld();
7368 }
7369
7370 //----------------------------------------------------------------------------
7371 // Cache this streamer info
7372 /////////////////////////////////////////////////////////////////////////////
7373
7374 if (!arr) {
7375 arr = new TObjArray(version+10, -1);
7376 if (!fConversionStreamerInfo.load()) {
7377 fConversionStreamerInfo = new std::map<std::string, TObjArray*>();
7378 }
7379 (*fConversionStreamerInfo)[cl->GetName()] = arr;
7380 }
7381 if (arr->At(info->GetClassVersion())) {
7382 Error("GetConversionStreamerInfo", "Conversion StreamerInfo from %s to %s version %d has already been created",
7383 this->GetName(), info->GetName(), info->GetClassVersion());
7384 delete arr->At(info->GetClassVersion());
7385 }
7386 arr->AddAtAndExpand( info, info->GetClassVersion() );
7387 return info;
7388}
7389
7390////////////////////////////////////////////////////////////////////////////////
7391/// Return a Conversion StreamerInfo from the class 'classname' for the layout represented by 'checksum' to this class, if any.
7392
7393TVirtualStreamerInfo *TClass::FindConversionStreamerInfo( const char* classname, UInt_t checksum ) const
7394{
7395 TClass *cl = TClass::GetClass( classname );
7396 if( !cl )
7397 return nullptr;
7398 return FindConversionStreamerInfo( cl, checksum );
7399}
7400
7401////////////////////////////////////////////////////////////////////////////////
7402/// Return a Conversion StreamerInfo from the class represented by cl for the layout represented by 'checksum' to this class, if any.
7403
7405{
7406 //---------------------------------------------------------------------------
7407 // Check if the classname was specified correctly
7408 /////////////////////////////////////////////////////////////////////////////
7409
7410 if( !cl )
7411 return nullptr;
7412
7413 if( cl == this )
7414 return FindStreamerInfo( checksum );
7415
7416 //----------------------------------------------------------------------------
7417 // Check if we already have it
7418 /////////////////////////////////////////////////////////////////////////////
7419
7420 TObjArray* arr = nullptr;
7421 TVirtualStreamerInfo* info = nullptr;
7422 if (fConversionStreamerInfo.load()) {
7423 std::map<std::string, TObjArray*>::iterator it;
7424
7426
7427 it = (*fConversionStreamerInfo).find( cl->GetName() );
7428
7429 if( it != (*fConversionStreamerInfo).end() ) {
7430 arr = it->second;
7431 }
7432 if (arr) {
7433 info = FindStreamerInfo( arr, checksum );
7434 }
7435 }
7436
7437 if( info )
7438 return info;
7439
7441
7442 //----------------------------------------------------------------------------
7443 // Get it from the foreign class
7444 /////////////////////////////////////////////////////////////////////////////
7445
7446 info = cl->FindStreamerInfo( checksum );
7447
7448 if( !info )
7449 return nullptr;
7450
7451 //----------------------------------------------------------------------------
7452 // We have the right info so we need to clone it to create new object with
7453 // non artificial streamer elements and we should build it for current class
7454 /////////////////////////////////////////////////////////////////////////////
7455
7456 int version = info->GetClassVersion();
7457 info = (TVirtualStreamerInfo*)info->Clone();
7458
7459 // When cloning the StreamerInfo we record (and thus restore)
7460 // the absolute value of the version, let's restore the sign.
7461 if (version == -1)
7462 info->SetClassVersion(-1);
7463
7464 if( !info->BuildFor( this ) ) {
7465 delete info;
7466 return nullptr;
7467 }
7468
7469 if (!info->IsCompiled()) {
7470 // Streamer info has not been compiled, but exists.
7471 // Therefore it was read in from a file and we have to do schema evolution?
7472 // Or it didn't have a dictionary before, but does now?
7473 info->BuildOld();
7474 }
7475
7476 //----------------------------------------------------------------------------
7477 // Cache this streamer info
7478 /////////////////////////////////////////////////////////////////////////////
7479
7480 if (!arr) {
7481 arr = new TObjArray(16, -2);
7482 if (!fConversionStreamerInfo.load()) {
7483 fConversionStreamerInfo = new std::map<std::string, TObjArray*>();
7484 }
7485 (*fConversionStreamerInfo)[cl->GetName()] = arr;
7486 }
7487 arr->AddAtAndExpand( info, info->GetClassVersion() );
7488
7489 return info;
7490}
7491
7492////////////////////////////////////////////////////////////////////////////////
7493/// Register a set of read rules for a target class.
7494///
7495/// Rules will end up here if they are created in a dictionary file that does not
7496/// contain the dictionary for the target class.
7497
7499 std::vector<::ROOT::Internal::TSchemaHelper> &&rules)
7500{
7502
7503 auto cl = TClass::GetClass(classname, false, false);
7504 if (cl) {
7505 auto rset = cl->GetSchemaRules(kTRUE);
7506 for (const auto &it : rules) {
7507 auto rule = new ROOT::TSchemaRule(type, cl->GetName(), it);
7508 TString errmsg;
7509 if (!rset->AddRule(rule, ROOT::Detail::TSchemaRuleSet::kCheckAll, &errmsg)) {
7510 ::Warning(
7511 "TGenericClassInfo",
7512 "The rule for class: \"%s\": version, \"%s\" and data members: \"%s\" has been skipped because %s.",
7513 cl->GetName(), it.fVersion.c_str(), it.fTarget.c_str(), errmsg.Data());
7514 delete rule;
7515 }
7516 }
7517 } else {
7518 auto &registry = GetReadRulesRegistry(type);
7519 auto ans = registry.try_emplace(classname, std::move(rules));
7520 if (!ans.second) {
7521 ans.first->second.insert(ans.first->second.end(), rules.begin(), rules.end());
7522 }
7523 }
7524}
7525
7526////////////////////////////////////////////////////////////////////////////////
7527/// Register the StreamerInfo in the given slot, change the State of the
7528/// TClass as appropriate.
7529
7531{
7532 if (info) {
7534 Int_t slot = info->GetClassVersion();
7536 && fStreamerInfo->At(slot) != nullptr
7537 && fStreamerInfo->At(slot) != info) {
7538 Error("RegisterStreamerInfo",
7539 "Register StreamerInfo for %s on non-empty slot (%d).",
7540 GetName(),slot);
7541 }
7542 fStreamerInfo->AddAtAndExpand(info, slot);
7543 if (fState <= kForwardDeclared) {
7544 fState = kEmulated;
7545 if (fCheckSum==0 && slot==fClassVersion) fCheckSum = info->GetCheckSum();
7546 }
7547 }
7548}
7549
7550////////////////////////////////////////////////////////////////////////////////
7551/// Remove and delete the StreamerInfo in the given slot.
7552/// Update the slot accordingly.
7553
7555{
7556 if (fStreamerInfo->GetSize() >= slot) {
7559 fStreamerInfo->RemoveAt(slot);
7560 if (fLastReadInfo.load() == info)
7561 fLastReadInfo = nullptr;
7562 if (fCurrentInfo.load() == info)
7563 fCurrentInfo = nullptr;
7564 delete info;
7565 if (fState == kEmulated && fStreamerInfo->GetEntries() == 0) {
7567 }
7568 }
7569}
7570
7571////////////////////////////////////////////////////////////////////////////////
7572/// Return true is the Hash/RecursiveRemove setup is consistent, i.e. when all
7573/// classes in the class hierarchy that overload TObject::Hash do call
7574/// ROOT::CallRecursiveRemoveIfNeeded in their destructor.
7575/// i.e. it is safe to call the Hash virtual function during the RecursiveRemove operation.
7576/// This routines is used for a small subset of the class for which we need
7577/// the answer before gROOT is properly initialized.
7578
7580{
7581 // Hand selection of correct classes, those classes should be
7582 // cross-checked in testHashRecursiveRemove.cxx
7583 static const char *handVerified[] = {
7584 "TEnvRec", "TDataType", "TObjArray", "TList", "THashList",
7585 "TClass", "TCling", "TInterpreter", "TMethod", "ROOT::Internal::TCheckHashRecursiveRemoveConsistency",
7586 "TCheckHashRecursiveRemoveConsistency", "TGWindow",
7587 "TDirectory", "TDirectoryFile", "TObject", "TH1",
7588 "TQClass", "TGlobal" };
7589
7590 if (cname && cname[0]) {
7591 for (auto cursor : handVerified) {
7592 if (strcmp(cname, cursor) == 0)
7593 return true;
7594 }
7595 }
7596 return false;
7597}
7598
7599////////////////////////////////////////////////////////////////////////////////
7600/// Return true is the Hash/RecursiveRemove setup is consistent, i.e. when all
7601/// classes in the class hierarchy that overload TObject::Hash do call
7602/// ROOT::CallRecursiveRemoveIfNeeded in their destructor.
7603/// i.e. it is safe to call the Hash virtual function during the RecursiveRemove operation.
7604
7609
7610////////////////////////////////////////////////////////////////////////////////
7611/// Return true if we have access to a constructor usable for I/O. This is
7612/// typically the default constructor but can also be a constructor specifically
7613/// marked for I/O (for example a constructor taking a TRootIOCtor* as an
7614/// argument). In other words, if this routine returns true, TClass::New is
7615/// guarantee to succeed.
7616/// To know if the class described by this TClass has a default constructor
7617/// (public or not), use
7618/// \code{.cpp}
7619/// cl->GetProperty() & kClassHasDefaultCtor
7620/// \endcode
7621/// To know if the class described by this TClass has a public default
7622/// constructor use:
7623/// \code{.cpp}
7624/// gInterpreter->ClassInfo_HasDefaultConstructor(aClass->GetClassInfo());
7625/// \endcode
7626
7628{
7629
7630 if (fNew) return kTRUE;
7631
7632 if (HasInterpreterInfo()) {
7635 }
7636 if (fCollectionProxy) {
7637 return kTRUE;
7638 }
7639 if (fCurrentInfo.load()) {
7640 // Emulated class, we know how to construct them via the TStreamerInfo
7641 return kTRUE;
7642 }
7643 return kFALSE;
7644}
7645
7646////////////////////////////////////////////////////////////////////////////////
7647/// Returns true if this class has an definition and/or overload of the
7648/// member function Hash.
7649///
7650/// For example to test if the class overload TObject::Hash use
7651/// ~~~ {.cpp}
7652/// if (cl->IsTObject() && cl->HasLocalHashMember())
7653/// ~~~
7654
7656{
7657 if (fProperty == (-1))
7658 Property();
7660}
7661
7662////////////////////////////////////////////////////////////////////////////////
7663/// Return the wrapper around Browse.
7664
7666{
7667 return fBrowse;
7668}
7669
7670////////////////////////////////////////////////////////////////////////////////
7671/// Return the wrapper around Merge.
7672
7674{
7675 return fMerge;
7676}
7677
7678////////////////////////////////////////////////////////////////////////////////
7679/// Return the wrapper around Merge.
7680
7685
7686////////////////////////////////////////////////////////////////////////////////
7687/// Return the wrapper around new ThisClass().
7688
7690{
7691 return fNew;
7692}
7693
7694////////////////////////////////////////////////////////////////////////////////
7695/// Return the wrapper around new ThisClass[].
7696
7698{
7699 return fNewArray;
7700}
7701
7702////////////////////////////////////////////////////////////////////////////////
7703/// Return the wrapper around delete ThisObject.
7704
7706{
7707 return fDelete;
7708}
7709
7710////////////////////////////////////////////////////////////////////////////////
7711/// Return the wrapper around delete [] ThisObject.
7712
7717
7718////////////////////////////////////////////////////////////////////////////////
7719/// Return the wrapper around the destructor
7720
7722{
7723 return fDestructor;
7724}
7725
7726////////////////////////////////////////////////////////////////////////////////
7727/// Return the wrapper around the directory auto add function.
7728
free(fBuffer)
#define R__likely(expr)
Definition RConfig.hxx:569
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define a(i)
Definition RSha256.hxx:99
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
short Version_t
Class version identifier (short)
Definition RtypesCore.h:80
unsigned char UChar_t
Unsigned Character 1 byte (unsigned char)
Definition RtypesCore.h:53
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:70
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:69
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:91
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:132
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
TClass *(* DictFuncPtr_t)()
Definition Rtypes.h:85
void(* MemberStreamerFunc_t)(TBuffer &, void *, Int_t)
Definition Rtypes.h:79
TClass *(* IsAGlobalFunc_t)(const TClass *, const void *obj)
Definition Rtypes.h:101
void(* ClassStreamerFunc_t)(TBuffer &, void *)
Definition Rtypes.h:77
void(* ClassConvStreamerFunc_t)(TBuffer &, void *, const TClass *)
Definition Rtypes.h:78
R__EXTERN TClassTable * gClassTable
TVirtualMutex * gInterpreterMutex
Definition TClass.cxx:134
TClass::ENewType & TClass__GetCallingNew()
Definition TClass.cxx:269
static bool IsFromRootCling()
Definition TClass.cxx:176
ROOT::TMapDeclIdToTClass DeclIdMap_t
Definition TClass.h:82
ROOT::TMapTypeToTClass IdMap_t
Definition TClass.h:81
void(* tcling_callfunc_Wrapper_t)(void *, int, void **, void *)
const Bool_t kIterBackward
Definition TCollection.h:43
EDataType
Definition TDataType.h:28
@ kNoType_t
Definition TDataType.h:33
@ kUInt_t
Definition TDataType.h:30
@ kClassIsValid
@ kClassIsTriviallyRelocatable
@ kIsPointer
Definition TDictionary.h:78
@ kIsClass
Definition TDictionary.h:65
@ kIsEnum
Definition TDictionary.h:68
@ kIsFundamental
Definition TDictionary.h:70
@ kIsAbstract
Definition TDictionary.h:71
@ kIsArray
Definition TDictionary.h:79
@ kIsStatic
Definition TDictionary.h:80
@ kIsStruct
Definition TDictionary.h:66
@ kIsUnion
Definition TDictionary.h:67
@ kIsNamespace
Definition TDictionary.h:95
@ kIsVirtualBase
Definition TDictionary.h:89
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:139
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h prop
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:142
R__EXTERN TVirtualMutex * gInterpreterMutex
R__EXTERN TInterpreter * gCling
#define gInterpreter
@ kMenuToggle
Definition TMethod.h:34
@ kMenuNoMenu
Definition TMethod.h:32
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:792
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:417
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2585
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
R__EXTERN void **(* gThreadTsd)(void *, Int_t)
#define R__LOCKGUARD2(mutex)
#define R__LOCKGUARD(mutex)
#define gPad
#define R__WRITE_LOCKGUARD(mutex)
#define R__READ_LOCKGUARD(mutex)
TCanvas * alignment()
Definition alignment.C:1
Bool_t AddRule(TSchemaRule *rule, EConsistencyCheck checkConsistency=kCheckAll, TString *errmsg=nullptr)
The consistency check always fails if the TClass object was not set! if checkConsistency is: kNoCheck...
void SetClass(TClass *cls)
Set the TClass associated with this rule set.
A spin mutex-as-code-guard class.
DeclIdMap_t::key_type key_type
Definition TClass.cxx:439
DeclIdMap_t::size_type size_type
Definition TClass.cxx:443
multimap< TDictionary::DeclId_t, TClass * > DeclIdMap_t
Definition TClass.cxx:438
size_type CountElementsWithKey(const key_type &key)
Definition TClass.cxx:455
std::pair< const_iterator, const_iterator > equal_range
Definition TClass.cxx:442
equal_range Find(const key_type &key) const
Definition TClass.cxx:459
void Remove(const key_type &key)
Definition TClass.cxx:464
DeclIdMap_t::const_iterator const_iterator
Definition TClass.cxx:441
DeclIdMap_t::mapped_type mapped_type
Definition TClass.cxx:440
void Add(const key_type &key, mapped_type obj)
Definition TClass.cxx:449
mapped_type Find(const key_type &key) const
Definition TClass.cxx:392
IdMap_t::size_type size_type
Definition TClass.cxx:375
IdMap_t::mapped_type mapped_type
Definition TClass.cxx:380
IdMap_t::const_iterator const_iterator
Definition TClass.cxx:374
std::map< std::string, TClass * > IdMap_t
Definition TClass.cxx:372
IdMap_t::key_type key_type
Definition TClass.cxx:373
void Remove(const key_type &key)
Definition TClass.cxx:400
void Add(const key_type &key, mapped_type &obj)
Definition TClass.cxx:387
Bool_t SetFromRule(const char *rule)
Set the content fot this object from the rule See TClass::AddRule for details on the syntax.
const char * GetTargetString() const
Get the target data members of this rule as a simple string (i.e. the in memory data member).
const char * GetVersion() const
Get the version string.
const char * GetTargetClass() const
Get the targte class of this rule (i.e. the in memory class).
static TClass * Class()
TBrowser * fBrowser
Definition TClass.cxx:979
~TAutoInspector() override
Definition TClass.cxx:986
Bool_t IsTreatingNonAccessibleTypes() override
Definition TClass.cxx:989
TAutoInspector(TBrowser *b)
Definition TClass.cxx:981
void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t isTransient) override
This method is called from ShowMembers() via AutoBrowse().
Definition TClass.cxx:995
Each class (see TClass) has a linked list of its base class(es).
Definition TBaseClass.h:33
Int_t GetDelta()
Get offset from "this" to part of base class.
ROOT::ESTLType IsSTLContainer()
Return which type (if any) of STL container the data member is.
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
TClass * GetClassPointer(Bool_t load=kTRUE)
Get pointer to the base class TClass.
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Buffer base class used for serializing objects.
Definition TBuffer.h:43
void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t isTransient) override
This method is called from ShowMembers() via BuildRealdata().
Definition TClass.cxx:842
TClass * fRealDataClass
Definition TClass.cxx:826
void * fRealDataObject
Definition TClass.cxx:825
TBuildRealData(void *obj, TClass *cl)
Definition TClass.cxx:829
Objects following this interface can be passed onto the TROOT object to implement a user customized w...
virtual TClass * GetClass(const char *classname, Bool_t load)=0
Describes one element of the context menu associated to a class The menu item may describe.
virtual void SetToggle(Bool_t toggle=kTRUE)
TClassRef is used to implement a permanent reference to a TClass object.
Definition TClassRef.h:29
virtual void Stream(TBuffer &b, void *objp, const TClass *onfileClass)
virtual TClassStreamer * Generate() const
static DictFuncPtr_t GetDict(const char *cname)
Given the class name returns the Dictionary() function of a class (uses hash of name).
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).
InsertTClassInRegistryRAII(TClass::EState &state, const char *name, TDeclNameRegistry &emuRegistry)
Definition TClass.cxx:250
Bool_t HasDeclName(const char *name) const
Definition TClass.cxx:225
void AddQualifiedName(const char *name)
Extract this part of the name.
Definition TClass.cxx:198
TDeclNameRegistry(Int_t verbLevel=0)
TDeclNameRegistry class constructor.
Definition TClass.cxx:187
std::atomic_flag fSpinLock
Definition TClass.h:173
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
UInt_t GetCheckSum(ECheckSum code=kCurrentCheckSum) const
Call GetCheckSum with validity check.
Definition TClass.cxx:6693
Bool_t IsSyntheticPair() const
Definition TClass.h:538
RepoCont_t fObjectVersionRepository
Definition TClass.h:354
ShowMembersFunc_t fShowMembers
Definition TClass.h:229
TDataMember * GetDataMember(const char *datamember) const
Return pointer to datamember object with name "datamember".
Definition TClass.cxx:3506
TVirtualIsAProxy * fIsA
!pointer to the class's IsA proxy.
Definition TClass.h:233
TList * GetListOfUsingDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of using declarations of a class.
Definition TClass.cxx:3849
void ForceReload(TClass *oldcl)
we found at least one equivalent.
Definition TClass.cxx:1305
ROOT::DelArrFunc_t fDeleteArray
Definition TClass.h:244
Bool_t CanSplit() const
Return true if the data member of this TClass can be saved separately.
Definition TClass.cxx:2331
TClassStreamer * fStreamer
Definition TClass.h:230
void SetDirectoryAutoAdd(ROOT::DirAutoAdd_t dirAutoAddFunc)
Install a new wrapper around the directory auto add function.
Definition TClass.cxx:7228
void * NewArray(Long_t nElements, ENewType defConstructor=kClassNew) const
Return a pointer to a newly allocated array of objects of this class.
Definition TClass.cxx:5322
static TDeclNameRegistry fNoInfoOrEmuOrFwdDeclNameRegistry
Definition TClass.h:338
TListOfFunctionTemplates * fFuncTemplate
Definition TClass.h:209
ClassStreamerFunc_t fStreamerFunc
Definition TClass.h:247
void AdoptReferenceProxy(TVirtualRefProxy *proxy)
Adopt the Reference proxy pointer to indicate that this class represents a reference.
Definition TClass.cxx:6873
TMethod * GetClassMethod(Longptr_t faddr)
Look for a method in this class that has the interface function address faddr.
Definition TClass.cxx:4600
TVirtualStreamerInfo * DetermineCurrentStreamerInfo()
Determine and set pointer to current TVirtualStreamerInfo.
Definition TClass.cxx:5813
void Browse(TBrowser *b) override
This method is called by a browser to get the class information.
Definition TClass.cxx:2022
EState GetState() const
Definition TClass.h:504
ROOT::ESTLType GetCollectionType() const
Return the 'type' of the STL the TClass is representing.
Definition TClass.cxx:2912
void Draw(Option_t *option="") override
Draw detailed class inheritance structure.
Definition TClass.cxx:2499
void ResetInstanceCount()
Definition TClass.h:566
ClassStreamerFunc_t GetStreamerFunc() const
Get a wrapper/accessor function around this class custom streamer (member function).
Definition TClass.cxx:2965
void RemoveStreamerInfo(Int_t slot)
Remove and delete the StreamerInfo in the given slot.
Definition TClass.cxx:7554
void SetCanSplit(Int_t splitmode)
Set the splitability of this class:
Definition TClass.cxx:5787
bool AdoptMemberStreamer(const char *name, TMemberStreamer *strm)
Adopt the TMemberStreamer pointer to by p and use it to Stream non basic member name.
Definition TClass.cxx:6894
TList * CreateListOfDataMembers(std::atomic< TListOfDataMembers * > &data, TDictionary::EMemberSelection selection, bool load)
Create the list containing the TDataMembers (of actual data members or members pulled in through usin...
Definition TClass.cxx:3804
TVirtualStreamerInfo * GetStreamerInfoAbstractEmulated(Int_t version=0) const
For the case where the requestor class is emulated and this class is abstract, returns a pointer to t...
Definition TClass.cxx:4826
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition TClass.cxx:5107
void SetMerge(ROOT::MergeFunc_t mergeFunc)
Install a new wrapper around 'Merge'.
Definition TClass.cxx:7169
void SetBrowse(ROOT::BrowseFunc_t browseFunc)
Install a new wrapper around 'Browse'.
Definition TClass.cxx:7161
ConvSIMap_t fConversionStreamerInfo
Definition TClass.h:202
ROOT::DirAutoAdd_t fDirAutoAdd
Definition TClass.h:246
Bool_t HasDataMemberInfo() const
Definition TClass.h:420
std::atomic< std::size_t > fAlignment
Definition TClass.h:251
TVirtualRefProxy * fRefProxy
!Pointer to reference proxy if this class represents a reference
Definition TClass.h:289
TList * GetMenuList() const
Return the list of menu items associated with the class.
Definition TClass.cxx:4458
ROOT::MergeFunc_t fMerge
Definition TClass.h:238
TMethod * GetMethod(const char *method, const char *params, Bool_t objectIsConst=kFALSE)
Find the best method (if there is one) matching the parameters.
Definition TClass.cxx:4528
static TClass * Load(TBuffer &b)
Load class description from I/O buffer and return class object.
Definition TClass.cxx:5888
EState fState
!Current 'state' of the class (Emulated,Interpreted,Loaded)
Definition TClass.h:286
ROOT::DesFunc_t GetDestructor() const
Return the wrapper around the destructor.
Definition TClass.cxx:7721
TMethod * GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
Definition TClass.cxx:4573
void CopyCollectionProxy(const TVirtualCollectionProxy &)
Replaces the collection proxy for this class.
Definition TClass.cxx:2482
Int_t fStreamerType
!cached of the streaming method to use
Definition TClass.h:285
TList * fRealData
Definition TClass.h:203
static void RegisterReadRules(ROOT::TSchemaRule::RuleType_t, const char *classname, std::vector<::ROOT::Internal::TSchemaHelper > &&rules)
Register a set of read rules for a target class.
Definition TClass.cxx:7498
void ls(Option_t *opt="") const override
The ls function lists the contents of a class on stdout.
Definition TClass.cxx:4317
std::atomic< TList * > fBase
Definition TClass.h:204
std::atomic< Char_t > fCanSplit
!Indicates whether this class can be split or not. Values are -1, 0, 1, 2
Definition TClass.h:253
Bool_t HasDictionary() const
Check whether a class has a dictionary or not.
Definition TClass.cxx:3969
const TList * GetListOfAllPublicMethods(Bool_t load=kTRUE)
Returns a list of all public methods of this class and its base classes.
Definition TClass.cxx:3908
TList * GetListOfAllPublicDataMembers(Bool_t load=kTRUE)
Returns a list of all public data members of this class and its base classes.
Definition TClass.cxx:3925
static void AddClassToDeclIdMap(TDictionary::DeclId_t id, TClass *cl)
static: Add a TClass* to the map of classes.
Definition TClass.cxx:578
virtual ~TClass()
TClass dtor. Deletes all list that might have been created.
Definition TClass.cxx:1653
Bool_t fIsSyntheticPair
Indicates whether this class represents a pair and was not created from a dictionary nor interpreter ...
Definition TClass.h:258
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
Definition TClass.cxx:5529
Version_t fClassVersion
Definition TClass.h:225
std::atomic< TVirtualStreamerInfo * > fCurrentInfo
!cached current streamer info.
Definition TClass.h:287
TList * GetListOfFunctionTemplates(Bool_t load=kTRUE)
Return TListOfFunctionTemplates for a class.
Definition TClass.cxx:3861
void * DynamicCast(const TClass *base, void *obj, Bool_t up=kTRUE)
Cast obj of this class type up to baseclass cl if up is true.
Definition TClass.cxx:5032
const char * fImplFileName
Definition TClass.h:218
void RegisterStreamerInfo(TVirtualStreamerInfo *info)
Register the StreamerInfo in the given slot, change the State of the TClass as appropriate.
Definition TClass.cxx:7530
std::atomic< UInt_t > fCheckSum
Definition TClass.h:223
void UnregisterAddressInRepository(const char *where, void *location, const TClass *what) const
Definition TClass.cxx:320
std::atomic< TListOfFunctions * > fMethod
Definition TClass.h:211
static void RemoveClassDeclId(TDictionary::DeclId_t id)
Definition TClass.cxx:605
void SetNewArray(ROOT::NewArrFunc_t newArrayFunc)
Install a new wrapper around 'new []'.
Definition TClass.cxx:7193
Bool_t CallShowMembers(const void *obj, TMemberInspector &insp, Bool_t isTransient=kFALSE) const
Call ShowMembers() on the obj of this class type, passing insp and parent.
Definition TClass.cxx:2217
const char * fDeclFileName
Definition TClass.h:217
void SetCollectionProxy(const ROOT::Detail::TCollectionProxyInfo &)
Create the collection proxy object (and the streamer object) from using the information in the TColle...
Definition TClass.cxx:6431
static Bool_t HasDictionarySelection(const char *clname)
Check whether a class has a dictionary or ROOT can load one.
Definition TClass.cxx:3980
void AdoptSchemaRules(ROOT::Detail::TSchemaRuleSet *rules)
Adopt a new set of Data Model Evolution rules.
Definition TClass.cxx:1913
static void StreamerInstrumented(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
Case of instrumented class with a library.
Definition TClass.cxx:7028
TVirtualStreamerInfo * SetStreamerInfo(Int_t version, const char *info="")
Info is a string describing the names and types of attributes written by the class Streamer function.
Definition TClass.cxx:6561
static std::atomic< Int_t > fgClassCount
Definition TClass.h:336
TVirtualStreamerInfo * GetCurrentStreamerInfo()
Definition TClass.h:454
ROOT::DirAutoAdd_t GetDirectoryAutoAdd() const
Return the wrapper around the directory auto add function.
Definition TClass.cxx:7729
void AddImplFile(const char *filename, int line)
Definition TClass.cxx:1959
TCollection * GetListOfMethodOverloads(const char *name) const
Return the collection of functions named "name".
Definition TClass.cxx:3890
std::atomic< TListOfEnums * > fEnums
Definition TClass.h:208
static Bool_t HasNoInfoOrEmuOrFwdDeclaredDecl(const char *)
Definition TClass.cxx:3465
TVirtualMutex * fOVRMutex
Definition TClass.h:352
TList * GetListOfEnums(Bool_t load=kTRUE)
Return a list containing the TEnums of a class.
Definition TClass.cxx:3749
Bool_t IsStartingWithTObject() const
Returns true if this class inherits from TObject and if the start of the TObject parts is at the very...
Definition TClass.cxx:6105
TList * GetListOfMethods(Bool_t load=kTRUE)
Return list containing the TMethods of a class.
Definition TClass.cxx:3875
size_t GetClassAlignment() const
Return the alignment requirement (in bytes) for objects of this class.
Definition TClass.cxx:5840
TClass()
Internal, default constructor.
Definition TClass.cxx:1139
Short_t fDeclFileLine
Definition TClass.h:219
Int_t GetNmethods()
Return the number of methods of this class Note that in case the list of methods is not yet created,...
Definition TClass.cxx:4690
std::atomic< Bool_t > fIsOffsetStreamerSet
!saved remember if fOffsetStreamer has been set.
Definition TClass.h:270
void IgnoreTObjectStreamer(Bool_t ignore=kTRUE)
When the class kIgnoreTObjectStreamer bit is set, the automatically generated Streamer will not call ...
Definition TClass.cxx:4958
TClassStreamer * GetStreamer() const
Return the Streamer Class allowing streaming (if any).
Definition TClass.cxx:2940
static IdMap_t * GetIdMap()
Definition TClass.cxx:471
void SetDelete(ROOT::DelFunc_t deleteFunc)
Install a new wrapper around 'delete'.
Definition TClass.cxx:7201
@ kLoading
Definition TClass.h:342
@ kUnloading
Definition TClass.h:342
static Int_t AutoBrowse(TObject *obj, TBrowser *browser)
Browse external object inherited from TObject.
Definition TClass.cxx:1973
ROOT::NewFunc_t GetNew() const
Return the wrapper around new ThisClass().
Definition TClass.cxx:7689
TClass * GetBaseClass(const char *classname)
Return pointer to the base class "classname".
Definition TClass.cxx:2667
Longptr_t GetDataMemberOffset(const char *membername) const
return offset for member name.
Definition TClass.cxx:3544
Int_t GetNdata()
Return the number of data members of this class Note that in case the list of data members is not yet...
Definition TClass.cxx:4671
void SetDestructor(ROOT::DesFunc_t destructorFunc)
Install a new wrapper around the destructor.
Definition TClass.cxx:7217
virtual void PostLoadCheck()
Do the initialization that can only be done after the CINT dictionary has been fully populated and ca...
Definition TClass.cxx:6135
void LoadClassInfo() const
Try to load the ClassInfo if available.
Definition TClass.cxx:5997
void SetResetAfterMerge(ROOT::ResetAfterMergeFunc_t resetFunc)
Install a new wrapper around 'ResetAfterMerge'.
Definition TClass.cxx:7177
TVirtualStreamerInfo * GetStreamerInfoImpl(Int_t version, Bool_t silent) const
Definition TClass.cxx:4751
Bool_t MatchLegacyCheckSum(UInt_t checksum) const
Return true if the checksum passed as argument is one of the checksum value produced by the older che...
Definition TClass.cxx:6682
TViewPubFunctions * fAllPubMethod
Definition TClass.h:214
Bool_t HasInterpreterInfo() const
Definition TClass.h:424
static void AddClass(TClass *cl)
static: Add a class to the list and map of classes.
Definition TClass.cxx:557
void GetMissingDictionariesForBaseClasses(TCollection &result, TCollection &visited, bool recurse)
Verify the base classes always.
Definition TClass.cxx:3990
ROOT::Detail::TSchemaRuleSet * fSchemaRules
! Schema evolution rules
Definition TClass.h:290
std::atomic< Long_t > fProperty
!Property See TClass::Property() for details
Definition TClass.h:264
static void StreamerDefault(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
Default streaming in cases where either we have no way to know what to do or if Property() has not ye...
Definition TClass.cxx:7065
void SetUnloaded()
Call this method to indicate that the shared library containing this class's code has been removed (u...
Definition TClass.cxx:6497
ROOT::DelArrFunc_t GetDeleteArray() const
Return the wrapper around delete [] ThisObject.
Definition TClass.cxx:7713
Bool_t HasInterpreterInfoInMemory() const
Definition TClass.h:423
TList * fClassMenuList
Definition TClass.h:215
ClassConvStreamerFunc_t fConvStreamerFunc
Definition TClass.h:249
void BuildRealData(void *pointer=nullptr, Bool_t isTransient=kFALSE)
Build a full list of persistent data members.
Definition TClass.cxx:2043
void SetRuntimeProperties()
Internal routine to set calculate the class properties that can only be known at run-time,...
Definition TClass.cxx:6380
void BuildEmulatedRealData(const char *name, Longptr_t offset, TClass *cl, Bool_t isTransient=kFALSE)
Build the list of real data for an emulated class.
Definition TClass.cxx:2124
std::unordered_map< std::string, std::vector< ROOT::Internal::TSchemaHelper > > SchemaHelperMap_t
Definition TClass.h:374
static TClass * LoadClass(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Definition TClass.cxx:5922
TString fSharedLibs
Definition TClass.h:231
const std::type_info * GetTypeInfo() const
Definition TClass.h:512
void SetStreamerImpl(Int_t streamerType)
Internal routine to set fStreamerImpl based on the value of fStreamerType.
Definition TClass.cxx:6401
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
Definition TClass.cxx:3833
ENewType
Definition TClass.h:110
@ kRealNew
Definition TClass.h:110
void Move(void *arenaFrom, void *arenaTo) const
Register the fact that an object was moved from the memory location 'arenaFrom' to the memory locatio...
Definition TClass.cxx:4419
static DeclIdMap_t * GetDeclIdMap()
Definition TClass.cxx:482
Short_t GetDeclFileLine() const
Definition TClass.h:444
void SetStreamerFunc(ClassStreamerFunc_t strm)
Set a wrapper/accessor function around this class custom streamer.
Definition TClass.cxx:7114
const char * GetImplFileName() const
Definition TClass.h:471
TList * GetListOfRealData() const
Definition TClass.h:468
Int_t Size() const
Return size of object of this class.
Definition TClass.cxx:5871
void SetCurrentStreamerInfo(TVirtualStreamerInfo *info)
Set pointer to current TVirtualStreamerInfo.
Definition TClass.cxx:5825
static DictFuncPtr_t GetDict(const char *cname)
Return a pointer to the dictionary loading function generated by rootcint.
Definition TClass.cxx:3489
Longptr_t fOffsetStreamer
!saved info to call Streamer
Definition TClass.h:284
ROOT::NewArrFunc_t GetNewArray() const
Return the wrapper around new ThisClass[].
Definition TClass.cxx:7697
static void StreamerTObjectEmulated(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
Case of TObjects when we do not have the library defining the class.
Definition TClass.cxx:7015
std::atomic< Int_t > fSizeof
Definition TClass.h:250
ROOT::NewFunc_t fNew
Definition TClass.h:241
ROOT::ResetAfterMergeFunc_t GetResetAfterMerge() const
Return the wrapper around Merge.
Definition TClass.cxx:7681
TMethod * GetClassMethodWithPrototype(const char *name, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
Definition TClass.cxx:4644
Bool_t CanIgnoreTObjectStreamer()
Definition TClass.h:406
void SetGlobalIsA(IsAGlobalFunc_t)
This function installs a global IsA function for this class.
Definition TClass.cxx:6487
void GetMissingDictionariesForMembers(TCollection &result, TCollection &visited, bool recurse)
Verify the Data Members.
Definition TClass.cxx:4007
TObjArray * fStreamerInfo
Definition TClass.h:201
const ROOT::Detail::TSchemaRuleSet * GetSchemaRules() const
Return the set of the schema rules if any.
Definition TClass.cxx:1939
TObject * Clone(const char *newname="") const override
Create a Clone of this TClass object using a different name but using the same 'dictionary'.
Definition TClass.cxx:2418
TVirtualCollectionProxy * fCollectionProxy
Definition TClass.h:224
static ENewType IsCallingNew()
Static method returning the defConstructor flag passed to TClass::New().
Definition TClass.cxx:6078
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition TClass.cxx:3699
void Store(TBuffer &b) const
Store class description on I/O buffer.
Definition TClass.cxx:6036
void InterpretedShowMembers(void *obj, TMemberInspector &insp, Bool_t isTransient)
Do a ShowMembers() traversal of all members and base classes' members using the reflection informatio...
Definition TClass.cxx:2254
static THashTable * fgClassTypedefHash
Definition TClass.h:348
void Init(const char *name, Version_t cversion, const std::type_info *info, TVirtualIsAProxy *isa, const char *dfil, const char *ifil, Int_t dl, Int_t il, ClassInfo_t *classInfo, Bool_t silent)
Initialize a TClass object.
Definition TClass.cxx:1339
std::atomic< TListOfDataMembers * > fData
Definition TClass.h:205
static void StreamerStreamerInfo(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
Case of where we should directly use the StreamerInfo.
Definition TClass.cxx:7050
const TObjArray * GetStreamerInfos() const
Definition TClass.h:508
void SetClassVersion(Version_t version)
Private function.
Definition TClass.cxx:5804
char * EscapeChars(const char *text) const
Introduce an escape character (@) in front of a special chars.
Definition TClass.cxx:2580
const std::type_info * fTypeInfo
Definition TClass.h:228
std::atomic< TVirtualStreamerInfo * > fLastReadInfo
!cached streamer info used in the last read.
Definition TClass.h:288
static void StreamerTObject(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
Case of TObjects.
Definition TClass.cxx:6985
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
Definition TClass.cxx:6088
@ kDefault
Definition TClass.h:344
@ kEmulatedStreamer
Definition TClass.h:344
@ kExternal
Definition TClass.h:344
@ kForeign
Definition TClass.h:344
@ kInstrumented
Definition TClass.h:344
@ kTObject
Definition TClass.h:344
static Bool_t AddRule(const char *rule)
Add a schema evolution customization rule.
Definition TClass.cxx:1883
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition TClass.cxx:6114
static void RemoveClass(TClass *cl)
static: Remove a class from the list and map of classes
Definition TClass.cxx:587
Bool_t HasLocalHashMember() const
Returns true if this class has an definition and/or overload of the member function Hash.
Definition TClass.cxx:7655
void DeleteArray(void *ary, Bool_t dtorOnly=kFALSE)
Explicitly call operator delete[] for an array.
Definition TClass.cxx:5658
ClassConvStreamerFunc_t GetConvStreamerFunc() const
Get a wrapper/accessor function around this class custom conversion streamer (member function).
Definition TClass.cxx:2973
Bool_t IsForeign() const
Return kTRUE is the class is Foreign (the class does not have a Streamer method).
Definition TClass.cxx:6123
ClassInfo_t * GetClassInfo() const
Definition TClass.h:448
ROOT::DelFunc_t fDelete
Definition TClass.h:243
TViewPubDataMembers * fAllPubData
Definition TClass.h:213
Bool_t IsTriviallyRelocatable() const
Return kTRUE if an object of this class can be relocated to a new address with a raw memory copy,...
Definition TClass.cxx:4405
ClassInfo_t * fClassInfo
Definition TClass.h:226
TVirtualStreamerInfo * GetStreamerInfo(Int_t version=0, Bool_t isTransient=kFALSE) const
returns a pointer to the TVirtualStreamerInfo object for version If the object does not exist,...
Definition TClass.cxx:4716
Bool_t HasConsistentHashMember()
Return 'true' if we can guarantee that if this class (or any class in this class inheritance hierarch...
Definition TClass.h:517
void AdoptStreamer(TClassStreamer *strm)
Adopt a TClassStreamer object.
Definition TClass.cxx:7086
TClass * GetBaseDataMember(const char *datamember)
Return pointer to (base) class that contains datamember.
Definition TClass.cxx:2853
ECheckSum
Definition TClass.h:111
@ kLatestCheckSum
Definition TClass.h:120
@ kNoRange
Definition TClass.h:115
@ kCurrentCheckSum
Definition TClass.h:112
@ kNoBaseCheckSum
Definition TClass.h:119
@ kReflex
Definition TClass.h:117
@ kReflexNoComment
Definition TClass.h:114
@ kWithTypeDef
Definition TClass.h:116
@ kNoRangeCheck
Definition TClass.h:118
@ kNoEnum
Definition TClass.h:113
void Dump() const override
Dump contents of object on stdout.
Definition TClass.h:411
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4991
Int_t GetBaseClassOffset(const TClass *toBase, void *address=nullptr, bool isDerivedObject=true)
Definition TClass.cxx:2817
ObjectPtr NewObjectArray(Long_t nElements, ENewType defConstructor=kClassNew) const
Return a pointer to a newly allocated array of objects of this class.
Definition TClass.cxx:5338
TVirtualCollectionProxy * GetCollectionProxy() const
Return the proxy describing the collection (if any).
Definition TClass.cxx:2923
void ResetCaches()
To clean out all caches.
Definition TClass.cxx:4274
Long_t ClassProperty() const
Return the C++ property of this class, eg.
Definition TClass.cxx:2408
const char * GetSharedLibs()
Get the list of shared libraries containing the code for class cls.
Definition TClass.cxx:3686
void CalculateStreamerOffset() const
Calculate the offset between an object of this class to its base class TObject.
Definition TClass.cxx:2195
void GetMissingDictionariesForPairElements(TCollection &result, TCollection &visited, bool recurse)
Definition TClass.cxx:4036
void ReplaceWith(TClass *newcl) const
Definition TClass.cxx:4201
void RegisterAddressInRepository(const char *where, void *location, const TClass *what) const
Definition TClass.cxx:292
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
Definition TClass.cxx:6268
Bool_t HasDefaultConstructor(Bool_t testio=kFALSE) const
Return true if we have access to a constructor usable for I/O.
Definition TClass.cxx:7627
void GetMenuItems(TList *listitems)
Returns list of methods accessible by context menu.
Definition TClass.cxx:3937
void SetNew(ROOT::NewFunc_t newFunc)
Install a new wrapper around 'new'.
Definition TClass.cxx:7185
std::atomic< TMethodCall * > fIsAMethod
!saved info to call a IsA member function
Definition TClass.h:235
static Int_t ReadRules()
Read the class.rules files from the default location:.
Definition TClass.cxx:1813
Bool_t CanSplitBaseAllow()
Definition TClass.cxx:2259
void MoveAddressInRepository(const char *where, void *oldadd, void *newadd, const TClass *what) const
Definition TClass.cxx:339
std::atomic< StreamerImpl_t > fStreamerImpl
! Pointer to the function implementing streaming for this class
Definition TClass.h:296
void SetContextMenuTitle(const char *title)
Change (i.e. set) the title of the TNamed.
Definition TClass.cxx:6456
void SetMemberStreamer(const char *name, MemberStreamerFunc_t strm)
Install a new member streamer (p will be copied).
Definition TClass.cxx:6929
std::atomic< TClass ** > fPersistentRef
!Persistent address of pointer to this TClass object and its successors.
Definition TClass.h:197
IsAGlobalFunc_t fGlobalIsA
Definition TClass.h:234
TVirtualStreamerInfo * GetConversionStreamerInfo(const char *onfile_classname, Int_t version) const
Return a Conversion StreamerInfo from the class 'classname' for version number 'version' to this clas...
Definition TClass.cxx:7286
Short_t GetImplFileLine() const
Definition TClass.h:472
TMethod * GetMethodAllAny(const char *method)
Return pointer to method without looking at parameters.
Definition TClass.cxx:4501
std::atomic< UChar_t > fRuntimeProperties
! Properties that can only be evaluated at run-time
Definition TClass.h:282
@ kInterpreted
Definition TClass.h:129
@ kHasTClassInit
Definition TClass.h:130
@ kEmulated
Definition TClass.h:128
@ kNoInfo
Definition TClass.h:125
@ kLoaded
Definition TClass.h:133
@ kForwardDeclared
Definition TClass.h:127
@ kNamespaceForMeta
Definition TClass.h:134
TVirtualStreamerInfo * FindConversionStreamerInfo(const char *onfile_classname, UInt_t checksum) const
Return a Conversion StreamerInfo from the class 'classname' for the layout represented by 'checksum' ...
Definition TClass.cxx:7393
Int_t GetBaseClassOffsetRecurse(const TClass *toBase)
Return data member offset to the base class "cl".
Definition TClass.cxx:2717
ROOT::DelFunc_t GetDelete() const
Return the wrapper around delete ThisObject.
Definition TClass.cxx:7705
static TClass * LoadClassDefault(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Definition TClass.cxx:5944
void SetClassSize(Int_t sizof)
Definition TClass.h:316
TMethod * FindClassOrBaseMethodWithId(DeclId_t faddr)
Find a method with decl id in this class or its bases.
Definition TClass.cxx:4557
static void StreamerExternal(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
There is special streamer for the class.
Definition TClass.cxx:6973
Long_t fClassProperty
!C++ Property of the class (is abstract, has virtual table, etc.)
Definition TClass.h:265
TString fContextMenuTitle
Definition TClass.h:227
static void StreamerTObjectInitialized(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
Case of TObjects when fIsOffsetStreamerSet is known to have been set.
Definition TClass.cxx:6999
static void ConvStreamerInstrumented(const TClass *pThis, void *object, TBuffer &b, const TClass *onfile_class)
Case of instrumented class with a library.
Definition TClass.cxx:7037
std::atomic< Bool_t > fCanLoadClassInfo
!Indicates whether the ClassInfo is supposed to be available.
Definition TClass.h:269
void SetConvStreamerFunc(ClassConvStreamerFunc_t strm)
Set a wrapper/accessor function around this class custom conversion streamer.
Definition TClass.cxx:7137
ROOT::BrowseFunc_t GetBrowse() const
Return the wrapper around Browse.
Definition TClass.cxx:7665
TVirtualStreamerInfo * FindStreamerInfo(TObjArray *arr, UInt_t checksum) const
Find the TVirtualStreamerInfo in the StreamerInfos corresponding to checksum.
Definition TClass.cxx:7266
void GetMissingDictionaries(THashTable &result, bool recurse=false)
Get the classes that have a missing dictionary starting from this one.
Definition TClass.cxx:4148
void MakeCustomMenuList()
Makes a customizable version of the popup menu list, i.e.
Definition TClass.cxx:4342
TVirtualStreamerInfo * FindStreamerInfoAbstractEmulated(UInt_t checksum) const
For the case where the requestor class is emulated and this class is abstract, returns a pointer to t...
Definition TClass.cxx:4889
static SchemaHelperMap_t & GetReadRulesRegistry(ROOT::TSchemaRule::RuleType_t type)
Return the registry for the unassigned read rules.
Definition TClass.cxx:1925
TMethod * GetMethodAny(const char *method)
Return pointer to method without looking at parameters.
Definition TClass.cxx:4491
TVirtualIsAProxy * GetIsAProxy() const
Return the proxy implementing the IsA functionality.
Definition TClass.cxx:2981
ROOT::MergeFunc_t GetMerge() const
Return the wrapper around Merge.
Definition TClass.cxx:7673
ROOT::ResetAfterMergeFunc_t fResetAfterMerge
Definition TClass.h:240
Bool_t IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TClass.h:534
std::atomic< Bool_t > fHasRootPcmInfo
!Whether info was loaded from a root pcm.
Definition TClass.h:268
TClass * GetActualClass(const void *object) const
Return a pointer to the real class of the object.
Definition TClass.cxx:2619
ROOT::DesFunc_t fDestructor
Definition TClass.h:245
const char * GetDeclFileName() const
Return name of the file containing the declaration of this class.
Definition TClass.cxx:3530
ObjectPtr NewObject(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Definition TClass.cxx:5121
TRealData * GetRealData(const char *name) const
Return pointer to TRealData element with name "name".
Definition TClass.cxx:3570
void SetDeleteArray(ROOT::DelArrFunc_t deleteArrayFunc)
Install a new wrapper around 'delete []'.
Definition TClass.cxx:7209
Bool_t fHasCustomStreamerMember
The class has a Streamer method and it is implemented by the user or an older (not StreamerInfo based...
Definition TClass.h:262
TFunctionTemplate * GetFunctionTemplate(const char *name)
Definition TClass.cxx:3670
void ResetClassInfo()
Make sure that the current ClassInfo is up to date.
Definition TClass.cxx:4239
ROOT::NewArrFunc_t fNewArray
Definition TClass.h:242
Int_t ReadBuffer(TBuffer &b, void *pointer, Int_t version, UInt_t start, UInt_t count)
Function called by the Streamer functions to deserialize information from buffer b into object at p.
Definition TClass.cxx:6943
void GetMissingDictionariesWithRecursionCheck(TCollection &result, TCollection &visited, bool recurse)
From the second level of recursion onwards it is different state check.
Definition TClass.cxx:4053
ROOT::BrowseFunc_t fBrowse
Definition TClass.h:237
bool IsClassStructOrUnion() const
Definition TClass.h:364
@ kHasLocalHashMember
Definition TClass.h:99
@ kHasNameMapNode
Definition TClass.h:108
@ kIgnoreTObjectStreamer
Definition TClass.h:100
@ kUnloaded
Definition TClass.h:101
@ kWarned
Definition TClass.h:107
@ kStartWithTObject
Definition TClass.h:106
@ kIsTObject
Definition TClass.h:103
@ kIsForeign
Definition TClass.h:104
std::atomic< TListOfDataMembers * > fUsingData
Definition TClass.h:206
TListOfFunctions * GetMethodList()
Return (create an empty one if needed) the list of functions.
Definition TClass.cxx:4472
void ResetMenuList()
Resets the menu list to it's standard value.
Definition TClass.cxx:4302
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.
Definition TClass.cxx:2999
Int_t WriteBuffer(TBuffer &b, void *pointer, const char *info="")
Function called by the Streamer functions to serialize object at p to buffer b.
Definition TClass.cxx:6964
static TClass * LoadClassCustom(const char *requestedname, Bool_t silent)
Helper function used by TClass::GetClass().
Definition TClass.cxx:5974
Short_t fImplFileLine
Definition TClass.h:220
static TClass * Class()
Collection abstract base class.
Definition TCollection.h:65
static TClass * Class()
void ls(Option_t *option="") const override
List (ls) all objects in this collection.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual void Add(TObject *obj)=0
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
All ROOT classes may have RTTI (run time type identification) support added.
Definition TDataMember.h:31
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
const char * GetTrueTypeName() const
Get the desugared type name of this data member, including const and volatile qualifiers.
Bool_t IsPersistent() const
Definition TDataMember.h:91
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
Int_t GetArrayDim() const
Return number of array dimensions.
Bool_t IsBasic() const
Return true if data member is a basic type, e.g. char, int, long...
Bool_t IsaPointer() const
Return true if data member is a pointer.
TDataType * GetDataType() const
Definition TDataMember.h:76
const char * GetTypeName() const
Get the decayed type name of this data member, removing const and volatile qualifiers,...
const char * GetFullTypeName() const
Get the concrete type name of this data member, including const and volatile qualifiers.
Basic data type descriptor (datatype information is obtained from CINT).
Definition TDataType.h:44
Int_t GetType() const
Definition TDataType.h:71
Long_t Property() const override
Get property description word. For meaning of bits see EProperty.
const char * AsString(void *buf) const
Return string containing value in buffer formatted according to the basic data type.
TString GetTypeName()
Get basic type of typedef, e,g.: "class TDirectory*" -> "TDirectory".
static TDataType * GetDataType(EDataType type)
Given a EDataType type, get the TDataType* that represents it.
static void GetDateTime(UInt_t datetime, Int_t &date, Int_t &time)
Static function that returns the date and time.
Definition TDatime.cxx:427
This class defines an abstract interface that must be implemented by all classes that contain diction...
EMemberSelection
Kinds of members to include in lists.
const void * DeclId_t
void Inspect(TClass *cl, const char *parent, const char *name, const void *addr, Bool_t isTransient) override
Print value of member mname.
Definition TClass.cxx:643
TDumpMembers(bool noAddr)
Definition TClass.cxx:626
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
Definition TEnum.cxx:181
@ kNone
Definition TEnum.h:55
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
This class stores a (key,value) pair using an external hash.
Definition TExMap.h:33
Long64_t GetValue(ULong64_t hash, Long64_t key)
Return the value belonging to specified key and hash value.
Definition TExMap.cxx:173
void AddAt(UInt_t slot, ULong64_t hash, Long64_t key, Long64_t value)
Add an (key,value) pair to the table.
Definition TExMap.cxx:116
Dictionary for function template This class describes one single function template.
Global functions class (global functions are obtained from CINT).
Definition TFunction.h:30
Int_t GetNargs() const
Number of function arguments.
THashTable implements a hash table to store TObject's.
Definition THashTable.h:35
void Add(TObject *obj) override
Add object to the hash table.
const TList * GetListForObject(const char *name) const
Return the TList corresponding to object's name based hash value.
TObject * Remove(TObject *obj) override
Remove object from the hashtable.
virtual Bool_t ClassInfo_HasMethod(ClassInfo_t *, const char *) const
virtual const char * DataMemberInfo_Name(DataMemberInfo_t *) const
virtual const char * DataMemberInfo_TypeName(DataMemberInfo_t *) const
virtual int DataMemberInfo_TypeSize(DataMemberInfo_t *) const
virtual void * ClassInfo_New(ClassInfo_t *) const
virtual Bool_t ClassInfo_IsValid(ClassInfo_t *) const
virtual Int_t AutoParse(const char *cls)=0
virtual void ClassInfo_Delete(ClassInfo_t *) const
virtual void ClassInfo_DeleteArray(ClassInfo_t *, void *, bool) const
virtual Long_t ClassInfo_Property(ClassInfo_t *) const
virtual int ClassInfo_Size(ClassInfo_t *) const
virtual const char * ClassInfo_FullName(ClassInfo_t *) const
virtual int SetClassAutoLoading(int) const
virtual const char * ClassInfo_Title(ClassInfo_t *) const
virtual Long_t DataMemberInfo_TypeProperty(DataMemberInfo_t *) const
virtual int DataMemberInfo_Next(DataMemberInfo_t *) const
virtual size_t ClassInfo_AlignOf(ClassInfo_t *) const
virtual DataMemberInfo_t * DataMemberInfo_Factory(ClassInfo_t *, TDictionary::EMemberSelection) const
virtual Long_t DataMemberInfo_Property(DataMemberInfo_t *) const
virtual int DataMemberInfo_ArrayDim(DataMemberInfo_t *) const
virtual void DataMemberInfo_Delete(DataMemberInfo_t *) const
virtual int DataMemberInfo_MaxIndex(DataMemberInfo_t *, Int_t) const
TDictionary::DeclId_t DeclId_t
virtual Bool_t ClassInfo_HasDefaultConstructor(ClassInfo_t *, Bool_t=kFALSE) const
virtual Long_t ClassInfo_ClassProperty(ClassInfo_t *) const
virtual Longptr_t ClassInfo_GetBaseOffset(ClassInfo_t *, ClassInfo_t *, void *=nullptr, bool=true) const
virtual void ClassInfo_Destruct(ClassInfo_t *, void *) const
TIsAProxy implementation class.
Definition TIsAProxy.h:27
void Reset()
A collection of TDataMember objects designed for fast access given a DeclId_t and for keep track of T...
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
static TClass * Class()
A collection of TEnum objects designed for fast access given a DeclId_t and for keep track of TEnum t...
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TObject * FindObject(const char *name) const override
Specialize FindObject to do search for the a function just by name or create it if its not already in...
void Load()
Load all the functions known to the interpreter for the scope 'fClass' into this collection.
void Delete(Option_t *option="") override
Delete all TFunction object files.
A collection of TFunction objects designed for fast access given a DeclId_t and for keep track of TFu...
TFunction * Get(DeclId_t id)
Return (after creating it if necessary) the TMethod or TFunction describing the function correspondin...
virtual TList * GetListForObject(const char *name) const
Return the set of overloads for this name, collecting all available ones.
TObject * FindObject(const TObject *obj) const override
Find object using its hash value (returned by its Hash() member).
A doubly linked list.
Definition TList.h:38
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:708
void Add(TObject *obj) override
Definition TList.h:81
void AddLast(TObject *obj) override
Add object at the end of the list.
Definition TList.cxx:149
virtual TObjLink * FirstLink() const
Definition TList.h:107
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:600
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
Definition TMap.h:40
Abstract base class for accessing the data-members of a class.
virtual void Inspect(TClass *cl, const char *parent, const char *name, const void *addr)
Each ROOT method (see TMethod) has a linked list of its arguments.
Definition TMethodArg.h:36
const char * GetFullTypeName() const
Get full type description of method argument, e.g.: "class TDirectory*".
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
TClass * GetClass() const
Definition TMethod.h:55
EMenuItemKind IsMenuItem() const
Definition TMethod.h:56
virtual TList * GetListOfMethodArgs()
Returns methodarg list and additionally updates fDataMember in TMethod by calling FindDataMember();.
Definition TMethod.cxx:305
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
Definition TNamed.cxx:73
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:173
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
TString fName
Definition TNamed.h:32
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:149
void ls(Option_t *option="") const override
List TNamed name and title.
Definition TNamed.cxx:112
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
void Clear(Option_t *option="") override
Remove all objects from the array.
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
Int_t GetEntries() const override
Return the number of objects in array (i.e.
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const override
Definition TObjArray.h:170
TObject * UncheckedAt(Int_t i) const
Definition TObjArray.h:90
TObject * RemoveAt(Int_t idx) override
Remove object at index idx.
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
Int_t GetLast() const override
Return index of last object in array.
Int_t LowerBound() const
Definition TObjArray.h:97
void Add(TObject *obj) override
Definition TObjArray.h:68
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:42
static void SetObjectStat(Bool_t stat)
Turn on/off tracking of objects in the TObjectTable.
Definition TObject.cxx:1186
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:461
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition TObject.cxx:217
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:995
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:424
static TClass * Class()
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:161
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
static Bool_t GetObjectStat()
Get status of object stat flag.
Definition TObject.cxx:1179
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1124
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:897
virtual TClass * IsA() const
Definition TObject.h:248
void MakeZombie()
Definition TObject.h:55
void ResetBit(UInt_t f)
Definition TObject.h:203
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1070
Class used by TMap to store (key,value) pairs.
Definition TMap.h:103
Persistent version of a TClass.
Definition TProtoClass.h:38
Bool_t FillTClass(TClass *pcl)
Move data from this TProtoClass into cl.
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
Definition TROOT.cxx:3397
The TRealData class manages the effective list of all data members for a given class.
Definition TRealData.h:30
const char * GetName() const override
Returns name of object.
Definition TRealData.h:52
void AdoptStreamer(TMemberStreamer *p)
Definition TRealData.cxx:66
Long_t GetThisOffset() const
Definition TRealData.h:55
void SetIsObject(Bool_t isObject)
Definition TRealData.h:57
static TClass * Class()
static TClass * Class()
TClass * GetClassPointer() const override
Returns a pointer to the TClass of this element.
static TClass * Class()
Describe one element (data member) to be Streamed.
Int_t GetType() const
virtual const char * GetFullName() const
Return element name including dimensions, if any Note that this function stores the name into a stati...
virtual TClass * GetClassPointer() const
Returns a pointer to the TClass of this element and updates fClassObject.
Int_t GetArrayDim() const
virtual Bool_t IsaPointer() const
const char * GetTypeName() const
TClass * IsA() const override
Int_t GetOffset() const
virtual Bool_t IsBase() const
Return kTRUE if the element represent a base class.
TClass * GetClassPointer() const override
Returns a pointer to the TClass of this element.
static TClass * Class()
Basic string class.
Definition TString.h:137
Ssiz_t Length() const
Definition TString.h:426
static constexpr Ssiz_t kNPOS
Definition TString.h:285
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
Definition TString.h:704
const char * Data() const
Definition TString.h:385
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:714
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:633
Bool_t IsNull() const
Definition TString.h:423
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition TString.cxx:685
TString & Remove(Ssiz_t pos)
Definition TString.h:695
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2460
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2438
static TClass * Class()
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:661
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1687
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1097
View implementing the TList interface and giving access all the TDictionary describing public data me...
void Load()
Load all the DataMembers known to the interpreter for the scope 'fClass' and all its bases classes.
void Delete(Option_t *option="") override
Delete is not allowed in this class.
View implementing the TList interface and giving access all the TFunction describing public methods i...
void Load()
Load all the functions known to the interpreter for the scope 'fClass' and all its bases classes.
RAII helper class that ensures that PushProxy() / PopProxy() are called when entering / leaving a C++...
Defines a common interface to inspect/change the contents of an object that represents a collection.
virtual Int_t GetProperties() const
Return miscallenous properties of the proxy (see TVirtualCollectionProxy::EProperty)
virtual UInt_t Sizeof() const =0
Return the sizeof() of the collection object.
virtual TClass::ObjectPtr NewObjectArray(Int_t nElements) const
Construct an array of nElements container objects and return the base address of the array.
virtual void Destructor(void *p, Bool_t dtorOnly=kFALSE) const
Execute the container destructor.
virtual void DeleteArray(void *p, Bool_t dtorOnly=kFALSE) const
Execute the container array destructor.
virtual TClass * GetValueClass() const =0
If the value type is a user-defined class, return a pointer to the TClass representing the value type...
virtual TClass::ObjectPtr NewObject() const
Construct a new container object and return its address.
virtual void * At(UInt_t idx)=0
Return the address of the value at index idx
virtual UInt_t Size() const =0
Return the current number of elements in the container.
virtual TVirtualCollectionProxy * Generate() const =0
Returns a clean object of the actual class that derives from TVirtualCollectionProxy.
virtual Bool_t Reset()
Reset the information gathered from StreamerInfos and value's TClass.
virtual Bool_t HasPointers() const =0
Return true if the content is of type 'pointer to'.
virtual void SetClass(TClass *cl)=0
This class implements a mutex interface.
small helper class to store/restore gPad context in TPad methods
Definition TVirtualPad.h:58
auto GetSaved() const
Definition TVirtualPad.h:66
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:53
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual void DrawClassObject(const TObject *obj, Option_t *option="")=0
virtual void Release()=0
virtual void SetClass(TClass *classptr)=0
virtual TVirtualRefProxy * Clone() const =0
Abstract Interface class describing Streamer information for one class.
virtual TVirtualStreamerInfo * GenerateInfoForPair(const std::string &pairclassname, bool silent, size_t hint_pair_offset, size_t hint_pair_size)=0
Generate the TClass and TStreamerInfo for the requested pair.
virtual void DeleteArray(void *p, Bool_t dtorOnly=kFALSE)=0
virtual void Clear(Option_t *="") override=0
Set name and title to empty strings ("").
virtual void SetClassVersion(Int_t vers)=0
virtual TClassStreamer * GenEmulatedClassStreamer(const char *class_name, Bool_t silent)=0
virtual TVirtualStreamerInfo * NewInfo(TClass *cl)=0
virtual TClass * GetActualClass(const void *obj) const =0
virtual UInt_t GetCheckSum() const =0
virtual Int_t GetOffset(const char *) const =0
static const char * GetElementCounterStart(const char *dmTitle)
Given a comment/title declaring an array counter, for example:
virtual void Build(Bool_t isTransient=kFALSE)=0
virtual void BuildCheck(TFile *file=nullptr, Bool_t load=kTRUE)=0
virtual Bool_t BuildFor(const TClass *cl)=0
virtual TVirtualCollectionProxy * GenExplicitProxy(const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl)=0
virtual void * NewArray(Long_t nElements, void *ary=nullptr)=0
virtual TVirtualCollectionProxy * GenEmulatedProxy(const char *class_name, Bool_t silent)=0
virtual void SetClass(TClass *cl)=0
virtual TObjArray * GetElements() const =0
virtual Int_t GetSize() const =0
virtual void BuildOld()=0
static TVirtualStreamerInfo * Factory()
Static function returning a pointer to a new TVirtualStreamerInfo object.
virtual size_t GetClassAlignment() const =0
virtual void * New(void *obj=nullptr)=0
virtual Version_t GetOldVersion() const =0
virtual Int_t GetOnFileClassVersion() const =0
virtual void Destructor(void *p, Bool_t dtorOnly=kFALSE)=0
virtual Bool_t CompareContent(TClass *cl, TVirtualStreamerInfo *info, Bool_t warn, Bool_t complete, TFile *file)=0
virtual Int_t GetClassVersion() const =0
virtual void Update(const TClass *oldClass, TClass *newClass)=0
virtual TClass * GetClass() const =0
TLine * line
return c1
Definition legend1.C:41
constexpr T AlignUp(T value, T align) noexcept
Round value up to the next multiple of align.
Definition BitUtils.hxx:44
R__EXTERN void * gMmallocDesc
Definition TStorage.h:141
constexpr bool IsValidAlignment(std::size_t align) noexcept
Return true if align is a valid C++ alignment value: strictly positive and a power of two.
Definition BitUtils.hxx:36
Bool_t HasConsistentHashMember(TClass &clRef)
Return true is the Hash/RecursiveRemove setup is consistent, i.e.
Definition TClass.cxx:7605
void(* DirAutoAdd_t)(void *, TDirectory *)
Definition Rtypes.h:119
R__EXTERN TVirtualRWMutex * gCoreMutex
void(* ResetAfterMergeFunc_t)(void *, TFileMergeInfo *)
Definition Rtypes.h:121
@ kClassThreadSlot
void(* DesFunc_t)(void *)
Definition Rtypes.h:118
TClass * CreateClass(const char *cname, Version_t id, const std::type_info &info, TVirtualIsAProxy *isa, const char *dfil, const char *ifil, Int_t dl, Int_t il)
Global function called by a class' static Dictionary() method (see the ClassDef macro).
Definition TClass.cxx:6045
void(* DelFunc_t)(void *)
Definition Rtypes.h:116
ESTLType
Definition ESTLType.h:28
@ kSTLmap
Definition ESTLType.h:33
@ kSTLunorderedmultimap
Definition ESTLType.h:45
@ kSTLunorderedmap
Definition ESTLType.h:44
@ kNotSTL
Definition ESTLType.h:29
@ kSTLmultimap
Definition ESTLType.h:34
void(* BrowseFunc_t)(const void *, TBrowser *)
Definition Rtypes.h:122
void *(* NewArrFunc_t)(Long_t size, void *arena)
Definition Rtypes.h:115
void Class_ShowMembers(TClass *cl, const void *obj, TMemberInspector &)
Indirect call to the implementation of ShowMember allowing [forward] declaration with out a full defi...
Definition TClass.cxx:615
EFunctionMatchMode
@ kExactMatch
void(* DelArrFunc_t)(void *)
Definition Rtypes.h:117
void *(* NewFunc_t)(void *)
Definition Rtypes.h:114
Long64_t(* MergeFunc_t)(void *, TCollection *, TFileMergeInfo *)
Definition Rtypes.h:120
ROOT::ESTLType STLKind(std::string_view type)
Converts STL container name to number.
bool IsStdPairBase(std::string_view name)
Definition TClassEdit.h:217
std::string ResolveTypedef(const char *tname, bool resolveAll=false)
bool IsStdArray(std::string_view name)
Definition TClassEdit.h:212
bool IsStdClass(const char *type)
return true if the class belongs to the std namespace
bool IsStdPair(std::string_view name)
Definition TClassEdit.h:213
bool IsInterpreterDetail(const char *type)
Return true if the type is one the interpreter details which are only forward declared (ClassInfo_t e...
char * DemangleTypeIdName(const std::type_info &ti, int &errorCode)
Demangle in a portable way the type id name.
ROOT::ESTLType IsSTLCont(std::string_view type)
type : type name: vector<list<classA,allocator>,allocator> result: 0 : not stl container code of cont...
std::string ShortType(const char *typeDesc, int mode)
Return the absolute type of typeDesc.
bool IsArtificial(std::string_view name)
Definition TClassEdit.h:188
int GetSplit(const char *type, std::vector< std::string > &output, int &nestedLoc, EModType mode=TClassEdit::kNone)
Stores in output (after emptying it) the split type.
void GetNormalizedName(std::string &norm_name, std::string_view name)
Return the normalized name.
@ kDropStlDefault
Definition TClassEdit.h:83
bool IsSTLBitset(const char *type)
Return true is the name is std::bitset<number> or bitset<number>
UInt_t Find(std::list< std::pair< const Node< T > *, Float_t > > &nlist, const Node< T > *node, const T &event, UInt_t nfind)
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.
static const char * what
Definition stlLoader.cc:5
bool IsTemplate()
Check if the type is a template.
std::vector< std::string > fElements
Definition TClassEdit.h:125
TVirtualStreamerInfo * GetAllocator() const
Definition TClass.h:152
void * GetPtr() const
Definition TClass.h:150
TClass::ENewType & fCurrentValue
Definition TClass.cxx:276
TClass__GetCallingNewRAII(TClass::ENewType newvalue)
Definition TClass.cxx:279
TClass::ENewType fOldValue
Definition TClass.cxx:277
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4