OGLplus  (0.59.0) a C++ wrapper for rendering APIs

eagine::msgbus::subscriber Class Reference

Template for subscribers with variable count of handled message types. More...

#include <eagine/message_bus/subscriber.hpp>

Public Types

using method_handler = callable_ref< bool(const message_context &, stored_message &)>
 Alias for method/message handler callable reference.
 

Public Member Functions

 subscriber (endpoint &bus) noexcept
 Construction from a reference to endpoint.
 
template<typename Class , bool(Class::*)(const message_context &, stored_message &) Method>
void add_method (Class *instance, message_id msg_id, member_function_constant< bool(Class::*)(const message_context &, stored_message &), Method > method)
 Adds a handler for messages with the specified message id.
 
template<typename Class , bool(Class::*)(const message_context &, stored_message &) Method>
void add_method (Class *instance, message_handler_map< member_function_constant< bool(Class::*)(const message_context &, stored_message &), Method >> msg_map) noexcept
 Adds a handler for messages with the specified message id.
 
template<typename Class , bool(Class::*)(const message_context &, stored_message &) Method>
void add_method (std::tuple< Class *, message_handler_map< member_function_constant< bool(Class::*)(const message_context &, stored_message &), Method >>> imm) noexcept
 Adds a handler for messages with the specified message id.
 
template<typename Class , bool(Class::*)(const message_context &, stored_message &) Method, identifier_t ClassId, identifier_t MethodId>
void add_method (Class *instance, static_message_handler_map< static_message_id< ClassId, MethodId >, member_function_constant< bool(Class::*)(const message_context &, stored_message &), Method >> msg_map) noexcept
 Adds a handler for messages with the specified message id.
 
auto process_one () -> bool
 Handles (and removes) one of poending received messages. More...
 
auto process_all () -> span_size_t
 Handles (and removes) all poending received messages. More...
 
void announce_subscriptions () const
 Sends messages to the bus saying which messages this can handle. More...
 
void allow_subscriptions () const
 Sends messages to the router saying which messages should be forwarded. More...
 
void retract_subscriptions () const noexcept
 Sends messages to the bus saying which messages this cannot handle. More...
 
void respond_to_subscription_query (identifier_t source_id) const noexcept
 Sends messages responding to a subscription query. More...
 
void respond_to_subscription_query (identifier_t source_id, message_id sub_msg) const noexcept
 Sends messages responding to a subscription query. More...
 
- Public Member Functions inherited from eagine::interface< subscriber >
constexpr interface (const interface &)=delete
 Not copyable.
 
auto operator= (interface &&)=delete
 Not move assignable.
 
auto operator= (const interface &)=delete
 Not copy assignable.
 
- Public Member Functions inherited from eagine::msgbus::subscriber_base
 operator bool () noexcept
 Tests if this subscribes has an associated endpoint and is usable.
 
auto bus () noexcept -> auto &
 Returns a reference to the associated endpoint. More...
 
auto bus () const noexcept -> auto &
 Returns a const reference to the associated endpoint. More...
 
auto update () const noexcept -> bool
 Updates the internal endpoint state (should be called repeatedly).
 
auto verify_bits (const stored_message &message) noexcept -> verification_bits
 Uses the associated endpoint to verify the specified message.
 
void query_subscriptions_of (identifier_t target_id)
 Queries the subscriptions of the remote endpoint with the specified id. More...
 
void query_subscribers_of (message_id sub_msg)
 Queries remote nodes subscribing to the specified message. More...
 
 subscriber_base (const subscriber_base &)=delete
 Not copy assignable.
 
auto operator= (subscriber_base &&)=delete
 Not move assignable.
 
auto operator= (const subscriber_base &)=delete
 Not copy constructible.
 

Additional Inherited Members

- Protected Member Functions inherited from eagine::interface< subscriber >
constexpr interface () noexcept=default
 Default constructible by derived.
 
constexpr interface (interface &&) noexcept=default
 Move constructible by derived.
 

Detailed Description

Template for subscribers with variable count of handled message types.

See also
static_subscriber

Member Function Documentation

◆ allow_subscriptions()

void eagine::msgbus::subscriber::allow_subscriptions ( ) const
inline

Sends messages to the router saying which messages should be forwarded.

See also
announce_subscriptions
retract_subscriptions
respond_to_subscription_query

◆ announce_subscriptions()

void eagine::msgbus::subscriber::announce_subscriptions ( ) const
inline

Sends messages to the bus saying which messages this can handle.

See also
retract_subscriptions
respond_to_subscription_query
allow_subscriptions

◆ process_all()

auto eagine::msgbus::subscriber::process_all ( ) -> span_size_t
inline

Handles (and removes) all poending received messages.

See also
process_one
Examples
eagine/message_bus/007_ping.cpp.

Referenced by eagine::msgbus::service_composition< sudoku_solver<> >::update_and_process_all().

◆ process_one()

auto eagine::msgbus::subscriber::process_one ( ) -> bool
inline

Handles (and removes) one of poending received messages.

See also
process_all

◆ respond_to_subscription_query() [1/2]

void eagine::msgbus::subscriber::respond_to_subscription_query ( identifier_t  source_id) const
inlinenoexcept

Sends messages responding to a subscription query.

See also
retract_subscriptions
announce_subscriptions

◆ respond_to_subscription_query() [2/2]

void eagine::msgbus::subscriber::respond_to_subscription_query ( identifier_t  source_id,
message_id  sub_msg 
) const
inlinenoexcept

Sends messages responding to a subscription query.

See also
retract_subscriptions
announce_subscriptions

◆ retract_subscriptions()

void eagine::msgbus::subscriber::retract_subscriptions ( ) const
inlinenoexcept

Sends messages to the bus saying which messages this cannot handle.

See also
announce_subscriptions
respond_to_subscription_query
allow_subscriptions

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

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).