| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
DataWriter.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_PUBLISHER__DATAWRITER_HPP
20#define FASTDDS_DDS_PUBLISHER__DATAWRITER_HPP
21
22#include <fastdds/dds/builtin/topic/PublicationBuiltinTopicData.hpp>
23#include <fastdds/dds/builtin/topic/SubscriptionBuiltinTopicData.hpp>
24#include <fastdds/dds/core/Entity.hpp>
25#include <fastdds/dds/core/ReturnCode.hpp>
26#include <fastdds/dds/core/status/BaseStatus.hpp>
27#include <fastdds/dds/core/status/DeadlineMissedStatus.hpp>
28#include <fastdds/dds/core/status/IncompatibleQosStatus.hpp>
29#include <fastdds/dds/core/status/PublicationMatchedStatus.hpp>
30#include <fastdds/dds/core/status/StatusMask.hpp>
31#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
32#include <fastdds/fastdds_dll.hpp>
33#include <fastdds/rtps/common/LocatorList.hpp>
34#include <fastdds/rtps/common/Time_t.hpp>
35
36 namespace eprosima {
37 namespace fastdds {
38 namespace rtps {
39
40 class WriteParams;
41 struct GUID_t;
42
43} // namespace rtps
44
45 namespace dds {
46
47 class DataReader;
48 class PublisherListener;
49 class PublisherImpl;
50 class Publisher;
51
52 class TypeSupport;
53
54 class DataWriterImpl;
55 class DataWriterListener;
56 class DataWriterQos;
57 class Topic;
58
59 struct IContentFilter;
60
66 class DataWriter : public DomainEntity
67{
68 protected:
69
70 friend class PublisherImpl;
71 friend class DataWriterImpl;
72
77 DataWriter(
78 DataWriterImpl* impl,
79 const StatusMask& mask = StatusMask::all());
80
81 DataWriter(
82 Publisher* pub,
83 Topic* topic,
84 const DataWriterQos& qos = DATAWRITER_QOS_DEFAULT,
85 DataWriterListener* listener = nullptr,
86 const StatusMask& mask = StatusMask::all());
87
88 public:
89
93 enum class LoanInitializationKind
94 {
102 NO_LOAN_INITIALIZATION,
103
110 ZERO_LOAN_INITIALIZATION,
111
118 CONSTRUCTED_LOAN_INITIALIZATION
119 };
120
121 virtual ~DataWriter();
122
129 FASTDDS_EXPORTED_API ReturnCode_t enable() override;
130
137 FASTDDS_EXPORTED_API ReturnCode_t write(
138 const void* const data);
139
147 FASTDDS_EXPORTED_API ReturnCode_t write(
148 const void* const data,
149 fastdds::rtps::WriteParams& params);
150
162 FASTDDS_EXPORTED_API ReturnCode_t write(
163 const void* const data,
164 const InstanceHandle_t& handle);
165
182 FASTDDS_EXPORTED_API ReturnCode_t write_w_timestamp(
183 const void* const data,
184 const InstanceHandle_t& handle,
185 const fastdds::dds::Time_t& timestamp);
186
196 FASTDDS_EXPORTED_API InstanceHandle_t register_instance(
197 const void* const instance);
198
217 FASTDDS_EXPORTED_API InstanceHandle_t register_instance_w_timestamp(
218 const void* const instance,
219 const fastdds::dds::Time_t& timestamp);
220
232 FASTDDS_EXPORTED_API ReturnCode_t unregister_instance(
233 const void* const instance,
234 const InstanceHandle_t& handle);
235
255 FASTDDS_EXPORTED_API ReturnCode_t unregister_instance_w_timestamp(
256 const void* const instance,
257 const InstanceHandle_t& handle,
258 const fastdds::dds::Time_t& timestamp);
259
274 FASTDDS_EXPORTED_API ReturnCode_t get_key_value(
275 void* key_holder,
276 const InstanceHandle_t& handle);
277
289 FASTDDS_EXPORTED_API InstanceHandle_t lookup_instance(
290 const void* const instance) const;
291
297 FASTDDS_EXPORTED_API const fastdds::rtps::GUID_t& guid() const;
298
304 FASTDDS_EXPORTED_API InstanceHandle_t get_instance_handle() const;
305
311 FASTDDS_EXPORTED_API TypeSupport get_type() const;
312
319 FASTDDS_EXPORTED_API ReturnCode_t wait_for_acknowledgments(
320 const fastdds::dds::Duration_t& max_wait);
321
328 FASTDDS_EXPORTED_API ReturnCode_t get_offered_deadline_missed_status(
329 OfferedDeadlineMissedStatus& status);
330
337 FASTDDS_EXPORTED_API ReturnCode_t get_offered_incompatible_qos_status(
338 OfferedIncompatibleQosStatus& status);
339
346 FASTDDS_EXPORTED_API ReturnCode_t get_publication_matched_status(
347 PublicationMatchedStatus& status) const;
348
356 FASTDDS_EXPORTED_API ReturnCode_t set_qos(
357 const DataWriterQos& qos);
358
364 FASTDDS_EXPORTED_API const DataWriterQos& get_qos() const;
365
372 FASTDDS_EXPORTED_API ReturnCode_t get_qos(
373 DataWriterQos& qos) const;
374
380 FASTDDS_EXPORTED_API Topic* get_topic() const;
381
387 FASTDDS_EXPORTED_API const DataWriterListener* get_listener() const;
388
395 FASTDDS_EXPORTED_API ReturnCode_t set_listener(
396 DataWriterListener* listener);
397
405 FASTDDS_EXPORTED_API ReturnCode_t set_listener(
406 DataWriterListener* listener,
407 const StatusMask& mask);
408
424 FASTDDS_EXPORTED_API ReturnCode_t dispose(
425 const void* const data,
426 const InstanceHandle_t& handle);
427
448 FASTDDS_EXPORTED_API ReturnCode_t dispose_w_timestamp(
449 const void* const instance,
450 const InstanceHandle_t& handle,
451 const fastdds::dds::Time_t& timestamp);
458 FASTDDS_EXPORTED_API ReturnCode_t get_liveliness_lost_status(
459 LivelinessLostStatus& status);
460
466 FASTDDS_EXPORTED_API const Publisher* get_publisher() const;
467
480 FASTDDS_EXPORTED_API ReturnCode_t assert_liveliness();
481
491 FASTDDS_EXPORTED_API ReturnCode_t get_matched_subscription_data(
492 SubscriptionBuiltinTopicData& subscription_data,
493 const InstanceHandle_t& subscription_handle) const;
494
503 FASTDDS_EXPORTED_API ReturnCode_t get_matched_subscriptions(
504 std::vector<InstanceHandle_t>& subscription_handles) const;
505
512 FASTDDS_EXPORTED_API ReturnCode_t clear_history(
513 size_t* removed);
514
540 FASTDDS_EXPORTED_API ReturnCode_t loan_sample(
541 void*& sample,
542 LoanInitializationKind initialization = LoanInitializationKind::NO_LOAN_INITIALIZATION);
543
556 FASTDDS_EXPORTED_API ReturnCode_t discard_loan(
557 void*& sample);
558
567 FASTDDS_EXPORTED_API ReturnCode_t get_sending_locators(
568 rtps::LocatorList& locators) const;
569
586 FASTDDS_EXPORTED_API ReturnCode_t wait_for_acknowledgments(
587 const void* const instance,
588 const InstanceHandle_t& handle,
589 const fastdds::dds::Duration_t& max_wait);
590
599 FASTDDS_EXPORTED_API ReturnCode_t get_publication_builtin_topic_data(
600 PublicationBuiltinTopicData& publication_data) const;
601
614 FASTDDS_EXPORTED_API ReturnCode_t set_sample_prefilter(
615 std::shared_ptr<IContentFilter> prefilter);
616
632 FASTDDS_EXPORTED_API ReturnCode_t set_related_datareader(
633 const DataReader* related_reader);
634
635 protected:
636
637 DataWriterImpl* impl_;
638};
639
640} // namespace dds
641} // namespace fastdds
642} // namespace eprosima
643
644#endif // FASTDDS_DDS_PUBLISHER__DATAWRITER_HPP
eprosima::fastdds::dds::DataReader
Class DataReader, contains the actual implementation of the behaviour of the Subscriber.
Definition DataReader.hpp:83
eprosima::fastdds::dds::DataWriter::set_listener
FASTDDS_EXPORTED_API ReturnCode_t set_listener(DataWriterListener *listener, const StatusMask &mask)
Modifies the DataWriterListener.
eprosima::fastdds::dds::DataWriter::discard_loan
FASTDDS_EXPORTED_API ReturnCode_t discard_loan(void *&sample)
Discards a loaned sample pointer.
eprosima::fastdds::dds::DataWriter::get_liveliness_lost_status
FASTDDS_EXPORTED_API ReturnCode_t get_liveliness_lost_status(LivelinessLostStatus &status)
Returns the liveliness lost status.
eprosima::fastdds::dds::DataWriter::register_instance_w_timestamp
FASTDDS_EXPORTED_API InstanceHandle_t register_instance_w_timestamp(const void *const instance, const fastdds::dds::Time_t &timestamp)
This operation performs the same function as register_instance and can be used instead of register_in...
eprosima::fastdds::dds::DataWriter::dispose
FASTDDS_EXPORTED_API ReturnCode_t dispose(const void *const data, const InstanceHandle_t &handle)
This operation requests the middleware to delete the data (the actual deletion is postponed until the...
eprosima::fastdds::dds::DataWriter::set_related_datareader
FASTDDS_EXPORTED_API ReturnCode_t set_related_datareader(const DataReader *related_reader)
This operation sets the key of the DataReader that is related to this DataWriter.
eprosima::fastdds::dds::DataWriter::write
FASTDDS_EXPORTED_API ReturnCode_t write(const void *const data, fastdds::rtps::WriteParams &params)
Write data with params to the topic.
eprosima::fastdds::dds::DataWriter::get_topic
FASTDDS_EXPORTED_API Topic * get_topic() const
Retrieves the topic for this DataWriter.
eprosima::fastdds::dds::DataWriter::get_publisher
FASTDDS_EXPORTED_API const Publisher * get_publisher() const
Getter for the Publisher that creates this DataWriter.
eprosima::fastdds::dds::DataWriter::set_qos
FASTDDS_EXPORTED_API ReturnCode_t set_qos(const DataWriterQos &qos)
Establishes the DataWriterQos for this DataWriter.
eprosima::fastdds::dds::DataWriter::assert_liveliness
FASTDDS_EXPORTED_API ReturnCode_t assert_liveliness()
This operation manually asserts the liveliness of the DataWriter.
eprosima::fastdds::dds::DataWriter::DataWriterImpl
friend class DataWriterImpl
Definition DataWriter.hpp:71
eprosima::fastdds::dds::DataWriter::write
FASTDDS_EXPORTED_API ReturnCode_t write(const void *const data)
Write data to the topic.
eprosima::fastdds::dds::DataWriter::loan_sample
FASTDDS_EXPORTED_API ReturnCode_t loan_sample(void *&sample, LoanInitializationKind initialization=LoanInitializationKind::NO_LOAN_INITIALIZATION)
Get a pointer to the internal pool where the user could directly write.
eprosima::fastdds::dds::DataWriter::DataWriter
DataWriter(DataWriterImpl *impl, const StatusMask &mask=StatusMask::all())
Create a data writer, assigning its pointer to the associated implementation.
eprosima::fastdds::dds::DataWriter::impl_
DataWriterImpl * impl_
Definition DataWriter.hpp:637
eprosima::fastdds::dds::DataWriter::DataWriter
DataWriter(Publisher *pub, Topic *topic, const DataWriterQos &qos=DATAWRITER_QOS_DEFAULT, DataWriterListener *listener=nullptr, const StatusMask &mask=StatusMask::all())
eprosima::fastdds::dds::DataWriter::get_matched_subscription_data
FASTDDS_EXPORTED_API ReturnCode_t get_matched_subscription_data(SubscriptionBuiltinTopicData &subscription_data, const InstanceHandle_t &subscription_handle) const
Retrieves in a subscription associated with the DataWriter.
eprosima::fastdds::dds::DataWriter::get_publication_matched_status
FASTDDS_EXPORTED_API ReturnCode_t get_publication_matched_status(PublicationMatchedStatus &status) const
Returns the publication matched status.
eprosima::fastdds::dds::DataWriter::unregister_instance
FASTDDS_EXPORTED_API ReturnCode_t unregister_instance(const void *const instance, const InstanceHandle_t &handle)
This operation reverses the action of register_instance.
eprosima::fastdds::dds::DataWriter::get_type
FASTDDS_EXPORTED_API TypeSupport get_type() const
Get data type associated to the DataWriter.
eprosima::fastdds::dds::DataWriter::lookup_instance
FASTDDS_EXPORTED_API InstanceHandle_t lookup_instance(const void *const instance) const
NOT YET IMPLEMENTED.
eprosima::fastdds::dds::DataWriter::get_key_value
FASTDDS_EXPORTED_API ReturnCode_t get_key_value(void *key_holder, const InstanceHandle_t &handle)
This operation can be used to retrieve the instance key that corresponds to an instance_handle.
eprosima::fastdds::dds::DataWriter::~DataWriter
virtual ~DataWriter()
eprosima::fastdds::dds::DataWriter::guid
FASTDDS_EXPORTED_API const fastdds::rtps::GUID_t & guid() const
Returns the DataWriter's GUID.
eprosima::fastdds::dds::DataWriter::get_qos
FASTDDS_EXPORTED_API const DataWriterQos & get_qos() const
Retrieves the DataWriterQos for this DataWriter.
eprosima::fastdds::dds::DataWriter::LoanInitializationKind
LoanInitializationKind
How to initialize samples loaned with loan_sample.
Definition DataWriter.hpp:94
eprosima::fastdds::dds::DataWriter::LoanInitializationKind::ZERO_LOAN_INITIALIZATION
@ ZERO_LOAN_INITIALIZATION
Initialize all memory with zero-valued bytes.
Definition DataWriter.hpp:110
eprosima::fastdds::dds::DataWriter::LoanInitializationKind::NO_LOAN_INITIALIZATION
@ NO_LOAN_INITIALIZATION
Do not perform initialization of sample.
Definition DataWriter.hpp:102
eprosima::fastdds::dds::DataWriter::LoanInitializationKind::CONSTRUCTED_LOAN_INITIALIZATION
@ CONSTRUCTED_LOAN_INITIALIZATION
Use in-place constructor initialization.
Definition DataWriter.hpp:118
eprosima::fastdds::dds::DataWriter::get_sending_locators
FASTDDS_EXPORTED_API ReturnCode_t get_sending_locators(rtps::LocatorList &locators) const
Get the list of locators from which this DataWriter may send data.
eprosima::fastdds::dds::DataWriter::get_instance_handle
FASTDDS_EXPORTED_API InstanceHandle_t get_instance_handle() const
Returns the DataWriter's InstanceHandle.
eprosima::fastdds::dds::DataWriter::unregister_instance_w_timestamp
FASTDDS_EXPORTED_API ReturnCode_t unregister_instance_w_timestamp(const void *const instance, const InstanceHandle_t &handle, const fastdds::dds::Time_t &timestamp)
This operation performs the same function as unregister_instance and can be used instead of unregiste...
eprosima::fastdds::dds::DataWriter::get_offered_incompatible_qos_status
FASTDDS_EXPORTED_API ReturnCode_t get_offered_incompatible_qos_status(OfferedIncompatibleQosStatus &status)
Returns the offered incompatible qos status.
eprosima::fastdds::dds::DataWriter::set_listener
FASTDDS_EXPORTED_API ReturnCode_t set_listener(DataWriterListener *listener)
Modifies the DataWriterListener, sets the mask to StatusMask::all().
eprosima::fastdds::dds::DataWriter::get_publication_builtin_topic_data
FASTDDS_EXPORTED_API ReturnCode_t get_publication_builtin_topic_data(PublicationBuiltinTopicData &publication_data) const
Retrieve the publication data discovery information.
eprosima::fastdds::dds::DataWriter::register_instance
FASTDDS_EXPORTED_API InstanceHandle_t register_instance(const void *const instance)
Informs that the application will be modifying a particular instance.
eprosima::fastdds::dds::DataWriter::set_sample_prefilter
FASTDDS_EXPORTED_API ReturnCode_t set_sample_prefilter(std::shared_ptr< IContentFilter > prefilter)
Set a sample prefilter to be used.
eprosima::fastdds::dds::DataWriter::dispose_w_timestamp
FASTDDS_EXPORTED_API ReturnCode_t dispose_w_timestamp(const void *const instance, const InstanceHandle_t &handle, const fastdds::dds::Time_t &timestamp)
This operation performs the same functions as dispose except that the application provides the value ...
eprosima::fastdds::dds::DataWriter::enable
FASTDDS_EXPORTED_API ReturnCode_t enable() override
This operation enables the DataWriter.
eprosima::fastdds::dds::DataWriter::get_matched_subscriptions
FASTDDS_EXPORTED_API ReturnCode_t get_matched_subscriptions(std::vector< InstanceHandle_t > &subscription_handles) const
Fills the given vector with the InstanceHandle_t of matched DataReaders.
eprosima::fastdds::dds::DataWriter::write
FASTDDS_EXPORTED_API ReturnCode_t write(const void *const data, const InstanceHandle_t &handle)
Write data with handle.
eprosima::fastdds::dds::DataWriter::PublisherImpl
friend class PublisherImpl
Definition DataWriter.hpp:70
eprosima::fastdds::dds::DataWriter::get_listener
FASTDDS_EXPORTED_API const DataWriterListener * get_listener() const
Retrieves the listener for this DataWriter.
eprosima::fastdds::dds::DataWriter::wait_for_acknowledgments
FASTDDS_EXPORTED_API ReturnCode_t wait_for_acknowledgments(const void *const instance, const InstanceHandle_t &handle, const fastdds::dds::Duration_t &max_wait)
Block the current thread until the writer has received the acknowledgment corresponding to the given ...
eprosima::fastdds::dds::DataWriter::get_offered_deadline_missed_status
FASTDDS_EXPORTED_API ReturnCode_t get_offered_deadline_missed_status(OfferedDeadlineMissedStatus &status)
Returns the offered deadline missed status.
eprosima::fastdds::dds::DataWriter::wait_for_acknowledgments
FASTDDS_EXPORTED_API ReturnCode_t wait_for_acknowledgments(const fastdds::dds::Duration_t &max_wait)
Waits the current thread until all writers have received their acknowledgments.
eprosima::fastdds::dds::DataWriter::write_w_timestamp
FASTDDS_EXPORTED_API ReturnCode_t write_w_timestamp(const void *const data, const InstanceHandle_t &handle, const fastdds::dds::Time_t &timestamp)
This operation performs the same function as write except that it also provides the value for the sou...
eprosima::fastdds::dds::DataWriter::clear_history
FASTDDS_EXPORTED_API ReturnCode_t clear_history(size_t *removed)
Clears the DataWriter history.
eprosima::fastdds::dds::DataWriter::get_qos
FASTDDS_EXPORTED_API ReturnCode_t get_qos(DataWriterQos &qos) const
Fills the DataWriterQos with the values of this DataWriter.
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::Publisher
Class Publisher, used to send data to associated subscribers.
Definition Publisher.hpp:61
eprosima::fastdds::dds::PublisherListener
Class PublisherListener, allows the end user to implement callbacks triggered by certain events.
Definition PublisherListener.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::TypeSupport
Class TypeSupport used to provide the DomainRTPSParticipant with the methods to serialize,...
Definition TypeSupport.hpp:47
eprosima::fastdds::rtps::LocatorList
Class LocatorList, a Locator vector that doesn't allow duplicates.
Definition LocatorList.hpp:97
eprosima::fastdds::rtps::WriteParams
This class contains additional information of a CacheChange.
Definition WriteParams.hpp:36
eprosima::fastdds::dds
Definition BuiltinTopicKey.hpp:26
eprosima::fastdds::dds::LivelinessLostStatus
BaseStatus LivelinessLostStatus
Alias of BaseStatus.
Definition BaseStatus.hpp:41
eprosima::fastdds::dds::OfferedIncompatibleQosStatus
IncompatibleQosStatus OfferedIncompatibleQosStatus
Alias of IncompatibleQosStatus.
Definition IncompatibleQosStatus.hpp:90
eprosima::fastdds::dds::OfferedDeadlineMissedStatus
DeadlineMissedStatus OfferedDeadlineMissedStatus
Typedef of DeadlineMissedStatus.
Definition DeadlineMissedStatus.hpp:57
eprosima::fastdds::dds::SubscriptionBuiltinTopicData
rtps::SubscriptionBuiltinTopicData SubscriptionBuiltinTopicData
Definition SubscriptionBuiltinTopicData.hpp:28
eprosima::fastdds::dds::InstanceHandle_t
eprosima::fastdds::rtps::InstanceHandle_t InstanceHandle_t
Definition InstanceHandle.hpp:31
eprosima::fastdds::dds::DATAWRITER_QOS_DEFAULT
FASTDDS_EXPORTED_API const DataWriterQos DATAWRITER_QOS_DEFAULT
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::fastdds::dds::PublicationBuiltinTopicData
rtps::PublicationBuiltinTopicData PublicationBuiltinTopicData
Definition PublicationBuiltinTopicData.hpp:28
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::dds::IContentFilter
The interface that content filter objects should implement.
Definition IContentFilter.hpp:37
eprosima::fastdds::dds::PublicationMatchedStatus
A structure storing the publication status.
Definition PublicationMatchedStatus.hpp:32
eprosima::fastdds::dds::Time_t
Structure Time_t, used to describe times at a DDS level.
Definition Time_t.hpp:36
eprosima::fastdds::rtps::GUID_t
Structure GUID_t, entity identifier, unique in DDS-RTPS Domain.
Definition Guid.hpp:40