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