Cyclone ISO C++ API Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
dds::sub::AnyDataReader Class Reference

Typeless base class for the typed DataReader. More...

#include "AnyDataReader.hpp"

Inherits dds::core::Entity.

Inherited by dds::sub::DataReader< T >.

Public Member Functions

template<typename H__ >
 AnyDataReader (const H__ &h)
 
void close ()
 
void enable ()
 
const dds::core::InstanceHandle instance_handle () const
 
bool is_nil () const
 
dds::core::status::LivelinessChangedStatus liveliness_changed_status ()
 
bool operator!= (const null_type nil) const
 
template<typename R >
bool operator!= (const R &ref) const
 
DELEGATE * operator-> ()
 
const DELEGATE * operator-> () const
 
AnyDataReaderoperator<< (const dds::sub::qos::DataReaderQos &qos)
 
template<typename T__ >
AnyDataReaderoperator= (const T__ &rhs)
 
bool operator== (const null_type) const
 
template<typename R >
bool operator== (const R &ref) const
 
const AnyDataReaderoperator>> (dds::sub::qos::DataReaderQos &qos) const
 
dds::sub::qos::DataReaderQos qos () const
 
void qos (const dds::sub::qos::DataReaderQos &qos)
 
dds::core::status::RequestedDeadlineMissedStatus requested_deadline_missed_status ()
 
dds::core::status::RequestedIncompatibleQosStatus requested_incompatible_qos_status ()
 
void retain ()
 
dds::core::status::SampleLostStatus sample_lost_status ()
 
dds::core::status::SampleRejectedStatus sample_rejected_status ()
 
const dds::core::status::StatusMask status_changes ()
 
const dds::sub::Subscribersubscriber () const
 
dds::core::status::SubscriptionMatchedStatus subscription_matched_status ()
 
const dds::topic::TopicDescriptiontopic_description () const
 
void wait_for_historical_data (const dds::core::Duration &timeout)
 

Detailed Description

Typeless base class for the typed DataReader.

DataReaders are created type specific (fi DataReader<Foo::Bar> reader). However, there are many places in the API (and possibly application) where the type can not be known while still some DataReader has to be passed around, stored or even typeless functionality called.
Main examples in the API that need typeless DataReader are: Subscriber, SubscriberListener and DomainParticipantListener.

See also
dds::sub::DataReader

Definition at line 50 of file AnyDataReader.hpp.

Constructor & Destructor Documentation

◆ AnyDataReader()

template<typename H__ >
dds::sub::AnyDataReader::AnyDataReader ( const H__ &  h)
inline

Definition at line 59 of file AnyDataReader.hpp.

Member Function Documentation

◆ close()

void dds::core::Entity::close ( )
inherited

This function closes the entity and releases related resources.

Resource management for some reference types might involve relatively heavyweight operating- system resources — such as e.g., threads, mutexes, and network sockets — in addition to memory. These objects therefore provide a method close() that shall halt network communication (in the case of entities) and dispose of any appropriate operating-system resources.

Users of this PSM are recommended to call close on objects of all reference types once they are finished using them. In addition, implementations may automatically close objects that they deem to be no longer in use, subject to the following restrictions:

  • Any object to which the application has a direct reference is still in use.
  • Any object that has been explicitly retained is still in use
  • The creator of any object that is still in use is itself still in use.
Returns
void

◆ enable()

void dds::core::Entity::enable ( )
inherited

Enable entity.

This operation enables the Entity. Entity objects can be created either enabled or disabled. This is controlled by the value of the dds::core::policy::EntityFactory QoS policy on the corresponding factory for the Entity.

Enabled entities are immediately activated at creation time meaning all their immutable QoS settings can no longer be changed. Disabled Entities are not yet activated, so it is still possible to change there immutable QoS settings. However, once activated the immutable QoS settings can no longer be changed.

Creating disabled entities can make sense when the creator of the Entity does not yet know which QoS settings to apply, thus allowing another piece of code to set the QoS later on.

The default setting of dds::core::policy::EntityFactory is such that, by default, it is not necessary to explicitly call enable on newly- created entities.

