|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Fixed-size event table implementation. More...
#include <driven_table.H>
Public Types | |
| using | Event_Handler = typename Event_Table< Signature >::Event_Handler |
Public Types inherited from Event_Table< Signature > | |
| using | Event_Handler = std::function< Signature > |
Public Member Functions | |
| size_t | size () const override |
| Get table size (implements Event_Table virtual method) | |
| Static_Event_Table (const size_t num_events=0) | |
| Construct a static event table with a fixed size. | |
| Static_Event_Table (const Static_Event_Table &)=delete | |
| Copying disabled (events may contain non-copyable captures) | |
| Static_Event_Table & | operator= (const Static_Event_Table &)=delete |
| Static_Event_Table (Static_Event_Table &&other) noexcept | |
| Move constructor - transfers ownership of the array. | |
| Static_Event_Table & | operator= (Static_Event_Table &&other) noexcept |
| Move assignment - transfers ownership of the array. | |
| ~Static_Event_Table () override=default | |
| Destructor - automatically frees the underlying array. | |
Public Member Functions inherited from Event_Table< Signature > | |
| virtual | ~Event_Table ()=default |
| Virtual destructor for proper cleanup in derived classes. | |
| template<typename Callable > | |
| void | register_event (const size_t index, Callable &&fct) |
| Register an event at a specific index. | |
| template<typename Callable > | |
| size_t | register_event (Callable &&fct) |
| Append a new event and return its auto-assigned index. | |
| void | unregister_event (const size_t index) |
| Unregister an event at the given index. | |
| bool | is_registered (const size_t index) const |
| Check if an event is registered at the given index. | |
| template<typename F > | |
| bool | check (const size_t, F) const |
| Legacy check method (for backward compatibility). | |
| template<typename... Args> | |
| auto | execute_event (const size_t index, Args &&... args) const |
| Execute the event at the given index with type-safe arguments. | |
Private Member Functions | |
| void | verify_index (const size_t i) const |
| Verify index is within valid range. | |
| const Event_Handler * | read_table (const size_t i) const override |
| Read event at index (implements Event_Table virtual method) | |
| void | write_table (const size_t i, Event_Handler &&event_fct) override |
| Write event at index (implements Event_Table virtual method) | |
| void | clear_slot (size_t i) override |
| Clear event at index (implements Event_Table virtual method) | |
Static Private Member Functions | |
| static Event_Handler * | allocate (const size_t num_events) |
The handlers of a table of num_events events, all of them empty; none for a table without events. | |
Private Attributes | |
| std::unique_ptr< Event_Handler[]> | table |
| Array of event handlers. | |
| size_t | size_table |
| Fixed size of the table. | |
Additional Inherited Members |
Fixed-size event table implementation.
Uses a fixed-size array of event handlers. The size is determined at construction and cannot be changed afterward. Suitable when the number of possible events is known in advance.
register_event(fct) (without an explicit index) is not supported on static tables and will always throw range_error. Use register_event(index, fct) instead.| Signature | Function signature for events (e.g., void(int), int(double, bool)) |
Definition at line 381 of file driven_table.H.
| using Static_Event_Table< Signature >::Event_Handler = typename Event_Table<Signature>::Event_Handler |
Definition at line 384 of file driven_table.H.
|
inlineexplicit |
Construct a static event table with a fixed size.
All event slots are initialized to empty.
| num_events | Number of event slots to allocate (default: 0) |
| std::overflow_error | if the bytes of num_events handlers do not fit in a size_t |
| std::bad_alloc | if there is no memory for the handlers |
Definition at line 447 of file driven_table.H.
|
delete |
Copying disabled (events may contain non-copyable captures)
|
inlinenoexcept |
Move constructor - transfers ownership of the array.
The moved-from object is left in a valid but empty state.
| other | Table to move from (will be emptied) |
Definition at line 464 of file driven_table.H.
|
overridedefault |
Destructor - automatically frees the underlying array.
|
inlinestaticprivate |
The handlers of a table of num_events events, all of them empty; none for a table without events.
Definition at line 422 of file driven_table.H.
References ah_overflow_error_if.
|
inlineoverrideprivatevirtual |
Clear event at index (implements Event_Table virtual method)
Implements Event_Table< Signature >.
Definition at line 414 of file driven_table.H.
References Static_Event_Table< Signature >::table, and Static_Event_Table< Signature >::verify_index().
|
delete |
|
inlinenoexcept |
Move assignment - transfers ownership of the array.
Deletes the current array and takes ownership of other's array.
| other | Table to move from (will be emptied) |
Definition at line 477 of file driven_table.H.
References Static_Event_Table< Signature >::size_table, and Static_Event_Table< Signature >::table.
|
inlineoverrideprivatevirtual |
Read event at index (implements Event_Table virtual method)
Implements Event_Table< Signature >.
Definition at line 400 of file driven_table.H.
References Static_Event_Table< Signature >::table, and Static_Event_Table< Signature >::verify_index().
|
inlineoverridevirtual |
Get table size (implements Event_Table virtual method)
Implements Event_Table< Signature >.
Definition at line 436 of file driven_table.H.
References Static_Event_Table< Signature >::size_table.
|
inlineprivate |
Verify index is within valid range.
| i | Index to verify |
| range_error | if the index is out of bounds |
Definition at line 394 of file driven_table.H.
References ah_range_error_if, and Static_Event_Table< Signature >::size_table.
Referenced by Static_Event_Table< Signature >::clear_slot(), Static_Event_Table< Signature >::read_table(), and Static_Event_Table< Signature >::write_table().
|
inlineoverrideprivatevirtual |
Write event at index (implements Event_Table virtual method)
Implements Event_Table< Signature >.
Definition at line 407 of file driven_table.H.
References Static_Event_Table< Signature >::table, and Static_Event_Table< Signature >::verify_index().
|
private |
Fixed size of the table.
Definition at line 388 of file driven_table.H.
Referenced by Static_Event_Table< Signature >::operator=(), Static_Event_Table< Signature >::size(), and Static_Event_Table< Signature >::verify_index().
|
private |
Array of event handlers.
Definition at line 387 of file driven_table.H.
Referenced by Static_Event_Table< Signature >::clear_slot(), Static_Event_Table< Signature >::operator=(), Static_Event_Table< Signature >::read_table(), and Static_Event_Table< Signature >::write_table().