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