hdk-grid 0.0.1
Header-only foundational library for the Hollow Development Kit.
Loading...
Searching...
No Matches
hdk::grid::eps::Conduit< ArgTypes > Class Template Reference

#include <EPS.hpp>

Classes

class  Tap

Public Types

typedef std::function< void(ArgTypes...)> Callback_t
 Type alias for event callback function.

Public Member Functions

virtual ~Conduit ()=default
virtual Tap Attach (Callback_t callback)
 Register a callback for this event.
virtual bool Detach (std::uint64_t id)
 Detach by subscription ID.
virtual bool Pause (std::uint64_t id)
virtual bool Resume (std::uint64_t id)
virtual bool IsPaused (std::uint64_t id) const
virtual void Trigger (ArgTypes... args) const
 Trigger the event, invoking all registered callbacks.
void operator() (ArgTypes... args) const
 Convenience operator for triggering the event.
Tap operator% (Callback_t callback)

Detailed Description

template<typename... ArgTypes>
class hdk::grid::eps::Conduit< ArgTypes >

Definition at line 14 of file EPS.hpp.

Member Typedef Documentation

◆ Callback_t

template<typename... ArgTypes>
typedef std::function<void(ArgTypes...)> hdk::grid::eps::Conduit< ArgTypes >::Callback_t

Type alias for event callback function.

A callback is a function that takes the specified ArgTypes and returns void. Example: std::function<void(int, const std::string&)>

Definition at line 19 of file EPS.hpp.

Constructor & Destructor Documentation

◆ ~Conduit()

template<typename... ArgTypes>
virtual hdk::grid::eps::Conduit< ArgTypes >::~Conduit ( )
virtualdefault

Member Function Documentation

◆ Attach()

template<typename... ArgTypes>
virtual Tap hdk::grid::eps::Conduit< ArgTypes >::Attach ( Callback_t callback)
inlinevirtual

Register a callback for this event.

Adds a callback to the list of subscriptions. The callback will be invoked whenever Trigger() is called, with the provided arguments passed to the callback.

Parameters
callbackThe callback function to register (std::function)
Returns
Tap An RAII handle that manages the subscription lifetime
Note
Callback must be callable with the template ArgTypes
Move semantics: callback is moved into the dispatcher

Definition at line 120 of file EPS.hpp.

Referenced by operator%().

◆ Detach()

template<typename... ArgTypes>
virtual bool hdk::grid::eps::Conduit< ArgTypes >::Detach ( std::uint64_t id)
inlinevirtual

Detach by subscription ID.

Removes a subscription by its numeric ID. This is used internally by Tap objects but can also be called directly if needed.

Parameters
idThe subscription ID to remove
Returns
true if unsubscription was successful, false if ID not found

Definition at line 128 of file EPS.hpp.

◆ IsPaused()

template<typename... ArgTypes>
virtual bool hdk::grid::eps::Conduit< ArgTypes >::IsPaused ( std::uint64_t id) const
inlinevirtual

Definition at line 168 of file EPS.hpp.

◆ operator%()

template<typename... ArgTypes>
Tap hdk::grid::eps::Conduit< ArgTypes >::operator% ( Callback_t callback)
inline

Definition at line 197 of file EPS.hpp.

References Attach().

◆ operator()()

template<typename... ArgTypes>
void hdk::grid::eps::Conduit< ArgTypes >::operator() ( ArgTypes... args) const
inline

Convenience operator for triggering the event.

Equivalent to Trigger(args...). Allows the dispatcher to be called like a function.

Definition at line 196 of file EPS.hpp.

References Trigger().

◆ Pause()

template<typename... ArgTypes>
virtual bool hdk::grid::eps::Conduit< ArgTypes >::Pause ( std::uint64_t id)
inlinevirtual

Definition at line 142 of file EPS.hpp.

◆ Resume()

template<typename... ArgTypes>
virtual bool hdk::grid::eps::Conduit< ArgTypes >::Resume ( std::uint64_t id)
inlinevirtual

Definition at line 155 of file EPS.hpp.

◆ Trigger()

template<typename... ArgTypes>
virtual void hdk::grid::eps::Conduit< ArgTypes >::Trigger ( ArgTypes... args) const
inlinevirtual

Trigger the event, invoking all registered callbacks.

Invokes all active callbacks with the provided arguments. Callbacks are invoked sequentially in the order they were registered. If a callback throws an exception, behavior is undefined.

Thread safety: This method acquires a lock to copy callbacks, then releases it before invocation. This allows callbacks to subscribe/unsubscribe during execution, but the newly subscribed callbacks will be invoked on the next Trigger call.

Parameters
argsArguments to pass to each callback
Note
This method is thread-safe
Safe to call from multiple threads concurrently
Safe for callbacks to subscribe/unsubscribe (though changes take effect next trigger)

Definition at line 180 of file EPS.hpp.

Referenced by operator()().


The documentation for this class was generated from the following files: