RTC Toolkit  2.0.0
eventServiceIf.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_COMPONENTFRAMEWORK_EVENTSERVICEIF_HPP
13 #define RTCTK_COMPONENTFRAMEWORK_EVENTSERVICEIF_HPP
14 
16 #include <string>
17 
18 namespace rtctk::componentFramework {
19 
20 class EventPublisherIf;
21 class EventSubscriberIf;
22 
27 public:
28  virtual ~EventServiceIf() = default;
29 
35  virtual std::unique_ptr<EventPublisherIf> MakePublisher(std::string const& topic) = 0;
36 
42  virtual std::unique_ptr<EventSubscriberIf> MakeSubscriber(std::string const& topic) = 0;
43 };
44 
49 public:
50  virtual ~EventPublisherIf() = default;
51 
57  virtual void Publish(JsonPayload const& sample) = 0;
58 };
59 
64 public:
65  virtual ~EventSubscriberIf() = default;
66 
77  virtual void Subscribe(std::function<void(JsonPayload const&)> cb) = 0;
78 
82  virtual void Unsubscribe() = 0;
83 };
84 
85 } // namespace rtctk::componentFramework
86 
87 #endif // RTCTK_COMPONENTFRAMEWORK_EVENTSERVICEIF_HPP
rtctk::componentFramework::EventServiceIf::~EventServiceIf
virtual ~EventServiceIf()=default
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::EventPublisherIf::~EventPublisherIf
virtual ~EventPublisherIf()=default
rtctk::componentFramework::EventPublisherIf
Interface class for publishing JSON events.
Definition: eventServiceIf.hpp:48
rtctk::componentFramework::EventSubscriberIf
Interface class for subscribing to JSON events.
Definition: eventServiceIf.hpp:63
jsonPayload.hpp
Defines the JSON payload type JsonPayload.
rtctk::componentFramework::EventServiceIf
Interface class for providing pub/sub facilities for JSON events.
Definition: eventServiceIf.hpp:26
rtctk::componentFramework::EventSubscriberIf::~EventSubscriberIf
virtual ~EventSubscriberIf()=default
rtctk::componentFramework::EventServiceIf::MakeSubscriber
virtual std::unique_ptr< EventSubscriberIf > MakeSubscriber(std::string const &topic)=0
Creates a new subscriber for a specified topic.
rtctk::componentFramework::EventServiceIf::MakePublisher
virtual std::unique_ptr< EventPublisherIf > MakePublisher(std::string const &topic)=0
Creates a new publisher for a specified topic.
rtctk::componentFramework::EventSubscriberIf::Subscribe
virtual void Subscribe(std::function< void(JsonPayload const &)> cb)=0
Subscribes to a specified topic.
rtctk::componentFramework::EventPublisherIf::Publish
virtual void Publish(JsonPayload const &sample)=0
Publishes a JSON object.
rtctk::componentFramework::EventSubscriberIf::Unsubscribe
virtual void Unsubscribe()=0
Unsubscribes from a specified topic.
rtctk::componentFramework::JsonPayload
nlohmann::json JsonPayload
Type requirements:
Definition: jsonPayload.hpp:24