Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TObject.cxx
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Rene Brun 26/12/94
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 TObject
13\ingroup Base
14
15Mother of all ROOT objects.
16
17The TObject class provides default behaviour and protocol for all
18objects in the ROOT system. It provides protocol for object I/O,
19error handling, sorting, inspection, printing, drawing, etc.
20Every object which inherits from TObject can be stored in the
21ROOT collection classes.
22
23TObject's bits can be used as flags, bits 0 - 13 and 24-31 are
24reserved as global bits while bits 14 - 23 can be used in different
25class hierarchies (watch out for overlaps).
26
27 Note: Class inheriting directly or indirectly from TObject should not use
28 `= default` for any of the constructors.
29 The default implementation for a constructor can sometime do 'more' than we
30 expect (and still being standard compliant). On some platforms it will reset
31 all the data member of the class including its base class's member before the
32 actual execution of the base class constructor.
33 `TObject`'s implementation of the `IsOnHeap` bit requires the memory occupied
34 by `TObject::fUniqueID` to *not* be reset between the execution of `TObject::operator new`
35 and the `TObject` constructor (Finding the magic pattern there is how we can determine
36 that the object was allocated on the heap).
37*/
38
39#include <cstring>
40#if !defined(WIN32) && !defined(__MWERKS__) && !defined(R__SOLARIS)
41#include <strings.h>
42#endif
43#include <cstdlib>
44#include <cstdio>
45#include <sstream>
46#include <fstream>
47#include <iostream>
48#include <iomanip>
49#include <limits>
50
51#include "Varargs.h"
52#include "snprintf.h"
53#include "TObject.h"
54#include "TBuffer.h"
55#include "TClass.h"
56#include "TGuiFactory.h"
57#include "TMethod.h"
58#include "TROOT.h"
59#include "TError.h"
60#include "TObjectTable.h"
61#include "TVirtualPad.h"
62#include "TInterpreter.h"
63#include "TMemberInspector.h"
64#include "TRefTable.h"
65#include "TProcessID.h"
66
69
70#if defined(__clang__) || defined(__GNUC__)
71#define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
72#define ATTRIBUTE_NO_SANITIZE_THREAD __attribute__((no_sanitize_thread))
73#else
74#define ATTRIBUTE_NO_SANITIZE_ADDRESS
75#define ATTRIBUTE_NO_SANITIZE_THREAD
76#endif
77
78namespace ROOT {
79namespace Internal {
80
81// Return true if delete changes/poisons/taints the memory.
82//
83// Detect whether operator delete taints the memory. If it does, we can not rely
84// on TestBit(kNotDeleted) to check if the memory has been deleted (but in case,
85// like TClonesArray, where we know the destructor will be called but not operator
86// delete, we can still use it to detect the cases where the destructor was called.
87
91{
92 static constexpr UInt_t kGoldenUUID = 0x00000021;
93 static constexpr UInt_t kGoldenbits = 0x03000000;
94
95 TObject *o = new TObject;
97 UInt_t *o_fuid = &(o->fUniqueID);
98 UInt_t *o_fbits = &(o->fBits);
99
100 if (*o_fuid != kGoldenUUID) {
101 Error("CheckingDeleteSideEffects", "fUniqueID is not as expected, we got 0x%.8x instead of 0x%.8x", *o_fuid,
103 }
104 if (*o_fbits != kGoldenbits) {
105 Error("CheckingDeleteSideEffects", "fBits is not as expected, we got 0x%.8x instead of 0x%.8x", *o_fbits,
107 }
108 if (gDebug >= 9) {
109 unsigned char *oc = reinterpret_cast<unsigned char *>(o); // for address calculations
110 unsigned char references[sizeof(TObject)];
111 memcpy(references, oc, sizeof(TObject));
112
113 // The effective part of this code (the else statement is just that without
114 // any of the debug statement)
115 delete o;
116
117 // Not using the error logger, as there routine is meant to be called
118 // during library initialization/loading.
119 fprintf(stderr, "DEBUG: Checking before and after delete the content of a TObject with uniqueID 0x21\n");
120 for (size_t i = 0; i < sizeof(TObject); i += 4) {
121 fprintf(stderr, "DEBUG: 0x%.8x vs 0x%.8x\n", *(int *)(references + i), *(int *)(oc + i));
122 }
123 } else
124 delete o; // the 'if' part is that surrounded by the debug code.
125
126 // Intentionally accessing the deleted memory to check whether it has been changed as
127 // a consequence (side effect) of executing operator delete. If there no change, we
128 // can guess this is always the case and we can rely on the changes to fBits made
129 // by ~TObject to detect use-after-delete error (and print a message rather than
130 // stop the program with a segmentation fault)
131#if defined(_MSC_VER) && defined(__SANITIZE_ADDRESS__)
132 // on Windows, even __declspec(no_sanitize_address) does not prevent catching
133 // heap-use-after-free errorswhen using the /fsanitize=address compiler flag
134 // so don't even try
135 return true;
136#endif
137 if (*o_fbits != 0x01000000) {
138 // operator delete tainted the memory, we can not rely on TestBit(kNotDeleted)
139 return true;
140 }
141 return false;
142}
143
145{
146 static const bool value = DeleteChangesMemoryImpl();
147 if (gDebug >= 9)
148 DeleteChangesMemoryImpl(); // To allow for printing the debug info
149 return value;
150}
151
152} // namespace Internal
153} // namespace ROOT
154
155////////////////////////////////////////////////////////////////////////////////
156/// Copy this to obj.
157
158void TObject::Copy(TObject &obj) const
159{
160 obj.fUniqueID = fUniqueID; // when really unique don't copy
161 if (obj.IsOnHeap()) { // test uses fBits so don't move next line
162 obj.fBits = fBits;
163 obj.fBits |= kIsOnHeap;
164 } else {
165 obj.fBits = fBits;
166 obj.fBits &= ~kIsOnHeap;
168 obj.fBits &= ~kIsReferenced;
169 obj.fBits &= ~kCanDelete;
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// TObject destructor. Removes object from all canvases and object browsers
174/// if observer bit is on and remove from the global object table.
175
177{
178 // if (!TestBit(kNotDeleted))
179 // Fatal("~TObject", "object deleted twice");
180
182
184
187}
188
189////////////////////////////////////////////////////////////////////////////////
190/// Private helper function which will dispatch to
191/// TObjectTable::AddObj.
192/// Included here to avoid circular dependency between header files.
193
198
199////////////////////////////////////////////////////////////////////////////////
200/// Append graphics object to current pad. In case no current pad is set
201/// yet, create a default canvas with the name "c1".
202
204{
205 if (!gPad)
206 gROOT->MakeDefCanvas();
207
208 if (!gPad->IsEditable())
209 return;
210
211 gPad->Add(this, option);
212}
213
214////////////////////////////////////////////////////////////////////////////////
215/// Browse object. May be overridden for another default action
216
218{
219 // Inspect();
220 TClass::AutoBrowse(this, b);
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// Returns name of class to which the object belongs.
225
226const char *TObject::ClassName() const
227{
228 return IsA()->GetName();
229}
230
231////////////////////////////////////////////////////////////////////////////////
232/// Make a clone of an object using the Streamer facility.
233/// If the object derives from TNamed, this function is called
234/// by TNamed::Clone. TNamed::Clone uses the optional argument to set
235/// a new name to the newly created object.
236///
237/// If the object class has a DirectoryAutoAdd function, it will be
238/// called at the end of the function with the parameter gDirectory.
239/// This usually means that the object will be appended to the current
240/// ROOT directory.
241
242TObject *TObject::Clone(const char *) const
243{
244 if (gDirectory) {
245 return gDirectory->CloneObject(this);
246 } else {
247 // Some of the streamer (eg. roofit's) expect(ed?) a valid gDirectory during streaming.
248 return gROOT->CloneObject(this);
249 }
250}
251
252////////////////////////////////////////////////////////////////////////////////
253/// Compare abstract method. Must be overridden if a class wants to be able
254/// to compare itself with other objects. Must return -1 if this is smaller
255/// than obj, 0 if objects are equal and 1 if this is larger than obj.
256
258{
259 AbstractMethod("Compare");
260 return 0;
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Delete this object. Typically called as a command via the interpreter.
265/// Normally use "delete" operator when object has been allocated on the heap.
266
268{
269 if (IsOnHeap()) {
270 // Delete object from CINT symbol table so it can not be used anymore.
271 // CINT object are always on the heap.
272 gInterpreter->DeleteGlobal(this);
273
274 delete this;
275 }
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Computes distance from point (px,py) to the object.
280/// This member function must be implemented for each graphics primitive.
281/// This default function returns a big number (999999).
282
284{
285 // AbstractMethod("DistancetoPrimitive");
286 return 999999;
287}
288
289////////////////////////////////////////////////////////////////////////////////
290/// Default Draw method for all objects
291
296
297////////////////////////////////////////////////////////////////////////////////
298/// Draw class inheritance tree of the class to which this object belongs.
299/// If a class B inherits from a class A, description of B is drawn
300/// on the right side of description of A.
301/// Member functions overridden by B are shown in class A with a blue line
302/// crossing-out the corresponding member function.
303/// The following picture is the class inheritance tree of class TPaveLabel:
304///
305/// \image html base_object.png
306
308{
309 IsA()->Draw();
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Draw a clone of this object in the current selected pad with:
314/// `gROOT->SetSelectedPad(c1)`.
315/// If pad was not selected - `gPad` will be used.
316/// \note For histograms, use the more specialised TH1::DrawCopy().
317
319{
321 auto pad = gROOT->GetSelectedPad();
322 if (pad)
323 pad->cd();
324
325 TObject *newobj = Clone();
326 if (!newobj)
327 return nullptr;
328
329 if (!option || !*option)
331
332 if (pad) {
333 pad->Add(newobj, option);
334 pad->Update();
335 } else {
336 newobj->Draw(option);
337 }
338
339 return newobj;
340}
341
342////////////////////////////////////////////////////////////////////////////////
343/// Dump contents of object on stdout.
344/// Using the information in the object dictionary (class TClass)
345/// each data member is interpreted.
346/// If a data member is a pointer, the pointer value is printed
347///
348/// The following output is the Dump of a TArrow object:
349/// ~~~ {.cpp}
350/// fAngle 0 Arrow opening angle (degrees)
351/// fArrowSize 0.2 Arrow Size
352/// fOption.*fData
353/// fX1 0.1 X of 1st point
354/// fY1 0.15 Y of 1st point
355/// fX2 0.67 X of 2nd point
356/// fY2 0.83 Y of 2nd point
357/// fUniqueID 0 object unique identifier
358/// fBits 50331648 bit field status word
359/// fLineColor 1 line color
360/// fLineStyle 1 line style
361/// fLineWidth 1 line width
362/// fFillColor 19 fill area color
363/// fFillStyle 1001 fill area style
364/// ~~~
365
366void TObject::Dump() const
367{
368 // Get the actual address of the object.
369 const void *actual = IsA()->DynamicCast(TObject::Class(), this, kFALSE);
370 IsA()->Dump(actual);
371}
372
373////////////////////////////////////////////////////////////////////////////////
374/// Execute method on this object with the given parameter string, e.g.
375/// "3.14,1,\"text\"".
376
377void TObject::Execute(const char *method, const char *params, Int_t *error)
378{
379 if (!IsA())
380 return;
381
383
384 gInterpreter->Execute(this, IsA(), method, params, error);
385
386 if (gPad && must_cleanup)
387 gPad->Modified();
388}
389
390////////////////////////////////////////////////////////////////////////////////
391/// Execute method on this object with parameters stored in the TObjArray.
392/// The TObjArray should contain an argv vector like:
393/// ~~~ {.cpp}
394/// argv[0] ... argv[n] = the list of TObjString parameters
395/// ~~~
396
398{
399 if (!IsA())
400 return;
401
403
404 gInterpreter->Execute(this, IsA(), method, params, error);
405
406 if (gPad && must_cleanup)
407 gPad->Modified();
408}
409
410////////////////////////////////////////////////////////////////////////////////
411/// Execute action corresponding to an event at (px,py). This method
412/// must be overridden if an object can react to graphics events.
413
415{
416 // AbstractMethod("ExecuteEvent");
417}
418
419////////////////////////////////////////////////////////////////////////////////
420/// Must be redefined in derived classes.
421/// This function is typically used with TCollections, but can also be used
422/// to find an object by name inside this object.
423
424TObject *TObject::FindObject(const char *) const
425{
426 return nullptr;
427}
428
429////////////////////////////////////////////////////////////////////////////////
430/// Must be redefined in derived classes.
431/// This function is typically used with TCollections, but can also be used
432/// to find an object inside this object.
433
435{
436 return nullptr;
437}
438
439////////////////////////////////////////////////////////////////////////////////
440/// Get option used by the graphics system to draw this object.
441/// Note that before calling object.GetDrawOption(), you must
442/// have called object.Draw(..) before in the current pad.
443
445{
446 if (!gPad)
447 return "";
448
449 TListIter next(gPad->GetListOfPrimitives());
450 while (auto obj = next()) {
451 if (obj == this)
452 return next.GetOption();
453 }
454 return "";
455}
456
457////////////////////////////////////////////////////////////////////////////////
458/// Returns name of object. This default method returns the class name.
459/// Classes that give objects a name should override this method.
460
461const char *TObject::GetName() const
462{
463 return IsA()->GetName();
464}
465
466////////////////////////////////////////////////////////////////////////////////
467/// Returns mime type name of object. Used by the TBrowser (via TGMimeTypes
468/// class). Override for class of which you would like to have different
469/// icons for objects of the same class.
470
471const char *TObject::GetIconName() const
472{
473 return nullptr;
474}
475
476////////////////////////////////////////////////////////////////////////////////
477/// Return the unique object id.
478
480{
481 return fUniqueID;
482}
483
484////////////////////////////////////////////////////////////////////////////////
485/// Returns string containing info about the object at position (px,py).
486/// This method is typically overridden by classes of which the objects
487/// can report peculiarities for different positions.
488/// Returned string will be re-used (lock in MT environment).
489
491{
492 if (!gPad)
493 return (char *)"";
494 static char info[64];
495 Float_t x = gPad->AbsPixeltoX(px);
496 Float_t y = gPad->AbsPixeltoY(py);
497 snprintf(info, 64, "x=%g, y=%g", gPad->PadtoX(x), gPad->PadtoY(y));
498 return info;
499}
500
501////////////////////////////////////////////////////////////////////////////////
502/// Returns title of object. This default method returns the class title
503/// (i.e. description). Classes that give objects a title should override
504/// this method.
505
506const char *TObject::GetTitle() const
507{
508 return IsA()->GetTitle();
509}
510
511////////////////////////////////////////////////////////////////////////////////
512/// Execute action in response of a timer timing out. This method
513/// must be overridden if an object has to react to timers.
514
516{
517 return kFALSE;
518}
519
520////////////////////////////////////////////////////////////////////////////////
521/// Return hash value for this object.
522///
523/// Note: If this routine is overloaded in a derived class, this derived class
524/// should also add
525/// ~~~ {.cpp}
526/// ROOT::CallRecursiveRemoveIfNeeded(*this)
527/// ~~~
528/// Otherwise, when RecursiveRemove is called (by ~TObject or example) for this
529/// type of object, the transversal of THashList and THashTable containers will
530/// will have to be done without call Hash (and hence be linear rather than
531/// logarithmic complexity). You will also see warnings like
532/// ~~~
533/// Error in <ROOT::Internal::TCheckHashRecursiveRemoveConsistency::CheckRecursiveRemove>: The class SomeName overrides
534/// TObject::Hash but does not call TROOT::RecursiveRemove in its destructor.
535/// ~~~
536///
537
539{
540 // return (ULong_t) this >> 2;
541 const void *ptr = this;
542 return TString::Hash(&ptr, sizeof(void *));
543}
544
545////////////////////////////////////////////////////////////////////////////////
546/// Returns kTRUE if object inherits from class "classname".
547
548Bool_t TObject::InheritsFrom(const char *classname) const
549{
550 return IsA()->InheritsFrom(classname);
551}
552
553////////////////////////////////////////////////////////////////////////////////
554/// Returns kTRUE if object inherits from TClass cl.
555
557{
558 return IsA()->InheritsFrom(cl);
559}
560
561////////////////////////////////////////////////////////////////////////////////
562/// Dump contents of this object in a graphics canvas.
563/// Same action as Dump but in a graphical form.
564/// In addition pointers to other objects can be followed.
565///
566/// The following picture is the Inspect of a histogram object:
567/// \image html base_inspect.png
568
570{
571 gGuiFactory->CreateInspectorImp(this, 400, 200);
572}
573
574////////////////////////////////////////////////////////////////////////////////
575/// Returns kTRUE in case object contains browsable objects (like containers
576/// or lists of other objects).
577
579{
580 return kFALSE;
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Default equal comparison (objects are equal if they have the same
585/// address in memory). More complicated classes might want to override
586/// this function.
587
589{
590 return obj == this;
591}
592
593////////////////////////////////////////////////////////////////////////////////
594/// The ls function lists the contents of a class on stdout. Ls output
595/// is typically much less verbose then Dump().
596
598{
600 std::cout << "OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << " : ";
601 std::cout << Int_t(TestBit(kCanDelete));
602 if (option && strstr(option, "noaddr") == nullptr) {
603 std::cout << " at: " << this;
604 }
605 std::cout << std::endl;
606}
607
608////////////////////////////////////////////////////////////////////////////////
609/// This method must be overridden to handle object notification (the base implementation is no-op).
610///
611/// Different objects in ROOT use the `Notify` method for different purposes, in coordination
612/// with other objects that call this method at the appropriate time.
613///
614/// For example, `TLeaf` uses it to load class information; `TBranchRef` to load contents of
615/// referenced branches `TBranchRef`; most notably, based on `Notify`, `TChain` implements a
616/// callback mechanism to inform interested parties when it switches to a new sub-tree.
618{
619 return kFALSE;
620}
621
622////////////////////////////////////////////////////////////////////////////////
623/// This method must be overridden if a class wants to paint itself.
624/// The difference between Paint() and Draw() is that when a object
625/// draws itself it is added to the display list of the pad in
626/// which it is drawn (and automatically redrawn whenever the pad is
627/// redrawn). While paint just draws the object without adding it to
628/// the pad display list.
629
631{
632 // AbstractMethod("Paint");
633}
634
635////////////////////////////////////////////////////////////////////////////////
636/// Pop on object drawn in a pad to the top of the display list. I.e. it
637/// will be drawn last and on top of all other primitives.
638
640{
641 if (!gPad || !gPad->GetListOfPrimitives())
642 return;
643
644 if (this == gPad->GetListOfPrimitives()->Last())
645 return;
646
647 TListIter next(gPad->GetListOfPrimitives());
648 while (auto obj = next())
649 if (obj == this) {
650 TString opt = next.GetOption();
651 gPad->Remove(this, kFALSE); // do not issue modified by remove
652 gPad->Add(this, opt.Data());
653 return;
654 }
655}
656
657////////////////////////////////////////////////////////////////////////////////
658/// This method must be overridden when a class wants to print itself.
659
661{
662 std::cout << "OBJ: " << IsA()->GetName() << "\t" << GetName() << "\t" << GetTitle() << std::endl;
663}
664
665////////////////////////////////////////////////////////////////////////////////
666/// Read contents of object with specified name from the current directory.
667/// First the key with the given name is searched in the current directory,
668/// next the key buffer is deserialized into the object.
669/// The object must have been created before via the default constructor.
670/// See TObject::Write().
671
673{
674 if (gDirectory)
675 return gDirectory->ReadTObject(this, name);
676 return 0;
677}
678
679////////////////////////////////////////////////////////////////////////////////
680/// Recursively remove this object from a list. Typically implemented
681/// by classes that can contain multiple references to a same object.
682
684
685////////////////////////////////////////////////////////////////////////////////
686/// Save this object in the file specified by filename.
687///
688/// - if "filename" contains ".root" the object is saved in filename as root
689/// binary file.
690///
691/// - if "filename" contains ".xml" the object is saved in filename as a xml
692/// ascii file.
693///
694/// - if "filename" contains ".cc" the object is saved in filename as C code
695/// independent from ROOT. The code is generated via SavePrimitive().
696/// Specific code should be implemented in each object to handle this
697/// option. Like in TF1::SavePrimitive().
698///
699/// - otherwise the object is written to filename as a CINT/C++ script. The
700/// C++ code to rebuild this object is generated via SavePrimitive(). The
701/// "option" parameter is passed to SavePrimitive. By default it is an empty
702/// string. It can be used to specify the Draw option in the code generated
703/// by SavePrimitive.
704///
705/// The function is available via the object context menu.
706
707void TObject::SaveAs(const char *filename, Option_t *option) const
708{
709 //==============Save object as a root file===================================
710 if (filename && strstr(filename, ".root")) {
711 if (gDirectory)
712 gDirectory->SaveObjectAs(this, filename, "");
713 return;
714 }
715
716 //==============Save object as a XML file====================================
717 if (filename && strstr(filename, ".xml")) {
718 if (gDirectory)
719 gDirectory->SaveObjectAs(this, filename, "");
720 return;
721 }
722
723 //==============Save object as a JSON file================================
724 if (filename && strstr(filename, ".json")) {
725 if (gDirectory)
726 gDirectory->SaveObjectAs(this, filename, option);
727 return;
728 }
729
730 //==============Save object as a C, ROOT independent, file===================
731 if (filename && strstr(filename, ".cc")) {
733 if (filename && strlen(filename) > 0) {
734 fname = filename;
735 } else {
736 fname.Form("%s.cc", GetName());
737 }
738 std::ofstream out;
739 out.open(fname.Data(), std::ios::out);
740 if (!out.good()) {
741 Error("SaveAs", "cannot open file: %s", fname.Data());
742 return;
743 }
744 ((TObject *)this)->SavePrimitive(out, "cc");
745 out.close();
746 Info("SaveAs", "cc file: %s has been generated", fname.Data());
747 return;
748 }
749
750 //==============Save as a C++ CINT file======================================
752 if (filename && strlen(filename) > 0) {
753 fname = filename;
754 } else {
755 fname.Form("%s.C", GetName());
756 }
757 std::ofstream out;
758 out.open(fname.Data(), std::ios::out);
759 if (!out.good()) {
760 Error("SaveAs", "cannot open file: %s", fname.Data());
761 return;
762 }
763 out << "{" << std::endl;
764 out << "//========= Macro generated from object: " << GetName() << "/" << GetTitle() << std::endl;
765 out << "//========= by ROOT version" << gROOT->GetVersion() << std::endl;
766 ((TObject *)this)->SavePrimitive(out, option);
767 out << "}" << std::endl;
768 out.close();
769 Info("SaveAs", "C++ Macro file: %s has been generated", fname.Data());
770}
771
772////////////////////////////////////////////////////////////////////////////////
773/// Save object constructor in the output stream "out".
774/// Can be used as first statement when implementing SavePrimitive() method for the object
775
776void TObject::SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name,
778{
779 if (empty_line)
780 out << " \n";
781
782 out << " ";
783 if (!gROOT->ClassSaved(cl))
784 out << cl->GetName() << " *";
785 out << variable_name << " = new " << cl->GetName() << "(" << constructor_agrs << ");\n";
786}
787
788////////////////////////////////////////////////////////////////////////////////
789/// Save array in the output stream "out" as vector.
790/// Create unique variable name based on prefix value
791/// Returns name of vector which can be used in constructor or in other places of C++ code
792/// If flag === kTRUE, just add empty line
793/// If flag === 111, check if array is empty and return nullptr or <vectorname>.data()
794
795TString TObject::SavePrimitiveVector(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Int_t flag)
796{
797 thread_local int vectid = 0;
798
799 if (flag == (Int_t)kTRUE)
800 out << " \n";
801 else if (flag == 111) {
802 // check if array empty or contains only zeros
803 Bool_t empty = kTRUE;
804 if (arr)
805 for (Int_t n = 0; n < len; ++n)
806 if (arr[n]) {
807 empty = kFALSE;
808 break;
809 }
810
811 if (empty)
812 return "nullptr";
813 }
814
815 TString vectname = TString::Format("%s_vect%d", prefix, vectid++);
816
817 out << " std::vector<Double_t> " << vectname;
818 if (len > 0) {
819 const auto old_precision{out.precision()};
820 constexpr auto max_precision{std::numeric_limits<double>::digits10 + 1};
821 out << std::setprecision(max_precision);
822 Bool_t use_new_lines = len > 15;
823
824 out << "{";
825 for (Int_t i = 0; i < len; i++) {
826 out << (((i % 10 == 0) && use_new_lines) ? "\n " : " ") << arr[i];
827 if (i < len - 1)
828 out << ",";
829 }
830 out << (use_new_lines ? "\n }" : " }");
831
832 out << std::setprecision(old_precision);
833 }
834 out << ";\n";
835 if (flag == 111)
836 vectname.Append(".data()"); // just to be used as args
837 return vectname;
838}
839
840////////////////////////////////////////////////////////////////////////////////
841/// Save invocation of primitive Draw() method
842/// Skipped if option contains "nodraw" string
843
844void TObject::SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option)
845{
846 if (!option || !strstr(option, "nodraw")) {
847 out << " " << variable_name << "->Draw(";
848 if (option && *option)
849 out << "\"" << TString(option).ReplaceSpecialCppChars() << "\"";
850 out << ");\n";
851 }
852}
853
854////////////////////////////////////////////////////////////////////////////////
855/// Save a primitive as a C++ statement(s) on output stream "out".
856
857void TObject::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
858{
859 out << "//Primitive: " << GetName() << "/" << GetTitle() << ". You must implement " << ClassName()
860 << "::SavePrimitive" << std::endl;
861}
862
863////////////////////////////////////////////////////////////////////////////////
864/// Set drawing option for object. This option only affects
865/// the drawing style and is stored in the option field of the
866/// TObjOptLink supporting a TPad's primitive list (TList).
867/// Note that it does not make sense to call object.SetDrawOption(option)
868/// before having called object.Draw().
869
871{
872 if (!gPad || !option)
873 return;
874
875 TListIter next(gPad->GetListOfPrimitives());
876 while (auto obj = next())
877 if (obj == this) {
878 next.SetOption(option);
879 return;
880 }
881}
882
883////////////////////////////////////////////////////////////////////////////////
884/// Set or unset the user status bits as specified in f.
885
887{
888 if (set)
889 SetBit(f);
890 else
891 ResetBit(f);
892}
893
894////////////////////////////////////////////////////////////////////////////////
895/// Set the unique object id.
896
898{
899 fUniqueID = uid;
900}
901
902////////////////////////////////////////////////////////////////////////////////
903/// Set current style settings in this object
904/// This function is called when either TCanvas::UseCurrentStyle
905/// or TROOT::ForceStyle have been invoked.
906
908
909////////////////////////////////////////////////////////////////////////////////
910/// Write this object to the current directory.
911/// The data structure corresponding to this object is serialized.
912/// The corresponding buffer is written to the current directory
913/// with an associated key with name "name".
914///
915/// Writing an object to a file involves the following steps:
916///
917/// - Creation of a support TKey object in the current directory.
918/// The TKey object creates a TBuffer object.
919///
920/// - The TBuffer object is filled via the class::Streamer function.
921///
922/// - If the file is compressed (default) a second buffer is created to
923/// hold the compressed buffer.
924///
925/// - Reservation of the corresponding space in the file by looking
926/// in the TFree list of free blocks of the file.
927///
928/// - The buffer is written to the file.
929///
930/// Bufsize can be given to force a given buffer size to write this object.
931/// By default, the buffersize will be taken from the average buffer size
932/// of all objects written to the current file so far.
933///
934/// If a name is specified, it will be the name of the key.
935/// If name is not given, the name of the key will be the name as returned
936/// by GetName().
937///
938/// The option can be a combination of: kSingleKey, kOverwrite or kWriteDelete
939/// Using the kOverwrite option a previous key with the same name is
940/// overwritten. The previous key is deleted before writing the new object.
941/// Using the kWriteDelete option a previous key with the same name is
942/// deleted only after the new object has been written. This option
943/// is safer than kOverwrite but it is slower.
944/// NOTE: Neither kOverwrite nor kWriteDelete reduces the size of a TFile--
945/// the space is simply freed up to be overwritten; in the case of a TTree,
946/// it is more complicated. If one opens a TTree, appends some entries,
947/// then writes it out, the behaviour is effectively the same. If, however,
948/// one creates a new TTree and writes it out in this way,
949/// only the metadata is replaced, effectively making the old data invisible
950/// without deleting it. TTree::Delete() can be used to mark all disk space
951/// occupied by a TTree as free before overwriting its metadata this way.
952/// The kSingleKey option is only used by TCollection::Write() to write
953/// a container with a single key instead of each object in the container
954/// with its own key.
955///
956/// An object is read from the file into memory via TKey::Read() or
957/// via TObject::Read().
958///
959/// The function returns the total number of bytes written to the file.
960/// It returns 0 if the object cannot be written.
961
963{
965 return 0;
966
967 TString opt = "";
968 if (option & kSingleKey)
969 opt += "SingleKey";
970 if (option & kOverwrite)
971 opt += "OverWrite";
972 if (option & kWriteDelete)
973 opt += "WriteDelete";
974
975 if (gDirectory)
976 return gDirectory->WriteTObject(this, name, opt.Data(), bufsize);
977
978 const char *objname = name ? name : GetName();
979 Error("Write", "The current directory (gDirectory) is null. The object (%s) has not been written.", objname);
980 return 0;
981}
982
983////////////////////////////////////////////////////////////////////////////////
984/// Write this object to the current directory. For more see the
985/// const version of this method.
986
988{
989 return ((const TObject *)this)->Write(name, option, bufsize);
990}
991
992////////////////////////////////////////////////////////////////////////////////
993/// Stream an object of class TObject.
994
996{
997 if (IsA()->CanIgnoreTObjectStreamer())
998 return;
1000 if (R__b.IsReading()) {
1001 R__b.SkipVersion(); // Version_t R__v = R__b.ReadVersion(); if (R__v) { }
1002 R__b >> fUniqueID;
1003 const UInt_t isonheap = fBits & kIsOnHeap; // Record how this instance was actually allocated.
1004 R__b >> fBits;
1005 fBits |= isonheap | kNotDeleted; // by definition de-serialized object are not yet deleted.
1006 if (TestBit(kIsReferenced)) {
1007 // if the object is referenced, we must read its old address
1008 // and store it in the ProcessID map in gROOT
1009 R__b >> pidf;
1010 pidf += R__b.GetPidOffset();
1011 TProcessID *pid = R__b.ReadProcessID(pidf);
1012 if (pid) {
1013 UInt_t gpid = pid->GetUniqueID();
1014 if (gpid >= 0xff) {
1015 fUniqueID = fUniqueID | 0xff000000;
1016 } else {
1017 fUniqueID = (fUniqueID & 0xffffff) + (gpid << 24);
1018 }
1019 pid->PutObjectWithID(this);
1020 }
1021 }
1022 } else {
1023 R__b.WriteVersion(TObject::IsA());
1024 // Can not read TFile.h here and avoid going through the interpreter by
1025 // simply hard-coding this value.
1026 // This **must** be equal to TFile::k630forwardCompatibility
1027 constexpr int TFile__k630forwardCompatibility = BIT(2);
1028 const auto parent = R__b.GetParent();
1029 if (!TestBit(kIsReferenced)) {
1030 R__b << fUniqueID;
1031 if (R__unlikely(parent && parent->TestBit(TFile__k630forwardCompatibility)))
1032 R__b << fBits;
1033 else
1034 R__b << (fBits & (~kIsOnHeap & ~kNotDeleted));
1035 } else {
1036 // if the object is referenced, we must save its address/file_pid
1037 UInt_t uid = fUniqueID & 0xffffff;
1038 R__b << uid;
1039 if (R__unlikely(parent && parent->TestBit(TFile__k630forwardCompatibility)))
1040 R__b << fBits;
1041 else
1042 R__b << (fBits & (~kIsOnHeap & ~kNotDeleted));
1044 // add uid to the TRefTable if there is one
1046 if (table)
1047 table->Add(uid, pid);
1048 pidf = R__b.WriteProcessID(pid);
1049 R__b << pidf;
1050 }
1051 }
1052}
1053
1054////////////////////////////////////////////////////////////////////////////////
1055/// Interface to ErrorHandler (protected).
1056
1057void TObject::DoError(int level, const char *location, const char *fmt, va_list va) const
1058{
1059 const char *classname = "UnknownClass";
1060 if (TROOT::Initialized())
1061 classname = ClassName();
1062
1063 ::ErrorHandler(level, Form("%s::%s", classname, location), fmt, va);
1064}
1065
1066////////////////////////////////////////////////////////////////////////////////
1067/// Issue info message. Use "location" to specify the method where the
1068/// warning occurred. Accepts standard printf formatting arguments.
1069
1070void TObject::Info(const char *location, const char *va_(fmt), ...) const
1071{
1072 va_list ap;
1073 va_start(ap, va_(fmt));
1074 DoError(kInfo, location, va_(fmt), ap);
1075 va_end(ap);
1076}
1077
1078////////////////////////////////////////////////////////////////////////////////
1079/// Issue warning message. Use "location" to specify the method where the
1080/// warning occurred. Accepts standard printf formatting arguments.
1081
1082void TObject::Warning(const char *location, const char *va_(fmt), ...) const
1083{
1084 va_list ap;
1085 va_start(ap, va_(fmt));
1086 DoError(kWarning, location, va_(fmt), ap);
1087 va_end(ap);
1088 if (TROOT::Initialized())
1089 gROOT->Message(1001, this);
1090}
1091
1092////////////////////////////////////////////////////////////////////////////////
1093/// Issue error message. Use "location" to specify the method where the
1094/// error occurred. Accepts standard printf formatting arguments.
1095
1096void TObject::Error(const char *location, const char *va_(fmt), ...) const
1097{
1098 va_list ap;
1099 va_start(ap, va_(fmt));
1100 DoError(kError, location, va_(fmt), ap);
1101 va_end(ap);
1102 if (TROOT::Initialized())
1103 gROOT->Message(1002, this);
1104}
1105
1106////////////////////////////////////////////////////////////////////////////////
1107/// Issue system error message. Use "location" to specify the method where
1108/// the system error occurred. Accepts standard printf formatting arguments.
1109
1110void TObject::SysError(const char *location, const char *va_(fmt), ...) const
1111{
1112 va_list ap;
1113 va_start(ap, va_(fmt));
1114 DoError(kSysError, location, va_(fmt), ap);
1115 va_end(ap);
1116 if (TROOT::Initialized())
1117 gROOT->Message(1003, this);
1118}
1119
1120////////////////////////////////////////////////////////////////////////////////
1121/// Issue fatal error message. Use "location" to specify the method where the
1122/// fatal error occurred. Accepts standard printf formatting arguments.
1123
1124void TObject::Fatal(const char *location, const char *va_(fmt), ...) const
1125{
1126 va_list ap;
1127 va_start(ap, va_(fmt));
1128 DoError(kFatal, location, va_(fmt), ap);
1129 va_end(ap);
1130 if (TROOT::Initialized())
1131 gROOT->Message(1004, this);
1132}
1133
1134////////////////////////////////////////////////////////////////////////////////
1135/// Call this function within a function that you don't want to define as
1136/// purely virtual, in order not to force all users deriving from that class to
1137/// implement that maybe (on their side) unused function; but at the same time,
1138/// emit a run-time warning if they try to call it, telling that it is not
1139/// implemented in the derived class: action must thus be taken on the user side
1140/// to override it. In other word, this method acts as a "runtime purely virtual"
1141/// warning instead of a "compiler purely virtual" error.
1142/// \warning This interface is a legacy function that is no longer recommended
1143/// to be used by new development code.
1144/// \note The name "AbstractMethod" does not imply that it's an abstract method
1145/// in the strict C++ sense.
1146
1147void TObject::AbstractMethod(const char *method) const
1148{
1149 Warning(method, "this method must be overridden!");
1150}
1151
1152////////////////////////////////////////////////////////////////////////////////
1153/// Use this method to signal that a method (defined in a base class)
1154/// may not be called in a derived class (in principle against good
1155/// design since a child class should not provide less functionality
1156/// than its parent, however, sometimes it is necessary).
1157
1158void TObject::MayNotUse(const char *method) const
1159{
1160 Warning(method, "may not use this method");
1161}
1162
1163////////////////////////////////////////////////////////////////////////////////
1164/// Use this method to declare a method obsolete. Specify as of which version
1165/// the method is obsolete and as from which version it will be removed.
1166
1167void TObject::Obsolete(const char *method, const char *asOfVers, const char *removedFromVers) const
1168{
1169 const char *classname = "UnknownClass";
1170 if (TROOT::Initialized())
1171 classname = ClassName();
1172
1173 ::Obsolete(Form("%s::%s", classname, method), asOfVers, removedFromVers);
1174}
1175
1176////////////////////////////////////////////////////////////////////////////////
1177/// Get status of object stat flag.
1178
1180{
1181 return fgObjectStat;
1182}
1183////////////////////////////////////////////////////////////////////////////////
1184/// Turn on/off tracking of objects in the TObjectTable.
1185
1187{
1188 fgObjectStat = stat;
1189}
1190
1191////////////////////////////////////////////////////////////////////////////////
1192/// Return destructor only flag
1193
1195{
1196 return fgDtorOnly;
1197}
1198
1199////////////////////////////////////////////////////////////////////////////////
1200/// Set destructor only flag
1201
1203{
1204 fgDtorOnly = (Longptr_t)obj;
1205}
1206
1207////////////////////////////////////////////////////////////////////////////////
1208/// Operator delete
1209
1210void TObject::operator delete(void *ptr)
1211{
1212 if ((Longptr_t)ptr != fgDtorOnly)
1214 else
1215 fgDtorOnly = 0;
1216}
1217
1218////////////////////////////////////////////////////////////////////////////////
1219/// Operator delete []
1220
1221void TObject::operator delete[](void *ptr)
1222{
1223 if ((Longptr_t)ptr != fgDtorOnly)
1225 else
1226 fgDtorOnly = 0;
1227}
1228
1229////////////////////////////////////////////////////////////////////////////////
1230/// Operator delete for sized deallocation.
1231
1232void TObject::operator delete(void *ptr, size_t size)
1233{
1234 if ((Longptr_t)ptr != fgDtorOnly)
1236 else
1237 fgDtorOnly = 0;
1238}
1239
1240////////////////////////////////////////////////////////////////////////////////
1241/// Operator delete [] for sized deallocation.
1242
1243void TObject::operator delete[](void *ptr, size_t size)
1244{
1245 if ((Longptr_t)ptr != fgDtorOnly)
1247 else
1248 fgDtorOnly = 0;
1249}
1250
1251////////////////////////////////////////////////////////////////////////////////
1252/// Print value overload
1253
1254std::string cling::printValue(TObject *val)
1255{
1256 std::ostringstream strm;
1257 strm << "Name: " << val->GetName() << " Title: " << val->GetTitle();
1258 return strm.str();
1259}
1260
1261////////////////////////////////////////////////////////////////////////////////
1262/// Only called by placement new when throwing an exception.
1263
1264void TObject::operator delete(void *ptr, void *vp)
1265{
1267}
1268
1269////////////////////////////////////////////////////////////////////////////////
1270/// Only called by placement new[] when throwing an exception.
1271
1272void TObject::operator delete[](void *ptr, void *vp)
1273{
1275}
1276
1278{
1279 obj.fBits &= ~TObject::kIsOnHeap;
1280}
#define R__unlikely(expr)
Definition RConfig.hxx:592
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:78
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:60
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:70
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:61
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:72
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
#define BIT(n)
Definition Rtypes.h:91
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gDirectory
Definition TDirectory.h:385
constexpr Int_t kError
Definition TError.h:47
void ErrorHandler(int level, const char *location, const char *fmt, std::va_list va)
General error handler function. It calls the user set error handler.
Definition TError.cxx:111
constexpr Int_t kFatal
Definition TError.h:50
constexpr Int_t kWarning
Definition TError.h:46
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
constexpr Int_t kInfo
Definition TError.h:45
constexpr Int_t kSysError
Definition TError.h:49
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
char name[80]
Definition TGX11.cxx:148
R__EXTERN TGuiFactory * gGuiFactory
Definition TGuiFactory.h:66
#define gInterpreter
R__EXTERN TObjectTable * gObjectTable
#define ATTRIBUTE_NO_SANITIZE_ADDRESS
Definition TObject.cxx:74
#define ATTRIBUTE_NO_SANITIZE_THREAD
Definition TObject.cxx:75
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:777
#define gROOT
Definition TROOT.h:417
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2570
#define gPad
#define va_(arg)
Definition Varargs.h:35
#define snprintf
Definition civetweb.c:1579
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Buffer base class used for serializing objects.
Definition TBuffer.h:43
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static Int_t AutoBrowse(TObject *obj, TBrowser *browser)
Browse external object inherited from TObject.
Definition TClass.cxx:1968
virtual TInspectorImp * CreateInspectorImp(const TObject *obj, UInt_t width, UInt_t height)
Create a batch version of TInspectorImp.
Iterator of linked list.
Definition TList.h:196
Option_t * GetOption() const override
Returns the object option stored in the list.
Definition TList.cxx:1274
void SetOption(Option_t *option)
Sets the object option stored in the list.
Definition TList.cxx:1283
Each ROOT class (see TClass) has a linked list of methods.
Definition TMethod.h:38
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
An array of TObjects.
Definition TObjArray.h:31
static void AddObj(TObject *obj)
Add an object to the global object table gObjectTable.
void RemoveQuietly(TObject *obj)
Remove an object from the object table.
Mother of all ROOT objects.
Definition TObject.h:42
void AbstractMethod(const char *method) const
Call this function within a function that you don't want to define as purely virtual,...
Definition TObject.cxx:1147
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TObject.cxx:578
virtual void Inspect() const
Dump contents of this object in a graphics canvas.
Definition TObject.cxx:569
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point (px,py) to the object.
Definition TObject.cxx:283
static void SetObjectStat(Bool_t stat)
Turn on/off tracking of objects in the TObjectTable.
Definition TObject.cxx:1186
virtual Bool_t Notify()
This method must be overridden to handle object notification (the base implementation is no-op).
Definition TObject.cxx:617
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:588
@ kOverwrite
overwrite existing object with same name
Definition TObject.h:101
@ kSingleKey
write collection with single key
Definition TObject.h:100
@ kWriteDelete
write object, then delete previous key with same name
Definition TObject.h:102
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:461
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition TObject.cxx:217
virtual void Dump() const
Dump contents of object on stdout.
Definition TObject.cxx:366
UInt_t fUniqueID
object unique identifier
Definition TObject.h:46
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual const char * GetIconName() const
Returns mime type name of object.
Definition TObject.cxx:471
virtual void RecursiveRemove(TObject *obj)
Recursively remove this object from a list.
Definition TObject.cxx:683
virtual void DoError(int level, const char *location, const char *fmt, va_list va) const
Interface to ErrorHandler (protected).
Definition TObject.cxx:1057
virtual Bool_t HandleTimer(TTimer *timer)
Execute action in response of a timer timing out.
Definition TObject.cxx:515
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:242
virtual UInt_t GetUniqueID() const
Return the unique object id.
Definition TObject.cxx:479
@ kIsOnHeap
object is on heap
Definition TObject.h:90
@ kNotDeleted
object has not been deleted
Definition TObject.h:91
UInt_t fBits
bit field status word
Definition TObject.h:47
static Longptr_t fgDtorOnly
object for which to call dtor only (i.e. no delete)
Definition TObject.h:49
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
Definition TObject.cxx:995
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
Definition TObject.cxx:1110
R__ALWAYS_INLINE Bool_t IsOnHeap() const
Definition TObject.h:160
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual void UseCurrentStyle()
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyl...
Definition TObject.cxx:907
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition TObject.cxx:444
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
Definition TObject.cxx:1158
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
Definition TObject.cxx:318
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition TObject.cxx:414
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition TObject.cxx:424
static TClass * Class()
virtual void Execute(const char *method, const char *params, Int_t *error=nullptr)
Execute method on this object with the given parameter string, e.g.
Definition TObject.cxx:377
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition TObject.cxx:490
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition TObject.cxx:857
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Definition TObject.cxx:987
@ kOnlyPrepStep
Used to request that the class specific implementation of TObject::Write just prepare the objects to ...
Definition TObject.h:115
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save this object in the file specified by filename.
Definition TObject.cxx:707
virtual void Delete(Option_t *option="")
Delete this object.
Definition TObject.cxx:267
static Longptr_t GetDtorOnly()
Return destructor only flag.
Definition TObject.cxx:1194
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:886
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:548
static Bool_t GetObjectStat()
Get status of object stat flag.
Definition TObject.cxx:1179
virtual void Copy(TObject &object) const
Copy this to obj.
Definition TObject.cxx:158
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition TObject.cxx:870
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1124
static void SetDtorOnly(void *obj)
Set destructor only flag.
Definition TObject.cxx:1202
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
Definition TObject.cxx:897
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:506
virtual void DrawClass() const
Draw class inheritance tree of the class to which this object belongs.
Definition TObject.cxx:307
virtual TClass * IsA() const
Definition TObject.h:248
virtual Int_t Compare(const TObject *obj) const
Compare abstract method.
Definition TObject.cxx:257
virtual ~TObject()
TObject destructor.
Definition TObject.cxx:176
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
Definition TObject.cxx:844
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:292
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
Definition TObject.cxx:630
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition TObject.cxx:660
virtual void Pop()
Pop on object drawn in a pad to the top of the display list.
Definition TObject.cxx:639
virtual ULong_t Hash() const
Return hash value for this object.
Definition TObject.cxx:538
virtual void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
Definition TObject.cxx:597
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
Definition TObject.cxx:776
static TString SavePrimitiveVector(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Int_t flag=0)
Save array in the output stream "out" as vector.
Definition TObject.cxx:795
static Bool_t fgObjectStat
if true keep track of objects in TObjectTable
Definition TObject.h:50
void ResetBit(UInt_t f)
Definition TObject.h:203
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:71
@ kIsReferenced
if object is referenced by a TRef or TRefArray
Definition TObject.h:74
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:73
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
Definition TObject.cxx:672
static void AddToTObjectTable(TObject *)
Private helper function which will dispatch to TObjectTable::AddObj.
Definition TObject.cxx:194
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition TObject.cxx:1070
void Obsolete(const char *method, const char *asOfVers, const char *removedFromVers) const
Use this method to declare a method obsolete.
Definition TObject.cxx:1167
A TProcessID identifies a ROOT job in a unique way in time and space.
Definition TProcessID.h:74
void PutObjectWithID(TObject *obj, UInt_t uid=0)
stores the object at the uid th slot in the table of objects The object uniqued is set as well as its...
static TProcessID * GetProcessWithUID(const TObject *obj)
static function returning a pointer to TProcessID with its pid encoded in the highest byte of obj->Ge...
static Bool_t Initialized()
Return kTRUE if the TROOT object has been initialized.
Definition TROOT.cxx:3067
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3052
A TRefTable maintains the association between a referenced object and the parent object supporting th...
Definition TRefTable.h:35
static TRefTable * GetRefTable()
Static function returning the current TRefTable.
virtual Int_t Add(Int_t uid, TProcessID *context=nullptr)
Add a new uid to the table.
Definition TRefTable.cxx:87
static void ObjectDealloc(void *vp)
Used to deallocate a TObject on the heap (via TObject::operator delete()).
Definition TStorage.cxx:321
Basic string class.
Definition TString.h:138
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1121
const char * Data() const
Definition TString.h:386
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition TString.cxx:684
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:2459
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
small helper class to store/restore gPad context in TPad methods
Definition TVirtualPad.h:61
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
bool DeleteChangesMemory()
Definition TObject.cxx:144
void MarkTObjectAsNotOnHeap(TObject &obj)
Definition TObject.cxx:1277
bool DeleteChangesMemoryImpl()
Definition TObject.cxx:90
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition TROOT.h:406