event/Service.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <swarmio/Mailbox.h>
7 #include <string>
8 #include <memory>
9 #include <map>
10 
11 namespace swarmio::services::event
12 {
18  class SWARMIO_API Service final : public Mailbox, public discovery::Discoverable
19  {
20  private:
21 
26  std::map<std::string, Handler*> _handlers;
27 
32  std::mutex _mutex;
33 
34  public:
35 
44  static void Trigger(Endpoint* endpoint, const data::event::Notification& event);
45 
56  static ErrorAwaiter Trigger(Endpoint* endpoint, const data::event::Notification& event, const Node* node);
57 
63  Service(Endpoint* endpoint)
64  : Mailbox(endpoint)
65  {
66  FinishConstruction();
67  }
68 
77  virtual bool ReceiveMessage(const Node* sender, const data::Message* message) override;
78 
87  void RegisterHandler(const std::string& name, Handler* handler);
88 
96  void UnregisterHandler(const std::string& name);
97 
105  virtual void DescribeService(data::discovery::Response& descriptor) override;
106  };
107 }
The Event service is responsible for triggering, handling and monitoring events.
Definition: event/Service.h:18
std::mutex _mutex
Mutex to protect handler list.
Definition: event/Service.h:32
std::map< std::string, Handler * > _handlers
Map of handlers.
Definition: event/Service.h:26
An Awaiter that checks whether the operation was a success.
Definition: ErrorAwaiter.h:11
Abstract base class for Endpoint implementations.
Definition: Endpoint.h:25
Interface for discoverable services.
Definition: Discoverable.h:12
Abstract base class for Event handlers.
Definition: Handler.h:13
Represents a Node the Endpoint knows about and can send messages to.
Service(Endpoint *endpoint)
Construct a new Service object.
Definition: event/Service.h:63
Abstract base class for Mailbox implementations.
Definition: Mailbox.h:13


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