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