41#if !defined(WIN32) && !defined(__MWERKS__) && !defined(R__SOLARIS)
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))
75#define ATTRIBUTE_NO_SANITIZE_ADDRESS
76#define ATTRIBUTE_NO_SANITIZE_THREAD
93 static constexpr UInt_t kGoldenUUID = 0x00000021;
94 static constexpr UInt_t kGoldenbits = 0x03000000;
101 if (*o_fuid != kGoldenUUID) {
102 Error(
"CheckingDeleteSideEffects",
"fUniqueID is not as expected, we got 0x%.8x instead of 0x%.8x", *o_fuid,
105 if (*o_fbits != kGoldenbits) {
106 Error(
"CheckingDeleteSideEffects",
"fBits is not as expected, we got 0x%.8x instead of 0x%.8x", *o_fbits,
110 unsigned char *oc =
reinterpret_cast<unsigned char *
>(o);
111 unsigned char references[
sizeof(
TObject)];
112 memcpy(references, oc,
sizeof(
TObject));
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));
132#if defined(_MSC_VER) && defined(__SANITIZE_ADDRESS__)
138 if (*o_fbits != 0x01000000) {
207 gROOT->MakeDefCanvas();
212 gPad->Add(
this, option);
249 return gROOT->CloneObject(
this);
322 auto pad =
gROOT->GetSelectedPad();
330 if (!option || !*option)
334 pad->Add(newobj, option);
337 newobj->
Draw(option);
387 if (
gPad && must_cleanup)
407 if (
gPad && must_cleanup)
451 while (
auto obj = next()) {
495 static char info[64];
542 const void *ptr =
this;
603 if (option && strstr(option,
"noaddr") ==
nullptr) {
604 std::cout <<
" at: " <<
this;
606 std::cout << std::endl;
642 if (!
gPad || !
gPad->GetListOfPrimitives())
645 if (
this ==
gPad->GetListOfPrimitives()->Last())
649 while (
auto obj = next())
711 if (filename && strstr(filename,
".root")) {
718 if (filename && strstr(filename,
".xml")) {
725 if (filename && strstr(filename,
".json")) {
727 gDirectory->SaveObjectAs(
this, filename, option);
732 if (filename && strstr(filename,
".cc")) {
734 if (filename && strlen(filename) > 0) {
740 out.open(fname.
Data(), std::ios::out);
742 Error(
"SaveAs",
"cannot open file: %s", fname.
Data());
745 ((
TObject *)
this)->SavePrimitive(out,
"cc");
747 Info(
"SaveAs",
"cc file: %s has been generated", fname.
Data());
753 if (filename && strlen(filename) > 0) {
759 out.open(fname.
Data(), std::ios::out);
761 Error(
"SaveAs",
"cannot open file: %s", fname.
Data());
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;
770 Info(
"SaveAs",
"C++ Macro file: %s has been generated", fname.
Data());
778 const char *constructor_agrs,
Bool_t empty_line)
784 if (!
gROOT->ClassSaved(cl))
786 out << variable_name <<
" = new " << cl->
GetName() <<
"(" << constructor_agrs <<
");\n";
798 thread_local int vectid = 0;
802 else if (flag == 111) {
818 out <<
" std::vector<Double_t> " << vectname;
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;
826 for (
Int_t i = 0; i < len; i++) {
827 out << (((i % 10 == 0) && use_new_lines) ?
"\n " :
" ") << arr[i];
831 out << (use_new_lines ?
"\n }" :
" }");
833 out << std::setprecision(old_precision);
837 vectname.
Append(
".data()");
847 if (!option || !strstr(option,
"nodraw")) {
848 out <<
" " << variable_name <<
"->Draw(";
849 if (option && *option)
861 <<
"::SavePrimitive" << std::endl;
873 if (!
gPad || !option)
877 delete gPad->FindObject(
"Tframe");
878 while (
auto obj = next())
975 opt +=
"WriteDelete";
981 Error(
"Write",
"The current directory (gDirectory) is null. The object (%s) has not been written.", objname);
991 return ((
const TObject *)
this)->Write(
name, option, bufsize);
999 if (
IsA()->CanIgnoreTObjectStreamer())
1029 constexpr int TFile__k630forwardCompatibility =
BIT(2);
1033 if (
R__unlikely(parent && parent->TestBit(TFile__k630forwardCompatibility)))
1041 if (
R__unlikely(parent && parent->TestBit(TFile__k630forwardCompatibility)))
1049 table->
Add(uid, pid);
1061 const char *classname =
"UnknownClass";
1075 va_start(ap,
va_(fmt));
1087 va_start(ap,
va_(fmt));
1091 gROOT->Message(1001,
this);
1101 va_start(ap,
va_(fmt));
1105 gROOT->Message(1002,
this);
1115 va_start(ap,
va_(fmt));
1119 gROOT->Message(1003,
this);
1129 va_start(ap,
va_(fmt));
1133 gROOT->Message(1004,
this);
1151 Warning(method,
"this method must be overridden!");
1162 Warning(method,
"may not use this method");
1171 const char *classname =
"UnknownClass";
1175 ::Obsolete(
Form(
"%s::%s", classname, method), asOfVers, removedFromVers);
1212void TObject::operator
delete(
void *ptr)
1223void TObject::operator
delete[](
void *ptr)
1234void TObject::operator
delete(
void *ptr,
size_t size)
1245void TObject::operator
delete[](
void *ptr,
size_t size)
1256std::string cling::printValue(
TObject *val)
1258 std::ostringstream strm;
1266void TObject::operator
delete(
void *ptr,
void *vp)
1274void TObject::operator
delete[](
void *ptr,
void *vp)
#define R__unlikely(expr)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned short UShort_t
Unsigned Short integer 2 bytes (unsigned short).
int Int_t
Signed integer 4 bytes (int).
long Longptr_t
Integer large enough to hold a pointer (platform-dependent).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
float Float_t
Float 4 bytes (float).
const char Option_t
Option string (const char).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
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.
constexpr Int_t kSysError
externTGuiFactory * gGuiFactory
externTObjectTable * gObjectTable
#define ATTRIBUTE_NO_SANITIZE_ADDRESS
#define ATTRIBUTE_NO_SANITIZE_THREAD
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Using a TBrowser one can browse all ROOT objects.
Buffer base class used for serializing objects.
virtual TProcessID * ReadProcessID(UShort_t pidf)=0
Return the current Process-ID.
virtual UShort_t WriteProcessID(TProcessID *pid)=0
Always return 0 (current processID).
TObject * GetParent() const
Return pointer to parent of this buffer.
virtual UShort_t GetPidOffset() const =0
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
virtual void SkipVersion(const TClass *cl=nullptr)=0
TClass instances represent classes, structs and namespaces in the ROOT type system.
void Draw(Option_t *option="") override
Draw detailed class inheritance structure.
void * DynamicCast(const TClass *base, void *obj, Bool_t up=kTRUE)
Cast obj of this class type up to baseclass cl if up is true.
static Int_t AutoBrowse(TObject *obj, TBrowser *browser)
Browse external object inherited from TObject.
void Dump() const override
Dump contents of object on stdout.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Option_t * GetOption() const override
Returns the object option stored in the list.
void SetOption(Option_t *option)
Sets the object option stored in the list.
Each ROOT class (see TClass) has a linked list of methods.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
static void AddObj(TObject *obj)
Add an object to the global object table gObjectTable.
Mother of all ROOT objects.
void AbstractMethod(const char *method) const
Call this function within a function that you don't want to define as purely virtual,...
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
virtual void Inspect() const
Dump contents of this object in a graphics canvas.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point (px,py) to the object.
static void SetObjectStat(Bool_t stat)
Turn on/off tracking of objects in the TObjectTable.
virtual Bool_t Notify()
This method must be overridden to handle object notification (the base implementation is no-op).
virtual Bool_t IsEqual(const TObject *obj) const
Default equal comparison (objects are equal if they have the same address in memory).
Bool_t TestBit(UInt_t f) const
virtual const char * GetName() const
Returns name of object.
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
virtual void Dump() const
Dump contents of object on stdout.
UInt_t fUniqueID
object unique identifier
@ kOnlyPrepStep
Used to request that the class specific implementation of TObject::Write just prepare the objects to ...
virtual const char * GetIconName() const
Returns mime type name of object.
virtual void RecursiveRemove(TObject *obj)
Recursively remove this object from a list.
virtual void DoError(int level, const char *location, const char *fmt, va_list va) const
Interface to ErrorHandler (protected).
virtual Bool_t HandleTimer(TTimer *timer)
Execute action in response of a timer timing out.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual UInt_t GetUniqueID() const
Return the unique object id.
UInt_t fBits
bit field status word
@ kNotDeleted
object has not been deleted
static Longptr_t fgDtorOnly
object for which to call dtor only (i.e. no delete)
virtual void Streamer(TBuffer &)
Stream an object of class TObject.
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void UseCurrentStyle()
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyl...
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
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...
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
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.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual void SaveAs(const char *filename="", Option_t *option="") const
Save this object in the file specified by filename.
virtual void Delete(Option_t *option="")
Delete this object.
static Longptr_t GetDtorOnly()
Return destructor only flag.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
static Bool_t GetObjectStat()
Get status of object stat flag.
virtual void Copy(TObject &object) const
Copy this to obj.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
static void SetDtorOnly(void *obj)
Set destructor only flag.
virtual void SetUniqueID(UInt_t uid)
Set the unique object id.
virtual const char * GetTitle() const
Returns title of object.
virtual void DrawClass() const
Draw class inheritance tree of the class to which this object belongs.
virtual TClass * IsA() const
virtual Int_t Compare(const TObject *obj) const
Compare abstract method.
@ kOverwrite
overwrite existing object with same name
@ kSingleKey
write collection with single key
@ kWriteDelete
write object, then delete previous key with same name
virtual ~TObject()
TObject destructor.
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.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
virtual void Pop()
Pop on object drawn in a pad to the top of the display list.
TObject()
TObject constructor.
virtual ULong_t Hash() const
Return hash value for this object.
virtual void ls(Option_t *option="") const
The ls function lists the contents of a class on stdout.
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".
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.
static Bool_t fgObjectStat
if true keep track of objects in TObjectTable
@ kMustCleanup
if object destructor must call RecursiveRemove()
virtual Int_t Read(const char *name)
Read contents of object with specified name from the current directory.
static void AddToTObjectTable(TObject *)
Private helper function which will dispatch to TObjectTable::AddObj.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
void Obsolete(const char *method, const char *asOfVers, const char *removedFromVers) const
Use this method to declare a method obsolete.
A TProcessID identifies a ROOT job in a unique way in time and space.
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.
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
A TRefTable maintains the association between a referenced object and the parent object supporting th...
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.
static void ObjectDealloc(void *vp)
Used to deallocate a TObject on the heap (via TObject::operator delete()).
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
const char * Data() const
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Handles synchronous and a-synchronous timer events.
small helper class to store/restore gPad context in TPad methods
bool DeleteChangesMemory()
void MarkTObjectAsNotOnHeap(TObject &obj)
bool DeleteChangesMemoryImpl()
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.