RTC Toolkit  2.0.0
ddsPub.hpp
Go to the documentation of this file.
1 
12 #ifndef RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSPUB_HPP_
13 #define RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSPUB_HPP_
15 #include <list>
16 
17 namespace rtctk::componentFramework {
18 
19 using namespace std::chrono_literals;
20 
25  std::string topic_name;
26  DataWriterListener *listener = nullptr;
27 
28  DdsWriterParams(const std::string &tn, DataWriterListener *l)
29  : topic_name(tn), listener(l) {
30  }
31 
32  DdsWriterParams(const std::string &tn) : topic_name(tn), listener(nullptr) {
33  }
34 };
35 
42 class DdsPub : public Dds {
43  Publisher *m_publisher;
44 
45  std::vector<DataWriter *> m_data_writers;
46 
47 public:
57  DdsPub(const std::string &qos_file,
58  std::string qos_profile = DEFAULT_QOS_PROFILE,
59  DomainId_t domain_id=DEFAULT_DOMAIN_ID);
60  virtual ~DdsPub();
61 
66  void CreatePublisher();
67 
71  void DestroyPublisher();
72 
79  DataWriter *CreateDataWriter(Topic *topic, DataWriterListener *listener = nullptr);
80 
88  void DestroyDataWriter(DataWriter *dw, bool to_be_removed = true, std::chrono::milliseconds wait_acks_timeout=5000ms);
89 
94  void CreateDataWriters();
95 
103  void DestroyAllDataWriters(std::chrono::milliseconds wait_acks_timeout=5000ms);
104 
110  void CreateManyDataWriters(std::vector<DdsWriterParams> const &);
111 
117  void CreateManyDataWriters(std::vector<std::string> const &topic_names);
118 
122  void DumpDDSstatistics();
123 
127  std::vector<DataWriter *> &GetDataWriters() {
128  return m_data_writers;
129  }
130 
131 
138  void WaitForAcks(DataWriter *dw, std::chrono::milliseconds wait_acks_timeout=5000ms);
139 
140 };
141 
142 } // namespace rtctk::componentFramework
143 
144 #endif // RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSPUB_HPP_
rtctk::componentFramework::DdsWriterParams::topic_name
std::string topic_name
Definition: ddsPub.hpp:25
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::DdsPub::GetDataWriters
std::vector< DataWriter * > & GetDataWriters()
returns vector of all DDS Data writers
Definition: ddsPub.hpp:127
rtctk::componentFramework::DdsWriterParams::DdsWriterParams
DdsWriterParams(const std::string &tn)
Definition: ddsPub.hpp:32
rtctk::componentFramework::DdsWriterParams
Structure that keeps together topic name and DDS Data Writer listener.
Definition: ddsPub.hpp:24
rtctk::componentFramework::DdsPub
All functionallty needed to create DDS entities for DDS data publishing is concentrated in this class...
Definition: ddsPub.hpp:42
rtctk::componentFramework::DdsWriterParams::DdsWriterParams
DdsWriterParams(const std::string &tn, DataWriterListener *l)
Definition: ddsPub.hpp:28
dds.hpp
Declares common DDS class.
rtctk::componentFramework::Dds
Common functionallty needed to create DDS entities like participant and topic that can be later used ...
Definition: dds.hpp:31