Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
swarmio::services::event::Service Class Referencefinal

The Event service is responsible for triggering, handling and monitoring events. More...

#include <Service.h>

Inheritance diagram for swarmio::services::event::Service:
Inheritance graph
[legend]

Public Member Functions

virtual void DescribeService (data::discovery::Response &descriptor) override
 Add descriptors for the service to the discovery descriptor. More...
 
virtual bool ReceiveMessage (const Node *sender, const data::Message *message) override
 Delivery point of all messages. More...
 
void RegisterHandler (const std::string &name, Handler *handler)
 Subscribe to events. More...
 
 Service (Endpoint *endpoint)
 Construct a new Service object. More...
 
void UnregisterHandler (const std::string &name)
 Unsubscribe from events. More...
 
- Public Member Functions inherited from swarmio::Mailbox
virtual void Disconnect ()
 Disconnect this Mailbox from the Endpoint. More...
 
EndpointGetEndpoint ()
 Get the associated Endpoint. More...
 
 Mailbox (const Mailbox &)=delete
 Remove copy constructor. More...
 
virtual void MailboxWasConnected () noexcept
 Called when the mailbox is attached to an already running endpoint or if the attached endpoint has just started. More...
 
virtual void MailboxWillBeDisconnected () noexcept
 Called right before the mailbox is disconnected from its endpoint or if the attached endpoint is about to stop. More...
 
virtual void NodeDidJoin (const Node *node) noexcept
 Called when a new Node has joined the group. More...
 
virtual void NodeWasDiscovered (const Node *node) noexcept
 Called when a new Node has been discovered. More...
 
virtual void NodeWillLeave (const Node *node) noexcept
 Called when a Node signals that it will leave. More...
 
Mailboxoperator= (const Mailbox &)=delete
 Remove assignment operator. More...
 
virtual ~Mailbox ()
 Destroy the Mailbox object. More...
 

Static Public Member Functions

static void Trigger (Endpoint *endpoint, const data::event::Notification &event)
 Trigger an event globally. More...
 
static ErrorAwaiter Trigger (Endpoint *endpoint, const data::event::Notification &event, const Node *node)
 Trigger an event on a remote Node. More...
 

Private Attributes

std::map< std::string, Handler * > _handlers
 Map of handlers. More...
 
std::mutex _mutex
 Mutex to protect handler list. More...
 

Additional Inherited Members

- Protected Member Functions inherited from swarmio::Mailbox
void FinishConstruction ()
 Called when the last constructor has finished its job. More...
 
void FinishMovingTo (Mailbox *other)
 Called when message handling should be passed onto the new instance. More...
 
 Mailbox ()
 Construct a disconnected Mailbox. More...
 
 Mailbox (Endpoint *endpoint)
 Construct a new Mailbox object. More...
 
 Mailbox (Mailbox &&other)
 Move a Mailbox object. More...
 

Detailed Description

The Event service is responsible for triggering, handling and monitoring events.

Definition at line 18 of file event/Service.h.

Constructor & Destructor Documentation

swarmio::services::event::Service::Service ( Endpoint endpoint)
inline

Construct a new Service object.

Parameters
endpointEndpoint

Definition at line 63 of file event/Service.h.

Member Function Documentation

void Service::DescribeService ( data::discovery::Response &  descriptor)
overridevirtual

Add descriptors for the service to the discovery descriptor.

Parameters
descriptorThe proposed response to load the description into

Implements swarmio::services::discovery::Discoverable.

Definition at line 101 of file event/Service.cpp.

bool Service::ReceiveMessage ( const Node sender,
const data::Message *  message 
)
overridevirtual

Delivery point of all messages.

Parameters
senderThe node that has sent the message
messageThe message itself
Returns
True if the message had been processed and should not be forwarded to other mailboxes

Reimplemented from swarmio::Mailbox.

Definition at line 45 of file event/Service.cpp.

void Service::RegisterHandler ( const std::string &  name,
Handler handler 
)

Subscribe to events.

Thread-safe.

Parameters
nameEvent name
handlerHandler

Definition at line 77 of file event/Service.cpp.

void Service::Trigger ( Endpoint endpoint,
const data::event::Notification &  event 
)
static

Trigger an event globally.

Thread-safe.

Parameters
endpointEndpoint to use
eventEvent to propagate

Definition at line 8 of file event/Service.cpp.

ErrorAwaiter Service::Trigger ( Endpoint endpoint,
const data::event::Notification &  event,
const Node node 
)
static

Trigger an event on a remote Node.

Thread-safe.

Parameters
endpointEndpoint to use
eventEvent to propagate
eventTarget node
Returns
ErrorAwaiter Async result

Definition at line 24 of file event/Service.cpp.

void Service::UnregisterHandler ( const std::string &  name)

Unsubscribe from events.

Thread-safe.

Parameters
nameEvent name

Definition at line 94 of file event/Service.cpp.

Member Data Documentation

std::map<std::string, Handler*> swarmio::services::event::Service::_handlers
private

Map of handlers.

Definition at line 26 of file event/Service.h.

std::mutex swarmio::services::event::Service::_mutex
private

Mutex to protect handler list.

Definition at line 32 of file event/Service.h.


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


swarmros
Author(s):
autogenerated on Fri Apr 3 2020 03:42:48