The enable operation is idempotent. Calling enable on an already- enabled Entity does not raise exceptions and has no effect.

If an Entity has not yet been enabled, the only operations that can be invoked on it are: the ones to set, get or copy the QosPolicy settings, the ones that set (or get) the listener, the ones that get the StatusCondition, the get_status_changes operation (although the status of a disabled entity never changes), and the ‘factory’ operations that create, delete or lookup other Entities. Other operations will throw the exception dds::core::NotEnabledError.

Entities created from a factory that is disabled are created disabled regardless of the setting of the dds::core::policy::EntityFactory Qos policy. Calling enable on an Entity whose factory is not enabled will fail and throw an dds::core::PreconditionNotMetError exception.

If the dds::core::policy::EntityFactory QoS policy has autoenable_created_entities set to TRUE, the enable operation on the factory will automatically enable all entities created from the factory.

The Listeners associated with an entity are not called until the entity is enabled. Conditions associated with an entity that is not enabled are inactive; that is, they have a trigger_value==false (dds::core::cond::Condition and dds::core::cond::WaitSet).

eg.

...
dds::sub::DataReader<Foo::Bar> dr(dp, topic, drqos);
dr.enable();
Returns
void
Exceptions
dds::core::PreconditionNotMetErrorEntities' factory is not enabled.

◆ instance_handle()

const dds::core::InstanceHandle dds::core::Entity::instance_handle ( ) const
inherited

This operation returns the InstanceHandle_t that represents the Entity.

The relevant state of some Entity objects are distributed using built-in topics. Each built-in topic sample represents the state of a specific Entity and has a unique instance_handle. This operation returns the instance_handle of the built-in topic sample that represents the specified Entity.
Some Entities (dds::pub::Publisher and dds::sub::Subscriber) do not have a corresponding built-in topic sample, but they still have an instance_handle that uniquely identifies the Entity. The instance_handles obtained this way can also be used to check whether a specific Entity is located in a specific DomainParticipant (dds::domain::DomainParticipant::contains_entity()).

Returns
dds::core::InstanceHandle Result value is the instance_handle of the built-in topic sample that represents the state of this Entity.

◆ is_nil()

template<typename DELEGATE>
bool dds::core::Reference< DELEGATE >::is_nil ( ) const
inherited

Check if the referenced object is nil.

In other words, check if the reference is pointing to a null object.

Returns
true if the referenced object is null.

◆ liveliness_changed_status()

dds::core::status::LivelinessChangedStatus dds::sub::AnyDataReader::liveliness_changed_status ( )

This operation obtains the LivelinessChangedStatus object of the DataReader.

This object contains the information whether the liveliness of one or more DataWriter objects that were writing instances read by the DataReader has changed. In other words, some DataWriter have become "alive" or "not alive".

The LivelinessChangedStatus can also be monitored using a DataReaderListener or by using the associated StatusCondition.

Returns
the LivelinessChangedStatus
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.

◆ operator!=() [1/2]

template<typename DELEGATE>
bool dds::core::Reference< DELEGATE >::operator!= ( const null_type  nil) const
inherited

Special operator!= used to check if this reference object does not equal the dds::core::null reference.

The non-null-check can be done like this:

if (r != dds::core::null) {
// Use the dds reference object r
}
Returns
true if this reference is not null.

◆ operator!=() [2/2]

template<typename DELEGATE>
template<typename R >
bool dds::core::Reference< DELEGATE >::operator!= ( const R &  ref) const
inherited

Compares two Reference objects and returns true if they are not equal.

Inequality is based on the referential inequality of the object being pointed to.

Parameters
refthe other Reference object
Returns
true when not equal

◆ operator->() [1/2]

template<typename DELEGATE>
DELEGATE* dds::core::Reference< DELEGATE >::operator-> ( )
inherited

The operator->() is provided to be able to directly invoke functions on the delegate.

The decision to provide direct access to the delegate was motivated by the need for providing a way that was not invasive with respect to the CXXDDS API and yet would allow for vendor-specific extension. Thus vendor-specific extensions can be invoked on the Reference and on all its subclasses as follows:

my_dds_entity.standard_function();
my_dds_entity->vendor_specific_extension();
Returns
a reference to delegate.

◆ operator->() [2/2]

template<typename DELEGATE>
const DELEGATE* dds::core::Reference< DELEGATE >::operator-> ( ) const
inherited

The operator->() is provided to be able to directly invoke functions on the delegate.

The decision to provide direct access to the delegate was motivated by the need for providing a way that was not invasive with respect to the CXXDDS API and yet would allow for vendor-specific extension. Thus vendor-specific extensions can be invoked on the Reference and on all its subclasses as follows:

my_dds_entity.standard_function();
my_dds_entity->vendor_specific_extension();
Returns
a reference to delegate.

◆ operator<<()

AnyDataReader& dds::sub::AnyDataReader::operator<< ( const dds::sub::qos::DataReaderQos qos)

This operation replaces the existing set of QosPolicy settings for a DataReader.

The parameter qos contains the object with the QosPolicy settings which is checked for self-consistency and mutability.

When the application tries to change a QosPolicy setting for an enabled DataReader, which can only be set before the DataReader is enabled, the operation will fail and a ImmutablePolicyError is thrown. In other words, the application must provide the presently set QosPolicy settings in case of the immutable QosPolicy settings. Only the mutable QosPolicy settings can be changed.

When the qos contains conflicting QosPolicy settings (not self-consistent), the operation will fail and an InconsistentPolicyError is thrown.

Parameters
qosthe qos
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.
dds::core::ImmutablePolicyErrorThe parameter qos contains an immutable QosPolicy setting with a different value than set during enabling of the DataReader.
dds::core::InconsistentPolicyErrorThe parameter qos contains conflicting QosPolicy settings,

◆ operator=()

template<typename T__ >
AnyDataReader& dds::sub::AnyDataReader::operator= ( const T__ &  rhs)
inline

Definition at line 75 of file AnyDataReader.hpp.

◆ operator==() [1/2]

template<typename DELEGATE>
bool dds::core::Reference< DELEGATE >::operator== ( const  null_type) const
inherited

Special operator== used to check if this reference object equals the dds::core::null reference.

The null-check can be done like this:

if (r == dds::core::null) {
// Do not use the dds reference object r in its current state
}
Returns
true if this reference is null.

◆ operator==() [2/2]

template<typename DELEGATE>
template<typename R >
bool dds::core::Reference< DELEGATE >::operator== ( const R &  ref) const
inherited

Compares two Reference objects and returns true if they are equal.

Equality is based on the referential equality of the object being pointed.

Parameters
refthe other Reference object
Returns
true when equal

◆ operator>>()

const AnyDataReader& dds::sub::AnyDataReader::operator>> ( dds::sub::qos::DataReaderQos qos) const

Gets the DataReaderQos setting for this instance.

Returns
the qos
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.

◆ qos() [1/2]

dds::sub::qos::DataReaderQos dds::sub::AnyDataReader::qos ( ) const

Gets the DataReaderQos setting for this instance.

Returns
the qos
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.

◆ qos() [2/2]

void dds::sub::AnyDataReader::qos ( const dds::sub::qos::DataReaderQos qos)

This operation replaces the existing set of QosPolicy settings for a DataReader.

The parameter qos contains the object with the QosPolicy settings which is checked for self-consistency and mutability.

When the application tries to change a QosPolicy setting for an enabled DataReader, which can only be set before the DataReader is enabled, the operation will fail and a ImmutablePolicyError is thrown. In other words, the application must provide the presently set QosPolicy settings in case of the immutable QosPolicy settings. Only the mutable QosPolicy settings can be changed.

When the qos contains conflicting QosPolicy settings (not self-consistent), the operation will fail and an InconsistentPolicyError is thrown.

Parameters
qosthe qos
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.
dds::core::ImmutablePolicyErrorThe parameter qos contains an immutable QosPolicy setting with a different value than set during enabling of the DataReader.
dds::core::InconsistentPolicyErrorThe parameter qos contains conflicting QosPolicy settings,

