Public Member Functions | Private Attributes
icl_core::AtScopeEnd Class Reference

#include <AtScopeEnd.h>

List of all members.

Public Member Functions

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

Private Attributes

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

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.

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.

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 Thu Jun 6 2019 20:22:26