RTC Toolkit 4.0.1
Loading...
Searching...
No Matches
malDdsEventService.hpp
Go to the documentation of this file.
1
13#ifndef RTCTK_COMPONENTFRAMEWORK_MALDDSEVENTSERVICE_HPP
14#define RTCTK_COMPONENTFRAMEWORK_MALDDSEVENTSERVICE_HPP
15
16#include <Rtctkif.hpp>
19
20#include <mal/Cii.hpp>
21#include <mal/Mal.hpp>
22#include <mal/utility/LoadMal.hpp>
23
24#include <map>
25#include <mutex>
26#include <string>
27
29
37public:
39
43 std::unique_ptr<EventPublisherIf> MakePublisher(std::string const& topic) override;
44
48 std::unique_ptr<EventSubscriberIf> MakeSubscriber(std::string const& topic) override;
49
50private:
51 elt::mal::Mal::Properties GetMalProperties();
52
53 // mal objects
54 elt::mal::Mal::Properties const m_props;
55 std::shared_ptr<elt::mal::Mal> m_mal;
56 elt::mal::CiiFactory& m_factory;
57};
58
66public:
67 // Use factory method from MalDdsEventService to construct publisher objects
69
73 void Publish(JsonPayload const& sample) override;
74
75private:
76 MalDdsEventPublisher(elt::mal::CiiFactory& factory,
77 std::string const& topic,
78 elt::mal::Mal::Properties const& props);
79
80 std::unique_ptr<elt::mal::ps::Publisher<rtctkif::GenericEvent>> m_publisher;
81 std::mutex m_mutex;
82};
83
91public:
92 // Use factory method from MalDdsEventService to construct subscriber objects
94
98 void Subscribe(std::function<void(JsonPayload const&)> cb) override;
99
103 void Unsubscribe() override;
104
105 inline static const std::string QOS_FILE = "config/rtctk/dds/eventServiceDdsQos.xml";
106
107private:
108 MalDdsEventSubscriber(elt::mal::CiiFactory& factory,
109 std::string const& topic,
110 elt::mal::Mal::Properties const& props);
111
112 std::unique_ptr<elt::mal::ps::Subscriber<rtctkif::GenericEvent>> m_subscriber;
113 std::unique_ptr<elt::mal::ps::Subscription> m_subscription;
114 std::mutex m_mutex;
115};
116
117} // namespace rtctk::componentFramework
118
119#endif // RTCTK_COMPONENTFRAMEWORK_MALDDSEVENTSERVICE_HPP
Interface class for publishing JSON events.
Definition: eventServiceIf.hpp:52
Interface class for providing pub/sub facilities for JSON events.
Definition: eventServiceIf.hpp:29
Interface class for subscribing to JSON events.
Definition: eventServiceIf.hpp:68
Implementation of event publisher.
Definition: malDdsEventService.hpp:65
void Publish(JsonPayload const &sample) override
Publishes a new data sample.
Definition: malDdsEventService.cpp:91
friend MalDdsEventService
Definition: malDdsEventService.hpp:68
Implementation of low-level event service using CII MAL DDS as middleware.
Definition: malDdsEventService.hpp:36
MalDdsEventService()
Definition: malDdsEventService.cpp:31
std::unique_ptr< EventPublisherIf > MakePublisher(std::string const &topic) override
Factory method to create a new publisher object.
Definition: malDdsEventService.cpp:71
std::unique_ptr< EventSubscriberIf > MakeSubscriber(std::string const &topic) override
Factory method to create a new subscriber object.
Definition: malDdsEventService.cpp:76
Implementation of event subscriber.
Definition: malDdsEventService.hpp:90
friend MalDdsEventService
Definition: malDdsEventService.hpp:93
void Unsubscribe() override
Unsubscribes from the topic.
Definition: malDdsEventService.cpp:131
void Subscribe(std::function< void(JsonPayload const &)> cb) override
Subscribes to the topic.
Definition: malDdsEventService.cpp:116
static const std::string QOS_FILE
Definition: malDdsEventService.hpp:105
Low-level interface of the event service.
Defines the JSON payload type JsonPayload.
Definition: commandReplier.cpp:22
nlohmann::json JsonPayload
Type requirements:
Definition: jsonPayload.hpp:25