RTC Toolkit  1.0.0
ddsPub.hpp
Go to the documentation of this file.
1 
11 #ifndef RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSPUB_HPP_
12 #define RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSPUB_HPP_
14 #include <list>
15 
16 namespace rtctk::componentFramework {
17 
22  std::string topic_name;
23  DataWriterListener *listener = nullptr;
24 
25  DdsTopicWriterListener(const std::string &tn, DataWriterListener *l)
26  : topic_name(tn), listener(l) {
27  }
28 
29  DdsTopicWriterListener(const std::string &tn) : topic_name(tn), listener(nullptr) {
30  }
31 };
32 
39 class DdsPub : public Dds {
40  Publisher *m_publisher;
41 
42  std::list<TypedDataWriter *> m_data_writers;
43 
44 public:
49  DdsPub(std::string qos_library = "RtcTk_Default_Library",
50  std::string qos_profile = "RtcTk_Default_Profile");
51  virtual ~DdsPub();
52 
57  void CreatePublisher();
58 
62  void DestroyPublisher();
63 
69  TypedDataWriter *CreateDataWriter(Topic *topic, DataWriterListener *listener = nullptr);
70 
77  void DestroyDataWriter(TypedDataWriter *dw, bool to_be_removed = true);
78 
83  void CreateDataWriters();
84 
90  void DestroyAllDataWriters();
91 
97  void CreateManyDataWriters(std::vector<DdsTopicWriterListener> const &);
98 
104  void CreateManyDataWriters(std::vector<std::string> const &topic_names);
105 
109  void DumpDDSstatistics();
110 
114  std::list<TypedDataWriter *> &GetDataWriters() {
115  return m_data_writers;
116  }
117 };
118 
119 } // namespace rtctk::componentFramework
120 
121 #endif // RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSPUB_HPP_
rtctk::componentFramework::TypedDataWriter
eprosima::fastdds::dds::DataWriter TypedDataWriter
Definition: ddsCommon.hpp:88
rtctk::componentFramework::DdsPub::DdsPub
DdsPub(std::string qos_library="RtcTk_Default_Library", std::string qos_profile="RtcTk_Default_Profile")
Definition: ddsPub.cpp:24
rtctk::componentFramework::DdsPub::CreateDataWriter
TypedDataWriter * CreateDataWriter(Topic *topic, DataWriterListener *listener=nullptr)
Creates DDS writer for particular topic for topic of type: rtctk::AgnosticTopic.
Definition: ddsPub.cpp:95
rtctk::componentFramework::DdsPub::DumpDDSstatistics
void DumpDDSstatistics()
Dumps / logs varios DDS statistic like NACks, ACKs, ...
Definition: ddsPub.cpp:230
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::DdsPub::DestroyPublisher
void DestroyPublisher()
Destroys DDS publisher.
Definition: ddsPub.cpp:77
rtctk::componentFramework::DdsPub::CreateManyDataWriters
void CreateManyDataWriters(std::vector< DdsTopicWriterListener > const &)
create DDS topics and DDS writers for the given list (vector) of topic names and #DdsWriterListener I...
Definition: ddsPub.cpp:176
rtctk::componentFramework::DdsPub::CreateDataWriters
void CreateDataWriters()
Creates DDS Data Writer for all DDS topics.
Definition: ddsPub.cpp:215
rtctk::componentFramework::DdsPub::DestroyDataWriter
void DestroyDataWriter(TypedDataWriter *dw, bool to_be_removed=true)
Destroys DDS data writer.
Definition: ddsPub.cpp:158
rtctk::componentFramework::DdsPub::DestroyAllDataWriters
void DestroyAllDataWriters()
Destroys DDS Data Writer for all DDS topics.
Definition: ddsPub.cpp:204
rtctk::componentFramework::DdsTopicWriterListener::DdsTopicWriterListener
DdsTopicWriterListener(const std::string &tn, DataWriterListener *l)
Definition: ddsPub.hpp:25
rtctk::componentFramework::DdsTopicWriterListener::listener
DataWriterListener * listener
Definition: ddsPub.hpp:23
rtctk::componentFramework::DdsPub
All functionallty needed to create DDS entities for DDS data publishing is concentrated in this class...
Definition: ddsPub.hpp:39
rtctk::componentFramework::DdsPub::GetDataWriters
std::list< TypedDataWriter * > & GetDataWriters()
returns vector of all DDS Data writers
Definition: ddsPub.hpp:114
rtctk::componentFramework::DdsPub::~DdsPub
virtual ~DdsPub()
Definition: ddsPub.cpp:30
rtctk::componentFramework::DdsTopicWriterListener::topic_name
std::string topic_name
Definition: ddsPub.hpp:22
rtctk::componentFramework::DdsTopicWriterListener::DdsTopicWriterListener
DdsTopicWriterListener(const std::string &tn)
Definition: ddsPub.hpp:29
rtctk::componentFramework::DdsPub::CreatePublisher
void CreatePublisher()
Creates DDS publisher.
Definition: ddsPub.cpp:38
dds.hpp
Declares common DDS class.
rtctk::componentFramework::DdsTopicWriterListener
Structure that keeps together topic name and DDS Data Writer listener.
Definition: ddsPub.hpp:21
rtctk::componentFramework::Dds
Common functionallty needed to create DDS entities like participant and topic that can be later used ...
Definition: dds.hpp:26