RTC Toolkit 4.0.2
Loading...
Searching...
No Matches
ddsSub.hpp
Go to the documentation of this file.
1
12#ifndef RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSSUB_HPP
13#define RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSSUB_HPP
14#include <list>
15
17
19
26 std::string topic_name;
27 DataReaderListener *listener = nullptr;
28 std::string multicast_address = {};
29
30 DdsReaderParams(const std::string &tn, DataReaderListener *l, const std::string &mc)
32 }
33
34 DdsReaderParams(const std::string &tn, DataReaderListener *l) : topic_name(tn), listener(l) {
35 }
36
37 explicit DdsReaderParams(const std::string &tn) : topic_name(tn), listener(nullptr) {
38 }
39};
40
48class DdsSub : public Dds {
49 Subscriber *m_subscriber;
50
51 std::vector<DataReader *> m_data_readers;
52
53public:
65 explicit DdsSub(const std::string &qos_file,
66 const std::string &qos_profile = DEFAULT_QOS_PROFILE,
67 DomainId_t domain_id = DEFAULT_DOMAIN_ID,
68 const std::string &participant_name = "");
69 virtual ~DdsSub();
70
75 void CreateSubscriber();
76
80 void DestroySubscriber();
81
90 DataReader *CreateDataReader(Topic *topic,
91 DataReaderListener *listener = nullptr,
92 const std::string &multicast_address = "");
93
100 void DestroyDataReader(DataReader *dr, bool to_be_removed = true);
101
106 void CreateDataReaders();
107
109
116
122 void CreateManyDataReaders(std::vector<DdsReaderParams> const &);
123
129 void CreateManyDataReaders(std::vector<std::string> &topic_names);
130
134 void DumpDDSstatistics();
135
139 std::vector<DataReader *> &GetDataReaders() {
140 return m_data_readers;
141 }
142};
143
144} // namespace rtctk::componentFramework
145
146#endif // RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSSUB_HPP
All functionality needed to create DDS entities for DDS data subscribing is concentrated in this clas...
Definition: ddsSub.hpp:48
void CreateManyDataReaders(std::vector< DdsReaderParams > const &)
create DDS topics and DDS readers for the given list (vector) of topic names and rtctk::componentFram...
Definition: ddsSub.cpp:214
virtual ~DdsSub()
Definition: ddsSub.cpp:37
void DumpDDSstatistics()
Dumps / logs varios DDS statistic like NACks, ACKs, ... for each DDS writer.
Definition: ddsSub.cpp:265
void DestroySubscriber()
Destroys DDS subscriber.
Definition: ddsSub.cpp:90
DataReader * CreateDataReader(Topic *topic, DataReaderListener *listener=nullptr, const std::string &multicast_address="")
Creates DDS data reader for particular topic for topic of type: rtctk::AgnosticTopic.
Definition: ddsSub.cpp:107
void DestroyAllDataReaders()
Destroys DDS Data Reader for all DDS topics.
Definition: ddsSub.cpp:241
void EnableAllDataReaders()
Definition: ddsSub.cpp:180
std::vector< DataReader * > & GetDataReaders()
returns vector of all DDS Data writers
Definition: ddsSub.hpp:139
void CreateDataReaders()
Creates DDS Data Reader for all DDS topics.
Definition: ddsSub.cpp:252
void CreateSubscriber()
Creates DDS subscriber.
Definition: ddsSub.cpp:46
void DestroyDataReader(DataReader *dr, bool to_be_removed=true)
Destroys DDS data reader.
Definition: ddsSub.cpp:193
Common functionallty needed to create DDS entities like participant and topic that can be later used ...
Definition: dds.hpp:33
static const DomainId_t DEFAULT_DOMAIN_ID
default Domain Id for different DDS
Definition: dds.hpp:168
static const std::string DEFAULT_QOS_PROFILE
default profile name for different DDS QoSs
Definition: dds.hpp:162
Declares common DDS class.
Definition: commandReplier.cpp:22
Structure that keeps together topic name and DDS Data Writer listener.
Definition: ddsSub.hpp:25
std::string topic_name
Definition: ddsSub.hpp:26
std::string multicast_address
Definition: ddsSub.hpp:28
DdsReaderParams(const std::string &tn)
Definition: ddsSub.hpp:37
DdsReaderParams(const std::string &tn, DataReaderListener *l, const std::string &mc)
Definition: ddsSub.hpp:30
DataReaderListener * listener
Definition: ddsSub.hpp:27
DdsReaderParams(const std::string &tn, DataReaderListener *l)
Definition: ddsSub.hpp:34