|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
RAII guard for graph algorithm initialization. More...
#include <ah_init_guard.H>
Public Member Functions | |
| Init_Guard (CleanupFunc f) | |
| Construct guard with cleanup function. | |
| ~Init_Guard () | |
| Destructor calls cleanup if not released. | |
| void | release () noexcept |
| Release the guard - cleanup will not be called. | |
| bool | is_released () const noexcept |
| Check if the guard has been released. | |
| Init_Guard (const Init_Guard &)=delete | |
| Non-copyable. | |
| Init_Guard & | operator= (const Init_Guard &)=delete |
| Init_Guard (Init_Guard &&other) noexcept | |
| Move constructor. | |
| Init_Guard & | operator= (Init_Guard &&other) noexcept |
| Move assignment operator. | |
Private Attributes | |
| CleanupFunc | cleanup |
| bool | released = false |
RAII guard for graph algorithm initialization.
This template class provides exception-safe cleanup for graph algorithms that allocate resources during initialization (e.g., node/arc cookies).
The guard calls the provided cleanup function when destroyed, unless release() has been called to indicate successful completion.
| CleanupFunc | A callable type (lambda, function object) that performs the cleanup when invoked with no arguments. |
Usage example:
Definition at line 79 of file ah_init_guard.H.
|
inlineexplicit |
Construct guard with cleanup function.
| f | Cleanup function to call on destruction (if not released). |
Definition at line 90 of file ah_init_guard.H.
|
inline |
Destructor calls cleanup if not released.
If release() was not called, the cleanup function is invoked.
Definition at line 96 of file ah_init_guard.H.
References Aleph::Init_Guard< CleanupFunc >::cleanup, Aleph::maps(), and Aleph::Init_Guard< CleanupFunc >::released.
|
delete |
Non-copyable.
|
inlinenoexcept |
Move constructor.
Transfers ownership of the cleanup function to this guard. The moved-from guard is marked as released.
| other | Guard to move from. |
Definition at line 126 of file ah_init_guard.H.
References Aleph::maps().
|
inlinenoexcept |
Check if the guard has been released.
Definition at line 113 of file ah_init_guard.H.
References Aleph::Init_Guard< CleanupFunc >::released.
|
delete |
|
inlinenoexcept |
Move assignment operator.
If this guard holds an active cleanup, it is executed first. Then ownership is transferred from other.
| other | Guard to move from. |
Definition at line 140 of file ah_init_guard.H.
References Aleph::Init_Guard< CleanupFunc >::cleanup, Aleph::maps(), and Aleph::Init_Guard< CleanupFunc >::released.
|
inlinenoexcept |
Release the guard - cleanup will not be called.
Call this method to indicate successful completion. After calling this, the cleanup function will not be invoked on destruction.
Definition at line 107 of file ah_init_guard.H.
References Aleph::Init_Guard< CleanupFunc >::released.
|
private |
Definition at line 81 of file ah_init_guard.H.
Referenced by Aleph::Init_Guard< CleanupFunc >::~Init_Guard(), and Aleph::Init_Guard< CleanupFunc >::operator=().
|
private |
Definition at line 82 of file ah_init_guard.H.
Referenced by Aleph::Init_Guard< CleanupFunc >::~Init_Guard(), Aleph::Init_Guard< CleanupFunc >::is_released(), Aleph::Init_Guard< CleanupFunc >::operator=(), and Aleph::Init_Guard< CleanupFunc >::release().