libbio
Loading...
Searching...
No Matches
Public Member Functions | List of all members
bio::SafelyAccess< CLASS > Class Template Reference

#include <SafelyAccess.h>

Public Member Functions

 SafelyAccess ()
 
 SafelyAccess (Pointer< CLASS > toAccess)
 
 ~SafelyAccess ()
 
Pointer< CLASSoperator-> ()
 
Pointer< const CLASSoperator-> () const
 
Pointer< CLASSoperator* ()
 
Pointer< const CLASSoperator* () const
 

Detailed Description

template<class CLASS>
class bio::SafelyAccess< CLASS >

SafelyAccess<> is a simple RAII wrapper around a ThreadSafe object.
If you don't supply the object to wrap, we assume it's a bio::Singleton with an Instance() method.
To access the members of a SafelyAccess<>ed class, please use the -> operator and only dereference if you absolutely must.
As always when dealing with threads, be careful about where you create and destroy these. Don't keep them around too long and don't deadlock ;)

Template Parameters
CLASSa child of bio::ThreadSafe.

Constructor & Destructor Documentation

◆ SafelyAccess() [1/2]

template<class CLASS >
bio::SafelyAccess< CLASS >::SafelyAccess ( )
inline

Constructor for Singletons.

◆ SafelyAccess() [2/2]

template<class CLASS >
bio::SafelyAccess< CLASS >::SafelyAccess ( Pointer< CLASS toAccess)
inline

Constructor for all other ThreadSafe objects.

Parameters
toAccess

◆ ~SafelyAccess()

template<class CLASS >
bio::SafelyAccess< CLASS >::~SafelyAccess ( )
inline

Release RAII lock.

Member Function Documentation

◆ operator*() [1/2]

template<class CLASS >
Pointer< CLASS > bio::SafelyAccess< CLASS >::operator* ( )
inline

Access the locked object.

Returns
a Pointer to the locked CLASS.

◆ operator*() [2/2]

template<class CLASS >
Pointer< const CLASS > bio::SafelyAccess< CLASS >::operator* ( ) const
inline

Access the locked object.

Returns
a Pointer to the locked CLASS.

◆ operator->() [1/2]

template<class CLASS >
Pointer< CLASS > bio::SafelyAccess< CLASS >::operator-> ( )
inline

Access the locked object.

Returns
a Pointer to the locked CLASS.

◆ operator->() [2/2]

template<class CLASS >
Pointer< const CLASS > bio::SafelyAccess< CLASS >::operator-> ( ) const
inline

Access the locked object.

Returns
a Pointer to the locked CLASS.

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