Logo ROOT  
Reference Guide
TCollection.cxx
Go to the documentation of this file.
1 // @(#)root/cont:$Id$
2 // Author: Fons Rademakers 13/08/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 TCollection
13 \ingroup Containers
14 Collection abstract base class. This class describes the base
15 protocol all collection classes have to implement. The ROOT
16 collection classes always store pointers to objects that inherit
17 from TObject. They never adopt the objects. Therefore, it is the
18 user's responsibility to take care of deleting the actual objects
19 once they are not needed anymore. In exceptional cases, when the
20 user is 100% sure nothing else is referencing the objects in the
21 collection, one can delete all objects and the collection at the
22 same time using the Delete() function.
23 
24 Collections can be iterated using an iterator object (see
25 TIterator). Depending on the concrete collection class there may be
26 some additional methods of iterating. See the respective classes.
27 
28 TCollection inherits from TObject since we want to be able to have
29 collections of collections.
30 
31 In a later release the collections may become templatized.
32 */
33 
34 #include "TCollection.h"
35 #include "Varargs.h"
36 #include "TBuffer.h"
37 #include "TClass.h"
38 #include "TROOT.h"
39 #include "TBrowser.h"
40 #include "TObjectTable.h"
41 #include "TRegexp.h"
42 #include "TPRegexp.h"
43 #include "TVirtualMutex.h"
44 #include "TError.h"
45 #include "TSystem.h"
46 #include "TObjArray.h"
47 #include <iostream>
48 #include <sstream>
49 
50 #include "TSpinLockGuard.h"
51 
53 
58 
61 
62 #ifdef R__CHECK_COLLECTION_MULTI_ACCESS
63 
64 void TCollection::TErrorLock::ConflictReport(std::thread::id holder, const char *accesstype,
65  const TCollection *collection, const char *function)
66 {
67 
68  auto local = std::this_thread::get_id();
69  std::stringstream cur, loc;
70  if (holder == std::thread::id())
71  cur << "None";
72  else
73  cur << "0x" << std::hex << holder;
74  loc << "0x" << std::hex << local;
75 
76  // std::cerr << "Error in " << function << ": Access (" << accesstype << ") to a collection (" <<
77  // collection->IsA()->GetName() << ":" << collection <<
78  // ") from multiple threads at a time. holder=" << "0x" << std::hex << holder << " readers=" << fReadSet.size() <<
79  // "0x" << std::hex << local << std::endl;
80 
81  ::Error(function,
82  "Access (%s) to a collection (%s:%p) from multiple threads at a time. holder=%s readers=%lu intruder=%s",
83  accesstype, collection->IsA()->GetName(), collection, cur.str().c_str(), fReadSet.size(), loc.str().c_str());
84 
85  std::set<std::thread::id> tmp;
86  for (auto r : fReadSet) tmp.insert(r);
87  for (auto r : tmp) {
88  std::stringstream reader;
89  reader << "0x" << std::hex << r;
90  ::Error(function, " Readers includes %s", reader.str().c_str());
91  }
93 }
94 
95 void TCollection::TErrorLock::Lock(const TCollection *collection, const char *function)
96 {
97  auto local = std::this_thread::get_id();
98 
99  std::thread::id holder;
100 
101  if (fWriteCurrent.compare_exchange_strong(holder, local)) {
102  // fWriteCurrent was the default id and is now local.
103  ++fWriteCurrentRecurse;
104  // std::cerr << "#" << "0x" << std::hex << local << " acquired first " << collection << " lock:" << this <<
105  // std::endl;
106 
107  // Now check if there is any readers lingering
108  if (fReadCurrentRecurse) {
109  if (fReadSet.size() > 1 || fReadSet.find(local) != fReadSet.end()) {
110  ConflictReport(std::thread::id(), "WriteLock while ReadLock taken", collection, function);
111  }
112  }
113  } else {
114  // fWriteCurrent was not the default id and is still the 'holder' thread id
115  // this id is now also in the holder variable
116  if (holder == local) {
117  // The holder was actually this thread, no problem there, we
118  // allow re-entrancy.
119  // std::cerr << "#" << "0x" << std::hex << local << " re-entered " << fWriteCurrentRecurse << " " << collection
120  // << " lock:" << this << std::endl;
121  } else {
122  ConflictReport(holder, "WriteLock", collection, function);
123  }
124  ++fWriteCurrentRecurse;
125  }
126 }
127 
128 void TCollection::TErrorLock::Unlock()
129 {
130  auto local = std::this_thread::get_id();
131  auto none = std::thread::id();
132 
133  --fWriteCurrentRecurse;
134  if (fWriteCurrentRecurse == 0) {
135  if (fWriteCurrent.compare_exchange_strong(local, none)) {
136  // fWriteCurrent was local and is now none.
137 
138  // std::cerr << "#" << "0x" << std::hex << local << " zero and cleaned : " << std::dec << fWriteCurrentRecurse
139  // << " 0x" << std::hex << fWriteCurrent.load() << " lock:" << this << std::endl;
140  } else {
141  // fWriteCurrent was not local, just live it as is.
142 
143  // std::cerr << "#" << "0x" << std::hex << local << " zero but somebody else : " << "0x" << std::hex <<
144  // fWriteCurrent.load() << " lock:" << this << std::endl;
145  }
146  } else {
147  // std::cerr << "#" << "0x" << std::hex << local << " still holding " << "0x" << std::hex << fWriteCurrentRecurse
148  // << " lock:" << this << std::endl;
149  }
150 
151  // std::cerr << "#" << "0x" << std::hex << local << " ended with : " << std::dec << fWriteCurrentRecurse << " 0x" <<
152  // std::hex << fWriteCurrent.load() << " lock:" << this << std::endl;
153 }
154 
155 void TCollection::TErrorLock::ReadLock(const TCollection *collection, const char *function)
156 {
157  auto local = std::this_thread::get_id();
158 
159  {
160  ROOT::Internal::TSpinLockGuard guard(fSpinLockFlag);
161  fReadSet.insert(local); // this is not thread safe ...
162  }
163  ++fReadCurrentRecurse;
164 
165  if (fWriteCurrentRecurse) {
166  auto holder = fWriteCurrent.load();
167  if (holder != local) ConflictReport(holder, "ReadLock with WriteLock taken", collection, function);
168  }
169 }
170 
171 void TCollection::TErrorLock::ReadUnlock()
172 {
173  auto local = std::this_thread::get_id();
174  {
175  ROOT::Internal::TSpinLockGuard guard(fSpinLockFlag);
176  fReadSet.erase(local); // this is not thread safe ...
177  }
178  --fReadCurrentRecurse;
179 }
180 
181 #endif // R__CHECK_COLLECTION_MULTI_ACCESS
182 
183 ////////////////////////////////////////////////////////////////////////////////
184 /// TNamed destructor.
185 
187 {
188  // Required since we overload TObject::Hash.
190 }
191 
192 ////////////////////////////////////////////////////////////////////////////////
193 /// Add all objects from collection col to this collection.
194 
196 {
197  TIter next(col);
198  TObject *obj;
199 
200  while ((obj = next()))
201  Add(obj);
202 }
203 
204 ////////////////////////////////////////////////////////////////////////////////
205 /// Add all arguments to the collection. The list of objects must be
206 /// terminated by 0, e.g.: l.AddVector(o1, o2, o3, o4, 0);
207 
209 {
210  va_list ap;
211  va_start(ap, va_(obj1));
212  TObject *obj;
213 
214  Add(va_(obj1));
215  while ((obj = va_arg(ap, TObject *)))
216  Add(obj);
217  va_end(ap);
218 }
219 
220 ////////////////////////////////////////////////////////////////////////////////
221 /// Make sure all objects in this collection inherit from class cl.
222 
224 {
225  TObject *obj;
226  TIter next(this);
227  Bool_t error = kFALSE;
228 
229  if (!cl) {
230  Error("AssertClass", "class == 0");
231  return kTRUE;
232  }
233 
234  for (int i = 0; (obj = next()); i++)
235  if (!obj->InheritsFrom(cl)) {
236  Error("AssertClass", "element %d is not an instance of class %s (%s)",
237  i, cl->GetName(), obj->ClassName());
238  error = kTRUE;
239  }
240  return error;
241 }
242 
243 ////////////////////////////////////////////////////////////////////////////////
244 /// Browse this collection (called by TBrowser).
245 /// If b=0, there is no Browse call TObject::Browse(0) instead.
246 /// This means TObject::Inspect() will be invoked indirectly
247 
249 {
250  TIter next(this);
251  TObject *obj;
252 
253  if (b)
254  while ((obj = next())) b->Add(obj);
255  else
257 }
258 
259 ////////////////////////////////////////////////////////////////////////////////
260 /// Make a clone of an collection using the Streamer facility.
261 /// If newname is specified, this will be the name of the new collection.
262 
263 TObject *TCollection::Clone(const char *newname) const
264 {
265  TCollection *new_collection = (TCollection*)TObject::Clone(newname);
266  if (newname && strlen(newname)) new_collection->SetName(newname);
267  return new_collection;
268 }
269 
270 
271 ////////////////////////////////////////////////////////////////////////////////
272 /// Compare two TCollection objects. Returns 0 when equal, -1 when this is
273 /// smaller and +1 when bigger (like strcmp()).
274 
276 {
277  if (this == obj) return 0;
278  return fName.CompareTo(obj->GetName());
279 }
280 
281 ////////////////////////////////////////////////////////////////////////////////
282 /// Draw all objects in this collection.
283 
285 {
286  TIter next(this);
287  TObject *object;
288 
289  while ((object = next())) {
290  object->Draw(option);
291  }
292 }
293 
294 ////////////////////////////////////////////////////////////////////////////////
295 /// Dump all objects in this collection.
296 
297 void TCollection::Dump() const
298 {
299  TIter next(this);
300  TObject *object;
301 
302  while ((object = next())) {
303  object->Dump();
304  }
305 }
306 
307 ////////////////////////////////////////////////////////////////////////////////
308 /// Find an object in this collection using its name. Requires a sequential
309 /// scan till the object has been found. Returns 0 if object with specified
310 /// name is not found.
311 
313 {
314  TIter next(this);
315  TObject *obj;
316 
317  while ((obj = next()))
318  if (!strcmp(name, obj->GetName())) return obj;
319  return 0;
320 }
321 
322 ////////////////////////////////////////////////////////////////////////////////
323 /// Find an object in this collection by name.
324 
326 {
327  return FindObject(name);
328 }
329 
330 ////////////////////////////////////////////////////////////////////////////////
331 /// Find an object in this collection using the object's IsEqual()
332 /// member function. Requires a sequential scan till the object has
333 /// been found. Returns 0 if object is not found.
334 /// Typically this function is overridden by a more efficient version
335 /// in concrete collection classes (e.g. THashTable).
336 
338 {
339  TIter next(this);
340  TObject *ob;
341 
342  while ((ob = next()))
343  if (ob->IsEqual(obj)) return ob;
344  return 0;
345 }
346 
347 ////////////////////////////////////////////////////////////////////////////////
348 /// Return name of this collection.
349 /// if no name, return the collection class name.
350 
351 const char *TCollection::GetName() const
352 {
353  if (fName.Length() > 0) return fName.Data();
354  return ClassName();
355 }
356 
357 ////////////////////////////////////////////////////////////////////////////////
358 /// Increase the collection's capacity by delta slots.
359 
361 {
362  if (delta < 0) {
363  Error("GrowBy", "delta < 0");
364  delta = Capacity();
365  }
366  return Capacity() + TMath::Range(2, kMaxInt - Capacity(), delta);
367 }
368 
369 ////////////////////////////////////////////////////////////////////////////////
370 /// Returns true if object is a null pointer.
371 
372 Bool_t TCollection::IsArgNull(const char *where, const TObject *obj) const
373 {
374  return obj ? kFALSE : (Error(where, "argument is a null pointer"), kTRUE);
375 }
376 
377 ////////////////////////////////////////////////////////////////////////////////
378 /// List (ls) all objects in this collection.
379 /// Wildcarding supported, eg option="xxx*" lists only objects
380 /// with names xxx*.
381 
382 void TCollection::ls(Option_t *option) const
383 {
385  std::cout <<"OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << " : "
386  << Int_t(TestBit(kCanDelete)) << std::endl;
387 
388  TRegexp re(option,kTRUE);
389  TIter next(this);
390  TObject *object;
391  char *star = 0;
392  if (option) star = (char*)strchr(option,'*');
393 
395  while ((object = next())) {
396  if (star) {
397  TString s = object->GetName();
398  if (s != option && s.Index(re) == kNPOS) continue;
399  }
400  object->ls(option);
401  }
403 }
404 
405 ////////////////////////////////////////////////////////////////////////////////
406 /// 'Notify' all objects in this collection.
408 {
409  Bool_t success = true;
410  for (auto obj : *this) success &= obj->Notify();
411  return success;
412 }
413 
414 ////////////////////////////////////////////////////////////////////////////////
415 /// Paint all objects in this collection.
416 
418 {
419  this->R__FOR_EACH(TObject,Paint)(option);
420 }
421 
422 ////////////////////////////////////////////////////////////////////////////////
423 /// Print the collection header.
424 
426 {
428  printf("Collection name='%s', class='%s', size=%d\n",
429  GetName(), ClassName(), GetSize());
430 }
431 
432 ////////////////////////////////////////////////////////////////////////////////
433 /// For given collection entry return the string that is used to
434 /// identify the object and, potentially, perform wildcard/regexp
435 /// filtering on.
436 
438 {
439  return entry->GetName();
440 }
441 
442 ////////////////////////////////////////////////////////////////////////////////
443 /// Print the collection entry.
444 
445 void TCollection::PrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const
446 {
447  TCollection* coll = dynamic_cast<TCollection*>(entry);
448  if (coll) {
449  coll->Print(option, recurse);
450  } else {
452  entry->Print(option);
453  }
454 }
455 
456 ////////////////////////////////////////////////////////////////////////////////
457 /// Default print for collections, calls Print(option, 1).
458 /// This will print the collection header and Print() methods of
459 /// all the collection entries.
460 ///
461 /// If you want to override Print() for a collection class, first
462 /// see if you can accomplish it by overriding the following protected
463 /// methods:
464 /// ~~~ {.cpp}
465 /// void PrintCollectionHeader(Option_t* option) const;
466 /// const char* GetCollectionEntryName(TObject* entry) const;
467 /// void PrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const;
468 /// ~~~
469 /// Otherwise override the `Print(Option_t *option, Int_t)`
470 /// variant. Remember to declare:
471 /// ~~~ {.cpp}
472 /// using TCollection::Print;
473 /// ~~~
474 /// somewhere close to the method declaration.
475 
476 void TCollection::Print(Option_t *option) const
477 {
478  Print(option, 1);
479 }
480 
481 ////////////////////////////////////////////////////////////////////////////////
482 /// Print the collection header and its elements.
483 ///
484 /// If recurse is non-zero, descend into printing of
485 /// collection-entries with recurse - 1.
486 /// This means, if recurse is negative, the recursion is infinite.
487 ///
488 /// Option is passed recursively.
489 
490 void TCollection::Print(Option_t *option, Int_t recurse) const
491 {
492  PrintCollectionHeader(option);
493 
494  if (recurse != 0)
495  {
496  TIter next(this);
497  TObject *object;
498 
500  while ((object = next())) {
501  PrintCollectionEntry(object, option, recurse - 1);
502  }
504  }
505 }
506 
507 ////////////////////////////////////////////////////////////////////////////////
508 /// Print the collection header and its elements that match the wildcard.
509 ///
510 /// If recurse is non-zero, descend into printing of
511 /// collection-entries with recurse - 1.
512 /// This means, if recurse is negative, the recursion is infinite.
513 ///
514 /// Option is passed recursively, but wildcard is only used on the
515 /// first level.
516 
517 void TCollection::Print(Option_t *option, const char* wildcard, Int_t recurse) const
518 {
519  PrintCollectionHeader(option);
520 
521  if (recurse != 0)
522  {
523  if (!wildcard) wildcard = "";
524  TRegexp re(wildcard, kTRUE);
525  Int_t nch = strlen(wildcard);
526  TIter next(this);
527  TObject *object;
528 
530  while ((object = next())) {
531  TString s = GetCollectionEntryName(object);
532  if (nch == 0 || s == wildcard || s.Index(re) != kNPOS) {
533  PrintCollectionEntry(object, option, recurse - 1);
534  }
535  }
537  }
538 }
539 
540 ////////////////////////////////////////////////////////////////////////////////
541 /// Print the collection header and its elements that match the regexp.
542 ///
543 /// If recurse is non-zero, descend into printing of
544 /// collection-entries with recurse - 1.
545 /// This means, if recurse is negative, the recursion is infinite.
546 ///
547 /// Option is passed recursively, but regexp is only used on the
548 /// first level.
549 
550 void TCollection::Print(Option_t *option, TPRegexp& regexp, Int_t recurse) const
551 {
552  PrintCollectionHeader(option);
553 
554  if (recurse != 0)
555  {
556  TIter next(this);
557  TObject *object;
558 
560  while ((object = next())) {
561  TString s = GetCollectionEntryName(object);
562  if (regexp.MatchB(s)) {
563  PrintCollectionEntry(object, option, recurse - 1);
564  }
565  }
567  }
568 }
569 
570 ////////////////////////////////////////////////////////////////////////////////
571 /// Remove object from this collection and recursively remove the object
572 /// from all other objects (and collections).
573 
575 {
576  if (!obj) return;
577 
578  // Scan list and remove obj in the list itself
579  while (Remove(obj))
580  ;
581 
582  // Scan again the list and invoke RecursiveRemove for all objects
583  TIter next(this);
584  TObject *object;
585 
586  while ((object = next())) {
587  if (object->TestBit(kNotDeleted)) object->RecursiveRemove(obj);
588  }
589 }
590 
591 ////////////////////////////////////////////////////////////////////////////////
592 /// Remove all objects in collection col from this collection.
593 
595 {
596  TIter next(col);
597  TObject *obj;
598 
599  while ((obj = next()))
600  Remove(obj);
601 }
602 
603 ////////////////////////////////////////////////////////////////////////////////
604 /// Stream all objects in the collection to or from the I/O buffer.
605 
606 void TCollection::Streamer(TBuffer &b)
607 {
608  Int_t nobjects;
609  TObject *obj;
610  UInt_t R__s, R__c;
611 
612  if (b.IsReading()) {
613  Version_t v = b.ReadVersion(&R__s, &R__c);
614  if (v > 2)
615  TObject::Streamer(b);
616  if (v > 1)
617  fName.Streamer(b);
618  b >> nobjects;
619  for (Int_t i = 0; i < nobjects; i++) {
620  b >> obj;
621  Add(obj);
622  }
623  b.CheckByteCount(R__s, R__c,TCollection::IsA());
624  } else {
625  R__c = b.WriteVersion(TCollection::IsA(), kTRUE);
626  TObject::Streamer(b);
627  fName.Streamer(b);
628  nobjects = GetSize();
629  b << nobjects;
630 
631  TIter next(this);
632 
633  while ((obj = next())) {
634  b << obj;
635  }
636  b.SetByteCount(R__c, kTRUE);
637  }
638 }
639 
640 ////////////////////////////////////////////////////////////////////////////////
641 /// Write all objects in this collection. By default all objects in
642 /// the collection are written individually (each object gets its
643 /// own key). Note, this is recursive, i.e. objects in collections
644 /// in the collection are also written individually. To write all
645 /// objects using a single key specify a name and set option to
646 /// TObject::kSingleKey (i.e. 1).
647 
648 Int_t TCollection::Write(const char *name, Int_t option, Int_t bsize) const
649 {
650  if ((option & kSingleKey)) {
651  return TObject::Write(name, option, bsize);
652  } else {
653  option &= ~kSingleKey;
654  Int_t nbytes = 0;
655  TIter next(this);
656  TObject *obj;
657  while ((obj = next())) {
658  nbytes += obj->Write(name, option, bsize);
659  }
660  return nbytes;
661  }
662 }
663 
664 ////////////////////////////////////////////////////////////////////////////////
665 /// Write all objects in this collection. By default all objects in
666 /// the collection are written individually (each object gets its
667 /// own key). Note, this is recursive, i.e. objects in collections
668 /// in the collection are also written individually. To write all
669 /// objects using a single key specify a name and set option to
670 /// TObject::kSingleKey (i.e. 1).
671 
672 Int_t TCollection::Write(const char *name, Int_t option, Int_t bsize)
673 {
674  return ((const TCollection*)this)->Write(name,option,bsize);
675 }
676 
677 ////////////////////////////////////////////////////////////////////////////////
678 /// Return the globally accessible collection.
679 
681 {
682  return fgCurrentCollection;
683 }
684 
685 ////////////////////////////////////////////////////////////////////////////////
686 /// Set this collection to be the globally accesible collection.
687 
689 {
690  fgCurrentCollection = this;
691 }
692 
693 ////////////////////////////////////////////////////////////////////////////////
694 /// Set up for garbage collection.
695 
697 {
699  if (!fgGarbageCollection) {
702  fgGarbageStack = 0;
703  }
704  fgGarbageStack++;
705 }
706 
707 ////////////////////////////////////////////////////////////////////////////////
708 /// Do the garbage collection.
709 
711 {
713  if (fgGarbageStack > 0) fgGarbageStack--;
719  }
720 }
721 
722 ////////////////////////////////////////////////////////////////////////////////
723 /// Add to the list of things to be cleaned up.
724 
726 {
727  {
729  if (fgGarbageCollection) {
730  if (!fgEmptyingGarbage) {
731  fgGarbageCollection->Add(obj);
732  return;
733  }
734  }
735  }
736  delete obj;
737 }
738 
739 ////////////////////////////////////////////////////////////////////////////////
740 /// Set whether this collection is the owner (enable==true)
741 /// of its content. If it is the owner of its contents,
742 /// these objects will be deleted whenever the collection itself
743 /// is delete. The objects might also be deleted or destructed when Clear
744 /// is called (depending on the collection).
745 
747 {
748  if (enable)
749  SetBit(kIsOwner);
750  else
752 }
753 
754 ////////////////////////////////////////////////////////////////////////////////
755 /// Set this collection to use a RW lock upon access, making it thread safe.
756 /// Return the previous state.
757 ///
758 /// Note: To test whether the usage is enabled do:
759 /// collection->TestBit(TCollection::kUseRWLock);
760 
762 {
763  bool prev = TestBit(TCollection::kUseRWLock);
765  return prev;
766 }
767 
768 ////////////////////////////////////////////////////////////////////////////////
769 /// Copy a TIter. This involves allocating a new TIterator of the right
770 /// sub class and assigning it with the original.
771 
772 TIter::TIter(const TIter &iter)
773 {
774  if (iter.fIterator) {
776  fIterator->operator=(*iter.fIterator);
777  } else
778  fIterator = 0;
779 }
780 
781 ////////////////////////////////////////////////////////////////////////////////
782 /// Assigning an TIter to another. This involves allocating a new TIterator
783 /// of the right sub class and assigning it with the original.
784 
786 {
787  if (this != &rhs) {
788  if (rhs.fIterator) {
789  delete fIterator;
791  fIterator->operator=(*rhs.fIterator);
792  }
793  }
794  return *this;
795 }
796 
797 ////////////////////////////////////////////////////////////////////////////////
798 /// Pointing to the first element of the container.
799 
801 {
802  fIterator->Reset();
803  fIterator->Next();
804  return *this;
805 }
806 
807 ////////////////////////////////////////////////////////////////////////////////
808 /// Pointing to the element after the last - to a nullptr value in our case.
809 
811 {
812  return TIter(static_cast<TIterator*>(nullptr));
813 }
814 
815 ////////////////////////////////////////////////////////////////////////////////
816 /// Return an empty collection for use with nullptr TRangeCast
817 
819 {
820  static TObjArray sEmpty;
821  return sEmpty;
822 }
823 
824 ////////////////////////////////////////////////////////////////////////////////
825 /// Return true if 'cl' inherits from 'base'.
826 
828 {
829  return cl->InheritsFrom(base);
830 }
gCollectionMutex
TVirtualMutex * gCollectionMutex
Definition: TCollection.cxx:52
TBrowser
Definition: TBrowser.h:37
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TObjectTable
Definition: TObjectTable.h:35
TObject::TestBit
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
TCollection::Print
virtual void Print(Option_t *option="") const
Default print for collections, calls Print(option, 1).
Definition: TCollection.cxx:476
Version_t
short Version_t
Definition: RtypesCore.h:65
TObjArray
Definition: TObjArray.h:37
TCollection::Compare
Int_t Compare(const TObject *obj) const
Compare two TCollection objects.
Definition: TCollection.cxx:275
TROOT::DecreaseDirLevel
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition: TROOT.cxx:2696
TSpinLockGuard.h
TCollection::IsArgNull
Bool_t IsArgNull(const char *where, const TObject *obj) const
Returns true if object is a null pointer.
Definition: TCollection.cxx:372
TCollection::Write
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write all objects in this collection.
Definition: TCollection.cxx:672
kNPOS
const Ssiz_t kNPOS
Definition: RtypesCore.h:115
TObject::Print
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition: TObject.cxx:552
TObjectTable::Add
void Add(TObject *obj)
Add an object to the object table.
Definition: TObjectTable.cxx:147
TString::Data
const char * Data() const
Definition: TString.h:369
TIter::fIterator
TIterator * fIterator
Definition: TCollection.h:236
TSystem::StackTrace
virtual void StackTrace()
Print a stack trace.
Definition: TSystem.cxx:733
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TCollection.h
TCollection::Remove
virtual TObject * Remove(TObject *obj)=0
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TCollection::GetCollectionEntryName
virtual const char * GetCollectionEntryName(TObject *entry) const
For given collection entry return the string that is used to identify the object and,...
Definition: TCollection.cxx:437
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:890
TCollection::SetOwner
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Definition: TCollection.cxx:746
TCollection::Draw
virtual void Draw(Option_t *option="")
Draw all objects in this collection.
Definition: TCollection.cxx:284
TCollection::Clone
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
Definition: TCollection.cxx:263
TIter::Begin
TIter & Begin()
Pointing to the first element of the container.
Definition: TCollection.cxx:800
TGeant4Unit::s
static constexpr double s
Definition: TGeant4SystemOfUnits.h:168
Int_t
int Int_t
Definition: RtypesCore.h:45
TVirtualMutex
Definition: TVirtualMutex.h:32
TBrowser.h
SafeDelete
#define SafeDelete(p)
Definition: RConfig.hxx:543
va_
#define va_(arg)
Definition: Varargs.h:41
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TClass.h
TCollection::fName
TString fName
Definition: TCollection.h:147
ROOT::Internal::EmptyCollection
const TCollection & EmptyCollection()
Return an empty collection for use with nullptr TRangeCast.
Definition: TCollection.cxx:818
TBuffer
Definition: TBuffer.h:43
TObject::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:403
Varargs.h
TString
Definition: TString.h:136
TCollection::AddVector
void AddVector(TObject *obj1,...)
Add all arguments to the collection.
Definition: TCollection.cxx:208
TCollection::AddAll
virtual void AddAll(const TCollection *col)
Add all objects from collection col to this collection.
Definition: TCollection.cxx:195
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TObject::InheritsFrom
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
v
@ v
Definition: rootcling_impl.cxx:3635
b
#define b(i)
Definition: RSha256.hxx:118
bool
TIterator
Definition: TIterator.h:30
TIter::operator=
TIter & operator=(const TIter &rhs)
Assigning an TIter to another.
Definition: TCollection.cxx:785
object
id
XFontStruct * id
Definition: TGX11.cxx:109
TCollection::fgCurrentCollection
static TCollection * fgCurrentCollection
Definition: TCollection.h:132
TROOT.h
TObject::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:359
TObject::Browse
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition: TObject.cxx:121
TRegexp.h
TPRegexp::MatchB
Bool_t MatchB(const TString &s, const TString &mods="", Int_t start=0, Int_t nMaxMatch=10)
Definition: TPRegexp.h:78
TObjectTable::Delete
void Delete(Option_t *opt="")
Delete all objects stored in the TObjectTable.
Definition: TObjectTable.cxx:195
TCollection::StartGarbageCollection
static void StartGarbageCollection()
Set up for garbage collection.
Definition: TCollection.cxx:696
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TClass::InheritsFrom
Bool_t InheritsFrom(const char *cl) const
Return kTRUE if this class inherits from a class with name "classname".
Definition: TClass.cxx:4772
TCollection::UseRWLock
virtual bool UseRWLock()
Set this collection to use a RW lock upon access, making it thread safe.
Definition: TCollection.cxx:761
TPRegexp.h
TBuffer.h
TCollection::Notify
virtual Bool_t Notify()
'Notify' all objects in this collection.
Definition: TCollection.cxx:407
TObject::ResetBit
void ResetBit(UInt_t f)
Definition: TObject.h:171
TSystem.h
TCollection::Dump
virtual void Dump() const
Dump all objects in this collection.
Definition: TCollection.cxx:297
TCollection::fgEmptyingGarbage
static Bool_t fgEmptyingGarbage
Definition: TCollection.h:134
TObject::SetBit
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:696
TCollection::GarbageCollect
static void GarbageCollect(TObject *obj)
Add to the list of things to be cleaned up.
Definition: TCollection.cxx:725
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TObject::kSingleKey
@ kSingleKey
write collection with single key
Definition: TObject.h:87
TObject::Clone
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:146
TCollection::GrowBy
virtual Int_t GrowBy(Int_t delta) const
Increase the collection's capacity by delta slots.
Definition: TCollection.cxx:360
TCollection::PrintCollectionEntry
virtual void PrintCollectionEntry(TObject *entry, Option_t *option, Int_t recurse) const
Print the collection entry.
Definition: TCollection.cxx:445
TObject::IsEqual
virtual Bool_t IsEqual(const TObject *obj) const
Default equal comparison (objects are equal if they have the same address in memory).
Definition: TObject.cxx:485
TCollection::SetCurrentCollection
void SetCurrentCollection()
Set this collection to be the globally accesible collection.
Definition: TCollection.cxx:688
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TCollection::Browse
void Browse(TBrowser *b)
Browse this collection (called by TBrowser).
Definition: TCollection.cxx:248
TCollection::MakeIterator
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const =0
TObjectTable.h
TCollection::Paint
virtual void Paint(Option_t *option="")
Paint all objects in this collection.
Definition: TCollection.cxx:417
TVirtualMutex.h
TROOT::IncreaseDirLevel
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition: TROOT.cxx:2792
TObject::kCanDelete
@ kCanDelete
if object in a list can be deleted
Definition: TObject.h:58
TCollection::RecursiveRemove
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition: TCollection.cxx:574
TMath::Range
Short_t Range(Short_t lb, Short_t ub, Short_t x)
Definition: TMathBase.h:244
TROOT::IndentLevel
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2800
TIterator::Next
virtual TObject * Next()=0
TCollection::PrintCollectionHeader
virtual void PrintCollectionHeader(Option_t *option) const
Print the collection header.
Definition: TCollection.cxx:425
ROOT::Internal::TSpinLockGuard
A spin mutex-as-code-guard class.
Definition: TSpinLockGuard.h:47
TRegexp
Definition: TRegexp.h:31
TPRegexp
Definition: TPRegexp.h:36
gSystem
R__EXTERN TSystem * gSystem
Definition: TSystem.h:559
R__FOR_EACH
#define R__FOR_EACH(type, proc)
Definition: TCollection.h:448
TIterator::Reset
virtual void Reset()=0
TCollection::GetCurrentCollection
static TCollection * GetCurrentCollection()
Return the globally accessible collection.
Definition: TCollection.cxx:680
TCollection::kUseRWLock
@ kUseRWLock
Definition: TCollection.h:144
R__LOCKGUARD2
#define R__LOCKGUARD2(mutex)
Definition: TVirtualMutex.h:106
TCollection::EmptyGarbageCollection
static void EmptyGarbageCollection()
Do the garbage collection.
Definition: TCollection.cxx:710
TString::CompareTo
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
Definition: TString.cxx:418
TIter::End
static TIter End()
Pointing to the element after the last - to a nullptr value in our case.
Definition: TCollection.cxx:810
TObject::kNotDeleted
@ kNotDeleted
object has not been deleted
Definition: TObject.h:78
TObjArray.h
TCollection::GetSize
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
TClass
Definition: TClass.h:80
TCollection::~TCollection
virtual ~TCollection()
TNamed destructor.
Definition: TCollection.cxx:186
TCollection::operator()
TObject * operator()(const char *name) const
Find an object in this collection by name.
Definition: TCollection.cxx:325
TCollection::SetName
void SetName(const char *name)
Definition: TCollection.h:204
TObject::Write
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition: TObject.cxx:795
TIter::TIter
TIter()
Definition: TCollection.h:239
TCollection::fgGarbageCollection
static TObjectTable * fgGarbageCollection
Definition: TCollection.h:133
TObject
Definition: TObject.h:37
TCollection::Capacity
Int_t Capacity() const
Definition: TCollection.h:165
TCollection::Add
virtual void Add(TObject *obj)=0
name
char name[80]
Definition: TGX11.cxx:110
TCollection::RemoveAll
void RemoveAll()
Definition: TCollection.h:202
TCollection::AssertClass
Bool_t AssertClass(TClass *cl) const
Make sure all objects in this collection inherit from class cl.
Definition: TCollection.cxx:223
kMaxInt
const Int_t kMaxInt
Definition: RtypesCore.h:103
TIter
Definition: TCollection.h:233
ROOT::Internal::ContaineeInheritsFrom
bool ContaineeInheritsFrom(TClass *cl, TClass *base)
Return true if 'cl' inherits from 'base'.
Definition: TCollection.cxx:827
TCollection::kIsOwner
@ kIsOwner
Definition: TCollection.h:142
TCollection::fgGarbageStack
static Int_t fgGarbageStack
Definition: TCollection.h:135
TIter::GetCollection
const TCollection * GetCollection() const
Definition: TCollection.h:250
TCollection::ls
virtual void ls(Option_t *option="") const
List (ls) all objects in this collection.
Definition: TCollection.cxx:382
TCollection
Definition: TCollection.h:63
ROOT::CallRecursiveRemoveIfNeeded
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition: TROOT.h:395
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:53
TCollection::GetName
virtual const char * GetName() const
Return name of this collection.
Definition: TCollection.cxx:351
TCollection::FindObject
virtual TObject * FindObject(const char *name) const
Find an object in this collection using its name.
Definition: TCollection.cxx:312
TObject::ClassName
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:130
int
Error
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition: TError.cxx:187
TError.h