public

Inheritance Graph

graph BT
	OptionalRegistryHandleHolder
	click OptionalRegistryHandleHolder "classUtil_1_1OptionalRegistryHandleHolder"

Description

Safe storage for an optional RegistryHandle .

By storing a handle that is obtained by registering an element at a Registry in an instance of this holder class, the registration of the element is automatically canceled when the holder is destroyed. This class can be used to apply the Resource Acquisition Is Initialization (RAII) idiom for an registered element. In contrast to the RegistryHandleHolder class, the handle inside this class is optional. This means that an instance of this class is allowed to hold nothing.

Parameters

handle_t
Type of the handle optionally stored inside the holder

Author: Benjamin Eikel

Date: 2013-11-26

Public Functions

   
   
  OptionalRegistryHandleHolder(register_fn_t registerFunction, unregister_fn_t unregisterFunction)
   
  ~OptionalRegistryHandleHolder()
   
  OptionalRegistryHandleHolder( OptionalRegistryHandleHolder && void)
   
  OptionalRegistryHandleHolder(const OptionalRegistryHandleHolder & void)
   
OptionalRegistryHandleHolder & operator=( OptionalRegistryHandleHolder && void)
   
OptionalRegistryHandleHolder & operator=(const OptionalRegistryHandleHolder & void)
   
bool enable()
   
bool disable()

Documentation

function
Util::OptionalRegistryHandleHolder::OptionalRegistryHandleHolder

public inline
     
     
OptionalRegistryHandleHolder( register_fn_t registerFunction,
  unregister_fn_t unregisterFunction
)    

Store the given functions. The handle is not created by calling theregisterFunction. The new instance will hold nothing. Call enable() to obtain a valid handle.

Parameters

registerFunction
A function without parameters that registers an element and returns a handle for the registered element
unregisterFunction
A function that receives a handle for an registered element and cancels the registration of that element

Defined in Util/RegistryHelper.h:105


function
Util::OptionalRegistryHandleHolder::~OptionalRegistryHandleHolder

public inline
   
   
~OptionalRegistryHandleHolder( )

If a valid handle is hold, cancel the registration of an element by calling the stored function with the stored handle as parameter.

Defined in Util/RegistryHelper.h:115


function
Util::OptionalRegistryHandleHolder::OptionalRegistryHandleHolder

public
     
     
OptionalRegistryHandleHolder( OptionalRegistryHandleHolder && void )

Defined in Util/RegistryHelper.h:118


function
Util::OptionalRegistryHandleHolder::OptionalRegistryHandleHolder

public
     
     
OptionalRegistryHandleHolder( const OptionalRegistryHandleHolder & void )

Defined in Util/RegistryHelper.h:119


function
Util::OptionalRegistryHandleHolder::operator=

public
     
     
OptionalRegistryHandleHolder & operator=( OptionalRegistryHandleHolder && void )

Defined in Util/RegistryHelper.h:120


function
Util::OptionalRegistryHandleHolder::operator=

public
     
     
OptionalRegistryHandleHolder & operator=( const OptionalRegistryHandleHolder & void )

Defined in Util/RegistryHelper.h:121


function
Util::OptionalRegistryHandleHolder::enable

public inline
   
   
bool enable( )

Register an element at a registry by calling the stored function. The handle will be stored inside this holder. If a valid handle is already stored, nothing will be done.

Parameters

true
A new handle was created by calling the registration function
false
A valid handle has already been stored before and nothing was done

Defined in Util/RegistryHelper.h:132


function
Util::OptionalRegistryHandleHolder::disable

public inline
   
   
bool disable( )

Cancel the registration of an element at a registry by calling the stored function. For this, the handle stored inside this holder will be used. If no valid handle is stored, nothing will be done.

Parameters

true
The registration was canceled by using the stored handle. The handle was removed and the holder holds nothing now.
false
No valid handle has been stored before and nothing was done

Defined in Util/RegistryHelper.h:149