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 bool fOwner; ///<! 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 fObj = obj;
38 fOwner = owner;
40 }
41
43 {
44 if (fOwner) delete fObj;
45 }
46
47 const TClass *GetClass() const final { return fObj ? fObj->IsA() : nullptr; }
48 const void *GetObject() const final { return fObj; }
49};
50
51
52} // namespace Browsable
53} // namespace Experimental
54} // namespace ROOT
55
56
57#endif
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
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:80
Mother of all ROOT objects.
Definition TObject.h:41
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...