RTC Toolkit  2.0.0
rtctkGenDdsPublisher.h
Go to the documentation of this file.
1 
12 #ifndef RTCTK_GEN_DDS_PUBLISHER_
13 #define RTCTK_GEN_DDS_PUBLISHER_
14 
17 
19 
21 
31 
32  uint16_t m_idx;
33  rtctk_cfw::DdsPub &m_dds_pub;
34  rtctk_cfw::DdsWriterListener *m_writer_listener = nullptr;
35  rtctk_cfw::Topic *m_topic = nullptr;
36  std::string m_topic_name;
37  rtctk_cfw::DataWriter *m_data_writer = nullptr;
38  uint16_t m_wait_for_n_subs;
39  uint16_t m_subs_so_far = 0;
40  std::chrono::microseconds m_sleep_period;
41 
42  rtctk::componentFramework::AgnosticTopic m_sample;
43  uint32_t m_payload_length;
44 
45  std::thread m_thread;
46  std::atomic<bool> m_thread_running = true;
47 
51  void PublishSamples();
55  bool WaitForSubs();
56 
57 public:
59  virtual ~GenDdsPublisher() noexcept;
60 
61  GenDdsPublisher() = delete;
62  GenDdsPublisher(const GenDdsPublisher &) = delete;
64 
73  void Initialize(std::string &topic_name,
74  uint16_t &wait_for_n_subs,
75  uint32_t &payload_size,
76  std::chrono::microseconds &sleep_period);
77 
82  void Finalize();
83 
84  // index of Generic DDS Publsiher
85  static std::atomic<uint16_t> s_idx;
86 }; // GenDdsPublisher
87 
88 } // namespace rtctk::standaloneTools
89 
90 #endif // RTCTK_GEN_DDS_PUBLISHER_
rtctk::standaloneTools::GenDdsPublisher::GenDdsPublisher
GenDdsPublisher(const GenDdsPublisher &)=delete
rtctk::standaloneTools::GenDdsPublisher
Generic DDS Publisher Class provides functionally to create one DDS Topic and one DDS DataWriter,...
Definition: rtctkGenDdsPublisher.h:30
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::standaloneTools::GenDdsPublisher::GenDdsPublisher
GenDdsPublisher()=delete
rtctk::componentFramework::DdsWriterListener
Listener class for differetn DDS events.
Definition: ddsWriterListener.hpp:25
mudpi::uint16_t
unsigned short uint16_t
Definition: mudpi.h:15
ddsWriterListener.hpp
DDS Writer Listener.
ddsPub.hpp
DDS Publisher.
rtctk::componentFramework::DdsPub
All functionallty needed to create DDS entities for DDS data publishing is concentrated in this class...
Definition: ddsPub.hpp:42
rtctk::standaloneTools::GenDdsPublisher::Finalize
void Finalize()
Stops publishing thread, and join it, delete DDS entities.
Definition: rtctkGenDdsPublisher.cpp:49
mudpi::uint32_t
unsigned int uint32_t
Definition: mudpi.h:16
rtctk::standaloneTools::GenDdsPublisher::s_idx
static std::atomic< uint16_t > s_idx
Definition: rtctkGenDdsPublisher.h:85
rtctk::standaloneTools
Definition: rtctkGenDdsPublisher.h:18
rtctk::standaloneTools::GenDdsPublisher::GenDdsPublisher
GenDdsPublisher(GenDdsPublisher &&)=delete
rtctk::standaloneTools::GenDdsPublisher::Initialize
void Initialize(std::string &topic_name, uint16_t &wait_for_n_subs, uint32_t &payload_size, std::chrono::microseconds &sleep_period)
Creates DDS Topic and Data Writer and publishing thread
Definition: rtctkGenDdsPublisher.cpp:31
rtctk::standaloneTools::GenDdsPublisher::~GenDdsPublisher
virtual ~GenDdsPublisher() noexcept
Definition: rtctkGenDdsPublisher.cpp:27