◆ requested_deadline_missed_status()

dds::core::status::RequestedDeadlineMissedStatus dds::sub::AnyDataReader::requested_deadline_missed_status ( )

This operation obtains the RequestedDeadlineMissedStatus object of the DataReader.

This object contains the information whether the deadline that the DataReader was expecting through its dds::core::policy::Deadline QosPolicy was not respected for a specific instance.

The RequestedDeadlineMissedStatus can also be monitored using a DataReaderListener or by using the associated StatusCondition.

Returns
the RequestedDeadlineMissedStatus
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.

◆ requested_incompatible_qos_status()

dds::core::status::RequestedIncompatibleQosStatus dds::sub::AnyDataReader::requested_incompatible_qos_status ( )

This operation obtains the RequestedIncompatibleQosStatus object of the DataReader.

This object contains the information whether a QosPolicy setting was incompatible with the offered QosPolicy setting.

The Request/Offering mechanism is applicable between the DataWriter and the DataReader. If the QosPolicy settings between DataWriter and DataReader are inconsistent, no communication between them is established. In addition the DataWriter will be informed via a REQUESTED_INCOMPATIBLE_QOS status change and the DataReader will be informed via an OFFERED_INCOMPATIBLE_QOS status change.

The RequestedIncompatibleQosStatus can also be monitored using a DataReaderListener or by using the associated StatusCondition.

Returns
the RequestedIncompatibleQosStatus
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.

◆ retain()

void dds::core::Entity::retain ( )
inherited

Retain the Entity, even when it goes out of scope.

This function indicates that references to this object may go out of scope but that the application expects to look it up again later. Therefore the Service must consider this object to be still in use and may not close it automatically.

Returns
void

◆ sample_lost_status()

dds::core::status::SampleLostStatus dds::sub::AnyDataReader::sample_lost_status ( )

This operation obtains the SampleLostStatus object of the DataReader.

This object contains information whether samples have been lost. This only applies when the dds::core::policy::Reliability QosPolicy is set to RELIABLE. If the ReliabilityQos Policy is set to BEST_EFFORT, the Data Distribution Service will not report the loss of samples.

The SampleLostStatus can also be monitored using a DataReaderListener or by using the associated StatusCondition.

Returns
the SampleLostStatus
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.

◆ sample_rejected_status()

dds::core::status::SampleRejectedStatus dds::sub::AnyDataReader::sample_rejected_status ( )

This operation obtains the SampleRejectedStatus object of the DataReader.

This object contains the information whether a received sample has been rejected. Samples may be rejected by the DataReader when it runs out of resource_limits to store incoming samples. Usually this means that old samples need to be "onsumed" (for example by "taking" them instead of "reading" them) to make room for newly incoming samples.

The SampleRejectedStatus can also be monitored using a DataReaderListener or by using the associated StatusCondition.

Returns
the SampleRejectedStatus
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.

◆ status_changes()

const dds::core::status::StatusMask dds::core::Entity::status_changes ( )
inherited

This operation returns a mask with the communication statuses in the Entity that are “triggered”.

This operation retrieves the list of communication statuses in the Entity that are triggered. That is the set of communication statuses whose value have changed since the last time the application called this operation. This operation shows whether a change has occurred even when the status seems unchanged because the status changed back to the original status.

When the Entity is first created or if the Entity is not enabled, all communication statuses are in the “un-triggered” state so the mask returned by the operation is empty.

The result value is a bit mask in which each bit shows which value has changed. The relevant bits represent one of the following statuses:

When the entity is first created, or if the entity is not enabled, all communication statuses are in the untriggered state so the list returned by the status_changes operation will be empty.

Each status bit is declared as a constant and can be used in an AND operation to check the status bit against the result of type StatusMask. Not all statuses are relevant to all Entity objects. See the respective Listener interfaces for each Entity for more information.

The list of statuses returned by the status_changes operation refers to the statuses that are triggered on the Entity itself, and does not include statuses that apply to contained entities.

