|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Generic RAII scope guard for cleanup operations on graphs. More...
#include <cookie_guard.H>
Public Member Functions | |
| Scope_Guard (const GT &g, Cleanup cleanup) | |
| Construct a scope guard. | |
| Scope_Guard (const Scope_Guard &)=delete | |
| Copying disabled. | |
| Scope_Guard & | operator= (const Scope_Guard &)=delete |
| Scope_Guard (Scope_Guard &&other) noexcept | |
| Move construction transfers ownership. | |
| ~Scope_Guard () | |
| Destructor - calls cleanup function if still active. | |
| void | release () noexcept |
| Release the guard without calling cleanup. | |
| bool | is_active () const noexcept |
| Check if guard is still active. | |
| void | cleanup_now () |
| Execute cleanup immediately and deactivate. | |
Private Attributes | |
| const GT & | graph |
| Cleanup | cleanup_fn |
| bool | active |
Generic RAII scope guard for cleanup operations on graphs.
Executes a cleanup function when the guard goes out of scope, unless explicitly released. Useful for ensuring cleanup happens even if exceptions occur.
| GT | Graph type. |
| Cleanup | Callable type for cleanup (e.g., lambda, functor). |
Definition at line 559 of file cookie_guard.H.
|
inline |
Construct a scope guard.
| g | Graph to pass to cleanup function. |
| cleanup | Function to call on destruction. |
Definition at line 571 of file cookie_guard.H.
|
delete |
Copying disabled.
|
inlinenoexcept |
Move construction transfers ownership.
Definition at line 580 of file cookie_guard.H.
References Aleph::maps().
|
inline |
Destructor - calls cleanup function if still active.
Definition at line 588 of file cookie_guard.H.
References Aleph::Scope_Guard< GT, Cleanup >::active, Aleph::Scope_Guard< GT, Cleanup >::cleanup_fn, and Aleph::Scope_Guard< GT, Cleanup >::graph.
Execute cleanup immediately and deactivate.
Safe to call multiple times - only first call executes cleanup.
Definition at line 607 of file cookie_guard.H.
References Aleph::Scope_Guard< GT, Cleanup >::active, Aleph::Scope_Guard< GT, Cleanup >::cleanup_fn, and Aleph::Scope_Guard< GT, Cleanup >::graph.
|
inlinenoexcept |
Check if guard is still active.
Definition at line 601 of file cookie_guard.H.
References Aleph::Scope_Guard< GT, Cleanup >::active.
|
delete |
|
inlinenoexcept |
Release the guard without calling cleanup.
Use this if cleanup was performed manually or is no longer needed.
Definition at line 598 of file cookie_guard.H.
References Aleph::Scope_Guard< GT, Cleanup >::active.
Definition at line 563 of file cookie_guard.H.
Referenced by Aleph::Scope_Guard< GT, Cleanup >::~Scope_Guard(), Aleph::Scope_Guard< GT, Cleanup >::cleanup_now(), Aleph::Scope_Guard< GT, Cleanup >::is_active(), and Aleph::Scope_Guard< GT, Cleanup >::release().
Definition at line 562 of file cookie_guard.H.
Referenced by Aleph::Scope_Guard< GT, Cleanup >::~Scope_Guard(), and Aleph::Scope_Guard< GT, Cleanup >::cleanup_now().
Definition at line 561 of file cookie_guard.H.
Referenced by Aleph::Scope_Guard< GT, Cleanup >::~Scope_Guard(), and Aleph::Scope_Guard< GT, Cleanup >::cleanup_now().