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