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