|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
RAII guard that clears graph cookies on destruction. More...
#include <cookie_guard.H>
Public Types | |
| using | Node = typename GT::Node |
| using | Arc = typename GT::Arc |
| using | Node_Deleter = std::function< void(Node *)> |
| Signature for custom node cookie deleter. | |
| using | Arc_Deleter = std::function< void(Arc *)> |
| Signature for custom arc cookie deleter. | |
Public Member Functions | |
| Cookie_Guard (const GT &g, bool _clear_nodes=true, bool _clear_arcs=true) noexcept | |
| Construct a cookie guard for the given graph. | |
| Cookie_Guard (const GT &g, Node_Deleter nd, Arc_Deleter ad=nullptr) noexcept | |
| Construct with custom deleters for cookie data. | |
| Cookie_Guard (const Cookie_Guard &)=delete | |
| Copying disabled. | |
| Cookie_Guard & | operator= (const Cookie_Guard &)=delete |
| Cookie_Guard (Cookie_Guard &&other) noexcept | |
| Move construction transfers ownership. | |
| Cookie_Guard & | operator= (Cookie_Guard &&other) noexcept |
| Move assignment transfers ownership. | |
| void | release () noexcept |
| Release the guard without clearing cookies. | |
| void | clear_now () |
| Manually trigger cleanup now. | |
| ~Cookie_Guard () | |
| Destructor - clears cookies if guard is still active. | |
Private Attributes | |
| GT & | graph |
| bool | clear_nodes |
| bool | clear_arcs |
| Node_Deleter | node_deleter |
| Arc_Deleter | arc_deleter |
| bool | active |
RAII guard that clears graph cookies on destruction.
This class provides automatic cleanup of node and arc cookies when the guard goes out of scope. This is essential for exception safety in graph algorithms.
| GT | Graph type (must have Node and Arc types with cookies). |
Definition at line 119 of file cookie_guard.H.
Definition at line 123 of file cookie_guard.H.
Signature for custom arc cookie deleter.
Definition at line 129 of file cookie_guard.H.
Definition at line 122 of file cookie_guard.H.
Signature for custom node cookie deleter.
Definition at line 126 of file cookie_guard.H.
|
inlinenoexcept |
Construct a cookie guard for the given graph.
| g | Graph to guard (const_cast applied - cookies are mutable). |
| _clear_nodes | Whether to clear node cookies (default: true). |
| _clear_arcs | Whether to clear arc cookies (default: true). |
Definition at line 146 of file cookie_guard.H.
|
inlinenoexcept |
Construct with custom deleters for cookie data.
Use this constructor when cookies point to dynamically allocated data that needs to be freed.
| g | Graph to guard (const_cast applied - cookies are mutable). |
| nd | Node deleter function (called for each node before clearing). |
| ad | Arc deleter function (called for each arc before clearing). |
Definition at line 168 of file cookie_guard.H.
|
delete |
Copying disabled.
|
inlinenoexcept |
Move construction transfers ownership.
Definition at line 178 of file cookie_guard.H.
References Aleph::maps().
|
inline |
Destructor - clears cookies if guard is still active.
Definition at line 248 of file cookie_guard.H.
References Aleph::Cookie_Guard< GT >::clear_now().
Referenced by Aleph::compute_cut_nodes().
|
inline |
Manually trigger cleanup now.
Clears cookies immediately and deactivates the guard.
Definition at line 217 of file cookie_guard.H.
References Aleph::Cookie_Guard< GT >::active, ARC_COOKIE, Aleph::Cookie_Guard< GT >::arc_deleter, Aleph::Cookie_Guard< GT >::clear_arcs, Aleph::Cookie_Guard< GT >::clear_nodes, GraphCommon< GT, Node, Arc >::get_arc_it(), GraphCommon< GT, Node, Arc >::get_node_it(), Aleph::Cookie_Guard< GT >::graph, Aleph::maps(), NODE_COOKIE, and Aleph::Cookie_Guard< GT >::node_deleter.
Referenced by Aleph::Cookie_Guard< GT >::~Cookie_Guard().
|
delete |
|
inlinenoexcept |
Move assignment transfers ownership.
Definition at line 187 of file cookie_guard.H.
References Aleph::Cookie_Guard< GT >::active, Aleph::Cookie_Guard< GT >::arc_deleter, Aleph::Cookie_Guard< GT >::clear_arcs, Aleph::Cookie_Guard< GT >::clear_nodes, Aleph::maps(), Aleph::Cookie_Guard< GT >::node_deleter, and Aleph::Cookie_Guard< GT >::release().
|
inlinenoexcept |
Release the guard without clearing cookies.
Call this if you want to keep the cookies after the guard goes out of scope (e.g., algorithm completed successfully and results are stored in cookies).
Definition at line 208 of file cookie_guard.H.
References Aleph::Cookie_Guard< GT >::active.
Referenced by Aleph::Cookie_Guard< GT >::operator=().
|
private |
Definition at line 137 of file cookie_guard.H.
Referenced by Aleph::Cookie_Guard< GT >::clear_now(), Aleph::Cookie_Guard< GT >::operator=(), and Aleph::Cookie_Guard< GT >::release().
|
private |
Definition at line 136 of file cookie_guard.H.
Referenced by Aleph::Cookie_Guard< GT >::clear_now(), and Aleph::Cookie_Guard< GT >::operator=().
|
private |
Definition at line 134 of file cookie_guard.H.
Referenced by Aleph::Cookie_Guard< GT >::clear_now(), and Aleph::Cookie_Guard< GT >::operator=().
|
private |
Definition at line 133 of file cookie_guard.H.
Referenced by Aleph::Cookie_Guard< GT >::clear_now(), and Aleph::Cookie_Guard< GT >::operator=().
|
private |
Definition at line 132 of file cookie_guard.H.
Referenced by Aleph::Cookie_Guard< GT >::clear_now().
|
private |
Definition at line 135 of file cookie_guard.H.
Referenced by Aleph::Cookie_Guard< GT >::clear_now(), and Aleph::Cookie_Guard< GT >::operator=().