ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Methods | Protected Fields | Private Methods | List of all members
Owner< TOwnable > Struct Template Reference

#include <owner.hpp>

Class Description

template<typename TOwnable>
struct aworx::lib::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.

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 41 of file owner.hpp.

Public Methods

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

Protected Fields

TOwnable & theOwnable
 

Private Methods

void * operator new (size_t)
 
void * operator new (size_t, void *)
 
void * operator new[] (size_t)
 
void * operator new[] (size_t, void *)
 
void operator= (const Owner &)
 

Constructor & Destructor Documentation

◆ Owner()

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 77 of file owner.hpp.

◆ ~Owner()

~Owner ( )
inline

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

Definition at line 92 of file owner.hpp.

Member Function Documentation

◆ operator new() [1/2]

void* operator new ( size_t  )
private

Private new to disallow heap allocation.

Returns
Never called.

◆ operator new() [2/2]

void* operator new ( size_t  ,
void *   
)
private

Private new to disallow heap allocation.

Returns
Never called.

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

void* operator new[] ( size_t  )
private

Private new to disallow heap allocation.

Returns
Never called.

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

void* operator new[] ( size_t  ,
void *   
)
private

Private new to disallow heap allocation.

Returns
Never called.

◆ operator=()

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

Private assignment operator.

Member Data Documentation

◆ theOwnable

TOwnable& theOwnable
protected

All we own is this.

Definition at line 64 of file owner.hpp.


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