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

Holder of any object instance.

Normally used with TFile, where any object can be read. Normally RShread or RUnique should be used

Author
Sergey Linev S.Lin.nosp@m.ev@g.nosp@m.si.de
Date
2019-10-19

Definition at line 24 of file RAnyObjectHolder.hxx.

Public Member Functions

 RAnyObjectHolder (TClass *cl, void *obj, bool owner=false)
 
virtual ~RAnyObjectHolder ()
 
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 TClass * GetClass () 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.
 
RHolder * DoCopy () 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
 Returns pointer with ownership, normally via unique_ptr<T>::release() or tobj->Clone()
 

Private Attributes

TClass * fClass {nullptr}
 ! object class
 
void * fObj {nullptr}
 ! plain holder without IO
 
bool fOwner {false}
 ! is object owner
 

#include <ROOT/Browsable/RAnyObjectHolder.hxx>

Inheritance diagram for ROOT::Browsable::RAnyObjectHolder:
[legend]

Constructor & Destructor Documentation

◆ RAnyObjectHolder()

ROOT::Browsable::RAnyObjectHolder::RAnyObjectHolder ( TClass * cl,
void * obj,
bool owner = false )
inline

Definition at line 48 of file RAnyObjectHolder.hxx.

◆ ~RAnyObjectHolder()

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

Definition at line 49 of file RAnyObjectHolder.hxx.

Member Function Documentation

◆ AccessObject()

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

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

Reimplemented from ROOT::Browsable::RHolder.

Definition at line 29 of file RAnyObjectHolder.hxx.

◆ CanCastTo()

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

Definition at line 66 of file RHolder.hxx.

◆ 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 84 of file RHolder.hxx.

◆ DoCopy()

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

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

Reimplemented from ROOT::Browsable::RHolder.

Definition at line 41 of file RAnyObjectHolder.hxx.

◆ Forget()

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

Clear all pointers without performing cleanup.

Reimplemented from ROOT::Browsable::RHolder.

Definition at line 55 of file RAnyObjectHolder.hxx.

◆ Get()

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

Returns direct object pointer cast to provided class.

Definition at line 74 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 120 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 105 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 88 of file RHolder.hxx.

◆ GetClass()

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

Returns class of contained object.

Implements ROOT::Browsable::RHolder.

Definition at line 62 of file RAnyObjectHolder.hxx.

◆ GetObject()

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

Returns direct (temporary) object pointer.

Implements ROOT::Browsable::RHolder.

Definition at line 63 of file RAnyObjectHolder.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 36 of file RHolder.hxx.

◆ InheritsFrom()

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

Definition at line 60 of file RHolder.hxx.

◆ TakeObject()

void * ROOT::Browsable::RAnyObjectHolder::TakeObject ( )
inlinefinalprotectedvirtual

Returns pointer with ownership, normally via unique_ptr<T>::release() or tobj->Clone()

Reimplemented from ROOT::Browsable::RHolder.

Definition at line 31 of file RAnyObjectHolder.hxx.

Member Data Documentation

◆ fClass

TClass* ROOT::Browsable::RAnyObjectHolder::fClass {nullptr}
private

! object class

Definition at line 25 of file RAnyObjectHolder.hxx.

◆ fObj

void* ROOT::Browsable::RAnyObjectHolder::fObj {nullptr}
private

! plain holder without IO

Definition at line 26 of file RAnyObjectHolder.hxx.

◆ fOwner

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

! is object owner

Definition at line 27 of file RAnyObjectHolder.hxx.

Libraries for ROOT::Browsable::RAnyObjectHolder:

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