RTC Toolkit  1.0.0
ddsSub.hpp
Go to the documentation of this file.
1 
11 #ifndef RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSSUB_HPP_
12 #define RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSSUB_HPP_
13 #include <list>
14 
16 
17 namespace rtctk::componentFramework {
18 
23  std::string topic_name;
24  DataReaderListener *listener = nullptr;
25  std::string multicast_address={};
26 
27 
28  DdsTopicReaderListener(const std::string &tn, DataReaderListener *l, const std::string &mc)
29  : topic_name(tn), listener(l), multicast_address(mc){
30  }
31 
32  DdsTopicReaderListener(const std::string &tn, DataReaderListener *l)
33  : topic_name(tn), listener(l) {
34  }
35 
36  DdsTopicReaderListener(const std::string &tn) : topic_name(tn), listener(nullptr) {
37  }
38 };
39 
46 class DdsSub : public Dds {
47  Subscriber *m_subscriber;
48 
49  std::list<TypedDataReader *> m_data_readers;
50 
51 public:
56  DdsSub(std::string qos_library = "RtcTk_Default_Library",
57  std::string qos_profile = "RtcTk_Default_Profile");
58  virtual ~DdsSub();
59 
64  void CreateSubscriber();
65 
71  TypedDataReader *CreateDataReader(Topic *topic, DataReaderListener *listener = nullptr, std::string multicast_address="");
72 
79  void DestroyDataReader(TypedDataReader *dr, bool to_be_removed = true);
80 
85  void CreateDataReaders();
86 
87  void EnableAllDataReaders();
88 
94  void DestroyAllDataReaders();
95 
101  void CreateManyDataReaders(std::vector<DdsTopicReaderListener> const &);
102 
108  void CreateManyDataReaders(std::vector<std::string> &topic_names);
109 
113  void DumpDDSstatistics();
114 
118  std::list<TypedDataReader *> &GetDataReaders() {
119  return m_data_readers;
120  }
121 };
122 
123 } // namespace rtctk::componentFramework
124 
125 #endif // RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSSUB_HPP_
rtctk::componentFramework::DdsTopicReaderListener
Structure that keeps together topic name and DDS Data Writer listener.
Definition: ddsSub.hpp:22
rtctk::componentFramework::DdsSub::CreateDataReaders
void CreateDataReaders()
Creates DDS Data Reader for all DDS topics.
Definition: ddsSub.cpp:249
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::DdsTopicReaderListener::DdsTopicReaderListener
DdsTopicReaderListener(const std::string &tn)
Definition: ddsSub.hpp:36
rtctk::componentFramework::TypedDataReader
eprosima::fastdds::dds::DataReader TypedDataReader
Definition: ddsCommon.hpp:89
rtctk::componentFramework::DdsSub::~DdsSub
virtual ~DdsSub()
Definition: ddsSub.cpp:35
rtctk::componentFramework::DdsTopicReaderListener::DdsTopicReaderListener
DdsTopicReaderListener(const std::string &tn, DataReaderListener *l, const std::string &mc)
Definition: ddsSub.hpp:28
rtctk::componentFramework::DdsTopicReaderListener::listener
DataReaderListener * listener
Definition: ddsSub.hpp:24
rtctk::componentFramework::DdsSub
All functionallty needed to create DDS entities for DDS data subscribing is concentrated in this clas...
Definition: ddsSub.hpp:46
rtctk::componentFramework::DdsSub::EnableAllDataReaders
void EnableAllDataReaders()
Definition: ddsSub.cpp:181
rtctk::componentFramework::DdsSub::DumpDDSstatistics
void DumpDDSstatistics()
Dumps / logs varios DDS statistic like NACks, ACKs, ...
Definition: ddsSub.cpp:262
rtctk::componentFramework::DdsSub::DdsSub
DdsSub(std::string qos_library="RtcTk_Default_Library", std::string qos_profile="RtcTk_Default_Profile")
Definition: ddsSub.cpp:29
rtctk::componentFramework::DdsSub::CreateSubscriber
void CreateSubscriber()
Creates DDS subscriber.
Definition: ddsSub.cpp:49
rtctk::componentFramework::DdsSub::CreateManyDataReaders
void CreateManyDataReaders(std::vector< DdsTopicReaderListener > const &)
create DDS topics and DDS readers for the given list (vector) of topic names and #DdsReaderListener I...
Definition: ddsSub.cpp:214
dds.hpp
Declares common DDS class.
rtctk::componentFramework::DdsTopicReaderListener::topic_name
std::string topic_name
Definition: ddsSub.hpp:23
rtctk::componentFramework::DdsSub::CreateDataReader
TypedDataReader * CreateDataReader(Topic *topic, DataReaderListener *listener=nullptr, std::string multicast_address="")
Creates DDS data reader for particular topic for topic of type: rtctk::AgnosticTopic.
Definition: ddsSub.cpp:101
rtctk::componentFramework::DdsTopicReaderListener::multicast_address
std::string multicast_address
Definition: ddsSub.hpp:25
rtctk::componentFramework::DdsSub::DestroyAllDataReaders
void DestroyAllDataReaders()
Destroys DDS Data Reader for all DDS topics.
Definition: ddsSub.cpp:238
rtctk::componentFramework::DdsSub::GetDataReaders
std::list< TypedDataReader * > & GetDataReaders()
returns vector of all DDS Data writers
Definition: ddsSub.hpp:118
rtctk::componentFramework::Dds
Common functionallty needed to create DDS entities like participant and topic that can be later used ...
Definition: dds.hpp:26
rtctk::componentFramework::DdsTopicReaderListener::DdsTopicReaderListener
DdsTopicReaderListener(const std::string &tn, DataReaderListener *l)
Definition: ddsSub.hpp:32
rtctk::componentFramework::DdsSub::DestroyDataReader
void DestroyDataReader(TypedDataReader *dr, bool to_be_removed=true)
Destroys DDS data reader.
Definition: ddsSub.cpp:196