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 Browsable {
16
17/** \class TObjectHolder
18\ingroup rbrowser
19\brief Holder of TObject instance. Should not be used very often, while ownership is undefined for it
20\author Sergey Linev <S.Linev@gsi.de>
21\date 2019-10-19
22\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
23*/
24
25class TObjectHolder : public RHolder {
26 TObject *fObj{nullptr}; ///<! plain holder without IO
27 void *fAdjusted{nullptr}; ///<! pointer on real class returned by fObj->IsA()
28 bool fOwner{false}; ///<! is TObject owner
29protected:
30 void *AccessObject() final { return fOwner ? nullptr : fObj; }
31 void *TakeObject() final;
32 RHolder *DoCopy() const final { return new TObjectHolder(fObj); }
33 void ClearROOTOwnership(TObject *obj);
34public:
35 TObjectHolder(TObject *obj, bool owner = false)
36 {
37 fAdjusted = fObj = obj;
38 fOwner = owner;
39 if (fOwner && fObj)
41 if (fAdjusted) {
43 if (offset > 0)
44 fAdjusted = (char *) fAdjusted - offset;
45 }
46 }
47
49 {
50 if (fOwner) delete fObj;
51 }
52
53 void Forget() final
54 {
55 fAdjusted = fObj = nullptr;
56 fOwner = false;
57 }
58
59 const TClass *GetClass() const final { return fObj ? fObj->IsA() : nullptr; }
60 const void *GetObject() const final { return fAdjusted; }
61};
62
63
64} // namespace Browsable
65} // namespace ROOT
66
67
68#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:35
Holder of TObject instance.
TObjectHolder(TObject *obj, bool owner=false)
RHolder * DoCopy() const final
Create copy of container, works only when pointer can be shared.
void Forget() final
Clear all pointers without performing cleanup.
const TClass * GetClass() const final
Returns class of contained object.
TObject * fObj
! plain holder without IO
const void * GetObject() const final
Returns direct (temporary) object pointer.
void * AccessObject() final
Returns plain object pointer without care about ownership, should not be used often.
void ClearROOTOwnership(TObject *obj)
Check if object is not registered in some global lists Prevent double deletion.
void * fAdjusted
! pointer on real class returned by fObj->IsA()
void * TakeObject() final
Return TObject instance with ownership If object is not owned by the holder, it will be cloned (excep...
bool fOwner
! is TObject owner
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:2858
Mother of all ROOT objects.
Definition TObject.h:41
static TClass * Class()
virtual TClass * IsA() const
Definition TObject.h:243
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...