RTI Connext Modern C++ API  Version 6.0.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dds::pub::DataWriter< T > Class Template Reference

<<reference-type>> Allows an application to publish data for a dds::topic::Topic More...

#include <dds/pub/DataWriter.hpp>

Inheritance diagram for dds::pub::DataWriter< T >:
dds::core::Entity

Public Member Functions

 DataWriter (const dds::pub::Publisher &pub, const dds::topic::Topic< T > &the_topic)
 Creates a DataWriter.
 
 DataWriter (const dds::pub::Publisher &pub, const dds::topic::Topic< T > &the_topic, const dds::pub::qos::DataWriterQos &the_qos, dds::pub::DataWriterListener< T > *the_listener=NULL, const dds::core::status::StatusMask &mask=dds::core::status::StatusMask::all())
 Creates a DataWriter with QoS and listener.
 
void write (const T &instance_data)
 Modifies the value of a data instance.
 
void write (const T &instance_data, const dds::core::Time &timestamp)
 Modifies the value of a data instance and specifies the timestamp.
 
void write (const T &instance_data, const dds::core::InstanceHandle &handle)
 Modifies the value of a data instance.
 
void write (const T &instance_data, const dds::core::InstanceHandle &handle, const dds::core::Time &source_timestamp)
 Modifies the value of a data instance and specifies the timestamp.
 
void write (const dds::topic::TopicInstance< T > &topic_instance)
 Write a dds::topic::TopicInstance.
 
void write (const dds::topic::TopicInstance< T > &topic_instance, const dds::core::Time &timestamp)
 Write a topic instance with time stamp.
 
template<typename FWIterator >
void write (const FWIterator &begin, const FWIterator &end)
 
template<typename FWIterator >
void write (const FWIterator &begin, const FWIterator &end, const dds::core::Time &timestamp)
 
template<typename SamplesFWIterator , typename HandlesFWIterator >
void write (const SamplesFWIterator &data_begin, const SamplesFWIterator &data_end, const HandlesFWIterator &handle_begin, const HandlesFWIterator &handle_end)
 Write a series of samples and their parallel instance handles.
 
template<typename SamplesFWIterator , typename HandlesFWIterator >
void write (const SamplesFWIterator &data_begin, const SamplesFWIterator &data_end, const HandlesFWIterator &handle_begin, const HandlesFWIterator &handle_end, const dds::core::Time &timestamp)
 Write a series of samples and their parallel instance handles and a timestamp.
 
DataWriteroperator<< (const T &data)
 Writes a sample.
 
DataWriteroperator<< (const std::pair< T, dds::core::Time > &data)
 Writes a sample with a timestamp.
 
DataWriteroperator<< (const std::pair< T, dds::core::InstanceHandle > &data)
 Writes a sample with an instance handle.
 
const dds::core::InstanceHandle register_instance (const T &instance_data)
 Informs RTI Connext that the application will be modifying a particar instance.
 
const dds::core::InstanceHandle register_instance (const T &instance_data, const dds::core::Time &source_timestamp)
 Informs RTI Connext that the application will be modifying a particular instance and specifies the timestamp.
 
DataWriterunregister_instance (const dds::core::InstanceHandle &handle)
 Unregister an instance.
 
DataWriterunregister_instance (const dds::core::InstanceHandle &handle, const dds::core::Time &source_timestamp)
 Unregister an instance with timestamp.
 
DataWriterdispose_instance (const dds::core::InstanceHandle &handle)
 Dispose an instance.
 
DataWriterdispose_instance (const dds::core::InstanceHandle &the_instance_handle, const dds::core::Time &source_timestamp)
 Dispose an instance with a timestamp.
 
T & key_value (T &key_holder, const dds::core::InstanceHandle &handle)
 Retrieve the instance key that corresponds to an instance handle.
 
dds::topic::TopicInstance< T > & key_value (dds::topic::TopicInstance< T > &key_holder, const dds::core::InstanceHandle &handle)
 Retrieve the instance key that corresponds to an instance handle.
 
dds::core::InstanceHandle lookup_instance (const T &key_holder)
 Retrieve the instance handle that corresponds to an instance key_holder.
 
dds::pub::qos::DataWriterQos qos () const
 Gets the DataWriterQos.
 
void qos (const dds::pub::qos::DataWriterQos &the_qos)
 Sets the DataWriterQos.
 
DataWriteroperator<< (const dds::pub::qos::DataWriterQos &the_qos)
 Set the DataWriterQos.
 
const DataWriteroperator>> (dds::pub::qos::DataWriterQos &the_qos) const
 Get the DataWriterQos.
 
const dds::topic::Topic< T > & topic () const
 Get the Topic associated with this DataWriter.
 
const dds::pub::Publisherpublisher () const
 Get the Publisher that owns this DataWriter.
 
void wait_for_acknowledgments (const dds::core::Duration &max_wait)
 Blocks the calling thread until all data written by reliable DataWriter entity is acknowledged, or until timeout expires.
 
void listener (DataWriterListener< T > *l, const dds::core::status::StatusMask &mask)
 Sets the DataWriter listener.
 
DataWriterListener< T > * listener () const
 Returns the listener currently associated with this DataWriter.
 
const
dds::core::status::LivelinessLostStatus 
liveliness_lost_status ()
 Get the LivelinessLostStatus.
 
const
dds::core::status::OfferedDeadlineMissedStatus 
offered_deadline_missed_status ()
 Get the OfferedDeadlineMissedStatus.
 
const
dds::core::status::OfferedIncompatibleQosStatus 
offered_incompatible_qos_status ()
 Get the OfferedIncompatibleQosStatus.
 
const
dds::core::status::PublicationMatchedStatus 
publication_matched_status ()
 Get the PublicationMatchedStatus.
 
void assert_liveliness ()
 Manually asserts the liveliness of this DataWriter.
 
void unregister_instance (rti::pub::WriteParams &params)
 <<extension>> Unregister an instance with parameters
 
void dispose_instance (rti::pub::WriteParams &params)
 <<extension>> Dispose an instance with parameters
 
bool is_sample_app_acknowledged (const rti::core::SampleIdentity &sample_id)
 <<extension>> Indicates if a sample is considered application-acknowledged
 
void wait_for_asynchronous_publishing (const dds::core::Duration &max_wait)
 <<extension>>
 
rti::core::status::ReliableWriterCacheChangedStatus reliable_writer_cache_changed_status ()
 <<extension>> Get the reliable cache status for this writer.
 
rti::core::status::ReliableReaderActivityChangedStatus reliable_reader_activity_changed_status ()
 <<extension>> Get the reliable reader activity changed status for this writer
 
rti::core::status::DataWriterCacheStatus datawriter_cache_status ()
 <<extension>> Get the cache status for this writer
 
rti::core::status::DataWriterProtocolStatus datawriter_protocol_status ()
 <<extension>> Get the protocol status for this writer
 
rti::core::status::DataWriterProtocolStatus matched_subscription_datawriter_protocol_status (const dds::core::InstanceHandle &subscription_handle)
 <<extension>> Get the datawriter protocol status for this writer, per matched subscription identified by the subscription_handle.
 
rti::core::status::DataWriterProtocolStatus matched_subscription_datawriter_protocol_status (const rti::core::Locator &subscription_locator)
 <<extension>> Get the datawriter protocol status for this writer, per matched subscription identified by the locator
 
rti::core::status::ServiceRequestAcceptedStatus service_request_accepted_status ()
 <<extension>> Get the service request accepted status for this writer
 
void flush ()
 <<extension>> Flushes the batch in progress in the context of the calling thread.
 
void write (const T &instance_data, rti::pub::WriteParams &params)
 <<extension>> Write with advanced parameters
 
T * create_data ()
 <<extension>> Create data from writer and initialize it
 
bool delete_data (T *sample)
 <<extension>> Delete data from writer
 
T * get_loan ()
 <<extension>> Get a loaned sample from this writer
 
void discard_loan (T &sample)
 <<extension>> Discard a loaned sample from this writer
 
const dds::core::InstanceHandle register_instance (const T &key, rti::pub::WriteParams &params)
 <<extension>> Registers and instance with parameters
 
- Public Member Functions inherited from dds::core::Entity
void enable ()
 Enables this entity (if it was created disabled)
 
const dds::core::status::StatusMask status_changes ()
 Retrieves the list of communication statuses that are triggered.
 
const dds::core::InstanceHandle instance_handle () const
 Get the instance handle that represents this entity.
 
void close ()
 Forces the destruction of this entity.
 
void retain ()
 Disables the automatic destruction of this entity.
 

Related Functions

(Note that these are not member functions.)

void ignore (dds::domain::DomainParticipant &participant, const dds::core::InstanceHandle &handle)
 Instructs RTI Connext to locally ignore a publication.
 
template<typename FwdIterator >
void ignore (dds::domain::DomainParticipant &participant, FwdIterator begin, FwdIterator end)
 Instructs RTI Connext to locally ignore several publications.
 
template<typename T >
dds::core::InstanceHandleSeq matched_subscriptions (const dds::pub::DataWriter< T > &writer)
 Retrieve the list of subscriptions currently associated with a dds::pub::DataWriter.
 
template<typename T , typename FwdIterator >
FwdIterator matched_subscriptions (const dds::pub::DataWriter< T > &writer, FwdIterator begin, FwdIterator end)
 Retrieve the list of subscriptions currently associated with a dds::pub::DataWriter.
 
template<typename T >
const
dds::topic::SubscriptionBuiltinTopicData 
matched_subscription_data (const dds::pub::DataWriter< T > &writer, const dds::core::InstanceHandle &subscription_handle)
 Retrieves information on a subscription that is currently associated with a dds::pub::DataWriter.
 
template<typename Writer , typename FwdIterator >
uint32_t find (const dds::pub::Publisher &publisher, const std::string &topic_name, FwdIterator begin, uint32_t max_size)
 Retrieves the dds::pub::DataWriter for a specific topic name.
 
template<typename Writer , typename BinIterator >
uint32_t find (const dds::pub::Publisher &publisher, const std::string &topic_name, BinIterator begin)
 Retrieves the dds::pub::DataWriter for a specific topic name.
 
template<typename AnyDataWriterBackInsertIterator >
uint32_t find_datawriters (dds::pub::Publisher publisher, AnyDataWriterBackInsertIterator begin)
 Retrieve all the dds::pub::DataWriter created from this dds::pub::Publisher.
 
template<typename AnyDataWriterForwardIterator >
uint32_t find_datawriters (dds::pub::Publisher publisher, AnyDataWriterForwardIterator begin, uint32_t max_size)
 Retrieve all the dds::pub::DataWriter created from this dds::pub::Publisher.
 
template<typename Writer >
Writer find_datawriter_by_topic_name (dds::pub::Publisher publisher, const std::string &topic_name)
 <<extension>> Retrieves a dds::pub::DataWriter with the given name within the dds::pub::Publisher
 
template<typename Writer >
Writer find_datawriter_by_name (dds::pub::Publisher publisher, const std::string &datawriter_name)
 <<extension>> Retrieves a dds::pub::DataWriter with the given name within the dds::pub::Publisher
 
template<typename Writer >
Writer find_datawriter_by_name (dds::domain::DomainParticipant participant, const std::string &datawriter_name)
 <<extension>> Retrieves a dds::pub::DataWriter within the dds::domain::DomainParticipant with the given name
 

Detailed Description

template<typename T>
class dds::pub::DataWriter< T >

<<reference-type>> Allows an application to publish data for a dds::topic::Topic

Template Parameters
TThe topic-type that the DataWriter publishes
QoS:
dds::pub::qos::DataWriterQos
Status:
dds::core::status::StatusMask::liveliness_lost(), dds::core::status::LivelinessLostStatus;
dds::core::status::StatusMask::offered_deadline_missed(), dds::core::status::OfferedDeadlineMissedStatus;
dds::core::status::StatusMask::offered_incompatible_qos(), dds::core::status::OfferedIncompatibleQosStatus;
dds::core::status::StatusMask::publication_matched(), dds::core::status::PublicationMatchedStatus;
dds::core::status::StatusMask::reliable_reader_activity_changed(), rti::core::status::ReliableReaderActivityChangedStatus;
dds::core::status::StatusMask::reliable_writer_cache_changed(), rti::core::status::ReliableWriterCacheChangedStatus.
Listener:
dds::pub::DataWriterListener

A dds::pub::DataWriter is attached to exactly one dds::pub::Publisher, that acts as a factory for it.

A dds::pub::DataWriter is bound to exactly one dds::topic::Topic and therefore to exactly one data type. The dds::topic::Topic must exist prior to the dds::pub::DataWriter's creation.

The following operations may be called even if the dds::pub::DataWriter is not enabled. Other operations will fail with dds::core::NotEnabledError if called on a disabled dds::pub::DataWriter:

Several dds::pub::DataWriter may operate in different threads. If they share the same dds::pub::Publisher, the middleware guarantees that its operations are thread-safe.

See Also
Operations Allowed in Listener Callbacks

Notes about DataWriter destruction

The deletion of the dds::pub::DataWriter will automatically unregister all instances. Depending on the settings of the WRITER_DATA_LIFECYCLE QosPolicy, the deletion of the dds::pub::DataWriter may also dispose all instances.

If the DataWriter's dds::core::policy::DestinationOrder::kind is dds::core::policy::DestinationOrderKind::BY_SOURCE_TIMESTAMP, deleting the DataWriter may fail if your application has previously used the operations that receive a timestamp (dds::pub::DataWriter::write(const T&,const dds::core::Time&), dds::pub::DataWriter::register_instance(const T&, const dds::core::Time&), dds::pub::DataWriter::unregister_instance(const dds::core::InstanceHandle&,const dds::core::Time&), or dds::pub::DataWriter::dispose_instance(const dds::core::InstanceHandle&,const dds::core::Time&)) with a timestamp larger (later) than the time at which the writer is deleted. To prevent the deletion from failing in this situation, either:

The DataWriter destructor will not throw any exceptions even if the destruction fails. Calling close() will throw in case of failure One of the Standard Exceptions or dds::core::PreconditionNotMetError.

See Also
DataWriter Use Cases
Entity Use Cases
Examples:
Foo_publisher.cxx.

Constructor & Destructor Documentation

template<typename T>
dds::pub::DataWriter< T >::DataWriter ( const dds::pub::Publisher pub,
const dds::topic::Topic< T > &  the_topic 
)
inline

Creates a DataWriter.

It uses the default DataWriterQos, and sets no listener.

Parameters
pubThe publisher that this DataWriter belongs to
the_topicThe Topic associated with this DataWriter
See Also
DataWriter(const dds::pub::Publisher& pub,const dds::topic::Topic<T>& topic,const dds::pub::qos::DataWriterQos& qos,dds::pub::DataWriterListener<T>* listener,const dds::core::status::StatusMask& mask)
template<typename T>
dds::pub::DataWriter< T >::DataWriter ( const dds::pub::Publisher pub,
const dds::topic::Topic< T > &  the_topic,
const dds::pub::qos::DataWriterQos the_qos,
dds::pub::DataWriterListener< T > *  the_listener = NULL,
const dds::core::status::StatusMask mask = dds::core::status::StatusMask::all() 
)
inline

Creates a DataWriter with QoS and listener.

When a DataWriter is created, only those transports already registered are available to the DataWriter. See Built-in Transport Plugins for details on when a builtin transport is registered.

Precondition
If publisher is enabled, topic must have been enabled. Otherwise, this operation will fail and no DataWriter will be created.
The given dds::topic::Topic must have been created from the same participant as this publisher. If it was created from a different participant, this method will fail.
Parameters
pubThe publisher that this DataWriter belongs to
the_topicThe Topic associated with this DataWriter
the_qosQoS to be used for creating the new Datawriter.
the_listenerThe DataWriter listener. The caller owns the listener and is responsible for deleting it only after resetting it or after deleting the DataWriter.
maskChanges of communication status to be invoked on the listener
See Also
Specifying QoS on entities for information on setting QoS before entity creation
dds::pub::qos::DataWriterQos for rules on consistency among QoS
dds::core::QosProvider::datawriter_qos()
dds::pub::Publisher::default_datawriter_qos()
dds::pub::qos::DataWriterQos::operator=(const dds::topic::qos::TopicQos&) which allows assigning the contents of a TopicQos into a DataWriterQos
listener()

Member Function Documentation

template<typename T>
void dds::pub::DataWriter< T >::write ( const T &  instance_data)
inline

Modifies the value of a data instance.

This operations does the same as write(const T&, const dds::core::InstanceHandle&) except that it deduces the identity of the instance from instance_data (by means of the key).

Parameters
instance_dataThe data sample to write.
See Also
write(const T&, const dds::core::InstanceHandle&)
template<typename T>
void dds::pub::DataWriter< T >::write ( const T &  instance_data,
const dds::core::Time timestamp 
)
inline

Modifies the value of a data instance and specifies the timestamp.

See Also
void write(const T&, const dds::core::InstanceHandle&, const dds::core::Time&)
Notes about DataWriter destruction
template<typename T>
void dds::pub::DataWriter< T >::write ( const T &  instance_data,
const dds::core::InstanceHandle handle 
)
inline

Modifies the value of a data instance.

When this operation is used, RTI Connext will automatically supply the value of the source_timestamp that is made available to dds::sub::DataReader objects by means of the source_timestamp attribute inside the dds::sub::SampleInfo. (Refer to dds::sub::SampleInfo and DESTINATION_ORDER QoS policy for details).

As a side effect, this operation asserts liveliness on the dds::pub::DataWriter itself, the dds::pub::Publisher and the dds::domain::DomainParticipant.

Note that the special value dds::core::InstanceHandle::nil() can be used for the parameter handle. This indicates the identity of the instance should be automatically deduced from the instance_data (by means of the key).

If handle is any value other than dds::core::InstanceHandle::nil(), then it must correspond to an instance that has been registered. If there is no correspondence, the operation will fail with dds::core::InvalidArgumentError.

RTI Connext will not detect the error when the handle is any value other than dds::core::InstanceHandle::nil(), corresponds to an instance that has been registered, but does not correspond to the instance deduced from the instance_data (by means of the key). RTI Connext will treat as if the write() operation is for the instance as indicated by the handle.

This operation may block if the RELIABILITY kind is set to dds::core::policy::ReliabilityKind::RELIABLE and the modification would cause data to be lost or else cause one of the limits specified in the RESOURCE_LIMITS to be exceeded.

Specifically, this operation may block in the following situations (note that the list may not be exhaustive), even if its dds::core::policy::HistoryKind is dds::core::policy::HistoryKind::KEEP_LAST:

This operation may also block when using dds::core::policy::ReliabilityKind::BEST_EFFORT and rti::core::policy::PublishModeKind_def::ASYNCHRONOUS. In this case, the dds::pub::DataWriter will queue samples until they are sent by the asynchronous publishing thread. The number of samples that can be stored is determined by the dds::core::policy::History. If the asynchronous thread does not send samples fast enough (e.g., when using a slow rti::pub::FlowController), the queue may fill up. In that case, subsequent write calls will block.

If this operation does block for any of the above reasons, the RELIABILITY max_blocking_time configures the maximum time the write operation may block (waiting for space to become available). If max_blocking_time elapses before the dds::pub::DataWriter is able to store the modification without exceeding the limits, the operation will time out (dds::core::TimeoutError).

If there are no instance resources left, this operation may fail with dds::core::OutOfResourcesError. Calling dds::pub::DataWriter::unregister_instance may help freeing up some resources.

This operation will fail with dds::core::PreconditionNotMetError if the timestamp is less than the timestamp used in the last writer operation (register, unregister, dispose, or write, with either the automatically supplied timestamp or the application-provided timestamp).

If an instance obtained from dds::pub::DataWriter::get_loan is modified with this operation, then all instances modified thereafter should be from dds::pub::DataWriter::get_loan.

Parameters
instance_data<<in>> The data to write.
Parameters
handle<<in>> Either the handle returned by a previous call to dds::pub::DataWriter::register_instance, or else the special value dds::core::InstanceHandle::nil(). If T has a key, handle must represent a registered instance of type T. Otherwise, this method may fail with dds::core::InvalidArgumentError.
Exceptions
Oneof the Standard Exceptions, dds::core::TimeoutError, dds::core::PreconditionNotMetError, dds::core::OutOfResourcesError, or dds::core::NotEnabledError.
MT Safety:
It is UNSAFE to modify instance_data before the operation has finished. The operation is otherwise SAFE.
See Also
dds::sub::DataReader
dds::pub::DataWriter::write(const T&,const dds::core::Time&)
DESTINATION_ORDER
template<typename T>
void dds::pub::DataWriter< T >::write ( const T &  instance_data,
const dds::core::InstanceHandle handle,
const dds::core::Time source_timestamp 
)
inline

Modifies the value of a data instance and specifies the timestamp.

Explicitly provides the timestamp that will be available to the dds::sub::DataReader objects by means of the source_timestamp attribute inside the dds::sub::SampleInfo. (Refer to dds::sub::SampleInfo and DESTINATION_ORDER QoS policy for details)

The constraints on the values of the handle parameter and the corresponding error behavior are the same specified for the dds::pub::DataWriter::write() operation.

This operation may block and time out (dds::core::TimeoutError) under the same circumtances described for dds::pub::DataWriter::write().

If there are no instance resources left, this operation may fail with dds::core::OutOfResourcesError. Calling dds::pub::DataWriter::unregister_instance may help free up some resources.

This operation may fail with dds::core::InvalidArgumentError under the same circumstances described for the write operation.

Parameters
instance_data<<in>> The data to write.
handle<<in>> Either the handle returned by a previous call to dds::pub::DataWriter::register_instance, or else the special value dds::core::InstanceHandle::nil(). If T has a key, handle must represent a registered instance of type T. Otherwise, this method may fail with dds::core::InvalidArgumentError.
source_timestamp<<in>> When using dds::core::policy::DestinationOrderKind::BY_SOURCE_TIMESTAMP the timestamp value must be greater than or equal to the timestamp value used in the last writer operation (register, unregister, dispose, or write, with either the automatically supplied timestamp or the application-provided timestamp) However, if it is less than the timestamp of the previous operation but the difference is less than the dds::core::policy::DestinationOrder::source_timestamp_tolerance, the timestamp of the previous operation will be used as the source timestamp of this sample. Otherwise, if the difference is greater than dds::core::policy::DestinationOrder::source_timestamp_tolerance, the function will return dds::core::InvalidArgumentError.
Exceptions
Oneof the Standard Exceptions, dds::core::TimeoutError, dds::core::OutOfResourcesError, or dds::core::NotEnabledError.
See Also
dds::pub::DataWriter::write()
dds::sub::DataReader
DESTINATION_ORDER
Notes about DataWriter destruction
template<typename T>
void dds::pub::DataWriter< T >::write ( const dds::topic::TopicInstance< T > &  topic_instance)
inline

Write a dds::topic::TopicInstance.

A TopicInstance encapsulates the sample and its associated instance handle.

Parameters
topic_instanceThe instance to write.
See Also
write(const T&, const dds::core::InstanceHandle&)
template<typename T>
void dds::pub::DataWriter< T >::write ( const dds::topic::TopicInstance< T > &  topic_instance,
const dds::core::Time timestamp 
)
inline

Write a topic instance with time stamp.

Parameters
topic_instancethe TopicInstance to write.
timestampthe timestamp for this sample.
See Also
void write(const T&, const dds::core::InstanceHandle&, const dds::core::Time&)
Notes about DataWriter destruction
template<typename T>
template<typename FWIterator >
void dds::pub::DataWriter< T >::write ( const FWIterator &  begin,
const FWIterator &  end 
)
inline

Write a series of samples or TopicInstances

Template Parameters
FWIteratorA forward iterator. Depending on its value type this function can write data samples or TopicInstance objects.
Parameters
beginThe beginning of the range
endThe end of the range
See Also
write(const T&)
write(const dds::topic::TopicInstance<T>&)
template<typename T>
template<typename FWIterator >
void dds::pub::DataWriter< T >::write ( const FWIterator &  begin,
const FWIterator &  end,
const dds::core::Time timestamp 
)
inline

Write a series of samples or TopicInstances with a given timestamp

Template Parameters
FWIteratorA forward iterator. Depending on its value type this function can write data samples or TopicInstance objects.
Parameters
beginThe beginning of the range
endThe end of the range
timestampThe timestamp to use for all samples in the range
See Also
write(const T&, const dds::core::Time&)
write(const dds::topic::TopicInstance<T>&, const dds::core::Time&)
Notes about DataWriter destruction
template<typename T>
template<typename SamplesFWIterator , typename HandlesFWIterator >
void dds::pub::DataWriter< T >::write ( const SamplesFWIterator &  data_begin,
const SamplesFWIterator &  data_end,
const HandlesFWIterator &  handle_begin,
const HandlesFWIterator &  handle_end 
)
inline

Write a series of samples and their parallel instance handles.

Template Parameters
SamplesFWIteratorSample forward iterator
HandlesFWIteratorInstanceHandle forward iterator
Parameters
data_beginThe beginning of the data sample range
data_endThe end of the data sample range
handle_beginThe beginning of the InstanceHandle range
handle_endThe end of the InstanceHandle range
See Also
write(const T&, const dds::core::InstanceHandle&)
template<typename T>
template<typename SamplesFWIterator , typename HandlesFWIterator >
void dds::pub::DataWriter< T >::write ( const SamplesFWIterator &  data_begin,
const SamplesFWIterator &  data_end,
const HandlesFWIterator &  handle_begin,
const HandlesFWIterator &  handle_end,
const dds::core::Time timestamp 
)
inline

Write a series of samples and their parallel instance handles and a timestamp.

See Also
Notes about DataWriter destruction
template<typename T>
DataWriter& dds::pub::DataWriter< T >::operator<< ( const T &  data)
inline

Writes a sample.

See Also
write(const T&)
template<typename T>
DataWriter& dds::pub::DataWriter< T >::operator<< ( const std::pair< T, dds::core::Time > &  data)
inline
template<typename T>
DataWriter& dds::pub::DataWriter< T >::operator<< ( const std::pair< T, dds::core::InstanceHandle > &  data)
inline

Writes a sample with an instance handle.

See Also
write(const T&, const dds::core::InstanceHandle&)
template<typename T>
const dds::core::InstanceHandle dds::pub::DataWriter< T >::register_instance ( const T &  instance_data)
inline

Informs RTI Connext that the application will be modifying a particar instance.

This operation is only useful for keyed data types. Using it for non-keyed types causes no effect and returns dds::core::InstanceHandle::nil(). The operation takes as a parameter an instance (of which only the key value is examined) and returns a handle that can be used in successive write() or dispose_instance() operations.

The operation gives RTI Connext an opportunity to pre-configure itself to improve performance.

The use of this operation by an application is optional even for keyed types. If an instance has not been pre-registered, the application can call the write() or dipose_instance() overloads that don't receive a dds::core::InstanceHandle and RTI Connext will auto-register the instance.

For best performance, the operation should be invoked prior to calling any operation that modifies the instance, such as dds::pub::DataWriter::write(), dds::pub::DataWriter::write(const T&,const dds::core::Time&), dds::pub::DataWriter::dispose_instance() and dds::pub::DataWriter::dispose_instance(const dds::core::InstanceHandle&,const dds::core::Time&) and the handle used in conjunction with the data for those calls.

When this operation is used, RTI Connext will automatically supply the value of the source_timestamp that is used.

This operation may fail and return dds::core::InstanceHandle::nil() if dds::core::policy::ResourceLimits::max_instances limit has been exceeded.

The operation is idempotent. If it is called for an already registered instance, it just returns the already allocated handle. This may be used to lookup and retrieve the handle allocated to a given instance.

This operation can only be called after dds::pub::DataWriter has been enabled. Otherwise, dds::core::InstanceHandle::nil() will be returned.

Parameters
instance_data<<in>> The instance that should be registered. Of this instance, only the fields that represent the key are examined by the function.
Returns
For keyed data type, a handle that can be used in the calls that take a dds::core::InstanceHandle, such as write, dispose, unregister_instance, or return dds::core::InstanceHandle::nil() on failure. If the instance_data is of a data type that has no keys, this function always returns dds::core::InstanceHandle::nil().
See Also
dds::pub::DataWriter::unregister_instance, dds::pub::DataWriter::key_value, Relationship between registration, liveliness and ownership
template<typename T>
const dds::core::InstanceHandle dds::pub::DataWriter< T >::register_instance ( const T &  instance_data,
const dds::core::Time source_timestamp 
)
inline

Informs RTI Connext that the application will be modifying a particular instance and specifies the timestamp.

The provided source_timestamp potentially affects the relative order in which readers observe events from multiple writers. Refer to DESTINATION_ORDER QoS policy for details.

This operation may fail and return dds::core::InstanceHandle::nil() if dds::core::policy::ResourceLimits::max_instances limit has been exceeded.

This operation can only be called after dds::pub::DataWriter has been enabled. Otherwise, dds::core::InstanceHandle::nil() will be returned.

Parameters
instance_data<<in>> The instance that should be registered. Of this instance, only the fields that represent the key are examined by the function.
source_timestamp<<in>> The timestamp value must be greater than or equal to the timestamp value used in the last writer operation (used in a register, unregister, dispose, or write, with either the automatically supplied timestamp or the application provided timestamp). This timestamp may potentially affect the order in which readers observe events from multiple writers.
Returns
For keyed data type, return a handle that can be used in the calls that take a dds::core::InstanceHandle, such as write, dispose, unregister_instance, or return dds::core::InstanceHandle::nil() on failure. If the instance_data is of a data type that has no keys, this function always return dds::core::InstanceHandle::nil().
See Also
dds::pub::DataWriter::unregister_instance, dds::pub::DataWriter::key_value
Notes about DataWriter destruction
template<typename T>
DataWriter& dds::pub::DataWriter< T >::unregister_instance ( const dds::core::InstanceHandle handle)
inline

Unregister an instance.

This operation is useful only for keyed data types. Using it for non-keyed types causes no effect and reports no error.

This operation should only be called on an instance that is currently registered. This includes instances that have been auto-registered by calling operations such as write or dispose as described in dds::pub::DataWriter::register_instance. Otherwise, this operation may fail with dds::core::InvalidArgumentError.

This only need be called just once per instance, regardless of how many times register_instance was called for that instance.

When this operation is used, RTI Connext will automatically supply the value of the source_timestamp that is used.

This operation informs RTI Connext that the dds::pub::DataWriter is no longer going to provide any information about the instance. This operation also indicates that RTI Connext can locally remove all information regarding that instance. The application should not attempt to use the handle previously allocated to that instance after calling this function.

The parameter handle must correspond to an instance that has been registered. If there is no correspondence, the operation will fail with dds::core::InvalidArgumentError.

If, after a dds::pub::DataWriter::unregister_instance, the application wants to modify (dds::pub::DataWriter::write() or dds::pub::DataWriter::dispose_instance()) an instance, it has to register it again, or else use the functions that don't receive a dds::core::InstanceHandle.

This operation does not indicate that the instance is deleted (that is the purpose of dds::pub::DataWriter::dispose_instance()). The operation dds::pub::DataWriter::unregister_instance just indicates that the dds::pub::DataWriter no longer has anything to say about the instance. dds::sub::DataReader entities that are reading the instance may receive a sample with dds::sub::status::InstanceState::not_alive_no_writers() for the instance, unless there are other dds::pub::DataWriter objects writing that same instance.

dds::core::policy::WriterDataLifecycle::autodispose_unregistered_instances controls whether instances are automatically disposed when they are unregistered.

This operation can affect the ownership of the data instance (see OWNERSHIP). If the dds::pub::DataWriter was the exclusive owner of the instance, then calling unregister_instance() will relinquish that ownership.

If dds::core::policy::Reliability::kind is set to dds::core::policy::ReliabilityKind::RELIABLE and the unregistration would overflow the resource limits of this writer or of a reader, this operation may block for up to dds::core::policy::Reliability::max_blocking_time; if this writer is still unable to unregister after that period, this method will fail with dds::core::TimeoutError.

Parameters
handle<<in>> represents the instance to be unregistered. It must represent an instance that has been registered. Otherwise, this method may fail with dds::core::InvalidArgumentError.
Exceptions
Oneof the Standard Exceptions, dds::core::TimeoutError or dds::core::NotEnabledError
See Also
dds::pub::DataWriter::register_instance
dds::pub::DataWriter::unregister_instance(const dds::core::InstanceHandle&,const dds::core::Time&)
dds::pub::DataWriter::key_value
Relationship between registration, liveliness and ownership
template<typename T>
DataWriter& dds::pub::DataWriter< T >::unregister_instance ( const dds::core::InstanceHandle handle,
const dds::core::Time source_timestamp 
)
inline

Unregister an instance with timestamp.

The provided source_timestamp potentially affects the relative order in which readers observe events from multiple writers. Refer to DESTINATION_ORDER QoS policy for details.

The constraints on the values of the handle parameter and the corresponding error behavior are the same specified for the dds::pub::DataWriter::unregister_instance operation.

This operation may block and may time out (dds::core::TimeoutError) under the same circumtances described for the unregister_instance operation.

Parameters
handle<<in>> represents the instance to be unregistered. It must represent an instance that has been registered. Otherwise, this method may fail with dds::core::InvalidArgumentError.
source_timestamp<<in>> The timestamp value must be greater than or equal to the timestamp value used in the last writer operation (used in a register, unregister, dispose, or write, with either the automatically supplied timestamp or the application provided timestamp). This timestamp may potentially affect the order in which readers observe events from multiple writers.
Exceptions
Oneof the Standard Exceptions, dds::core::TimeoutError or dds::core::NotEnabledError.
See Also
dds::pub::DataWriter::register_instance
dds::pub::DataWriter::unregister_instance
dds::pub::DataWriter::key_value
template<typename T>
DataWriter& dds::pub::DataWriter< T >::dispose_instance ( const dds::core::InstanceHandle handle)
inline

Dispose an instance.

This operation is useful only for keyed data types. Using it for non-keyed types has no effect and reports no error.

The actual deletion is postponed until there is no more use for that data in the whole system.

Applications are made aware of the deletion by means of operations on the dds::sub::DataReader objects that already knew that instance. dds::sub::DataReader objects that didn't know the instance will never see it.

When this operation is used, RTI Connext will automatically supply the value of the source_timestamp that is made available to dds::sub::DataReader objects by means of the source_timestamp attribute inside the dds::sub::SampleInfo.

The constraints on the values of the handle parameter and the corresponding error behavior are the same specified for the dds::pub::DataWriter::unregister_instance operation.

This operation may block and time out (dds::core::TimeoutError) under the same circumstances described for dds::pub::DataWriter::write().

If there are no instance resources left, this operation may fail with dds::core::OutOfResourcesError. Calling dds::pub::DataWriter::unregister_instance may help freeing up some resources.

Parameters
handleThe handle returned by a previous call to dds::pub::DataWriter::register_instance. If handle doesn't correspond to a registered instance, this function fails with dds::core::InvalidArgumentError.
Exceptions
Oneof the Standard Exceptions, dds::core::TimeoutError, dds::core::OutOfResourcesError or dds::core::NotEnabledError.
See Also
dds::pub::DataWriter::dispose_instance(const dds::core::InstanceHandle&,const dds::core::Time&)
Relationship between registration, liveliness and ownership
template<typename T>
DataWriter& dds::pub::DataWriter< T >::dispose_instance ( const dds::core::InstanceHandle the_instance_handle,
const dds::core::Time source_timestamp 
)
inline

Dispose an instance with a timestamp.

The constraints on the values of the handle parameter and the corresponding error behavior are the same specified for the dds::pub::DataWriter::dispose_instance() operation.

This operation may block and time out (dds::core::TimeoutError) under the same circumtances described for dds::pub::DataWriter::write().

If there are no instance resources left, this operation may fail with dds::core::OutOfResourcesError. Calling dds::pub::DataWriter::unregister_instance may help freeing up some resources.

Parameters
the_instance_handle<<in>> Either the handle returned by a previous call to dds::pub::DataWriter::register_instance, or else the special value dds::core::InstanceHandle::nil(). If T has a key, handle must represent a registered instance of type T. Otherwise, this method may fail with dds::core::InvalidArgumentError.
source_timestamp<<in>> The timestamp value must be greater than or equal to the timestamp value used in the last writer operation (used in a register, unregister, dispose, or write, with either the automatically supplied timestamp or the application provided timestamp). This timestamp may potentially affect the order in which readers observe events from multiple writers. This timestamp will be available to the dds::sub::DataReader objects by means of the source_timestamp attribute inside the dds::sub::SampleInfo.
Exceptions
Oneof the Standard Exceptions, dds::core::TimeoutError, dds::core::OutOfResourcesError or dds::core::NotEnabledError.
See Also
dds::pub::DataWriter::dispose_instance()
template<typename T>
T& dds::pub::DataWriter< T >::key_value ( T &  key_holder,
const dds::core::InstanceHandle handle 
)
inline

Retrieve the instance key that corresponds to an instance handle.

Useful for keyed data types.

The operation will only fill the fields that form the key inside the key_holder instance. If T has no key, this method has no effect and exit with no error.

For keyed data types, this operation may fail with dds::core::InvalidArgumentError if the handle does not correspond to an existing data-object known to the dds::pub::DataWriter.

Parameters
key_holder<<inout>> a user data type specific key holder, whose key fields are filled by this operation. If T has no key, this method has no effect.
Parameters
handle<<in>> the instance whose key is to be retrieved. If T has a key, handle must represent a registered instance of type T. Otherwise, this method will fail with dds::core::InvalidArgumentError. If T has a key and handle is dds::core::InstanceHandle::nil(), this method will fail with dds::core::InvalidArgumentError.
Exceptions
Oneof the Standard Exceptions or dds::core::NotEnabledError.
Returns
A reference to key_holder
See Also
dds::sub::DataReader::key_value
template<typename T>
dds::topic::TopicInstance<T>& dds::pub::DataWriter< T >::key_value ( dds::topic::TopicInstance< T > &  key_holder,
const dds::core::InstanceHandle handle 
)
inline

Retrieve the instance key that corresponds to an instance handle.

See Also
key_value(T&, const dds::core::InstanceHandle&)
template<typename T>
dds::core::InstanceHandle dds::pub::DataWriter< T >::lookup_instance ( const T &  key_holder)
inline

Retrieve the instance handle that corresponds to an instance key_holder.

Useful for keyed data types.

This operation takes as a parameter an instance and returns a handle that can be used in subsequent operations that accept an instance handle as an argument. The instance parameter is only used for the purpose of examining the fields that define the key. This operation does not register the instance in question. If the instance has not been previously registered, or if for any other reason RTI Connext is unable to provide an instance handle, RTI Connext will return the special value HANDLE_NIL.

Parameters
key_holder<<in>> a user data type specific key holder.
Returns
the instance handle associated with this instance. If T has no key, this method has no effect and returns dds::core::InstanceHandle::nil()
template<typename T>
dds::pub::qos::DataWriterQos dds::pub::DataWriter< T >::qos ( ) const
inline

Gets the DataWriterQos.

template<typename T>
void dds::pub::DataWriter< T >::qos ( const dds::pub::qos::DataWriterQos the_qos)
inline

Sets the DataWriterQos.

This operation modifies the QoS of the dds::pub::DataWriter.

The dds::core::policy::UserData, dds::core::policy::Deadline, dds::core::policy::LatencyBudget, dds::core::policy::OwnershipStrength, dds::core::policy::TransportPriority, dds::core::policy::Lifespan and dds::core::policy::WriterDataLifecycle can be changed. The other policies are immutable.

Parameters
the_qos<<in>> The dds::pub::qos::DataWriterQos to be set to. Policies must be consistent. Immutable policies cannot be changed after dds::pub::DataWriter is enabled. The special value DATAWRITER_QOS_DEFAULT can be used to indicate that the QoS of the dds::pub::DataWriter should be changed to match the current default dds::pub::qos::DataWriterQos set in the dds::pub::Publisher.
Exceptions
Oneof the Standard Exceptions, dds::core::ImmutablePolicyError or dds::core::InconsistentPolicyError
See Also
dds::pub::qos::DataWriterQos for rules on consistency among QoS
set_qos (abstract)
Operations Allowed in Listener Callbacks
template<typename T>
DataWriter& dds::pub::DataWriter< T >::operator<< ( const dds::pub::qos::DataWriterQos the_qos)
inline

Set the DataWriterQos.

Parameters
the_qosthe new qos for this DataWriter.
See Also
qos()
template<typename T>
const DataWriter& dds::pub::DataWriter< T >::operator>> ( dds::pub::qos::DataWriterQos the_qos) const
inline

Get the DataWriterQos.

Parameters
the_qosthe object to populate with the qos for this DataWriter.
See Also
qos()
template<typename T>
const dds::topic::Topic<T>& dds::pub::DataWriter< T >::topic ( ) const
inline

Get the Topic associated with this DataWriter.

template<typename T>
const dds::pub::Publisher& dds::pub::DataWriter< T >::publisher ( ) const
inline

Get the Publisher that owns this DataWriter.

template<typename T>
void dds::pub::DataWriter< T >::wait_for_acknowledgments ( const dds::core::Duration max_wait)
inline

Blocks the calling thread until all data written by reliable DataWriter entity is acknowledged, or until timeout expires.

This operation blocks the calling thread until either all data written by the reliable dds::pub::DataWriter entity is acknowledged by (a) all reliable dds::sub::DataReader entities that are matched and alive and (b) by all required subscriptions, or until the duration specified by the max_wait parameter elapses, whichever happens first. A successful completion indicates that all the samples written have been acknowledged by all reliable matched data readers and by all required subscriptions; a timeout indicates that max_wait elapsed before all the data was acknowledged.

Note that if a thread is blocked in the call to wait_for_acknowledgments on a DataWriter and a different thread writes new samples on the same DataWriter, the new samples must be acknowledged before unblocking the thread waiting on wait_for_acknowledgments.

If the dds::pub::DataWriter does not have dds::core::policy::Reliability kind set to RELIABLE, this operation will complete immediately with

Parameters
max_wait<<in>> Specifies maximum time to wait for acknowledgements dds::core::Duration .
Exceptions
Oneof the Standard Exceptions, dds::core::NotEnabledError, dds::core::TimeoutError
template<typename T>
void dds::pub::DataWriter< T >::listener ( DataWriterListener< T > *  l,
const dds::core::status::StatusMask mask 
)
inline

Sets the DataWriter listener.

Parameters
lThe DataWriterListener to set
maskThe dds::core::status::StatusMask associated with the listener
template<typename T>
DataWriterListener<T>* dds::pub::DataWriter< T >::listener ( ) const
inline

Returns the listener currently associated with this DataWriter.

If there's no listener it returns NULL.

template<typename T>
const dds::core::status::LivelinessLostStatus dds::pub::DataWriter< T >::liveliness_lost_status ( )
inline

Get the LivelinessLostStatus.

This also resets the status so that it is no longer considered changed.

Exceptions
Oneof the Standard Exceptions
template<typename T>
const dds::core::status::OfferedDeadlineMissedStatus dds::pub::DataWriter< T >::offered_deadline_missed_status ( )
inline

Get the OfferedDeadlineMissedStatus.

This also resets the status so that it is no longer considered changed.

Exceptions
Oneof the Standard Exceptions
template<typename T>
const dds::core::status::OfferedIncompatibleQosStatus dds::pub::DataWriter< T >::offered_incompatible_qos_status ( )
inline

Get the OfferedIncompatibleQosStatus.

This also resets the status so that it is no longer considered changed.

Exceptions
Oneof the Standard Exceptions
template<typename T>
const dds::core::status::PublicationMatchedStatus dds::pub::DataWriter< T >::publication_matched_status ( )
inline

Get the PublicationMatchedStatus.

This also resets the status so that it is no longer considered changed.

Exceptions
Oneof the Standard Exceptions
template<typename T>
void dds::pub::DataWriter< T >::assert_liveliness ( )
inline

Manually asserts the liveliness of this DataWriter.

This is used in combination with the LIVELINESS policy to indicate to RTI Connext that the dds::pub::DataWriter remains active.

You only need to use this operation if the LIVELINESS setting is either dds::core::policy::LivelinessKind::MANUAL_BY_PARTICIPANT or dds::core::policy::LivelinessKind::MANUAL_BY_TOPIC. Otherwise, it has no effect.

Note: writing data via the dds::pub::DataWriter::write() or dds::pub::DataWriter::write(const T&,const dds::core::Time&) operation asserts liveliness on the dds::pub::DataWriter itself, and its dds::domain::DomainParticipant. Consequently the use of assert_liveliness() is only needed if the application is not writing data regularly.

Exceptions
Oneof the Standard Exceptions or dds::core::NotEnabledError
See Also
dds::core::policy::Liveliness
template<typename T>
void unregister_instance ( rti::pub::WriteParams params)
template<typename T>
void dispose_instance ( rti::pub::WriteParams params)
template<typename T>
bool is_sample_app_acknowledged ( const rti::core::SampleIdentity sample_id)

<<extension>> Indicates if a sample is considered application-acknowledged

This method can be used to see if a sample has been application acknowledged by all the matching DataReaders that were alive when the sample was written.

If a DataReader does not enable application acknowledgment (by setting dds::core::policy::Reliability::acknowledgment_kind to a value other than rti::core::policy::AcknowledgmentKind_def::PROTOCOL), the sample is considered application acknowledged for that DataReader.

Parameters
sample_id<<in>> Sample identity.
Returns
true when the sample has been application acknowledged. Otherwise, false.
Exceptions
Oneof the Standard Exceptions
template<typename T>
void wait_for_asynchronous_publishing ( const dds::core::Duration max_wait)

<<extension>>

This operation blocks the calling thread (up to max_wait) until all data written by the asynchronous dds::pub::DataWriter is sent and acknowledged (if reliable) by all matched dds::sub::DataReader entities. A successful completion indicates that all the samples written have been sent and acknowledged where applicable; a time out indicates that max_wait elapsed before all the data was sent and/or acknowledged.

In other words, this guarantees that sending to best effort dds::sub::DataReader is complete in addition to what dds::pub::DataWriter::wait_for_acknowledgments provides.

If the dds::pub::DataWriter does not have rti::core::policy::PublishMode kind set to rti::core::policy::PublishModeKind_def::ASYNCHRONOUS the operation will complete immediately with .

Parameters
max_wait<<in>> Specifies maximum time to wait for acknowledgements dds::core::Duration .
Exceptions
Oneof the Standard Exceptions, dds::core::NotEnabledError, dds::core::TimeoutError
template<typename T>
rti::core::status::ReliableWriterCacheChangedStatus reliable_writer_cache_changed_status ( )

<<extension>> Get the reliable cache status for this writer.

This also resets the status so that it is no longer considered changed.

Exceptions
Oneof the Standard Exceptions
template<typename T>
rti::core::status::ReliableReaderActivityChangedStatus reliable_reader_activity_changed_status ( )

<<extension>> Get the reliable reader activity changed status for this writer

This also resets the status so that it is no longer considered changed.

Exceptions
Oneof the Standard Exceptions
template<typename T>
rti::core::status::DataWriterCacheStatus datawriter_cache_status ( )

<<extension>> Get the cache status for this writer

This also resets the status so that it is no longer considered changed.

Exceptions
Oneof the Standard Exceptions or dds::core::NotEnabledError.
template<typename T>
rti::core::status::DataWriterProtocolStatus datawriter_protocol_status ( )

<<extension>> Get the protocol status for this writer

This also resets the status so that it is no longer considered changed.

Exceptions
Oneof the Standard Exceptions or dds::core::NotEnabledError.
template<typename T>
rti::core::status::DataWriterProtocolStatus matched_subscription_datawriter_protocol_status ( const dds::core::InstanceHandle subscription_handle)

<<extension>> Get the datawriter protocol status for this writer, per matched subscription identified by the subscription_handle.

This also resets the status so that it is no longer considered changed.

Note: Status for a remote entity is only kept while the entity is alive. Once a remote entity is no longer alive, its status is deleted.

Parameters
subscription_handle<<in>> Handle to a specific subscription associated with the dds::sub::DataReader. Must correspond to a subscription currently associated with the dds::pub::DataWriter.
Exceptions
Oneof the Standard Exceptions or dds::core::NotEnabledError.
template<typename T>
rti::core::status::DataWriterProtocolStatus matched_subscription_datawriter_protocol_status ( const rti::core::Locator subscription_locator)

<<extension>> Get the datawriter protocol status for this writer, per matched subscription identified by the locator

This also resets the status so that it is no longer considered changed.

Note: Status for a remote entity is only kept while the entity is alive. Once a remote entity is no longer alive, its status is deleted.

Exceptions
Oneof the Standard Exceptions or dds::core::NotEnabledError.
Parameters
subscription_locator<<in>> Locator to a specific locator associated with the DataReader. Must correspond to a locator of one or more subscriptions currently associated with the DataWriter.
template<typename T>
rti::core::status::ServiceRequestAcceptedStatus service_request_accepted_status ( )

<<extension>> Get the service request accepted status for this writer

This also resets the status so that it is no longer considered changed.

Note: Status for a remote entity is only kept while the entity is alive. Once a remote entity is no longer alive, its status is deleted.

Exceptions
Oneof the Standard Exceptions or dds::core::NotEnabledError.
template<typename T>
void flush ( )

<<extension>> Flushes the batch in progress in the context of the calling thread.

After being flushed, the batch is available to be sent on the network.

If the dds::pub::DataWriter does not have rti::core::policy::PublishMode kind set to rti::core::policy::PublishModeKind_def::ASYNCHRONOUS, the batch will be sent on the network immediately (in the context of the calling thread).

If the dds::pub::DataWriter does have rti::core::policy::PublishMode kind set to rti::core::policy::PublishModeKind_def::ASYNCHRONOUS, the batch will be sent in the context of the asynchronous publishing thread.

This operation may block in the same conditions as dds::pub::DataWriter::write().

If this operation does block, the RELIABILITY max_blocking_time configures the maximum time the write operation may block (waiting for space to become available). If max_blocking_time elapses before the DDS_DataWriter is able to store the modification without exceeding the limits, the operation will fail with DDS_RETCODE_TIMEOUT.

MT Safety:
flush() is only thread-safe with batching if rti::core::policy::Batch::thread_safe_write is TRUE.
Exceptions
Oneof the Standard Exceptions, dds::core::TimeoutError, dds::core::OutOfResourcesError or dds::core::NotEnabledError.
template<typename T>
void write ( const T &  instance_data,
rti::pub::WriteParams params 
)

<<extension>> Write with advanced parameters

Allows provision of the sample identity, related sample identity, source timestamp, instance handle, and publication priority contained in params.

This operation may block and time out (dds::core::TimeoutError) under the same circumstances described for dds::pub::DataWriter::write().

If there are no instance resources left, this operation may fail with dds::core::OutOfResourcesError. Calling dds::pub::DataWriter::unregister_instance(rti::pub::WriteParams&) may help free up some resources.

This operation may fail with dds::core::InvalidArgumentError under the same circumstances described for the dds::pub::DataWriter::write().

Parameters
instance_data<<in>> The data to write.
params<<inout>> The write parameters. Note that this is an inout parameter if you activate rti::pub::WriteParams::replace_automatic_values; otherwise it won't be modified.
Exceptions
Oneof the Standard Exceptions, dds::core::TimeoutError, dds::core::OutOfResourcesError or dds::core::NotEnabledError.
See Also
dds::pub::DataWriter::write()
dds::sub::DataReader
template<typename T>
T * create_data ( )

<<extension>> Create data from writer and initialize it

Returns
Newly created data type
Exceptions
Oneof the Standard Exceptions
See Also
dds::pub::DataWriter::delete_data
template<typename T>
bool delete_data ( T *  sample)

<<extension>> Delete data from writer

The behavior of this API is identical to FooTypeSupport::delete_data.

Parameters
sample<<in>> Cannot be NULL.
Returns
true on success.
See Also
dds::pub::DataWriter::create_data
template<typename T>
T * get_loan ( )

<<extension>> Get a loaned sample from this writer

This operation is supported while using Zero Copy transfer over shared memory or FlatData language binding. For FlatData types, this function should be used directly if the type is final; if the type is mutable, rti::flat::build_data() should be used to obtain a sample builder to work with the loaned sample.

The loaned sample is obtained from a DataWriter-managed sample pool and is uninitialized by default. An initialized sample can be obtained by setting rti::core::policy::DataWriterResourceLimits::initialize_writer_loaned_sample to true. The rti::core::policy::DataWriterResourceLimits::writer_loaned_sample_allocation settings can be used to configure the DataWriter-managed sample pool.

dds::pub::DataWriter::get_loan fails with dds::core::OutOfResourcesError if rti::core::AllocationSettings::max_count samples have been loaned, and none of those samples has been written with dds::pub::DataWriter::write() or discarded via dds::pub::DataWriter::discard_loan.

Samples returned from dds::pub::DataWriter::get_loan have an associated state. Due to the optimized nature of the write operation while using Zero Copy transfer over shared memory or FlatData language binding, this sample state is used to control when a sample is available for reuse after the write operation. The possible sample states are free, allocated, removed or serialized. A sample that has never been allocated is "free". dds::pub::DataWriter::get_loan takes a "free" or "removed" sample and makes it "allocated". When a sample is written, its state transitions from "allocated" to "serialized", and the DataWriter takes responsibility for returning the sample back to its sample pool. The sample remains in the "serialized" state until it is removed from the DataWriter queue. For a reliable DataWriter, the sample is removed from the DataWriter's queue when the sample is acknowledged by all DataReaders. For a best-effort DataWriter, the sample is removed from the queue immediately after the write operation. After the sample is removed from the DataWriter queue, the sample is put back into the sample pool, and its state transitions from "serialized" to "removed". At this time, a new call to dds::pub::DataWriter::get_loan may return the same sample.

A loaned sample should not be reused to write a new value after the first write operation. Instead, a new sample from dds::pub::DataWriter::get_loan should be used to write the new value.

A loaned sample that has not been written can be returned to the DataWriter's sample pool by using dds::pub::DataWriter::discard_loan.

A DataWriter cannot write managed samples (created with get_loan) and unmanaged samples (created in any other way) at the same time. The first call to get_loan automatically prepares this DataWriter to work with managed samples. Calls to get_loan will fail with dds::core::PreconditionNotMetError if an unmanaged sample was written with this DataWriter earlier. Similarly, dds::pub::DataWriter::write() will fail to write an unmanaged sample if get_loan was called.

Returns
a loaned sample
Exceptions
Oneof the Standard Exceptions, dds::core::OutOfResourcesError or dds::core::PreconditionNotMetError.
See Also
dds::pub::DataWriter::discard_loan
template<typename T>
void discard_loan ( T &  sample)

<<extension>> Discard a loaned sample from this writer

This operation is supported while using Zero Copy transfer over shared memory or the FlatData language binding.

A loaned sample that hasn't been written can be returned to the DataWriter with this operation.

Parameters
sample<<in>> loaned sample to be discarded.
Exceptions
Oneof the Standard Exceptions or dds::core::NotEnabledError.
See Also
dds::pub::DataWriter::get_loan
template<typename T>
const dds::core::InstanceHandle register_instance ( const T &  key,
rti::pub::WriteParams params 
)

<<extension>> Registers and instance with parameters

See Also
dds::pub::DataWriter::write(const T&,rti::pub::WriteParams&)

Friends And Related Function Documentation

template<typename T>
void ignore ( dds::domain::DomainParticipant participant,
const dds::core::InstanceHandle handle 
)
related

Instructs RTI Connext to locally ignore a publication.

A publication is defined by the association of a topic name, user data, and partition set on the dds::pub::Publisher (see dds::topic::PublicationBuiltinTopicData). After this call, any data written by that publication's dds::pub::DataWriter will be ignored.

This operation can be used to ignore local and remote DataWriters.

The publication (DataWriter) to ignore is identified by the handle argument.

There is no way to reverse this operation.

Parameters
participantThe DomainParticipant where the publication will be ignored
handle<<in>> Handle of the dds::pub::DataWriter to be ignored.
Exceptions
Oneof the Standard Exceptions, dds::core::OutOfResourcesError or dds::core::NotEnabledError
See Also
dds::topic::PublicationBuiltinTopicData
dds::topic::publication_topic_name()
dds::sub::builtin_subscriber
template<typename FwdIterator >
void ignore ( dds::domain::DomainParticipant participant,
FwdIterator  begin,
FwdIterator  end 
)
related

Instructs RTI Connext to locally ignore several publications.

Template Parameters
FwdIteratorA forward iterator whose value type is dds::core::InstanceHandle
See Also
ignore(dds::domain::DomainParticipant&, const dds::core::InstanceHandle&);
template<typename T >
dds::core::InstanceHandleSeq matched_subscriptions ( const dds::pub::DataWriter< T > &  writer)
related

Retrieve the list of subscriptions currently associated with a dds::pub::DataWriter.

Matched subscriptions include all those in the same domain that have a matching dds::topic::Topic, compatible QoS and common partition that the dds::domain::DomainParticipant has not indicated should be "ignored" by means of the dds::sub::ignore operation.

The handles returned list are the ones that RTI Connext uses to locally identify the corresponding matched dds::sub::DataReader entities. These handles match the ones that appear in the dds::sub::SampleInfo::instance_handle field of the dds::sub::SampleInfo when reading the dds::topic::subscription_topic_name() builtin topic.

The maximum number of matches possible is configured with rti::core::policy::DomainParticipantResourceLimits. .

Exceptions
Oneof the Standard Exceptions, or dds::core::NotEnabledError
template<typename T , typename FwdIterator >
FwdIterator matched_subscriptions ( const dds::pub::DataWriter< T > &  writer,
FwdIterator  begin,
FwdIterator  end 
)
related

Retrieve the list of subscriptions currently associated with a dds::pub::DataWriter.

This operation is similar to matched_subscriptions(const dds::pub::DataWriter<T>&) but it copies the instance handles into an iterator range.

Template Parameters
FwdIteratorA forward iterator whose value type is dds::core::InstanceHandle
template<typename T >
const dds::topic::SubscriptionBuiltinTopicData matched_subscription_data ( const dds::pub::DataWriter< T > &  writer,
const dds::core::InstanceHandle subscription_handle 
)
related

Retrieves information on a subscription that is currently associated with a dds::pub::DataWriter.

The subscription_handle must correspond to a subscription currently associated with the dds::pub::DataWriter. Otherwise, the operation will fail and fail with dds::core::InvalidArgumentError. Use dds::pub::matched_subscriptions() to find the subscriptions that are currently matched with the dds::pub::DataWriter.

The above information is available through dds::sub::DataReaderListener::on_data_available() (if a reader listener is installed on the dds::sub::DataReader<dds::topic::SubscriptionBuiltinTopicData>).

Parameters
writerThe DataWriter to which the subscription is associated
subscription_handle<<in>>. Handle to a specific subscription associated with the dds::sub::DataReader. . Must correspond to a subscription currently associated with the dds::pub::DataWriter.
Exceptions
Oneof the Standard Exceptions, or dds::core::NotEnabledError
template<typename Writer , typename FwdIterator >
uint32_t find ( const dds::pub::Publisher publisher,
const std::string &  topic_name,
FwdIterator  begin,
uint32_t  max_size 
)
related

