RTC Toolkit 5.0.0
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(const std::string& topic) override;
44
48 std::unique_ptr<EventSubscriberIf> MakeSubscriber(const std::string& topic) override;
49
50private:
51 elt::mal::Mal::Properties GetMalProperties();
52
53 // cppcheck-suppress-begin unusedStructMember
54
55 // mal objects
56 const elt::mal::Mal::Properties m_props;
57 std::shared_ptr<elt::mal::Mal> m_mal;
58 elt::mal::CiiFactory& m_factory;
59
60 // cppcheck-suppress-end unusedStructMember
61};
62
70public:
71 // Use factory method from MalDdsEventService to construct publisher objects
73
77 void Publish(const JsonPayload& sample) override;
78
79private:
80 MalDdsEventPublisher(elt::mal::CiiFactory& factory,
81 const std::string& topic,
82 const elt::mal::Mal::Properties& props);
83
84 std::unique_ptr<elt::mal::ps::Publisher<rtctkif::GenericEvent>> m_publisher;
85 std::mutex m_mutex;
86};
87
95public:
96 // Use factory method from MalDdsEventService to construct subscriber objects
98
102 void Subscribe(std::function<void(const JsonPayload&)> cb) override;
103
107 void Unsubscribe() override;
108
109 // cppcheck-suppress unusedStructMember
110 inline static const std::string QOS_FILE = "config/rtctk/dds/eventServiceDdsQos.xml";
111
112private:
113 MalDdsEventSubscriber(elt::mal::CiiFactory& factory,
114 const std::string& topic,
115 const elt::mal::Mal::Properties& props);
116
117 std::unique_ptr<elt::mal::ps::Subscriber<rtctkif::GenericEvent>> m_subscriber;
118 std::unique_ptr<elt::mal::ps::Subscription> m_subscription;
119 std::mutex m_mutex;
120};
121
122} // namespace rtctk::componentFramework
123
124#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:69
void Publish(const JsonPayload &sample) override
Publishes a new data sample.
Definition malDdsEventService.cpp:101
friend MalDdsEventService
Definition malDdsEventService.hpp:72
Implementation of low-level event service using CII MAL DDS as middleware.
Definition malDdsEventService.hpp:36
MalDdsEventService()
Definition malDdsEventService.cpp:31
std::unique_ptr< EventSubscriberIf > MakeSubscriber(const std::string &topic) override
Factory method to create a new subscriber object.
Definition malDdsEventService.cpp:86
std::unique_ptr< EventPublisherIf > MakePublisher(const std::string &topic) override
Factory method to create a new publisher object.
Definition malDdsEventService.cpp:81
Implementation of event subscriber.
Definition malDdsEventService.hpp:94
void Subscribe(std::function< void(const JsonPayload &)> cb) override
Subscribes to the topic.
Definition malDdsEventService.cpp:126
friend MalDdsEventService
Definition malDdsEventService.hpp:97
void Unsubscribe() override
Unsubscribes from the topic.
Definition malDdsEventService.cpp:141
static const std::string QOS_FILE
Definition malDdsEventService.hpp:110
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
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23