ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
Owner< TOwnable > Class Template Reference

Description:

template<typename TOwnable>
class alib::lang::Owner< TOwnable >

Ensures that an object of template type TOwnable is acquired and properly released when unwinding the stack. This class is meant to be allocated only on the stack and not on the heap. Therefore, the new operators are declared private.

With debug builds the constructor expects caller source information parameters file , line and func . It is convenient to use macro ALIB_CALLER_PRUNED to provide those.

Note that this type is available only if ALib Strings is included in the ALib Distribution .

See also
Preprocessor macros ALIB_OWN, ALIB_LOCK and ALIB_LOCK_WITH for a convenient way to use this class.
Template Parameters
TOwnableThe type to own. The type needs to have methods Acquire and Release available.

Definition at line 43 of file owner.hpp.

#include <owner.hpp>

Public Method Index:

 Owner (TOwnable &ownable, const NCString &dbgFile, int dbgLine, const NCString &dbgFunc)
 
 ~Owner ()
 

Field Details:

◆ theOwnable

template<typename TOwnable >
TOwnable& theOwnable
protected

All we own is this.

Definition at line 66 of file owner.hpp.

Constructor(s) / Destructor Details::

◆ Owner()

template<typename TOwnable >
Owner ( TOwnable & ownable,
const NCString & dbgFile,
int dbgLine,
const NCString & dbgFunc )
inline

The constructor. Invokes Acquire() on the owner.

Parameters
ownableThe ownable to acquire.
dbgFileCaller information. Available only with debug builds.
dbgLineCaller information. Available only with debug builds.
dbgFuncCaller information. Available only with debug builds.

Definition at line 79 of file owner.hpp.

◆ ~Owner()

template<typename TOwnable >
~Owner ( )
inline

The destructor. Releases the owner by invoking Release().

Definition at line 94 of file owner.hpp.

Method Details:

◆ operator new() [1/2]

template<typename TOwnable >
void * operator new ( size_t )
private

Private new to disallow heap allocation.

Returns
Never called.

◆ operator new() [2/2]

template<typename TOwnable >
void * operator new ( size_t ,
void *  )
private

Private new to disallow heap allocation.

Returns
Never called.

◆ operator new[]() [1/2]

template<typename TOwnable >
void * operator new[] ( size_t )
private

Private new to disallow heap allocation.

Returns
Never called.

◆ operator new[]() [2/2]

template<typename TOwnable >
void * operator new[] ( size_t ,
void *  )
private

Private new to disallow heap allocation.

Returns
Never called.

◆ operator=()

template<typename TOwnable >
void operator= ( const Owner< TOwnable > & )
private

Private assignment operator.


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