Ocean
Loading...
Searching...
No Matches
Ocean::ScopedFunctionT< T > Class Template Reference

This class holds a function which will be invoked once the object is disposed. More...

#include <ScopedFunction.h>

Public Member Functions

 ScopedFunctionT ()=default
 Creates an object without function.
 
 ScopedFunctionT (T &&function) noexcept
 Creates a new object with a given function.
 
 ScopedFunctionT (ScopedFunctionT< T > &&scopedFunction) noexcept
 Move constructor.
 
 ~ScopedFunctionT ()
 Destructs this object and invoked the function if this object holds function.
 
void release ()
 Explicitly released this object.
 
void revoke ()
 Revokes the function call.
 
ScopedFunctionToperator= (ScopedFunctionT< T > &&scopedFunction) noexcept
 Move operator.
 

Protected Member Functions

 ScopedFunctionT (const ScopedFunctionT &)=delete
 Disabled copy constructor.
 
ScopedFunctionT< T > & operator= (const ScopedFunctionT &)=delete
 Disabled assign operator.
 

Protected Attributes

function_ = T()
 The function to be invoked.
 

Detailed Description

template<typename T>
class Ocean::ScopedFunctionT< T >

This class holds a function which will be invoked once the object is disposed.

Template Parameters
TThe data type of the function

Constructor & Destructor Documentation

◆ ScopedFunctionT() [1/4]

template<typename T >
Ocean::ScopedFunctionT< T >::ScopedFunctionT ( )
default

Creates an object without function.

◆ ScopedFunctionT() [2/4]

template<typename T >
Ocean::ScopedFunctionT< T >::ScopedFunctionT ( T &&  function)
explicitnoexcept

Creates a new object with a given function.

Parameters
functionThe function to be invoked once this object is disposed

◆ ScopedFunctionT() [3/4]

template<typename T >
Ocean::ScopedFunctionT< T >::ScopedFunctionT ( ScopedFunctionT< T > &&  scopedFunction)
noexcept

Move constructor.

Parameters
scopedFunctionObject to be moved

◆ ~ScopedFunctionT()

template<typename T >
Ocean::ScopedFunctionT< T >::~ScopedFunctionT ( )

Destructs this object and invoked the function if this object holds function.

◆ ScopedFunctionT() [4/4]

template<typename T >
Ocean::ScopedFunctionT< T >::ScopedFunctionT ( const ScopedFunctionT< T > &  )
protecteddelete

Disabled copy constructor.

Member Function Documentation

◆ operator=() [1/2]

template<typename T >
ScopedFunctionT< T > & Ocean::ScopedFunctionT< T >::operator= ( const ScopedFunctionT< T > &  )
protecteddelete

Disabled assign operator.

Returns
Reference to this object

◆ operator=() [2/2]

template<typename T >
ScopedFunctionT< T > & Ocean::ScopedFunctionT< T >::operator= ( ScopedFunctionT< T > &&  scopedFunction)
noexcept

Move operator.

Parameters
scopedFunctionThe object to be moved
Returns
Reference to this object

◆ release()

template<typename T >
void Ocean::ScopedFunctionT< T >::release ( )

Explicitly released this object.

In case this object holds a valid function, the function is invoked and then invalidated so that the function will not be invoked again when this object is disposed.

◆ revoke()

template<typename T >
void Ocean::ScopedFunctionT< T >::revoke ( )

Revokes the function call.

In case this object holds a valid function, the function is invalidated without calling the function.

Field Documentation

◆ function_

template<typename T >
T Ocean::ScopedFunctionT< T >::function_ = T()
protected

The function to be invoked.


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