Returns
dds::core::status::StatusMask a bit mask in which each bit shows which value has changed.

◆ subscriber()

const dds::sub::Subscriber& dds::sub::AnyDataReader::subscriber ( ) const

Get the Subscriber that owns this DataReader.

Returns
the Subscriber
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.

◆ subscription_matched_status()

dds::core::status::SubscriptionMatchedStatus dds::sub::AnyDataReader::subscription_matched_status ( )

This operation obtains the SubscriptionMatchedStatus object of the DataReader.

This object contains the information whether a new match has been discovered for the current subscription, or whether an existing match has ceased to exist.

This means that the status represents that either a DataWriter object has been discovered by the DataReader with the same Topic and a compatible Qos, or that a previously discovered DataWriter has ceased to be matched to the current DataReader. A DataWriter may cease to match when it gets deleted, when it changes its Qos to a value that is incompatible with the current DataReader or when either the DataReader or the DataWriter has chosen to put its matching counterpart on its ignore-list using the dds::sub::ignore or dds::pub::ignore operations on the DomainParticipant.

The operation may fail if the infrastructure does not hold the information necessary to fill in the SubscriptionMatchedStatus. This is the case when OpenSplice is configured not to maintain discovery information in the Networking Service. (See the description for the NetworkingService/Discovery/enabled property in the Deployment Manual for more information about this subject.) In this case the operation will throw UnsupportedError.

The SubscriptionMatchedStatus can also be monitored using a DataReaderListener or by using the associated StatusCondition.

Returns
the SubscriptionMatchedStatus
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.
dds::core::UnsupportedErrorOpenSplice is configured not to maintain the information about "associated" publications.

◆ topic_description()

const dds::topic::TopicDescription& dds::sub::AnyDataReader::topic_description ( ) const

Get the TopicDescription associated with this DataReader.

Returns
the TopicDescription
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.

◆ wait_for_historical_data()

void dds::sub::AnyDataReader::wait_for_historical_data ( const dds::core::Duration timeout)

This operation will block the application thread until all "historical" data is received.

This operation behaves differently for DataReader objects which have a non-VOLATILE dds::core::policy::Durability QosPolicy and for DataReader objects which have a VOLATILE dds::core::policy::Durability QosPolicy.

As soon as an application enables a non-VOLATILE DataReader it will start receiving both "historical" data, i.e. the data that was written prior to the time the DataReader joined the domain, as well as any new data written by the DataWriter objects. There are situations where the application logic may require the application to wait until all "historical" data is received. This is the purpose of the wait_for_historical_data operation.

As soon as an application enables a VOLATILE DataReader it will not start receiving "historical" data but only new data written by the DataWriter objects. By calling wait_for_historical_data the DataReader explicitly requests the Data Distribution Service to start receiving also the "historical" data and to wait until either all "historical" data is received, or the duration specified by the max_wait parameter has elapsed, whichever happens first.

Thread Blocking
The operation wait_for_historical_data blocks the calling thread until either all "historical" data is received, or the duration specified by the max_wait parameter elapses, whichever happens first. When the function returns normally, indicates that all the "historical" data was received. If the function throws TimeoutError, it indicates that max_wait elapsed before all the data was received.

Parameters
timeoutthe time to wait for historical data (can be dds::core::Duration::infinite())
Exceptions
dds::core::ErrorAn internal error has occurred.
dds::core::NullReferenceErrorThe entity was not properly created and references to dds::core::null.
dds::core::AlreadyClosedErrorThe entity has already been closed.
dds::core::NotEnabledErrorThe entity has not yet been enabled.
dds::core::TimeoutErrorNot all data is received before timeout elapsed.
dds::core::OutOfResourcesErrorThe Data Distribution Service ran out of resources to complete this operation.

The documentation for this class was generated from the following file:
dds::domain::qos::DomainParticipantQos
This class provides the basic mechanism for an application to specify Quality of Service attributes f...
Definition: DomainParticipantQos.hpp:58
dds::core::policy::EntityFactory::ManuallyEnable
static EntityFactory ManuallyEnable()