Public Member Functions | Private Attributes | List of all members
icl_core::AtScopeEnd Class Reference

#include <AtScopeEnd.h>

Public Member Functions

 AtScopeEnd (const boost::function< void()> &func)
 Create an object which runs func when it is destroyed. More...
 
void disable ()
 Disable the object, do not run the function upon destruction. More...
 
void enable ()
 Enable the object to run the function upon destruction (the default). More...
 
 ~AtScopeEnd ()
 Destructor, calls the function as promised. More...
 

Private Attributes

boost::function< void()> m_func
 The function to run upon destruction. More...
 
bool m_run_at_scope_end
 If false, m_func is not run upon destruction. More...
 

Detailed Description

A simple helper class which executes a specific function when the object runs out of scope. Sometimes it is much too complex to wrap some structure that is outside your control into a proper C++ class with a destructor, just to make sure that you never forget to clean up. In this case, just create an AtScopeEnd object and pass to it a matching cleanup function (any thing that can be called as a void() function).

Definition at line 38 of file AtScopeEnd.h.

Constructor & Destructor Documentation

icl_core::AtScopeEnd::AtScopeEnd ( const boost::function< void()> &  func)
inline

Create an object which runs func when it is destroyed.

Definition at line 42 of file AtScopeEnd.h.

icl_core::AtScopeEnd::~AtScopeEnd ( )
inline

Destructor, calls the function as promised.

Definition at line 48 of file AtScopeEnd.h.

Member Function Documentation

void icl_core::AtScopeEnd::disable ( )
inline

Disable the object, do not run the function upon destruction.

Definition at line 57 of file AtScopeEnd.h.

void icl_core::AtScopeEnd::enable ( )
inline

Enable the object to run the function upon destruction (the default).

Definition at line 59 of file AtScopeEnd.h.

Member Data Documentation

boost::function<void()> icl_core::AtScopeEnd::m_func
private

The function to run upon destruction.

Definition at line 63 of file AtScopeEnd.h.

bool icl_core::AtScopeEnd::m_run_at_scope_end
private

If false, m_func is not run upon destruction.

Definition at line 65 of file AtScopeEnd.h.


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


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:59