Type-safe callback slot that wraps a callable with optional ownership tracking. More...
#include <slot.h>
Classes | |
| struct | removeConstAndRef |
| Helper trait that strips const qualification and references from a type. More... | |
Public Types | |
| using | Function = std::function< void(Args...)> |
| Callable type that the slot wraps. | |
| template<typename T > | |
| using | RemoveConstAndRef = typename removeConstAndRef< T >::type |
| Convenience alias for removeConstAndRef. | |
Public Member Functions | |
| Slot (const Function &func, void *owner=nullptr, const char *prototype=nullptr, int id=-1) | |
| Constructs a Slot with the given callable and optional metadata. | |
| void * | owner () const |
| Returns the owner pointer associated with this slot. | |
| const char * | prototype () const |
| Returns the prototype string associated with this slot. | |
| int | id () const |
| Returns the numeric identifier for this slot. | |
| void | setID (int val) |
| Sets the numeric identifier for this slot. | |
| void | exec (Args... args) |
| Executes the slot's callable with the given typed arguments. | |
| void | exec (const VariantList &variantList) |
| Executes the slot's callable by unpacking arguments from a VariantList. | |
Static Public Member Functions | |
| static VariantList | pack (Args... args) |
| Packs the given arguments into a VariantList. | |
Type-safe callback slot that wraps a callable with optional ownership tracking.
Slot provides a mechanism for storing and invoking callbacks with a fixed argument signature. It supports direct invocation with typed arguments as well as deferred invocation from a VariantList, enabling type-erased signal/slot communication.
| Args | The argument types that the slot's callable accepts. |
|
inline |
Constructs a Slot with the given callable and optional metadata.
| func | The callable to invoke when the slot is executed. |
| owner | Optional pointer to the object that owns this slot. |
| prototype | Optional human-readable prototype string for introspection. |
| id | Optional numeric identifier for the slot, defaults to -1 (unset). |
Executes the slot's callable with the given typed arguments.
| args | The arguments to forward to the callable. |
|
inline |
Executes the slot's callable by unpacking arguments from a VariantList.
Each element in the VariantList is converted back to the corresponding typed argument and forwarded to the underlying callable.
| variantList | The list of Variant values to unpack as arguments. |
|
inlinestatic |
Packs the given arguments into a VariantList.
Each argument is converted to a Variant after stripping const and reference qualifiers. This is useful for serializing a set of arguments for later deferred invocation via exec(const VariantList &).
| args | The arguments to pack. |