SharedRef< REFCLASS, WRAPPER > Class Template Reference

#include <sharedref.h>

Inheritance diagram for SharedRef< REFCLASS, WRAPPER >:

Detailed Description

template<typename REFCLASS, typename WRAPPER = SharedObject<REFCLASS>>
class maxon::SharedRef< REFCLASS, WRAPPER >

SharedRef encapsulates a REFCLASS (e.g. String, Url, ImageLayer, ImageTexture...) to access it from multiple SharedRefs. With this technique it is possible to store COW objects in structures and allow the modification of the objects from outside.

Public Member Functions

Result< void > Create (const REFCLASS &ref)
 
Result< void > Create (REFCLASS &&ref)
 
const REFCLASS & GetRef () const
 
REFCLASS & GetRef ()
 
template<typename REFCLASSOUT >
const SharedRef< REFCLASSOUT, typename SharedRefHelper< WRAPPER >::template Rebind< REFCLASSOUT > > & Cast () const
 
 operator Bool () const
 
auto PrivateGetRef () const -> const decltype(this->_ref)&
 
auto PrivateGetRef () -> decltype(this->_ref)&
 

Private Member Functions

WRAPPER * GetWrapper () const
 

Member Function Documentation

◆ Create() [1/2]

Result<void> Create ( const REFCLASS &  ref)

Creates a new SharedRef object from the REFCLASS object.

◆ Create() [2/2]

Result<void> Create ( REFCLASS &&  ref)

Creates a new SharedRef object from the REFCLASS object.

◆ GetRef() [1/2]

const REFCLASS& GetRef ( ) const

Acquire access to the REFCLASS object.

◆ GetRef() [2/2]

REFCLASS& GetRef ( )

Acquire access to the REFCLASS object.

◆ Cast()

const SharedRef<REFCLASSOUT, typename SharedRefHelper<WRAPPER>::template Rebind<REFCLASSOUT> >& Cast ( ) const

Casts the SharedRef into another compatible object. e.g.:

ImageBaseSharedRef i = _imageTexture.AddChildren(imageLayer, nullptr) iferr_return;
entry->_loadingLayer = i.Cast<ImageLayer>() iferr_return;

◆ operator Bool()

operator Bool ( ) const
explicit

◆ PrivateGetRef() [1/2]

auto PrivateGetRef ( ) const -> const decltype(this->_ref)&

◆ PrivateGetRef() [2/2]

auto PrivateGetRef ( ) -> decltype(this->_ref)&

◆ GetWrapper()

WRAPPER* GetWrapper ( ) const
private
iferr_return
#define iferr_return
Definition: resultbase.h:1434