|
Aleph-w 3.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) | |
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 378 of file driven_table.H.
| using Static_Event_Table< Signature >::Event_Handler = typename Event_Table<Signature>::Event_Handler |
Definition at line 381 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) |
Definition at line 427 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 444 of file driven_table.H.
References Aleph::maps().
|
overridedefault |
Destructor - automatically frees the underlying array.
|
inlineoverrideprivatevirtual |
Clear event at index (implements Event_Table virtual method)
Implements Event_Table< Signature >.
Definition at line 411 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 457 of file driven_table.H.
References Aleph::maps(), 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 397 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 419 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 391 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 404 of file driven_table.H.
References Aleph::maps(), Static_Event_Table< Signature >::table, and Static_Event_Table< Signature >::verify_index().
|
private |
Fixed size of the table.
Definition at line 385 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 384 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().