Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
OptionalRef< T > Class Template Reference

#include "lib/optional-ref.hpp"

Description

template<typename T>
class lib::OptionalRef< T >

Optional or switchable link to an existing object.

This reference wrapper is accessed like a functor, but has the ability to be disabled. This disabled state is managed automatically by ctor and dtor, can be detected through bool check and – contrary to a NULL pointer – produces a real exception instead of crashing.

Note
not taking ownership of the pointee
See also
OptionalRef_test
lib::AutoRegistered usage example
SessionInterfaceModules::~SessionInterfaceModules()

Definition at line 52 of file optional-ref.hpp.

Public Member Functions

 OptionalRef ()
 
 ~OptionalRef ()
 
 OptionalRef (T &target)
 
 operator bool () const
 
T & operator() () const
 
void link_to (T &target)
 
void clear ()
 
bool isValid () const
 
bool points_to (T const &target) const
 

Friends

bool operator== (OptionalRef const &r1, OptionalRef const &r2)
 
bool operator!= (OptionalRef const &r1, OptionalRef const &r2)
 
bool operator== (OptionalRef const &ref, T const &otherTarget)
 
bool operator== (T const &otherTarget, OptionalRef const &ref)
 
bool operator!= (T const &otherTarget, OptionalRef const &ref)
 
bool operator!= (OptionalRef const &ref, T const &otherTarget)
 

Private Attributes

T * ref_
 

Constructor & Destructor Documentation

◆ OptionalRef() [1/2]

template<typename T >
OptionalRef ( )
inline

Definition at line 58 of file optional-ref.hpp.

◆ ~OptionalRef()

template<typename T >
~OptionalRef ( )
inline

Definition at line 62 of file optional-ref.hpp.

References OptionalRef< T >::clear().

+ Here is the call graph for this function:

◆ OptionalRef() [2/2]

template<typename T >
OptionalRef ( T &  target)
inlineexplicit
Parameters
target...not allowing implicit conversion from T&

Definition at line 70 of file optional-ref.hpp.

Member Function Documentation

◆ operator bool()

template<typename T >
operator bool ( ) const
inlineexplicit

Definition at line 74 of file optional-ref.hpp.

References OptionalRef< T >::isValid().

+ Here is the call graph for this function:

◆ operator()()

template<typename T >
T & operator() ( ) const
inline

Definition at line 78 of file optional-ref.hpp.

References OptionalRef< T >::isValid(), LERR_, and OptionalRef< T >::ref_.

+ Here is the call graph for this function:

◆ link_to()

template<typename T >
void link_to ( T &  target)
inline

Definition at line 90 of file optional-ref.hpp.

References OptionalRef< T >::ref_.

Referenced by AutoRegistered< TAR >::setRegistryInstance().

+ Here is the caller graph for this function:

◆ clear()

template<typename T >
void clear ( )
inline

Definition at line 96 of file optional-ref.hpp.

References OptionalRef< T >::ref_.

Referenced by OptionalRef< T >::~OptionalRef(), and AutoRegistered< TAR >::deactivateRegistryLink().

+ Here is the caller graph for this function:

◆ isValid()

template<typename T >
bool isValid ( ) const
inline

Definition at line 105 of file optional-ref.hpp.

References OptionalRef< T >::ref_.

Referenced by OptionalRef< T >::operator bool(), OptionalRef< T >::operator()(), and OptionalRef< T >::points_to().

+ Here is the caller graph for this function:

◆ points_to()

template<typename T >
bool points_to ( T const &  target) const
inline

Definition at line 111 of file optional-ref.hpp.

References OptionalRef< T >::isValid(), and OptionalRef< T >::ref_.

Referenced by AutoRegistered< TAR >::is_attached_to().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ ref_

Friends And Related Symbol Documentation

◆ operator== [1/3]

template<typename T >
bool operator== ( OptionalRef< T > const &  r1,
OptionalRef< T > const &  r2 
)
friend

Definition at line 118 of file optional-ref.hpp.

◆ operator!= [1/3]

template<typename T >
bool operator!= ( OptionalRef< T > const &  r1,
OptionalRef< T > const &  r2 
)
friend

Definition at line 123 of file optional-ref.hpp.

◆ operator== [2/3]

template<typename T >
bool operator== ( OptionalRef< T > const &  ref,
T const &  otherTarget 
)
friend
Parameters
otherTarget
Note
might throw

Definition at line 130 of file optional-ref.hpp.

◆ operator== [3/3]

template<typename T >
bool operator== ( T const &  otherTarget,
OptionalRef< T > const &  ref 
)
friend

Definition at line 135 of file optional-ref.hpp.

◆ operator!= [2/3]

template<typename T >
bool operator!= ( T const &  otherTarget,
OptionalRef< T > const &  ref 
)
friend

Definition at line 136 of file optional-ref.hpp.

◆ operator!= [3/3]

template<typename T >
bool operator!= ( OptionalRef< T > const &  ref,
T const &  otherTarget 
)
friend

Definition at line 137 of file optional-ref.hpp.

+ Inheritance diagram for OptionalRef< T >:
+ Collaboration diagram for OptionalRef< T >:

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