RTC Toolkit  2.0.0
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 
18 namespace rtctk::componentFramework {
19 
24 {
25  std::string topic_name;
26  DataReaderListener *listener = nullptr;
27  std::string multicast_address={};
28 
29 
30  DdsReaderParams(const std::string &tn, DataReaderListener *l, const std::string &mc)
31  : topic_name(tn), listener(l), multicast_address(mc){
32  }
33 
34  DdsReaderParams(const std::string &tn, DataReaderListener *l)
35  : topic_name(tn), listener(l) {
36  }
37 
38  DdsReaderParams(const std::string &tn) : topic_name(tn), listener(nullptr) {
39  }
40 };
41 
48 class DdsSub : public Dds {
49  Subscriber *m_subscriber;
50 
51  std::vector<DataReader *> m_data_readers;
52 
53 public:
63  DdsSub(const std::string &qos_file,
64  const std::string &qos_profile = DEFAULT_QOS_PROFILE,
65  DomainId_t domain_id = DEFAULT_DOMAIN_ID);
66  virtual ~DdsSub();
67 
72  void CreateSubscriber();
73 
77  void DestroySubscriber();
78 
86  DataReader *CreateDataReader(Topic *topic, DataReaderListener *listener = nullptr, std::string multicast_address="");
87 
94  void DestroyDataReader(DataReader *dr, bool to_be_removed = true);
95 
100  void CreateDataReaders();
101 
102  void EnableAllDataReaders();
103 
109  void DestroyAllDataReaders();
110 
116  void CreateManyDataReaders(std::vector<DdsReaderParams> const &);
117 
123  void CreateManyDataReaders(std::vector<std::string> &topic_names);
124 
128  void DumpDDSstatistics();
129 
133  std::vector<DataReader *> &GetDataReaders() {
134  return m_data_readers;
135  }
136 
137 };
138 
139 } // namespace rtctk::componentFramework
140 
141 #endif // RTCTK_COMPONENTFRAMEWORK_DATAPATH_DDSSUB_HPP_
rtctk::componentFramework::DdsReaderParams::multicast_address
std::string multicast_address
Definition: ddsSub.hpp:27
rtctk::componentFramework::Dds::DEFAULT_QOS_PROFILE
static const std::string DEFAULT_QOS_PROFILE
default profile name for different DDS QoSs
Definition: dds.hpp:147
rtctk::componentFramework::DdsSub::CreateDataReaders
void CreateDataReaders()
Creates DDS Data Reader for all DDS topics.
Definition: ddsSub.cpp:249
rtctk::componentFramework::DdsSub::DdsSub
DdsSub(const std::string &qos_file, const std::string &qos_profile=DEFAULT_QOS_PROFILE, DomainId_t domain_id=DEFAULT_DOMAIN_ID)
Definition: ddsSub.cpp:28
rtctk::componentFramework::DdsSub::CreateManyDataReaders
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
rtctk::componentFramework::DdsReaderParams::listener
DataReaderListener * listener
Definition: ddsSub.hpp:26
rtctk::componentFramework
Definition: commandReplier.cpp:20
rtctk::componentFramework::DdsReaderParams
Structure that keeps together topic name and DDS Data Writer listener.
Definition: ddsSub.hpp:24
rtctk::componentFramework::DdsReaderParams::DdsReaderParams
DdsReaderParams(const std::string &tn, DataReaderListener *l)
Definition: ddsSub.hpp:34
rtctk::componentFramework::DdsSub::~DdsSub
virtual ~DdsSub()
Definition: ddsSub.cpp:34
rtctk::componentFramework::DdsSub::GetDataReaders
std::vector< DataReader * > & GetDataReaders()
returns vector of all DDS Data writers
Definition: ddsSub.hpp:133
rtctk::componentFramework::Dds::DEFAULT_DOMAIN_ID
static const DomainId_t DEFAULT_DOMAIN_ID
default Domain Id for different DDS
Definition: dds.hpp:153
rtctk::componentFramework::DdsSub
All functionality needed to create DDS entities for DDS data subscribing is concentrated in this clas...
Definition: ddsSub.hpp:48
rtctk::componentFramework::DdsSub::EnableAllDataReaders
void EnableAllDataReaders()
Definition: ddsSub.cpp:178
rtctk::componentFramework::DdsSub::DumpDDSstatistics
void DumpDDSstatistics()
Dumps / logs varios DDS statistic like NACks, ACKs, ...
Definition: ddsSub.cpp:262
rtctk::componentFramework::DdsReaderParams::topic_name
std::string topic_name
Definition: ddsSub.hpp:25
rtctk::componentFramework::DdsSub::DestroySubscriber
void DestroySubscriber()
Destroys DDS subscriber.
Definition: ddsSub.cpp:89
rtctk::componentFramework::DdsSub::CreateSubscriber
void CreateSubscriber()
Creates DDS subscriber.
Definition: ddsSub.cpp:43
rtctk::componentFramework::DdsReaderParams::DdsReaderParams
DdsReaderParams(const std::string &tn, DataReaderListener *l, const std::string &mc)
Definition: ddsSub.hpp:30
rtctk::componentFramework::DdsSub::DestroyDataReader
void DestroyDataReader(DataReader *dr, bool to_be_removed=true)
Destroys DDS data reader.
Definition: ddsSub.cpp:193
rtctk::componentFramework::DdsSub::CreateDataReader
DataReader * 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:107
rtctk::componentFramework::DdsReaderParams::DdsReaderParams
DdsReaderParams(const std::string &tn)
Definition: ddsSub.hpp:38
dds.hpp
Declares common DDS class.
rtctk::componentFramework::DdsSub::DestroyAllDataReaders
void DestroyAllDataReaders()
Destroys DDS Data Reader for all DDS topics.
Definition: ddsSub.cpp:238
rtctk::componentFramework::Dds
Common functionallty needed to create DDS entities like participant and topic that can be later used ...
Definition: dds.hpp:31