Publishes callbacks (contracts) and allows blocking, delaying, or triggering them with arguments.
More...
#include <spk_contract_provider.hpp>
|
| class | Blocker |
| | RAII helper that ignores or delays triggers while active. More...
|
| class | Contract |
| | Handle to a subscribed job that can be resigned or triggered. More...
|
|
|
using | Job = typename Contract::Job |
| | Alias to the subscribed callback signature.
|
|
using | VoidJob = std::function<void()> |
| | Callback used for providers without parameters.
|
template<typename... TParameterTypes>
class spk::TContractProvider< TParameterTypes >
Publishes callbacks (contracts) and allows blocking, delaying, or triggering them with arguments.
- Template Parameters
-
| TParameterTypes | Parameter pack forwarded to subscribed jobs. |
auto contract = provider.
subscribe([](
int v){ handleValue(v); });
Publishes callbacks (contracts) and allows blocking, delaying, or triggering them with arguments.
Definition spk_contract_provider.hpp:29
void trigger(TParameterTypes... p_args) const
Triggers all subscribed jobs unless blocked/delayed.
Definition spk_contract_provider.hpp:459
Contract subscribe(const Job &p_job)
Subscribes a job and returns its contract handle.
Definition spk_contract_provider.hpp:406
◆ TContractProvider()
template<typename... TParameterTypes>
Move-constructs, transferring subscriptions and state.
- Parameters
-
◆ block()
template<typename... TParameterTypes>
Creates a blocker in the given mode.
- Parameters
-
| p_mode | Ignore drops triggers; Delay queues one trigger until unblocked. |
- Returns
- RAII Blocker that releases on destruction.
◆ nbContracts()
template<typename... TParameterTypes>
Returns the number of currently subscribed contracts.
- Returns
- Contract count.
◆ operator=()
template<typename... TParameterTypes>
Move-assigns, releasing current contracts and adopting the source state.
- Parameters
-
- Returns
- *this.
◆ relinquish()
template<typename... TParameterTypes>
Moves a contract into the relinquished list (no immediate unsubscribe).
- Parameters
-
◆ subscribe() [1/2]
template<typename... TParameterTypes>
Subscribes a job and returns its contract handle.
- Parameters
-
| p_job | Callback to invoke on trigger. |
- Returns
- Contract managing the subscription.
◆ subscribe() [2/2]
template<typename... TParameterTypes>
template<typename Dummy = void, typename = std::enable_if_t<(sizeof...(TParameterTypes) > 0), Dummy>>
Subscribes a job without parameters, wrapping it to match the signature.
- Parameters
-
| p_job | Callback without parameters. |
- Returns
- Contract managing the subscription.
◆ trigger()
template<typename... TParameterTypes>
Triggers all subscribed jobs unless blocked/delayed.
- Parameters
-
| p_args | Arguments forwarded to each job. |
◆ unsubscribe()
template<typename... TParameterTypes>
Unsubscribes a contract, removing it from the list.
- Parameters
-
The documentation for this class was generated from the following file: