| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
Subscriber.hpp
1// Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
18
19#ifndef FASTDDS_DDS_SUBSCRIBER__SUBSCRIBER_HPP
20#define FASTDDS_DDS_SUBSCRIBER__SUBSCRIBER_HPP
21
22#include <fastdds/dds/core/Entity.hpp>
23#include <fastdds/dds/core/ReturnCode.hpp>
24#include <fastdds/dds/subscriber/DataReaderListener.hpp>
25#include <fastdds/dds/subscriber/InstanceState.hpp>
26#include <fastdds/dds/subscriber/qos/DataReaderQos.hpp>
27#include <fastdds/dds/subscriber/qos/SubscriberQos.hpp>
28#include <fastdds/dds/subscriber/SampleState.hpp>
29#include <fastdds/dds/subscriber/ViewState.hpp>
30#include <fastdds/dds/topic/qos/TopicQos.hpp>
31#include <fastdds/dds/topic/TypeSupport.hpp>
32
33 namespace dds {
34 namespace sub {
35
36 class Subscriber;
37
38} // namespace sub
39} // namespace dds
40
41 namespace eprosima {
42 namespace fastdds {
43 namespace rtps {
44
45 class IPayloadPool;
46
47} // namespace rtps
48
49 namespace dds {
50
51 class DomainParticipant;
52 class SubscriberListener;
53 class SubscriberImpl;
54 class DataReader;
55 class DataReaderListener;
56 class DataReaderQos;
57 class TopicDescription;
65 class Subscriber : public DomainEntity
66{
67 protected:
68
69 friend class SubscriberImpl;
70 friend class DomainParticipantImpl;
71
76 Subscriber(
77 SubscriberImpl* pimpl,
78 const StatusMask& mask = StatusMask::all());
79
80 Subscriber(
81 DomainParticipant* dp,
82 const SubscriberQos& qos = SUBSCRIBER_QOS_DEFAULT,
83 SubscriberListener* listener = nullptr,
84 const StatusMask& mask = StatusMask::all());
85
86 public:
87
91 virtual ~Subscriber()
92 {
93 }
94
101 FASTDDS_EXPORTED_API ReturnCode_t enable() override;
102
108 FASTDDS_EXPORTED_API const SubscriberQos& get_qos() const;
109
116 FASTDDS_EXPORTED_API ReturnCode_t get_qos(
117 SubscriberQos& qos) const;
118
127 FASTDDS_EXPORTED_API ReturnCode_t set_qos(
128 const SubscriberQos& qos);
129
135 FASTDDS_EXPORTED_API const SubscriberListener* get_listener() const;
136
143 FASTDDS_EXPORTED_API ReturnCode_t set_listener(
144 SubscriberListener* listener);
145
153 FASTDDS_EXPORTED_API ReturnCode_t set_listener(
154 SubscriberListener* listener,
155 const StatusMask& mask);
166 FASTDDS_EXPORTED_API DataReader* create_datareader(
167 TopicDescription* topic,
168 const DataReaderQos& reader_qos,
169 DataReaderListener* listener = nullptr,
170 const StatusMask& mask = StatusMask::all(),
171 std::shared_ptr<fastdds::rtps::IPayloadPool> payload_pool = nullptr);
172
183 FASTDDS_EXPORTED_API DataReader* create_datareader_with_profile(
184 TopicDescription* topic,
185 const std::string& profile_name,
186 DataReaderListener* listener = nullptr,
187 const StatusMask& mask = StatusMask::all(),
188 std::shared_ptr<fastdds::rtps::IPayloadPool> payload_pool = nullptr);
189
201 FASTDDS_EXPORTED_API ReturnCode_t delete_datareader(
202 const DataReader* reader);
203
214 FASTDDS_EXPORTED_API DataReader* lookup_datareader(
215 const std::string& topic_name) const;
216
223 FASTDDS_EXPORTED_API ReturnCode_t get_datareaders(
224 std::vector<DataReader*>& readers) const;
225
238 FASTDDS_EXPORTED_API ReturnCode_t get_datareaders(
239 std::vector<DataReader*>& readers,
240 const std::vector<SampleStateKind>& sample_states,
241 const std::vector<ViewStateKind>& view_states,
242 const std::vector<InstanceStateKind>& instance_states) const;
243
249 FASTDDS_EXPORTED_API bool has_datareaders() const;
250
259 FASTDDS_EXPORTED_API ReturnCode_t begin_access();
260
269 FASTDDS_EXPORTED_API ReturnCode_t end_access();
270
271
281 FASTDDS_EXPORTED_API ReturnCode_t notify_datareaders() const;
282
289 FASTDDS_EXPORTED_API ReturnCode_t delete_contained_entities();
290
305 FASTDDS_EXPORTED_API ReturnCode_t set_default_datareader_qos(
306 const DataReaderQos& qos);
307
318 FASTDDS_EXPORTED_API const DataReaderQos& get_default_datareader_qos() const;
319
320
331 FASTDDS_EXPORTED_API DataReaderQos& get_default_datareader_qos();
332
344 FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos(
345 DataReaderQos& qos) const;
346
354 FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile(
355 const std::string& profile_name,
356 DataReaderQos& qos) const;
357
366 FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile(
367 const std::string& profile_name,
368 DataReaderQos& qos,
369 std::string& topic_name) const;
370
378 FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(
379 const std::string& xml,
380 DataReaderQos& qos) const;
381
390 FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(
391 const std::string& xml,
392 DataReaderQos& qos,
393 std::string& topic_name) const;
394
403 FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(
404 const std::string& xml,
405 DataReaderQos& qos,
406 const std::string& profile_name) const;
407
417 FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(
418 const std::string& xml,
419 DataReaderQos& qos,
420 std::string& topic_name,
421 const std::string& profile_name) const;
422
432 FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos_from_xml(
433 const std::string& xml,
434 DataReaderQos& qos) const;
435
446 FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos_from_xml(
447 const std::string& xml,
448 DataReaderQos& qos,
449 std::string& topic_name) const;
450
460 FASTDDS_EXPORTED_API static ReturnCode_t copy_from_topic_qos(
461 DataReaderQos& reader_qos,
462 const TopicQos& topic_qos);
463
469 FASTDDS_EXPORTED_API const DomainParticipant* get_participant() const;
470
476 FASTDDS_EXPORTED_API const InstanceHandle_t& get_instance_handle() const;
477
478 protected:
479
480 SubscriberImpl* impl_;
481
482 friend class ::dds::sub::Subscriber;
483};
484
485} // namespace dds
486} // namespace fastdds
487} // namespace eprosima
488
489#endif // FASTDDS_DDS_SUBSCRIBER__SUBSCRIBER_HPP
eprosima::fastdds::dds::DataReader
Class DataReader, contains the actual implementation of the behaviour of the Subscriber.
Definition DataReader.hpp:83
eprosima::fastdds::dds::DataReaderListener
Class DataReaderListener, it should be used by the end user to implement specific callbacks to certai...
Definition DataReaderListener.hpp:41
eprosima::fastdds::dds::DataReaderQos
Class DataReaderQos, containing all the possible Qos that can be set for a determined DataReader.
Definition DataReaderQos.hpp:44
eprosima::fastdds::dds::DomainEntity::DomainEntity
DomainEntity(const StatusMask &mask=StatusMask::all())
Constructor.
Definition Entity.hpp:184
eprosima::fastdds::dds::DomainParticipant
Class DomainParticipant used to group Publishers and Subscribers into a single working unit.
Definition DomainParticipant.hpp:86
eprosima::fastdds::dds::StatusMask
StatusMask is a bitmap or bitset field.
Definition StatusMask.hpp:48
eprosima::fastdds::dds::StatusMask::all
static StatusMask all()
Get all StatusMasks.
Definition StatusMask.hpp:104
eprosima::fastdds::dds::Subscriber::Subscriber
Subscriber(SubscriberImpl *pimpl, const StatusMask &mask=StatusMask::all())
Create a subscriber, assigning its pointer to the associated implementation.
eprosima::fastdds::dds::Subscriber::impl_
SubscriberImpl * impl_
Definition Subscriber.hpp:480
eprosima::fastdds::dds::Subscriber::get_default_datareader_qos
FASTDDS_EXPORTED_API DataReaderQos & get_default_datareader_qos()
This operation returns the default value of the DataReader QoS, that is, the QoS policies which will ...
eprosima::fastdds::dds::Subscriber::Subscriber
Subscriber(DomainParticipant *dp, const SubscriberQos &qos=SUBSCRIBER_QOS_DEFAULT, SubscriberListener *listener=nullptr, const StatusMask &mask=StatusMask::all())
eprosima::fastdds::dds::Subscriber::get_instance_handle
FASTDDS_EXPORTED_API const InstanceHandle_t & get_instance_handle() const
Returns the Subscriber's handle.
eprosima::fastdds::dds::Subscriber::get_default_datareader_qos
FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos(DataReaderQos &qos) const
This operation retrieves the default value of the DataReader QoS, that is, the QoS policies which wil...
eprosima::fastdds::dds::Subscriber::get_datareaders
FASTDDS_EXPORTED_API ReturnCode_t get_datareaders(std::vector< DataReader * > &readers) const
This operation allows the application to access the DataReader objects.
eprosima::fastdds::dds::Subscriber::set_listener
FASTDDS_EXPORTED_API ReturnCode_t set_listener(SubscriberListener *listener, const StatusMask &mask)
Modifies the SubscriberListener.
eprosima::fastdds::dds::Subscriber::copy_from_topic_qos
static FASTDDS_EXPORTED_API ReturnCode_t copy_from_topic_qos(DataReaderQos &reader_qos, const TopicQos &topic_qos)
Copies TopicQos into the corresponding DataReaderQos.
eprosima::fastdds::dds::Subscriber::get_datareader_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(const std::string &xml, DataReaderQos &qos, std::string &topic_name, const std::string &profile_name) const
Fills the DataReaderQos with the DataReader profile with profile_name to be found in the provided XML...
eprosima::fastdds::dds::Subscriber::delete_datareader
FASTDDS_EXPORTED_API ReturnCode_t delete_datareader(const DataReader *reader)
This operation deletes a DataReader that belongs to the Subscriber.
eprosima::fastdds::dds::Subscriber::lookup_datareader
FASTDDS_EXPORTED_API DataReader * lookup_datareader(const std::string &topic_name) const
This operation retrieves a previously-created DataReader belonging to the Subscriber that is attached...
eprosima::fastdds::dds::Subscriber::begin_access
FASTDDS_EXPORTED_API ReturnCode_t begin_access()
Indicates that the application is about to access the data samples in any of the DataReader objects a...
eprosima::fastdds::dds::Subscriber::Subscriber
friend class ::dds::sub::Subscriber
Definition Subscriber.hpp:482
eprosima::fastdds::dds::Subscriber::get_qos
FASTDDS_EXPORTED_API ReturnCode_t get_qos(SubscriberQos &qos) const
Retrieves the Subscriber Qos.
eprosima::fastdds::dds::Subscriber::get_datareader_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(const std::string &xml, DataReaderQos &qos, std::string &topic_name) const
Fills the DataReaderQos with the first DataReader profile found in the provided XML,...
eprosima::fastdds::dds::Subscriber::create_datareader
FASTDDS_EXPORTED_API DataReader * create_datareader(TopicDescription *topic, const DataReaderQos &reader_qos, DataReaderListener *listener=nullptr, const StatusMask &mask=StatusMask::all(), std::shared_ptr< fastdds::rtps::IPayloadPool > payload_pool=nullptr)
This operation creates a DataReader.
eprosima::fastdds::dds::Subscriber::set_default_datareader_qos
FASTDDS_EXPORTED_API ReturnCode_t set_default_datareader_qos(const DataReaderQos &qos)
This operation sets a default value of the DataReader QoS policies which will be used for newly creat...
eprosima::fastdds::dds::Subscriber::~Subscriber
virtual ~Subscriber()
Destructor.
Definition Subscriber.hpp:91
eprosima::fastdds::dds::Subscriber::end_access
FASTDDS_EXPORTED_API ReturnCode_t end_access()
Indicates that the application has finished accessing the data samples in DataReader objects managed ...
eprosima::fastdds::dds::Subscriber::notify_datareaders
FASTDDS_EXPORTED_API ReturnCode_t notify_datareaders() const
This operation invokes the operation on_data_available on the DataReaderListener objects attached to ...
eprosima::fastdds::dds::Subscriber::set_qos
FASTDDS_EXPORTED_API ReturnCode_t set_qos(const SubscriberQos &qos)
Allows modifying the Subscriber Qos.
eprosima::fastdds::dds::Subscriber::set_listener
FASTDDS_EXPORTED_API ReturnCode_t set_listener(SubscriberListener *listener)
Modifies the SubscriberListener, sets the mask to StatusMask::all().
eprosima::fastdds::dds::Subscriber::get_datareader_qos_from_profile
FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile(const std::string &profile_name, DataReaderQos &qos, std::string &topic_name) const
Fills the DataReaderQos with the values of the XML profile, and also its corresponding topic name (if...
eprosima::fastdds::dds::Subscriber::SubscriberImpl
friend class SubscriberImpl
Definition Subscriber.hpp:69
eprosima::fastdds::dds::Subscriber::get_datareader_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(const std::string &xml, DataReaderQos &qos) const
Fills the DataReaderQos with the first DataReader profile found in the provided XML.
eprosima::fastdds::dds::Subscriber::get_participant
FASTDDS_EXPORTED_API const DomainParticipant * get_participant() const
This operation returns the DomainParticipant to which the Subscriber belongs.
eprosima::fastdds::dds::Subscriber::delete_contained_entities
FASTDDS_EXPORTED_API ReturnCode_t delete_contained_entities()
Deletes all contained DataReaders.
eprosima::fastdds::dds::Subscriber::enable
FASTDDS_EXPORTED_API ReturnCode_t enable() override
This operation enables the Subscriber.
eprosima::fastdds::dds::Subscriber::get_datareader_qos_from_profile
FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_profile(const std::string &profile_name, DataReaderQos &qos) const
Fills the DataReaderQos with the values of the XML profile.
eprosima::fastdds::dds::Subscriber::get_qos
FASTDDS_EXPORTED_API const SubscriberQos & get_qos() const
Allows accessing the Subscriber Qos.
eprosima::fastdds::dds::Subscriber::get_default_datareader_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos_from_xml(const std::string &xml, DataReaderQos &qos) const
Fills the DataReaderQos with the default DataReader profile found in the provided XML (if there is).
eprosima::fastdds::dds::Subscriber::DomainParticipantImpl
friend class DomainParticipantImpl
Definition Subscriber.hpp:70
eprosima::fastdds::dds::Subscriber::get_default_datareader_qos
FASTDDS_EXPORTED_API const DataReaderQos & get_default_datareader_qos() const
This operation returns the default value of the DataReader QoS, that is, the QoS policies which will ...
eprosima::fastdds::dds::Subscriber::has_datareaders
FASTDDS_EXPORTED_API bool has_datareaders() const
This operation checks if the subscriber has DataReaders.
eprosima::fastdds::dds::Subscriber::create_datareader_with_profile
FASTDDS_EXPORTED_API DataReader * create_datareader_with_profile(TopicDescription *topic, const std::string &profile_name, DataReaderListener *listener=nullptr, const StatusMask &mask=StatusMask::all(), std::shared_ptr< fastdds::rtps::IPayloadPool > payload_pool=nullptr)
This operation creates a DataReader.
eprosima::fastdds::dds::Subscriber::get_datareaders
FASTDDS_EXPORTED_API ReturnCode_t get_datareaders(std::vector< DataReader * > &readers, const std::vector< SampleStateKind > &sample_states, const std::vector< ViewStateKind > &view_states, const std::vector< InstanceStateKind > &instance_states) const
This operation allows the application to access the DataReader objects that contain samples with the ...
eprosima::fastdds::dds::Subscriber::get_listener
FASTDDS_EXPORTED_API const SubscriberListener * get_listener() const
Retrieves the attached SubscriberListener.
eprosima::fastdds::dds::Subscriber::get_default_datareader_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_default_datareader_qos_from_xml(const std::string &xml, DataReaderQos &qos, std::string &topic_name) const
Fills the DataReaderQos with the default DataReader profile found in the provided XML (if there is),...
eprosima::fastdds::dds::Subscriber::get_datareader_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_datareader_qos_from_xml(const std::string &xml, DataReaderQos &qos, const std::string &profile_name) const
Fills the DataReaderQos with the DataReader profile with profile_name to be found in the provided XML...
eprosima::fastdds::dds::SubscriberListener
Class SubscriberListener, it should be used by the end user to implement specific callbacks to certai...
Definition SubscriberListener.hpp:41
eprosima::fastdds::dds::SubscriberQos
Class SubscriberQos, contains all the possible Qos that can be set for a determined Subscriber.
Definition SubscriberQos.hpp:38
eprosima::fastdds::dds::TopicDescription
Class TopicDescription, represents the fact that both publications and subscriptions are tied to a si...
Definition TopicDescription.hpp:38
eprosima::fastdds::dds::TopicQos
Class TopicQos, containing all the possible Qos that can be set for a determined Topic.
Definition TopicQos.hpp:40
eprosima::fastdds::rtps::IPayloadPool
An interface for classes responsible of serialized payload management.
Definition IPayloadPool.hpp:35
dds::sub
Definition DataReader.hpp:48
dds
Definition DomainParticipant.hpp:46
eprosima::fastdds::dds
Definition BuiltinTopicKey.hpp:26
eprosima::fastdds::dds::InstanceHandle_t
eprosima::fastdds::rtps::InstanceHandle_t InstanceHandle_t
Definition InstanceHandle.hpp:31
eprosima::fastdds::dds::SUBSCRIBER_QOS_DEFAULT
FASTDDS_EXPORTED_API const SubscriberQos SUBSCRIBER_QOS_DEFAULT
eprosima::fastdds::dds::ReturnCode_t
int32_t ReturnCode_t
Definition DDSReturnCode.hpp:59
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds
eprosima
eProsima namespace.