Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ROOT::Browsable::TObjectHolder Class Reference

Holder of TObject instance.

Should not be used very often, while ownership is undefined for it

Author
Sergey Linev S.Lin.nosp@m.ev@g.nosp@m.si.de
Date
2019-10-19
Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!

Definition at line 25 of file TObjectHolder.hxx.

Public Member Functions

 TObjectHolder (TObject *obj, bool owner=false)
virtual ~TObjectHolder ()
template<class T>
bool CanCastTo () const
auto Copy () const
 Clone container.
void Forget () final
 Clear all pointers without performing cleanup.
template<class T>
const T * Get () const
 Returns direct object pointer cast to provided class.
template<class T>
T * get_object ()
 Returns plains pointer on object without ownership, only can be used for TObjects.
template<class T>
std::shared_ptr< T > get_shared ()
 Returns shared_ptr of contained object.
template<class T>
std::unique_ptr< T > get_unique ()
 Returns unique_ptr of contained object.
const TClassGetClass () const final
 Returns class of contained object.
const void * GetObject () const final
 Returns direct (temporary) object pointer.
template<class T>
bool InheritsFrom () const

Protected Member Functions

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.
RHolderDoCopy () const final
 Create copy of container, works only when pointer can be shared.
virtual void * GetShared () const
 Returns pointer on existing shared_ptr<T>.
void * TakeObject () final
 Return TObject instance with ownership If object is not owned by the holder, it will be cloned (except TDirectory or TTree classes).

Private Attributes

void * fAdjusted {nullptr}
 ! pointer on real class returned by fObj->IsA()
TObjectfObj {nullptr}
 ! plain holder without IO
bool fOwner {false}
 ! is TObject owner

#include <ROOT/Browsable/TObjectHolder.hxx>

Inheritance diagram for ROOT::Browsable::TObjectHolder:
ROOT::Browsable::RHolder

Constructor & Destructor Documentation

◆ TObjectHolder()

ROOT::Browsable::TObjectHolder::TObjectHolder ( TObject * obj,
bool owner = false )
inline

Definition at line 35 of file TObjectHolder.hxx.

◆ ~TObjectHolder()

virtual ROOT::Browsable::TObjectHolder::~TObjectHolder ( )
inlinevirtual

Definition at line 48 of file TObjectHolder.hxx.

Member Function Documentation

◆ AccessObject()

void * ROOT::Browsable::TObjectHolder::AccessObject ( )
inlinefinalprotectedvirtual

Returns plain object pointer without care about ownership, should not be used often.

Reimplemented from ROOT::Browsable::RHolder.

Definition at line 30 of file TObjectHolder.hxx.

◆ CanCastTo()

template<class T>
bool ROOT::Browsable::RHolder::CanCastTo ( ) const
inlineinherited

Definition at line 67 of file RHolder.hxx.

◆ ClearROOTOwnership()

void TObjectHolder::ClearROOTOwnership ( TObject * obj)
protected

Check if object is not registered in some global lists Prevent double deletion.

Definition at line 20 of file TObjectHolder.cxx.

◆ Copy()

auto ROOT::Browsable::RHolder::Copy ( ) const
inlineinherited

Clone container.

Trivial for shared_ptr and TObject holder, does not work for unique_ptr

Definition at line 85 of file RHolder.hxx.

◆ DoCopy()

RHolder * ROOT::Browsable::TObjectHolder::DoCopy ( ) const
inlinefinalprotectedvirtual

Create copy of container, works only when pointer can be shared.

Reimplemented from ROOT::Browsable::RHolder.

Definition at line 32 of file TObjectHolder.hxx.

◆ Forget()

void ROOT::Browsable::TObjectHolder::Forget ( )
inlinefinalvirtual

Clear all pointers without performing cleanup.

Reimplemented from ROOT::Browsable::RHolder.

Definition at line 53 of file TObjectHolder.hxx.

◆ Get()

template<class T>
const T * ROOT::Browsable::RHolder::Get ( ) const
inlineinherited

Returns direct object pointer cast to provided class.

Definition at line 75 of file RHolder.hxx.

◆ get_object()

template<class T>
T * ROOT::Browsable::RHolder::get_object ( )
inlineinherited

Returns plains pointer on object without ownership, only can be used for TObjects.

Definition at line 121 of file RHolder.hxx.

◆ get_shared()

template<class T>
std::shared_ptr< T > ROOT::Browsable::RHolder::get_shared ( )
inlineinherited

Returns shared_ptr of contained object.

Definition at line 106 of file RHolder.hxx.

◆ get_unique()

template<class T>
std::unique_ptr< T > ROOT::Browsable::RHolder::get_unique ( )
inlineinherited

Returns unique_ptr of contained object.

Definition at line 89 of file RHolder.hxx.

◆ GetClass()

const TClass * ROOT::Browsable::TObjectHolder::GetClass ( ) const
inlinefinalvirtual

Returns class of contained object.

Implements ROOT::Browsable::RHolder.

Definition at line 59 of file TObjectHolder.hxx.

◆ GetObject()

const void * ROOT::Browsable::TObjectHolder::GetObject ( ) const
inlinefinalvirtual

Returns direct (temporary) object pointer.

Implements ROOT::Browsable::RHolder.

Definition at line 60 of file TObjectHolder.hxx.

◆ GetShared()

virtual void * ROOT::Browsable::RHolder::GetShared ( ) const
inlineprotectedvirtualinherited

Returns pointer on existing shared_ptr<T>.

Reimplemented in ROOT::Browsable::RShared< T >.

Definition at line 37 of file RHolder.hxx.

◆ InheritsFrom()

template<class T>
bool ROOT::Browsable::RHolder::InheritsFrom ( ) const
inlineinherited

Definition at line 61 of file RHolder.hxx.

◆ TakeObject()

void * TObjectHolder::TakeObject ( )
finalprotectedvirtual

Return TObject instance with ownership If object is not owned by the holder, it will be cloned (except TDirectory or TTree classes).

Reimplemented from ROOT::Browsable::RHolder.

Definition at line 37 of file TObjectHolder.cxx.

Member Data Documentation

◆ fAdjusted

void* ROOT::Browsable::TObjectHolder::fAdjusted {nullptr}
private

! pointer on real class returned by fObj->IsA()

Definition at line 27 of file TObjectHolder.hxx.

◆ fObj

TObject* ROOT::Browsable::TObjectHolder::fObj {nullptr}
private

! plain holder without IO

Definition at line 26 of file TObjectHolder.hxx.

◆ fOwner

bool ROOT::Browsable::TObjectHolder::fOwner {false}
private

! is TObject owner

Definition at line 28 of file TObjectHolder.hxx.


The documentation for this class was generated from the following files: