conduit 0.6.0
Modern C++23 header-only event-dispatching / event-transport library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
conduit::Bus Class Reference

#include <bus.hpp>

Inheritance diagram for conduit::Bus:
Inheritance graph
[legend]
Collaboration diagram for conduit::Bus:
Collaboration graph
[legend]

Public Member Functions

 Bus ()
 
 Bus (std::shared_ptr< EventRegistry > registry)
 
 ~Bus () override
 
 Bus (const Bus &)=delete
 
Busoperator= (const Bus &)=delete
 
 Bus (Bus &&)=delete
 
Busoperator= (Bus &&)=delete
 
template<typename Tp , typename... Args>
Tp & use_transport (Args &&... args)
 
void use_transport (std::shared_ptr< Transport > t)
 
template<typename M , typename... Args>
M & use_middleware (Args &&... args)
 
void use_middleware (std::shared_ptr< Middleware > m)
 
const std::shared_ptr< EventRegistry > & registry () const noexcept
 Shared registry handle.
 
template<typename T >
void register_event ()
 Register an event type T with the bus's event registry.
 
template<typename T , typename F >
Subscription listen (F &&handler, int priority=comms::Prioritized::DEFAULT_PRIORITY)
 Typed listener; the handler is called with const EventEnvelope& or const T&, or a shared_ptr<EventListener<T>>.
 
template<typename T >
Subscription listen (std::shared_ptr< EventListener< T > > listener)
 
template<typename F >
Subscription listen (const std::string_view pattern, F &&handler, const int priority=comms::Prioritized::DEFAULT_PRIORITY)
 Runtime listener by exact name or glob pattern.
 
void register_subscriber (EventSubscriber &s)
 
void publish (const EventEnvelope &env)
 
template<typename T >
void publish (EventBuilder< T > &&b)
 
template<typename T >
void publish (EventBuilder< T > &b)
 
template<typename T >
auto publish (T payload) -> void requires(std::is_base_of_v< parcel::ICell, T >)
 
void drain () const
 
void shutdown () noexcept
 
void deliver_to_listeners (const EventEnvelope &v) const
 Called by transports (e.g.
 
void report_transport_error (const std::string_view transport, const std::exception_ptr &ep) const noexcept
 Surface a transport-level failure (e.g.
 
void release (const detail::SubscriptionId id) noexcept override
 SubscriptionBackref hook.
 
- Public Member Functions inherited from conduit::detail::SubscriptionBackref
 SubscriptionBackref ()=default
 
 SubscriptionBackref (const SubscriptionBackref &)=default
 
 SubscriptionBackref (SubscriptionBackref &&) noexcept=default
 
SubscriptionBackrefoperator= (const SubscriptionBackref &)=default
 
SubscriptionBackrefoperator= (SubscriptionBackref &&) noexcept=default
 
virtual ~SubscriptionBackref ()=default
 

Constructor & Destructor Documentation

◆ Bus() [1/4]

conduit::Bus::Bus ( )
inline

◆ Bus() [2/4]

conduit::Bus::Bus ( std::shared_ptr< EventRegistry registry)
inlineexplicit

◆ ~Bus()

conduit::Bus::~Bus ( )
inlineoverride

◆ Bus() [3/4]

conduit::Bus::Bus ( const Bus )
delete

◆ Bus() [4/4]

conduit::Bus::Bus ( Bus &&  )
delete

Member Function Documentation

◆ deliver_to_listeners()

void conduit::Bus::deliver_to_listeners ( const EventEnvelope v) const
inline

Called by transports (e.g.

local::Transport) to perform the actual listener fan-out for an envelope. Public so transports can invoke it after scheduling onto their own executor.

◆ drain()

void conduit::Bus::drain ( ) const
inline

◆ listen() [1/3]

template<typename F >
Subscription conduit::Bus::listen ( const std::string_view  pattern,
F &&  handler,
const int  priority = comms::Prioritized::DEFAULT_PRIORITY 
)
inline

Runtime listener by exact name or glob pattern.

◆ listen() [2/3]

template<typename T , typename F >
Subscription conduit::Bus::listen ( F &&  handler,
int  priority = comms::Prioritized::DEFAULT_PRIORITY 
)
inline

Typed listener; the handler is called with const EventEnvelope& or const T&, or a shared_ptr<EventListener<T>>.

When the handler is a pointer-like to a comms::Prioritized and the caller does not pass an explicit priority, the priority is inherited from the handler.

◆ listen() [3/3]

template<typename T >
Subscription conduit::Bus::listen ( std::shared_ptr< EventListener< T > >  listener)
inline

◆ operator=() [1/2]

Bus & conduit::Bus::operator= ( Bus &&  )
delete

◆ operator=() [2/2]

Bus & conduit::Bus::operator= ( const Bus )
delete

◆ publish() [1/4]

void conduit::Bus::publish ( const EventEnvelope env)
inline

◆ publish() [2/4]

template<typename T >
void conduit::Bus::publish ( EventBuilder< T > &&  b)
inline

◆ publish() [3/4]

template<typename T >
void conduit::Bus::publish ( EventBuilder< T > &  b)
inline

◆ publish() [4/4]

template<typename T >
auto conduit::Bus::publish ( payload) -> void requires(std::is_base_of_v<parcel::ICell, T>)
inline

◆ register_event()

template<typename T >
void conduit::Bus::register_event ( )
inline

Register an event type T with the bus's event registry.

listen<T> and typed publish<T> overloads call this implicitly, so most callers never invoke it directly — it's exposed for pattern-only listeners that still want a known type's descriptor registered up front.

◆ register_subscriber()

void conduit::Bus::register_subscriber ( EventSubscriber s)
inline

◆ registry()

const std::shared_ptr< EventRegistry > & conduit::Bus::registry ( ) const
inlinenoexcept

Shared registry handle.

Transports that need to decode envelopes off the wire (MQTT, future brokered transports) share this same instance unless given their own at construction time.

◆ release()

void conduit::Bus::release ( const detail::SubscriptionId  id)
inlineoverridevirtualnoexcept

SubscriptionBackref hook.

Implements conduit::detail::SubscriptionBackref.

◆ report_transport_error()

void conduit::Bus::report_transport_error ( const std::string_view  transport,
const std::exception_ptr &  ep 
) const
inlinenoexcept

Surface a transport-level failure (e.g.

an inbound message that failed to decode) through the middleware pipeline. Called by transport adapters from their inbound paths; user code rarely invokes this directly.

◆ shutdown()

void conduit::Bus::shutdown ( )
inlinenoexcept

◆ use_middleware() [1/2]

template<typename M , typename... Args>
M & conduit::Bus::use_middleware ( Args &&...  args)
inline

◆ use_middleware() [2/2]

void conduit::Bus::use_middleware ( std::shared_ptr< Middleware m)
inline

◆ use_transport() [1/2]

template<typename Tp , typename... Args>
Tp & conduit::Bus::use_transport ( Args &&...  args)
inline

◆ use_transport() [2/2]

void conduit::Bus::use_transport ( std::shared_ptr< Transport t)
inline

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