Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TObjectHolder.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_Browsable_TObjectHolder
10#define ROOT7_Browsable_TObjectHolder
11
13
14namespace ROOT {
15namespace Experimental {
16namespace Browsable {
17
18/** \class TObjectHolder
19\ingroup rbrowser
20\brief Holder of TObject instance. Should not be used very often, while ownership is undefined for it
21\author Sergey Linev <S.Linev@gsi.de>
22\date 2019-10-19
23\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
24*/
25
26class TObjectHolder : public RHolder {
27 TObject *fObj{nullptr}; ///<! plain holder without IO
28 void *fAdjusted{nullptr}; ///<! pointer on real class returned by fObj->IsA()
29 bool fOwner{false}; ///<! is TObject owner
30protected:
31 void *AccessObject() final { return fOwner ? nullptr : fObj; }
32 void *TakeObject() final;
33 RHolder *DoCopy() const final { return new TObjectHolder(fObj); }
34 void ClearROOTOwnership(TObject *obj);
35public:
36 TObjectHolder(TObject *obj, bool owner = false)
37 {
38 fAdjusted = fObj = obj;
39 fOwner = owner;
40 if (fOwner && fObj)
42 if (fAdjusted) {
44 if (offset > 0)
45 fAdjusted = (char *) fAdjusted - offset;
46 }
47 }
48
50 {
51 if (fOwner) delete fObj;
52 }
53
54 const TClass *GetClass() const final { return fObj ? fObj->IsA() : nullptr; }
55 const void *GetObject() const final { return fAdjusted; }
56};
57
58
59} // namespace Browsable
60} // namespace Experimental
61} // namespace ROOT
62
63
64#endif
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 offset
Basic class for object holder of any kind.
Definition RHolder.hxx:33
void * AccessObject() final
Returns plain object pointer without care about ownership, should not be used often.
TObjectHolder(TObject *obj, bool owner=false)
const TClass * GetClass() const final
Returns class of contained object.
void ClearROOTOwnership(TObject *obj)
Check if object is not registered in some global lists Prevent double deletion.
TObject * fObj
! plain holder without IO
void * fAdjusted
! pointer on real class returned by fObj->IsA()
RHolder * DoCopy() const final
Create copy of container, works only when pointer can be shared.
const void * GetObject() const final
Returns direct (temporary) object pointer.
void * TakeObject() final
Return TObject instance with ownership If object is not owned by the holder, it will be cloned (excep...
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
Int_t GetBaseClassOffset(const TClass *toBase, void *address=nullptr, bool isDerivedObject=true)
Definition TClass.cxx:2791
Mother of all ROOT objects.
Definition TObject.h:41
static TClass * Class()
virtual TClass * IsA() const
Definition TObject.h:245
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.