simple thread
Public Member Functions | Protected Member Functions | List of all members
st::shared_context< CRTP, CRTPCTX > Struct Template Reference

CRTP-templated interface to provide shared context api. More...

#include <context.hpp>

Public Member Functions

void * get ()
 
void reset ()
 
 operator bool () const
 
bool operator== (const CRTP &rhs) const noexcept
 
bool operator!= (const CRTP &rhs) const noexcept
 
bool operator< (const CRTP &rhs) const noexcept
 
CRTP & operator= (const CRTP &rhs)
 assign the context More...
 

Protected Member Functions

std::shared_ptr< CRTPCTX > & ctx () const
 
void ctx (std::shared_ptr< CRTPCTX > new_ctx)
 

Detailed Description

template<typename CRTP, typename CRTPCTX>
struct st::shared_context< CRTP, CRTPCTX >

CRTP-templated interface to provide shared context api.

Implements the the shared API between objects in this library which act as abstracted shared pointers. By inheritting this template a type can guarantee

that it has a standardized implementation for various basic operators:

!= < = bool conversion

As well as standardized implementation for accessing the underlying pointer (of type CRTPCTX) which contains the real implementation: ctx() -> shared_ptr<CRTPCTX>& // getter ctx(shared_ptr<CRTPCTX>) -> void // setter

CRTP: curiously recurring template pattern, this should be equal to the child type which is implementing this object. IE: struct object : shared_context<object, object_context> A CRTP type's methods typically are abstracted indirect calls to a CRTPCTX's methods.

CRTPCTX: the CRTP's context type. This is the underlying (typically private, or hidden) type which contains the actual data and implementation for an object.

Member Function Documentation

◆ ctx() [1/2]

template<typename CRTP , typename CRTPCTX >
std::shared_ptr<CRTPCTX>& st::shared_context< CRTP, CRTPCTX >::ctx ( ) const
inlineprotected

WARNING: Blind manipulation of this value is dangerous.

Returns
context shared pointer reference

◆ ctx() [2/2]

template<typename CRTP , typename CRTPCTX >
void st::shared_context< CRTP, CRTPCTX >::ctx ( std::shared_ptr< CRTPCTX >  new_ctx)
inlineprotected
Parameters
ctxassign the context shared pointer

◆ operator bool()

template<typename CRTP , typename CRTPCTX >
st::shared_context< CRTP, CRTPCTX >::operator bool ( ) const
inline
Returns
true if object is allocated, else false

◆ operator!=()

template<typename CRTP , typename CRTPCTX >
bool st::shared_context< CRTP, CRTPCTX >::operator!= ( const CRTP &  rhs) const
inlinenoexcept
Returns
true if argument CRTP represents this CRTP (or no CRTP), else false

◆ operator<()

template<typename CRTP , typename CRTPCTX >
bool st::shared_context< CRTP, CRTPCTX >::operator< ( const CRTP &  rhs) const
inlinenoexcept
Returns
true if this is less than rhs, else false

◆ operator=()

template<typename CRTP , typename CRTPCTX >
CRTP& st::shared_context< CRTP, CRTPCTX >::operator= ( const CRTP &  rhs)
inline

assign the context

Returns
a reference to argument this object

◆ operator==()

template<typename CRTP , typename CRTPCTX >
bool st::shared_context< CRTP, CRTPCTX >::operator== ( const CRTP &  rhs) const
inlinenoexcept
Returns
true if argument CRTP represents this CRTP (or no CRTP), else false

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