RTC Toolkit 6.0.0-pre2
Loading...
Searching...
No Matches
genDdsPublisher.hpp
Go to the documentation of this file.
1
12#ifndef RTCTK_GENDDSPUBLISHER_HPP
13#define RTCTK_GENDDSPUBLISHER_HPP
14
17
18#include <thread>
19
21
22namespace rtctk_cfw = rtctk::componentFramework;
23
33 log4cplus::Logger& m_logger;
34 uint16_t m_idx = 0;
35 rtctk_cfw::DdsPub& m_dds_pub;
36 std::shared_ptr<rtctk_cfw::DdsWriterListener> m_writer_listener;
37 rtctk_cfw::Topic* m_topic = nullptr;
38 std::string m_topic_name = "";
39 rtctk_cfw::DataWriter* m_data_writer = nullptr;
40 uint16_t m_wait_for_n_subs = 0;
41 uint16_t m_subs_so_far = 0;
42 std::chrono::microseconds m_sleep_period = {};
43
44 rtctk::componentFramework::AgnosticTopic m_sample;
45 uint32_t m_payload_length = 0;
46 uint32_t m_sample_id_increment = 1;
47
48 std::thread m_thread;
49 std::atomic<bool> m_thread_running = true;
50
55 void PublishSamples();
59 bool WaitForSubs();
60
61public:
63 virtual ~GenDdsPublisher() = default;
64
65 GenDdsPublisher() = delete;
68
79 void Initialize(const std::string& topic_name,
80 uint16_t wait_for_n_subs,
81 uint32_t payload_size,
82 std::chrono::microseconds sleep_period,
83 uint32_t sample_id_increment);
84
88 void Finalize();
89
90 // index of Generic DDS Publsiher
91 static std::atomic<uint16_t> s_idx;
92}; // GenDdsPublisher
93
94} // namespace rtctk::standaloneTools
95
96#endif // RTCTK_GENDDSPUBLISHER_HPP
All functionallty needed to create DDS entities for DDS data publishing is concentrated in this class...
Definition ddsPub.hpp:47
static std::atomic< uint16_t > s_idx
Definition genDdsPublisher.hpp:91
GenDdsPublisher(const GenDdsPublisher &)=delete
GenDdsPublisher(rtctk::componentFramework::DdsPub &dds_pub)
Definition genDdsPublisher.cpp:25
void Finalize()
Stops publishing thread, and join it, delete DDS entities.
Definition genDdsPublisher.cpp:51
GenDdsPublisher(GenDdsPublisher &&)=delete
void Initialize(const std::string &topic_name, uint16_t wait_for_n_subs, uint32_t payload_size, std::chrono::microseconds sleep_period, uint32_t sample_id_increment)
Creates DDS Topic and Data Writer and publishing thread.
Definition genDdsPublisher.cpp:30
DDS Publisher.
DDS Writer Listener.
Definition commandReplier.cpp:22
Definition genDdsPublisher.hpp:20