Fast DDS  Version 3.1.2
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
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
32namespace dds {
33namespace pub {
34class Publisher;
35} // namespace pub
36} // namespace dds
37
38namespace eprosima {
39namespace fastdds {
40namespace rtps {
41
42class IPayloadPool;
43
44} // namespace rtps
45
46namespace dds {
47
48class DomainParticipant;
49class PublisherListener;
50class PublisherImpl;
51class DataWriter;
52class DataWriterListener;
53class Topic;
54
60class Publisher : public DomainEntity
61{
62protected:
63
64 friend class PublisherImpl;
66
73 const StatusMask& mask = StatusMask::all());
74
78 PublisherListener* listener = nullptr,
79 const StatusMask& mask = StatusMask::all());
80
81public:
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
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
262 const fastdds::dds::Duration_t& max_wait);
263
269 FASTDDS_EXPORTED_API const DomainParticipant* get_participant() const;
270
277
293 const DataWriterQos& qos);
294
305 FASTDDS_EXPORTED_API const DataWriterQos& get_default_datawriter_qos() const;
306
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
342 const std::string& profile_name,
343 DataWriterQos& qos) const;
344
354 const std::string& profile_name,
355 DataWriterQos& qos,
356 std::string& topic_name) const;
357
366 const std::string& xml,
367 DataWriterQos& qos) const;
368
378 const std::string& xml,
379 DataWriterQos& qos,
380 std::string& topic_name) const;
381
391 const std::string& xml,
392 DataWriterQos& qos,
393 const std::string& profile_name) const;
394
405 const std::string& xml,
406 DataWriterQos& qos,
407 std::string& topic_name,
408 const std::string& profile_name) const;
409
420 const std::string& xml,
421 DataWriterQos& qos) const;
422
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
461protected:
462
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
Class DataWriter, contains the actual implementation of the behaviour of the DataWriter.
Definition DataWriter.hpp:64
Class DataWriterListener, allows the end user to implement callbacks triggered by certain events.
Definition DataWriterListener.hpp:39
Class DataWriterQos, containing all the possible Qos that can be set for a determined DataWriter.
Definition DataWriterQos.hpp:85
The DomainEntity class is a subclass of Entity created in order to differentiate between DomainPartic...
Definition Entity.hpp:166
Class DomainParticipant used to group Publishers and Subscribers into a single working unit.
Definition DomainParticipant.hpp:78
Class Publisher, used to send data to associated subscribers.
Definition Publisher.hpp:61
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...
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,...
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.
FASTDDS_EXPORTED_API const InstanceHandle_t & get_instance_handle() const
Returns the Publisher's handle.
FASTDDS_EXPORTED_API const PublisherQos & get_qos() const
Allows accessing the Publisher Qos.
FASTDDS_EXPORTED_API ReturnCode_t set_qos(const PublisherQos &qos)
Allows modifying the Publisher Qos.
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).
FASTDDS_EXPORTED_API ReturnCode_t delete_datawriter(const DataWriter *writer)
This operation deletes a DataWriter that belongs to the Publisher.
Publisher(PublisherImpl *p, const StatusMask &mask=StatusMask::all())
Create a publisher, assigning its pointer to the associated implementation.
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.
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 ...
FASTDDS_EXPORTED_API bool has_datawriters() const
This operation checks if the publisher has DataWriters.
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),...
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.
virtual ~Publisher()
Destructor.
FASTDDS_EXPORTED_API ReturnCode_t set_listener(PublisherListener *listener)
Modifies the PublisherListener, sets the mask to StatusMask::all()
PublisherImpl * impl_
Definition Publisher.hpp:463
FASTDDS_EXPORTED_API const PublisherListener * get_listener() const
Retrieves the attached PublisherListener.
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...
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 ...
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.
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.
FASTDDS_EXPORTED_API const DomainParticipant * get_participant() const
This operation returns the DomainParticipant to which the Publisher belongs.
FASTDDS_EXPORTED_API ReturnCode_t delete_contained_entities()
Deletes all contained DataWriters.
Publisher(DomainParticipant *dp, const PublisherQos &qos=PUBLISHER_QOS_DEFAULT, PublisherListener *listener=nullptr, const StatusMask &mask=StatusMask::all())
FASTDDS_EXPORTED_API ReturnCode_t enable() override
This operation enables the Publisher.
friend class PublisherImpl
Definition Publisher.hpp:64
FASTDDS_EXPORTED_API ReturnCode_t set_listener(PublisherListener *listener, const StatusMask &mask)
Modifies the PublisherListener.
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...
FASTDDS_EXPORTED_API ReturnCode_t resume_publications()
Indicates to FastDDS that the modifications to the DataWriters are complete.
FASTDDS_EXPORTED_API bool get_datawriters(std::vector< DataWriter * > &writers) const
Fills the given vector with all the datawriters of this publisher.
FASTDDS_EXPORTED_API ReturnCode_t suspend_publications()
Indicates to FastDDS that the contained DataWriters are about to be modified.
friend class DomainParticipantImpl
Definition Publisher.hpp:65
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...
FASTDDS_EXPORTED_API ReturnCode_t end_coherent_changes()
Signals the end of a set of coherent cache changes.
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...
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...
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...
FASTDDS_EXPORTED_API ReturnCode_t get_qos(PublisherQos &qos) const
Retrieves the Publisher Qos.
Class PublisherListener, allows the end user to implement callbacks triggered by certain events.
Definition PublisherListener.hpp:39
Class PublisherQos, containing all the possible Qos that can be set for a determined Publisher.
Definition PublisherQos.hpp:39
StatusMask is a bitmap or bitset field.
Definition StatusMask.hpp:48
static StatusMask all()
Get all StatusMasks.
Definition StatusMask.hpp:104
Class Topic, represents the fact that both publications and subscriptions are tied to a single data-t...
Definition Topic.hpp:53
Class TopicQos, containing all the possible Qos that can be set for a determined Topic.
Definition TopicQos.hpp:40
Definition DomainParticipant.hpp:45
FASTDDS_EXPORTED_API const PublisherQos PUBLISHER_QOS_DEFAULT
int32_t ReturnCode_t
Definition DDSReturnCode.hpp:59
eProsima namespace.
Structure Time_t, used to describe times at a DDS level.
Definition Time_t.hpp:36
Struct InstanceHandle_t, used to contain the key for WITH_KEY topics.
Definition InstanceHandle.hpp:154