Workspace 7.0.2
|
This file contains a class and factory method to easily create a generic scope guard in any given context by taking advantage of type inferencing and lambdas. This simplifies the code needed to use RAII to perform cleanup functionality regardless of how a method is exited. For example, deallocating dynamically allocated objects or closing a connection when a method exits, regardless of whether it exits successfully or due to an error. More...
#include <memory>
#include "Workspace/Application/LanguageUtils/errorchecks.h"
#include "Workspace/Application/logmanager.h"
Classes | |
class | ScopeGuard< Callable > |
Generic scopeguard to simplify RAII where cleanup is needed. More... | |
Namespaces | |
namespace | CSIRO |
Top level namespace for all Workspace code. | |
namespace | CSIRO::Application |
Application-level functionality for all workspace applications. | |
Functions | |
template<typename Callable > | |
ScopeGuard< Callable > | createScopeGuard (Callable rollback) |
The ScopeGuard::dismiss() method can be used to dismiss a guard if its rollback method is no longer required.
Sample usage: