Class Publisher

Inheritance Relationships

Base Type

Class Documentation

class Publisher : public dds::core::TEntity<detail::Publisher>

The Publisher acts on the behalf of one or several DataWriter objects that belong to it.

When it is informed of a change to the data associated with one of its DataWriter objects, it decides when it is appropriate to actually send the data-update message. In making this decision, it considers any extra information that goes with the data (timestamp, writer, etc.) as well as the QoS of the Publisher and the DataWriter.

See also

Publisher

Public Types

typedef PublisherListener Listener

Local convenience typedef for dds::pub::PublisherListener.

Public Functions

OMG_DDS_API const qos::PublisherQos & qos () const

Gets the PublisherQos setting for this instance.

Throws
  • dds::core::Error – An internal error has occurred.

  • dds::core::NullReferenceError – The entity was not properly created and references to dds::core::null.

  • dds::core::AlreadyClosedError – The entity has already been closed.

  • dds::core::OutOfResourcesError – The Data Distribution Service ran out of resources to complete this operation.

Returns

the qos

OMG_DDS_API void qos (const qos::PublisherQos &qos)

Sets the PublisherQos setting for this instance.

Parameters

qos – the qos

Throws
  • dds::core::Error – An internal error has occurred.

  • dds::core::NullReferenceError – The entity was not properly created and references to dds::core::null.

  • dds::core::AlreadyClosedError – The entity has already been closed.

  • dds::core::OutOfResourcesError – The Data Distribution Service ran out of resources to complete this operation.

OMG_DDS_API Publisher & operator<< (const qos::PublisherQos &qos)

Sets the PublisherQos setting for this instance.

Parameters

qos – the qos

Throws
  • dds::core::Error – An internal error has occurred.

  • dds::core::NullReferenceError – The entity was not properly created and references to dds::core::null.

  • dds::core::AlreadyClosedError – The entity has already been closed.

  • dds::core::OutOfResourcesError – The Data Distribution Service ran out of resources to complete this operation.

OMG_DDS_API Publisher & operator>> (qos::PublisherQos &qos)

Gets the PublisherQos setting for this instance.

Throws
  • dds::core::Error – An internal error has occurred.

  • dds::core::NullReferenceError – The entity was not properly created and references to dds::core::null.

  • dds::core::AlreadyClosedError – The entity has already been closed.

  • dds::core::OutOfResourcesError – The Data Distribution Service ran out of resources to complete this operation.

Returns

the qos

OMG_DDS_API Publisher & default_datawriter_qos (const qos::DataWriterQos &qos)

Sets the default DataWriterQos of the Publisher.

This operation sets the default SubscriberQos of the Publisher which is used for newly created Subscriber objects, when no QoS is provided.

This operation checks if the DataWriterQos is self consistent. If it is not, the operation has no effect and throws dds::core::InconsistentPolicyError.

The values set by this operation are returned by dds::pub::Publisher::default_datawriter_qos().

Parameters

qos – the default DataWriterQos

Throws
  • dds::core::Error – An internal error has occurred.

  • dds::core::NullReferenceError – The entity was not properly created and references to dds::core::null.

  • dds::core::AlreadyClosedError – The entity has already been closed.

  • dds::core::UnsupportedError – One or more of the selected QosPolicy values are currently not supported by OpenSplice.

  • dds::core::InconsistentPolicyError – The parameter qos contains conflicting QosPolicy settings, e.g. a history depth that is higher than the specified resource limits.

  • dds::core::OutOfResourcesError – The Data Distribution Service ran out of resources to complete this operation.

OMG_DDS_API qos::DataWriterQos default_datawriter_qos () const

Gets the default DataWriterQos of the Publisher.

This operation gets an object with the default DataWriter QosPolicy settings of the Publisher (that is the DataWriterQos) which is used for newly created DataWriter objects, in case no QoS was provided during the creation.

The values retrieved by this operation match the set of values specified on the last successful call to dds::pub::Publisher::default_datawriter_qos(const dds::pub::qos::DataWriterQos& qos), or, if the call was never made, the default values.

Throws
  • dds::core::Error – An internal error has occurred.

  • dds::core::NullReferenceError – The entity was not properly created and references to dds::core::null.

  • dds::core::AlreadyClosedError – The entity has already been closed.

  • dds::core::OutOfResourcesError – The Data Distribution Service ran out of resources to complete this operation.

Returns

the default DataWriterQos

OMG_DDS_API void listener (Listener *plistener, const dds::core::status::StatusMask &mask)

Register a listener with the Publisher.

The notifications received by the listener depend on the status mask with which it was registered.

Listener un-registration is performed by setting the listener to NULL.

See also listener information.

Parameters
  • plistener – the listener

  • mask – the mask defining the events for which the listener will be notified.

Throws
  • dds::core::Error – An internal error has occurred.

  • dds::core::NullReferenceError – The entity was not properly created and references to dds::core::null.

  • dds::core::AlreadyClosedError – The entity has already been closed.

  • dds::core::UnsupportedError – A status was selected that cannot be supported because the infrastructure does not maintain the required connectivity information.

  • dds::core::OutOfResourcesError – The Data Distribution Service ran out of resources to complete this operation.

OMG_DDS_API Listener * listener () const

Get the listener of this Publisher.

See also listener information.

Throws

dds::core::NullReferenceError – The entity was not properly created and references to dds::core::null.

Returns

the listener

OMG_DDS_API void wait_for_acknowledgments (const dds::core::Duration &timeout)

This operation blocks the calling thread until either all data written by the reliable DataWriter entities is acknowledged by all matched reliable DataReader entities, or else the duration specified by the timeout parameter elapses, whichever happens first.

Data is acknowledged by the local infrastructure when it does not need to be stored in its DataWriter’s local history. When a locally-connected subscription (including the networking service) has no more resources to store incoming samples it will start to reject these samples, resulting in their source DataWriters to store them temporarily in their own local history to be retransmitted at a later moment in time.

In such scenarios, the wait_for_acknowledgments operation will block until all contained DataWriters have retransmitted their entire history, which is therefore effectively empty, or until the max_wait timeout expires, whichever happens first. In the latter case it will throw

dds::core::TimeoutError.

Be aware that in case the operation returns normally, the data has only been acknowledged by the local infrastructure: it does not mean all remote subscriptions have already received the data. However, delivering the data to remote nodes is then the sole responsibility of the networking service: even when the publishing application would terminate, all data that has not yet been received may be considered ‘on-route’ and will therefore eventually arrive (unless the networking service itself will crash). In contrast, if a DataWriter would still have data in it’s local history buffer when it terminates, this data is considered ‘lost’.

This operation is intended to be used only if one or more of the contained DataWriters has its ReliabilityQosPolicyKind set to RELIABLE. Otherwise the operation will return immediately, since best-effort DataWriters will never store rejected samples in their local history: they will just drop them and continue business as usual.

Parameters

timeout – the time out duration

Throws
  • dds::core::Error – An internal error has occurred.

  • dds::core::NullReferenceError – The entity was not properly created and references to dds::core::null.

  • dds::core::AlreadyClosedError – The entity has already been closed.

  • dds::core::TimeoutError – Not all data is acknowledged before timeout elapsed.

  • dds::core::OutOfResourcesError – The Data Distribution Service ran out of resources to complete this operation.

OMG_DDS_API const dds::domain::DomainParticipant & participant () const

Return the DomainParticipant that owns this Publisher.

Throws
  • dds::core::Error – An internal error has occurred.

  • dds::core::NullReferenceError – The entity was not properly created and references to dds::core::null.

  • dds::core::AlreadyClosedError – The entity has already been closed.

Returns

the DomainParticipant

Public Members

const dds::domain::DomainParticipant *participant_