| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
Publisher.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
19
20#ifndef FASTDDS_DDS_PUBLISHER__PUBLISHER_HPP
21#define FASTDDS_DDS_PUBLISHER__PUBLISHER_HPP
22
23#include <fastdds/dds/core/Entity.hpp>
24#include <fastdds/dds/core/ReturnCode.hpp>
25#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
26#include <fastdds/dds/publisher/qos/PublisherQos.hpp>
27#include <fastdds/dds/topic/TypeSupport.hpp>
28#include <fastdds/rtps/common/Time_t.hpp>
29
30#include <fastdds/fastdds_dll.hpp>
31
32 namespace dds {
33 namespace pub {
34 class Publisher;
35} // namespace pub
36} // namespace dds
37
38 namespace eprosima {
39 namespace fastdds {
40 namespace rtps {
41
42 class IPayloadPool;
43
44} // namespace rtps
45
46 namespace dds {
47
48 class DomainParticipant;
49 class PublisherListener;
50 class PublisherImpl;
51 class DataWriter;
52 class DataWriterListener;
53 class Topic;
54
60 class Publisher : public DomainEntity
61{
62 protected:
63
64 friend class PublisherImpl;
65 friend class DomainParticipantImpl;
66
71 Publisher(
72 PublisherImpl* p,
73 const StatusMask& mask = StatusMask::all());
74
75 Publisher(
76 DomainParticipant* dp,
77 const PublisherQos& qos = PUBLISHER_QOS_DEFAULT,
78 PublisherListener* listener = nullptr,
79 const StatusMask& mask = StatusMask::all());
80
81 public:
82
86 virtual ~Publisher();
87
94 FASTDDS_EXPORTED_API ReturnCode_t enable() override;
95
101 FASTDDS_EXPORTED_API const PublisherQos& get_qos() const;
102
108 FASTDDS_EXPORTED_API ReturnCode_t get_qos(
109 PublisherQos& qos) const;
110
119 FASTDDS_EXPORTED_API ReturnCode_t set_qos(
120 const PublisherQos& qos);
121
127 FASTDDS_EXPORTED_API const PublisherListener* get_listener() const;
128
135 FASTDDS_EXPORTED_API ReturnCode_t set_listener(
136 PublisherListener* listener);
137
145 FASTDDS_EXPORTED_API ReturnCode_t set_listener(
146 PublisherListener* listener,
147 const StatusMask& mask);
148
159 FASTDDS_EXPORTED_API DataWriter* create_datawriter(
160 Topic* topic,
161 const DataWriterQos& qos,
162 DataWriterListener* listener = nullptr,
163 const StatusMask& mask = StatusMask::all(),
164 std::shared_ptr<fastdds::rtps::IPayloadPool> payload_pool = nullptr);
165
176 FASTDDS_EXPORTED_API DataWriter* create_datawriter_with_profile(
177 Topic* topic,
178 const std::string& profile_name,
179 DataWriterListener* listener = nullptr,
180 const StatusMask& mask = StatusMask::all(),
181 std::shared_ptr<fastdds::rtps::IPayloadPool> payload_pool = nullptr);
182
198 FASTDDS_EXPORTED_API ReturnCode_t delete_datawriter(
199 const DataWriter* writer);
200
211 FASTDDS_EXPORTED_API DataWriter* lookup_datawriter(
212 const std::string& topic_name) const;
213
221 FASTDDS_EXPORTED_API ReturnCode_t suspend_publications();
222
230 FASTDDS_EXPORTED_API ReturnCode_t resume_publications();
231
239 FASTDDS_EXPORTED_API ReturnCode_t begin_coherent_changes();
240
248 FASTDDS_EXPORTED_API ReturnCode_t end_coherent_changes();
249
261 FASTDDS_EXPORTED_API ReturnCode_t wait_for_acknowledgments(
262 const fastdds::dds::Duration_t& max_wait);
263
269 FASTDDS_EXPORTED_API const DomainParticipant* get_participant() const;
270
276 FASTDDS_EXPORTED_API ReturnCode_t delete_contained_entities();
277
292 FASTDDS_EXPORTED_API ReturnCode_t set_default_datawriter_qos(
293 const DataWriterQos& qos);
294
305 FASTDDS_EXPORTED_API const DataWriterQos& get_default_datawriter_qos() const;
306
318 FASTDDS_EXPORTED_API ReturnCode_t get_default_datawriter_qos(
319 DataWriterQos& qos) const;
320
330 FASTDDS_EXPORTED_API static ReturnCode_t copy_from_topic_qos(
331 fastdds::dds::DataWriterQos& writer_qos,
332 const fastdds::dds::TopicQos& topic_qos);
333
341 FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_profile(
342 const std::string& profile_name,
343 DataWriterQos& qos) const;
344
353 FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_profile(
354 const std::string& profile_name,
355 DataWriterQos& qos,
356 std::string& topic_name) const;
357
365 FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml(
366 const std::string& xml,
367 DataWriterQos& qos) const;
368
377 FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml(
378 const std::string& xml,
379 DataWriterQos& qos,
380 std::string& topic_name) const;
381
390 FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml(
391 const std::string& xml,
392 DataWriterQos& qos,
393 const std::string& profile_name) const;
394
404 FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml(
405 const std::string& xml,
406 DataWriterQos& qos,
407 std::string& topic_name,
408 const std::string& profile_name) const;
409
419 FASTDDS_EXPORTED_API ReturnCode_t get_default_datawriter_qos_from_xml(
420 const std::string& xml,
421 DataWriterQos& qos) const;
422
433 FASTDDS_EXPORTED_API ReturnCode_t get_default_datawriter_qos_from_xml(
434 const std::string& xml,
435 DataWriterQos& qos,
436 std::string& topic_name) const;
437
443 FASTDDS_EXPORTED_API const InstanceHandle_t& get_instance_handle() const;
444
451 FASTDDS_EXPORTED_API bool get_datawriters(
452 std::vector<DataWriter*>& writers) const;
453
459 FASTDDS_EXPORTED_API bool has_datawriters() const;
460
461 protected:
462
463 PublisherImpl* impl_;
464
465 friend class ::dds::pub::Publisher;
466};
467
468} // namespace dds
469} // namespace fastdds
470} // namespace eprosima
471
472#endif // FASTDDS_DDS_PUBLISHER__PUBLISHER_HPP
eprosima::fastdds::dds::DataWriter
Class DataWriter, contains the actual implementation of the behaviour of the DataWriter.
Definition DataWriter.hpp:67
eprosima::fastdds::dds::DataWriterListener
Class DataWriterListener, allows the end user to implement callbacks triggered by certain events.
Definition DataWriterListener.hpp:39
eprosima::fastdds::dds::DataWriterQos
Class DataWriterQos, containing all the possible Qos that can be set for a determined DataWriter.
Definition DataWriterQos.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::Publisher::set_default_datawriter_qos
FASTDDS_EXPORTED_API ReturnCode_t set_default_datawriter_qos(const DataWriterQos &qos)
This operation sets a default value of the DataWriter QoS policies which will be used for newly creat...
eprosima::fastdds::dds::Publisher::get_datawriter_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml(const std::string &xml, DataWriterQos &qos, std::string &topic_name) const
Fills the DataWriterQos with the first DataWriter profile found in the provided XML,...
eprosima::fastdds::dds::Publisher::get_datawriter_qos_from_profile
FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_profile(const std::string &profile_name, DataWriterQos &qos) const
Fills the DataWriterQos with the values of the XML profile.
eprosima::fastdds::dds::Publisher::get_instance_handle
FASTDDS_EXPORTED_API const InstanceHandle_t & get_instance_handle() const
Returns the Publisher's handle.
eprosima::fastdds::dds::Publisher::get_qos
FASTDDS_EXPORTED_API const PublisherQos & get_qos() const
Allows accessing the Publisher Qos.
eprosima::fastdds::dds::Publisher::set_qos
FASTDDS_EXPORTED_API ReturnCode_t set_qos(const PublisherQos &qos)
Allows modifying the Publisher Qos.
eprosima::fastdds::dds::Publisher::get_default_datawriter_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_default_datawriter_qos_from_xml(const std::string &xml, DataWriterQos &qos) const
Fills the DataWriterQos with the default DataWriter profile found in the provided XML (if there is).
eprosima::fastdds::dds::Publisher::delete_datawriter
FASTDDS_EXPORTED_API ReturnCode_t delete_datawriter(const DataWriter *writer)
This operation deletes a DataWriter that belongs to the Publisher.
eprosima::fastdds::dds::Publisher::Publisher
Publisher(PublisherImpl *p, const StatusMask &mask=StatusMask::all())
Create a publisher, assigning its pointer to the associated implementation.
eprosima::fastdds::dds::Publisher::create_datawriter_with_profile
FASTDDS_EXPORTED_API DataWriter * create_datawriter_with_profile(Topic *topic, const std::string &profile_name, DataWriterListener *listener=nullptr, const StatusMask &mask=StatusMask::all(), std::shared_ptr< fastdds::rtps::IPayloadPool > payload_pool=nullptr)
This operation creates a DataWriter.
eprosima::fastdds::dds::Publisher::get_default_datawriter_qos
FASTDDS_EXPORTED_API const DataWriterQos & get_default_datawriter_qos() const
This operation returns the default value of the DataWriter QoS, that is, the QoS policies which will ...
eprosima::fastdds::dds::Publisher::has_datawriters
FASTDDS_EXPORTED_API bool has_datawriters() const
This operation checks if the publisher has DataWriters.
eprosima::fastdds::dds::Publisher::get_default_datawriter_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_default_datawriter_qos_from_xml(const std::string &xml, DataWriterQos &qos, std::string &topic_name) const
Fills the DataWriterQos with the default DataWriter profile found in the provided XML (if there is),...
eprosima::fastdds::dds::Publisher::create_datawriter
FASTDDS_EXPORTED_API DataWriter * create_datawriter(Topic *topic, const DataWriterQos &qos, DataWriterListener *listener=nullptr, const StatusMask &mask=StatusMask::all(), std::shared_ptr< fastdds::rtps::IPayloadPool > payload_pool=nullptr)
This operation creates a DataWriter.
eprosima::fastdds::dds::Publisher::~Publisher
virtual ~Publisher()
Destructor.
eprosima::fastdds::dds::Publisher::Publisher
friend class ::dds::pub::Publisher
Definition Publisher.hpp:465
eprosima::fastdds::dds::Publisher::set_listener
FASTDDS_EXPORTED_API ReturnCode_t set_listener(PublisherListener *listener)
Modifies the PublisherListener, sets the mask to StatusMask::all().
eprosima::fastdds::dds::Publisher::impl_
PublisherImpl * impl_
Definition Publisher.hpp:463
eprosima::fastdds::dds::Publisher::get_listener
FASTDDS_EXPORTED_API const PublisherListener * get_listener() const
Retrieves the attached PublisherListener.
eprosima::fastdds::dds::Publisher::get_datawriter_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml(const std::string &xml, DataWriterQos &qos, const std::string &profile_name) const
Fills the DataWriterQos with the DataWriter profile with profile_name to be found in the provided XML...
eprosima::fastdds::dds::Publisher::lookup_datawriter
FASTDDS_EXPORTED_API DataWriter * lookup_datawriter(const std::string &topic_name) const
This operation retrieves a previously created DataWriter belonging to the Publisher that is attached ...
eprosima::fastdds::dds::Publisher::copy_from_topic_qos
static FASTDDS_EXPORTED_API ReturnCode_t copy_from_topic_qos(fastdds::dds::DataWriterQos &writer_qos, const fastdds::dds::TopicQos &topic_qos)
Copies TopicQos into the corresponding DataWriterQos.
eprosima::fastdds::dds::Publisher::get_datawriter_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml(const std::string &xml, DataWriterQos &qos) const
Fills the DataWriterQos with the first DataWriter profile found in the provided XML.
eprosima::fastdds::dds::Publisher::get_participant
FASTDDS_EXPORTED_API const DomainParticipant * get_participant() const
This operation returns the DomainParticipant to which the Publisher belongs.
eprosima::fastdds::dds::Publisher::delete_contained_entities
FASTDDS_EXPORTED_API ReturnCode_t delete_contained_entities()
Deletes all contained DataWriters.
eprosima::fastdds::dds::Publisher::Publisher
Publisher(DomainParticipant *dp, const PublisherQos &qos=PUBLISHER_QOS_DEFAULT, PublisherListener *listener=nullptr, const StatusMask &mask=StatusMask::all())
eprosima::fastdds::dds::Publisher::enable
FASTDDS_EXPORTED_API ReturnCode_t enable() override
This operation enables the Publisher.
eprosima::fastdds::dds::Publisher::PublisherImpl
friend class PublisherImpl
Definition Publisher.hpp:64
eprosima::fastdds::dds::Publisher::set_listener
FASTDDS_EXPORTED_API ReturnCode_t set_listener(PublisherListener *listener, const StatusMask &mask)
Modifies the PublisherListener.
eprosima::fastdds::dds::Publisher::get_datawriter_qos_from_profile
FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_profile(const std::string &profile_name, DataWriterQos &qos, std::string &topic_name) const
Fills the DataWriterQos with the values of the XML profile, and also its corresponding topic name (if...
eprosima::fastdds::dds::Publisher::resume_publications
FASTDDS_EXPORTED_API ReturnCode_t resume_publications()
Indicates to FastDDS that the modifications to the DataWriters are complete.
eprosima::fastdds::dds::Publisher::get_datawriters
FASTDDS_EXPORTED_API bool get_datawriters(std::vector< DataWriter * > &writers) const
Fills the given vector with all the datawriters of this publisher.
eprosima::fastdds::dds::Publisher::suspend_publications
FASTDDS_EXPORTED_API ReturnCode_t suspend_publications()
Indicates to FastDDS that the contained DataWriters are about to be modified.
eprosima::fastdds::dds::Publisher::DomainParticipantImpl
friend class DomainParticipantImpl
Definition Publisher.hpp:65
eprosima::fastdds::dds::Publisher::wait_for_acknowledgments
FASTDDS_EXPORTED_API ReturnCode_t wait_for_acknowledgments(const fastdds::dds::Duration_t &max_wait)
This operation blocks the calling thread until either all data written by the reliable DataWriter ent...
eprosima::fastdds::dds::Publisher::end_coherent_changes
FASTDDS_EXPORTED_API ReturnCode_t end_coherent_changes()
Signals the end of a set of coherent cache changes.
eprosima::fastdds::dds::Publisher::get_default_datawriter_qos
FASTDDS_EXPORTED_API ReturnCode_t get_default_datawriter_qos(DataWriterQos &qos) const
This operation retrieves the default value of the DataWriter QoS, that is, the QoS policies which wil...
eprosima::fastdds::dds::Publisher::begin_coherent_changes
FASTDDS_EXPORTED_API ReturnCode_t begin_coherent_changes()
Signals the beginning of a set of coherent cache changes using the Datawriters attached to the publis...
eprosima::fastdds::dds::Publisher::get_datawriter_qos_from_xml
FASTDDS_EXPORTED_API ReturnCode_t get_datawriter_qos_from_xml(const std::string &xml, DataWriterQos &qos, std::string &topic_name, const std::string &profile_name) const
Fills the DataWriterQos with the DataWriter profile with profile_name to be found in the provided XML...
eprosima::fastdds::dds::Publisher::get_qos
FASTDDS_EXPORTED_API ReturnCode_t get_qos(PublisherQos &qos) const
Retrieves the Publisher Qos.
eprosima::fastdds::dds::PublisherListener
Class PublisherListener, allows the end user to implement callbacks triggered by certain events.
Definition PublisherListener.hpp:39
eprosima::fastdds::dds::PublisherQos
Class PublisherQos, containing all the possible Qos that can be set for a determined Publisher.
Definition PublisherQos.hpp:39
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::Topic
Class Topic, represents the fact that both publications and subscriptions are tied to a single data-t...
Definition Topic.hpp:53
eprosima::fastdds::dds::TopicQos
Class TopicQos, containing all the possible Qos that can be set for a determined Topic.
Definition TopicQos.hpp:40
dds::pub
Definition Publisher.hpp:33
dds
Definition DomainParticipant.hpp:46
eprosima::fastdds::dds
Definition BuiltinTopicKey.hpp:26
eprosima::fastdds::dds::PUBLISHER_QOS_DEFAULT
FASTDDS_EXPORTED_API const PublisherQos PUBLISHER_QOS_DEFAULT
eprosima::fastdds::dds::InstanceHandle_t
eprosima::fastdds::rtps::InstanceHandle_t InstanceHandle_t
Definition InstanceHandle.hpp:31
eprosima::fastdds::dds::Duration_t
Time_t Duration_t
Definition Time_t.hpp:91
eprosima::fastdds::dds::ReturnCode_t
int32_t ReturnCode_t
Definition DDSReturnCode.hpp:59
eprosima
eProsima namespace.