Retrieves the dds::pub::DataWriter for a specific topic name.

This returned dds::pub::DataWriter is either enabled or disabled.

If more than one dds::pub::DataWriter is attached to the dds::pub::Publisher with the same topic_name, then this operation may return any one of them.

MT Safety:
UNSAFE. It is not safe to lookup a dds::pub::DataWriter in one thread while another thread is simultaneously creating or destroying that dds::pub::DataWriter. This function retrieves a previously-created DataWriter belonging to the dds::pub::Publisher that is attached to a dds::topic::Topic with a matching topic name. If no such DataWriter exists, the operation will return an empty container. The use of this operation on the built-in Publisher allows access to the built-in DataWriter entities for the built-in topics
Template Parameters
WriterThe type of the writer. It can be dds::pub::AnyDataWriter, or an instantiation of dds::pub::DataWriter<T> (if T is not the correct type, this function throws dds::core::InvalidDowncastError)
FwdIteratorThe type of forward iterator passed to this function
Parameters
publisherThe dds::pub::Publisher the DataWriter belongs to
topic_nameName of the dds::topic::Topic associated with the DataWriter that is to be looked up.
beginA forward iterator to the position in the destination container to insert the found DataWriter in
max_sizeOnly 1 DataWriter will be returned from this function
Returns
The number of DataWriters that were found (either 0 or 1)
template<typename Writer , typename BinIterator >
uint32_t find ( const dds::pub::Publisher publisher,
const std::string &  topic_name,
BinIterator  begin 
)
related

Retrieves the dds::pub::DataWriter for a specific topic name.

This returned dds::pub::DataWriter is either enabled or disabled.

If more than one dds::pub::DataWriter is attached to the dds::pub::Publisher with the same topic_name, then this operation may return any one of them.

MT Safety:
UNSAFE. It is not safe to lookup a dds::pub::DataWriter in one thread while another thread is simultaneously creating or destroying that dds::pub::DataWriter. This function retrieves a previously created DataWriter belonging to the dds::pub::Publisher that is attached to a dds::topic::Topic with a matching topic name. If no such DataWriter exists, the operation will return an empty container. The use of this operation on the built-in Publisher allows access to the built-in DataWriter entities for the built-in topics
Template Parameters
WriterThe type of the writer. It can be dds::pub::AnyDataWriter, or an instantiation of dds::pub::DataWriter<T> (if T is not the correct type, this function throws dds::core::InvalidDowncastError)
BinIteratorBinIterator The type of back-inserting iterator passed to this function
Parameters
publisherThe dds::pub::Publisher the DataWriter belongs to
topic_nameName of the dds::topic::Topic associated with the DataWriter that is to be looked up.
beginA back-inserting iterator to the position in the destination container to insert the found DataWriter into
Returns
The number of DataWriters that were found (either 0 or 1)
template<typename AnyDataWriterBackInsertIterator >
uint32_t find_datawriters ( dds::pub::Publisher  publisher,
AnyDataWriterBackInsertIterator  begin 
)
related

Retrieve all the dds::pub::DataWriter created from this dds::pub::Publisher.

Template Parameters
AnyDataWriterBackInsertIteratorAn iterator whose value_type is dds::pub::AnyDataWriter
Parameters
publisherThe dds::pub::Publisher the DataWriters belong to
beginA back-inserting iterator to the position in the destination container to insert the found DataWriters into
Returns
The number of found DataWriters
See Also
DDSWriterExampleModule_lookup
template<typename AnyDataWriterForwardIterator >
uint32_t find_datawriters ( dds::pub::Publisher  publisher,
AnyDataWriterForwardIterator  begin,
uint32_t  max_size 
)
related

Retrieve all the dds::pub::DataWriter created from this dds::pub::Publisher.

Template Parameters
AnyDataWriterForwardIteratorAn iterator whose value_type is dds::pub::AnyDataWriter
Parameters
publisherThe dds::pub::Publisher the DataWriters belong to
beginA forward iterator to the first position in the destination container to copy the found DataWriters into
max_sizeThe maximum number of DataWriters to return
Returns
The number of found DataWriters
See Also
DDSWriterExampleModule_lookup
template<typename Writer >
Writer find_datawriter_by_topic_name ( dds::pub::Publisher  publisher,
const std::string &  topic_name 
)
related

<<extension>> Retrieves a dds::pub::DataWriter with the given name within the dds::pub::Publisher

Every dds::pub::DataWriter in the system has an entity name which is configured and stored in the <<extension>> EntityName policy, ENTITY_NAME.

This operation retrieves the dds::pub::DataWriter within the dds::pub::Publisher whose name matches the one specified. If there are several dds::pub::DataWriter with the same name within the dds::pub::Publisher, the operation returns the first matching occurrence.

Template Parameters
WriterThe type of the writer. It can be dds::pub::AnyDataWriter, or an instantiation of dds::pub::DataWriter<T> (if T is not the correct type, this function throws dds::core::InvalidDowncastError)
Parameters
publisherThe dds::pub::Publisher that created the DataWriter to find
topic_nameEntity name of the DataWriter to find
Returns
The AnyDataWriter with the given name
See Also
DDSWriterExampleModule_lookup
template<typename Writer >
Writer find_datawriter_by_name ( dds::pub::Publisher  publisher,
const std::string &  datawriter_name 
)
related

<<extension>> Retrieves a dds::pub::DataWriter with the given name within the dds::pub::Publisher

Every dds::pub::DataWriter in the system has an entity name which is configured and stored in the <<extension>> EntityName policy, ENTITY_NAME.

This operation retrieves the dds::pub::DataWriter within the dds::pub::Publisher whose name matches the one specified. If there are several dds::pub::DataWriter with the same name within the dds::pub::Publisher, the operation returns the first matching occurrence.

Template Parameters
WriterThe type of the writer. It can be dds::pub::AnyDataWriter, or an instantiation of dds::pub::DataWriter<T> (if T is not the correct type, this function throws dds::core::InvalidDowncastError)
Parameters
publisherThe dds::pub::Publisher that created the DataWriter to find
datawriter_nameEntity name of the DataWriter to find
Returns
The WRITER with the given name
See Also
DDSWriterExampleModule_lookup
template<typename Writer >
Writer find_datawriter_by_name ( dds::domain::DomainParticipant  participant,
const std::string &  datawriter_name 
)
related

<<extension>> Retrieves a dds::pub::DataWriter within the dds::domain::DomainParticipant with the given name

Every dds::pub::DataWriter in the system has an entity name which is configured and stored in the EntityName policy, ENTITY_NAME.

Every dds::pub::Publisher in the system has an entity name which is also configured and stored in the EntityName policy.

This operation retrieves a dds::pub::DataWriter within a dds::pub::Publisher given the specified name which encodes both to the dds::pub::DataWriter and the dds::pub::Publisher name.

If there are several dds::pub::DataWriter with the same name within the corresponding dds::pub::Publisher this function returns the first matching occurrence.

The specified name might be given as a fully-qualified entity name or as a plain name.

The fully qualified entity name is a concatenation of the dds::pub::Publisher to which the dds::pub::DataWriter belongs and the entity name of of the dds::pub::DataWriter itself, separated by a double colon "::". For example: MyPublisherName::MyDataWriterName

The plain name contains the dds::pub::DataWriter name only. In this situation it is implied that the dds::pub::DataWriter belongs to the implicit dds::pub::Publisher so the use of a plain name is equivalent to specifying a fully qualified name with the dds::pub::Publisher name part being "implicit". For example: the plain name "MyDataWriterName" is equivalent to specifiying the fully qualified name "implicit::MyDataWriterName"

The dds::pub::DataWriter is only looked up within the dds::pub::Publisher specified in the fully qualified name, or within the implicit dds::pub::Publisher if the name was not fully qualified.

Template Parameters
WriterThe type of the writer. It can be dds::pub::AnyDataWriter, or an instantiation of dds::pub::DataWriter<T> (if T is not the correct type, this function throws dds::core::InvalidDowncastError)
Parameters
participantThe dds::domain::DomainParticipant within which the dds::pub::DataWriter exists
datawriter_nameEntityName of the DataWriter to find
Returns
The WRITER with the given name
See Also
implicit_publisher(const dds::domain::DomainParticipant& dp);
DDSWriterExampleModule_lookup

RTI Connext Modern C++ API Version 6.0.0 Copyright © Sun Mar 3 2019 Real-Time Innovations, Inc