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

<<reference-type>> Allows the application to: (1) declare the data it wishes to receive (i.e. make a subscription) and (2) access the data received by the attached dds::sub::Subscriber. More...

#include "dds/sub/DataReader.hpp"

Inheritance diagram for dds::sub::DataReader< T >:
dds::core::Entity

Classes

class  ManipulatorSelector
 A Selector class enabling the streaming API. More...
 
class  Selector
 The Selector class is used by the DataReader to compose read and take operations. More...
 

Public Member Functions

 DataReader (const dds::sub::Subscriber &sub, const dds::topic::Topic< T > &topic)
 Create a DataReader.
 
 DataReader (const dds::sub::Subscriber &sub, const dds::topic::Topic< T > &topic, const dds::sub::qos::DataReaderQos &qos, dds::sub::DataReaderListener< T > *listener=NULL, const dds::core::status::StatusMask &mask=dds::core::status::StatusMask::all())
 Create a DataReader.
 
 DataReader (const dds::sub::Subscriber &sub, const dds::topic::ContentFilteredTopic< T > &topic)
 Create a DataReader for a dds::topic::ContentFilteredTopic.
 
 DataReader (const dds::sub::Subscriber &sub, const dds::topic::ContentFilteredTopic< T > &topic, const dds::sub::qos::DataReaderQos &qos, dds::sub::DataReaderListener< T > *listener=NULL, const dds::core::status::StatusMask &mask=dds::core::status::StatusMask::all())
 Create a DataReader for a dds::topic::ContentFilteredTopic.
 
const dds::sub::status::DataStatedefault_filter_state ()
 Returns the default state for read/take operations.
 
DataReaderdefault_filter_state (const dds::sub::status::DataState &state)
 Set the default state filter for read/take operations.
 
DataReaderoperator>> (dds::sub::LoanedSamples< T > &ls)
 Use the stream operator to take samples, placing them into a LoanedSamples container.
 
ManipulatorSelector operator>> (bool(*manipulator)(ReadModeDummyType))
 Use the stream operator to read or take samples.
 
template<typename Functor >
ManipulatorSelector operator>> (Functor f)
 Use the stream operator to dictate the behavior of the read or take operation.
 
LoanedSamples< T > read ()
 Read all samples using the default filter state.
 
LoanedSamples< T > take ()
 Take all samples using the default filter state.
 
template<typename SamplesFWIterator >
uint32_t read (SamplesFWIterator sfit, int32_t max_samples)
 Read up to max_samples samples using the default filter state.
 
template<typename SamplesFWIterator >
uint32_t take (SamplesFWIterator sfit, int32_t max_samples)
 Take up to max_samples samples using the default filter state.
 
template<typename SamplesBIIterator >
uint32_t read (SamplesBIIterator sbit)
 Read all samples available in the reader cache using the default filter state.
 
template<typename SamplesBIIterator >
uint32_t take (SamplesBIIterator sbit)
 Take all samples available in the reader cache samples using the default filter state.
 
Selector select ()
 Get a Selector to perform complex data selections, such as per-instance selection, content and status filtering.
 
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.
 
const dds::core::InstanceHandle lookup_instance (const T &key_holder) const
 Retrieve the InstanceHandle that corresponds to an instance key holder.
 
dds::topic::TopicDescription
< DataType > 
topic_description () const
 Returns the dds::topic::TopicDescription associated with the DataReader.
 
const dds::sub::Subscribersubscriber () const
 Returns the Subscriber to which the DataReader belongs.
 
void listener (Listener *the_listener, const dds::core::status::StatusMask &event_mask)
 Sets the listener associated with this reader.
 
Listenerlistener () const
 Returns the listener currently associated with this DataReader.
 
dds::sub::qos::DataReaderQos qos () const
 Get the QoS associated with this reader.
 
void qos (const dds::sub::qos::DataReaderQos &qos)
 Set the QoS associated with this reader.
 
DataReaderoperator<< (const dds::sub::qos::DataReaderQos &the_qos)
 Set the QoS associated with this reader.
 
DataReaderoperator>> (dds::sub::qos::DataReaderQos &the_qos)
 Get the QoS associated with this reader.
 
void wait_for_historical_data (const dds::core::Duration &max_wait)
 Waits until all "historical" data is received for DataReaders that have a non-VOLATILE Durability Qos kind.
 
dds::core::status::LivelinessChangedStatus liveliness_changed_status () const
 Get the LivelinessChangedStatus for this DataReader.
 
dds::core::status::SampleRejectedStatus sample_rejected_status () const
 Get the SampleRejectedStatus for this DataReader.
 
dds::core::status::SampleLostStatus sample_lost_status () const
 Get the SampleLostStatus for this DataReader.
 
dds::core::status::RequestedDeadlineMissedStatus requested_deadline_missed_status ()
 Get the RequestedDeadlineMissedStatus for this DataReader.
 
dds::core::status::RequestedIncompatibleQosStatus requested_incompatible_qos_status () const
 Get the RequestedIncompatibleQosStatus for this DataReader.
 
dds::core::status::SubscriptionMatchedStatus subscription_matched_status () const
 Get the SubscriptionMatchedStatus for this DataReader.
 
rti::core::status::DataReaderCacheStatus datareader_cache_status () const
 <<extension>> Get the DataReaderCacheStatus for this DataReader
 
rti::core::status::DataReaderProtocolStatus datareader_protocol_status () const
 <<extension>> Get the DataReaderProtocolStatus for this DataReader
 
rti::core::status::DataReaderProtocolStatus matched_publication_datareader_protocol_status (const dds::core::InstanceHandle &publication_handle)
 <<extension>> Get the DataReaderProtocolStatus for this DataReader
 
void acknowledge_all ()
 <<extension>> Acknowledge all previously accessed samples
 
void acknowledge_all (const AckResponseData &response_data)
 <<extension>> Acknowledge all previously accessed samples
 
void acknowledge_sample (const dds::sub::SampleInfo &sample_info)
 <<extension>> Acknowledge a single sample explicitly
 
void acknowledge_sample (const dds::sub::SampleInfo &sample_info, const AckResponseData &response_data)
 <<extension>> Acknowledge a single sample explicitly
 
void read (T &sample)
 <<extension>> Copies the next not-previously-accessed data value from the DataReader via a read operation.
 
void read (T &sample, dds::sub::SampleInfo &sample_info)
 <<extension>> Copies the next not-previously-accessed data value from the DataReader via a read operation.
 
void take (T &sample)
 <<extension>> Copies the next not-previously-accessed data value from the DataReader via a take operation.
 
void take (T &sample, dds::sub::SampleInfo &sample_info)
 <<extension>> Copies the next not-previously-accessed data value from the DataReader via a take operation.
 
const std::string & topic_name () const
 <<extension>> Get the topic name associated with this DataReader
 
const std::string & type_name () const
 <<extension>> Get the type name associated with this DataReader
 
void close ()
 Close this DataReader.
 
- 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.)

bool read (dds::sub::ReadModeDummyType)
 The stream manipulator to indicate that the reader should read samples as opposed to taking the samples.
 
bool take (dds::sub::ReadModeDummyType)
 The stream manipulator to indicate that the reader should take samples as opposed to reading the samples.
 
dds::sub::functors::MaxSamplesManipulatorFunctor max_samples (uint32_t n)
 Stream manipulator to set the maximum number of samples to read or take.
 
dds::sub::functors::ContentFilterManipulatorFunctor content (const dds::sub::Query &query)
 Stream manipulator to set a Query to use during the subsequent read/take operation.
 
dds::sub::functors::ConditionManipulatorFunctor condition (const dds::sub::cond::QueryCondition &query_condition)
 Stream manipulator to set a QueryCondition to use during the subsequent read/take operation.
 
dds::sub::functors::StateFilterManipulatorFunctor state (const dds::sub::status::DataState &s)
 Stream manipulator to specify the DataState of the samples that should be read/taken.
 
dds::sub::functors::InstanceManipulatorFunctor instance (const dds::core::InstanceHandle &h)
 Stream manipulator to specify the instance whose samples should be read or taken.
 
dds::sub::functors::NextInstanceManipulatorFunctor next_instance (const dds::core::InstanceHandle &h)
 Stream manipulator to specify the samples belonging to the 'next' instance after the provided instance handle should be accessed.
 
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 subscriptions.
 
template<typename T >
const
::dds::core::InstanceHandleSeq 
matched_publications (const dds::sub::DataReader< T > &reader)
 Retrieve the list of publications currently "associated" with a DataReader.
 
template<typename T , typename FwdIterator >
FwdIterator matched_publications (const dds::sub::DataReader< T > &reader, FwdIterator begin, FwdIterator end)
 Retrieve the list of publications currently "associated" with a DataReader.
 
template<typename T >
const
dds::topic::PublicationBuiltinTopicData 
matched_publication_data (const dds::sub::DataReader< T > &reader, const dds::core::InstanceHandle &handle)
 This operation retrieves the information on a publication that is currently "associated" with the DataReader.
 
template<typename T >
dds::topic::ParticipantBuiltinTopicData matched_publication_participant_data (const dds::sub::DataReader< T > &reader, const dds::core::InstanceHandle &handle)
 <<extension>> This operation retrieves the information on the discovered dds::domain::DomainParticipant associated with the publication that is currently matching with the dds::sub::DataReader.
 
template<typename READER , typename FwdIterator >
uint32_t find (const dds::sub::Subscriber &subscriber, const std::string &topic_name, FwdIterator begin, uint32_t max_size)
 This function retrieves a previously-created DataReader belonging to the Subscriber that is attached to a Topic with a matching topic name.
 
template<typename READER , typename BinIterator >
uint32_t find (const dds::sub::Subscriber &subscriber, const std::string &topic_name, BinIterator begin)
 This function retrieves a previously-created DataReader belonging to the Subscriber that is attached to a Topic with a matching topic name.
 
template<typename READER , typename T , typename FwdIterator >
uint32_t find (const dds::sub::Subscriber &subscriber, const dds::topic::TopicDescription< T > &topic_description, FwdIterator begin, uint32_t max_size)
 
template<typename READER , typename T , typename BinIterator >
uint32_t find (const dds::sub::Subscriber &subscriber, const dds::topic::TopicDescription< T > &topic_description, BinIterator begin)
 This function retrieves a previously-created DataReader belonging to the Subscriber that is attached to a Topic with a matching TopicDescription.
 
template<typename AnyDataReaderBackInsertIterator >
uint32_t find_datareaders (dds::sub::Subscriber subscriber, AnyDataReaderBackInsertIterator begin)
 <<extension>> Retrieve all the dds::sub::DataReader created from this dds::sub::Subscriber
 
template<typename AnyDataReaderForwardIterator >
uint32_t find_datareaders (dds::sub::Subscriber subscriber, AnyDataReaderForwardIterator begin, uint32_t max_size)
 <<extension>> Retrieve all the readers created from a subscriber.
 
template<typename READER >
READER find_datareader_by_topic_name (dds::sub::Subscriber subscriber, const std::string &topic_name)
 <<extension>> Retrieves a dds::sub::DataReader with the given topic name within the dds::sub::Subscriber
 
template<typename READER >
READER find_datareader_by_name (dds::sub::Subscriber subscriber, const std::string &datareader_name)
 <<extension>> Retrieves a dds::sub::DataReader with the given name within the dds::sub::Subscriber
 
template<typename READER , typename T >
READER find_datareader_by_topic_description (const dds::sub::Subscriber &subscriber, const dds::topic::TopicDescription< T > &topic_description)
 <<extension>> Retrieves a dds::sub::DataReader with the given TopicDescription within the dds::sub::Subscriber
 
template<typename READER >
READER find_datareader_by_name (dds::domain::DomainParticipant participant, const std::string &datareader_name)
 <<extension>> Retrieves a dds::sub::DataReader within the dds::domain::DomainParticipant with the given name
 

Detailed Description

template<typename T>
class dds::sub::DataReader< T >

<<reference-type>> Allows the application to: (1) declare the data it wishes to receive (i.e. make a subscription) and (2) access the data received by the attached dds::sub::Subscriber.

Template Parameters
TThe topic-type that the DataReader subscribes to
QoS:
dds::sub::qos::DataReaderQos
Status:
dds::core::status::StatusMask::data_available();
dds::core::status::StatusMask::liveliness_changed(), dds::core::status::LivelinessChangedStatus;
dds::core::status::StatusMask::requested_deadline_missed(), dds::core::status::RequestedDeadlineMissedStatus;
dds::core::status::StatusMask::requested_incompatible_qos(), dds::core::status::RequestedIncompatibleQosStatus;
dds::core::status::StatusMask::sample_lost(), dds::core::status::SampleLostStatus;
dds::core::status::StatusMask::sample_rejected(), dds::core::status::SampleRejectedStatus;
dds::core::status::StatusMask::subscription_matched(), dds::core::status::SubscriptionMatchedStatus;
Listener:
dds::sub::DataReaderListener

A dds::sub::DataReader refers to exactly one TopicDescription (either a dds::topic::Topic, a dds::topic::ContentFilteredTopic or a MultiTopic) that identifies the data to be read.

The subscription has a unique resulting type. The data-reader may give access to several instances of the resulting type, which can be distinguished from each other by their key.

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

All sample-accessing operations may fail with the expection dds::core::PreconditionNotMetError as described in dds::sub::CoherentAccess::CoherentAccess().

See Also
Operations Allowed in Listener Callbacks
Access to data samples
DataReader Use Cases
Entity Use Cases
Examples:
Foo_subscriber.cxx.

Constructor & Destructor Documentation

template<typename T>
dds::sub::DataReader< T >::DataReader ( const dds::sub::Subscriber sub,
const dds::topic::Topic< T > &  topic 
)
inline

Create a DataReader.

It uses the default DataReaderQos, and no listener.

Parameters
subthe Subscriber owning this DataReader.
topicthe Topic associated with this DataReader.
template<typename T>
dds::sub::DataReader< T >::DataReader ( const dds::sub::Subscriber sub,
const dds::topic::Topic< T > &  topic,
const dds::sub::qos::DataReaderQos qos,
dds::sub::DataReaderListener< T > *  listener = NULL,
const dds::core::status::StatusMask mask = dds::core::status::StatusMask::all() 
)
inline

Create a DataReader.

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

MT Safety:
UNSAFE. If the qos parameter is omitted it is not safe to create the datareader while another thread may be simultaneously calling dds::sub::Subscriber::default_datareader_qos(dds::sub::qos::DataReaderQos).
Precondition
If sub is enabled, the topic must be enabled. If it is not, this operation will fail and no DataReader will be created.
The given dds::topic::Topic must have been created from the same participant as this subscriber. If it was created from a different participant no DataReader will be created.
Parameters
subthe Subscriber owning this DataReader.
topicthe Topic associated with this DataReader.
qosthe QoS settings for this DataReader.
listenerthe listener.
maskthe event mask associated to the DataReader listener.
See Also
Specifying QoS on entities for information on setting QoS before entity creation
dds::sub::qos::DataReaderQos for rules on consistency among QoS
dds::core::QosProvider::datareader_qos()
dds::sub::qos::DataReaderQos::operator=(const dds::topic::qos::TopicQos&) which allows assigning the contents of a TopicQos into a DataReaderQos
listener()
template<typename T>
dds::sub::DataReader< T >::DataReader ( const dds::sub::Subscriber sub,
const dds::topic::ContentFilteredTopic< T > &  topic 
)
inline

Create a DataReader for a dds::topic::ContentFilteredTopic.

This DataReader will only receive that data that matches the Filter associated with the ContentFilteredTopic. The QoS will be set to sub.default_datareader_qos().

Parameters
subthe Subscriber owning this DataReader.
topicthe content filtered topic
template<typename T>
dds::sub::DataReader< T >::DataReader ( const dds::sub::Subscriber sub,
const dds::topic::ContentFilteredTopic< T > &  topic,
const dds::sub::qos::DataReaderQos qos,
dds::sub::DataReaderListener< T > *  listener = NULL,
const dds::core::status::StatusMask mask = dds::core::status::StatusMask::all() 
)
inline

Create a DataReader for a dds::topic::ContentFilteredTopic.

This DataReader will only receive that data that mathes the Filter associated with the ContentFilteredTopic.

Parameters
subthe subscriber owning this DataReader.
topicthe content filtered topic.
qosthe QoS settings for this DataReader.
listenerthe listener.
maskthe event mask associated to the DataReader listener.

Member Function Documentation

template<typename T>
const dds::sub::status::DataState& dds::sub::DataReader< T >::default_filter_state ( )
inline

Returns the default state for read/take operations.

If left as default, it is set to dds::sub::status::DataState::any().

template<typename T>
DataReader& dds::sub::DataReader< T >::default_filter_state ( const dds::sub::status::DataState state)
inline

Set the default state filter for read/take operations.

Parameters
statethe state mask that will be used to read/take samples.
template<typename T>
DataReader& dds::sub::DataReader< T >::operator>> ( dds::sub::LoanedSamples< T > &  ls)
inline

Use the stream operator to take samples, placing them into a LoanedSamples container.

For example:

reader >> loaned_samples;

If you want to read samples, instead of take, you must use the stream manipulator read(dds::sub::ReadModeDummyType) and operator>>(bool(*manipulator)(ReadModeDummyType))

For example:

reader >> read >> loaned_samples;
Parameters
lsThe LoanedSamples container to put the taken samples into
See Also
operator>>(bool(*manipulator)(ReadModeDummyType))
operator>>(Functor f)
Accessing Received Data
template<typename T>
ManipulatorSelector dds::sub::DataReader< T >::operator>> ( bool(*)(ReadModeDummyType manipulator)
inline

Use the stream operator to read or take samples.

The read and take manipulators are defined externally to make it possible to control whether the stream operators reads or takes.

This stream operator can be chained together with operator>>(Functor f) to set other various properties of the read/take operation.

It is used as follows:

dr >> read >> loanedSamples;
dr >> take >> loanedSamples;

If either the read or take manipulator is not passed into the stream, the default behavior is to take.

Parameters
manipulatorEither read or take
See Also
operator>>(Functor f)
operator>>(dds::sub::LoanedSamples<T>& ls)
ReadModeDummyType
Accessing Received Data
template<typename T>
template<typename Functor >
ManipulatorSelector dds::sub::DataReader< T >::operator>> ( Functor  f)
inline

Use the stream operator to dictate the behavior of the read or take operation.

There are a number of pre-defined stream manipulators (functions which return a functor that will be used by the stream operator). They dictate how the samples will be read or taken:

  • max_samples: Read/Take up to a maximum number of samples
  • content: Read/Take using a Query
  • condition: Read/Take using a dds::sub::cond::QueryCondition
  • state: Read/Take only samples with a specific DataState
  • instance: Read/Take a specific instance
  • next_instance: Read/Take the next instance after a specified instance

For example, to read up to 10 samples that have not been read before:

dr >> read
>> max_samples(10)
>> state(DataState::new_data())
>> loanedSamples;
Parameters
fEach of the stream manipulators listed above return a Functor that will be passed to the stream operator. These Functors do not need to be accessed by the user directly. They should instead be passed indirectly via the return value of one of the provided stream manipulators.
See Also
dds::sub::max_samples(uint32_t n)
dds::sub::content(const dds::sub::Query& query)
dds::sub::condition(const dds::sub::cond::QueryCondition& query_condition)
dds::sub::state(const dds::sub::status::DataState& s)
dds::sub::instance(const dds::core::InstanceHandle& h)
dds::sub::next_instance(const dds::core::InstanceHandle& h)
Accessing Received Data
template<typename T>
LoanedSamples<T> dds::sub::DataReader< T >::read ( )
inline

Read all samples using the default filter state.

This operation offers the same functionality and API as dds::sub::DataReader::take except that the samples returned remain in the dds::sub::DataReader such that they can be retrieved again by means of a read or take operation.

Please refer to the documentation of dds::sub::DataReader::take for details on the number of samples returned as well as the order in which the samples appear in these sequences.

The act of reading a sample changes its sample_state to dds::sub::status::SampleState::read(). If the sample belongs to the most recent generation of the instance, it will also set the view_state of the instance to be dds::sub::status::ViewState::not_new_view(). It will not affect the instance_state of the instance.

Once the application completes its use of the samples, it must 'return the loan' to the dds::sub::DataReader by calling the dds::sub::LoanedSamples::return_loan() operation. The dds::sub::LoanedSamples destructor also takes care of returning the loan for you, so calling dds::sub::LoanedSamples::return_loan() explicitly is not required.

Important: When you loan data from the middleware, you must not keep any pointers to any part of the data samples or the dds::sub::SampleInfo objects after the call to dds::sub::LoanedSamples::return_loan(). Returning the loan places the objects back into a pool, allowing the middleware to overwrite them with new data.

Note: While you must call dds::sub::LoanedSamples::return_loan() at some point, you do not have to do so before the next dds::sub::DataReader::take call. However, failure to return the loan will eventually deplete the dds::sub::DataReader of the buffers it needs to receive new samples and eventually samples will start to be lost. The total number of buffers available to the dds::sub::DataReader is specified by the dds::core::policy::ResourceLimits and the rti::core::policy::DataReaderResourceLimits.

Important: If the samples "returned" by this method are loaned from RTI Connext (see dds::sub::DataReader::take for more information on memory loaning), it is important that their contents not be changed. Because the memory in which the data is stored belongs to the middleware, any modifications made to the data will be seen the next time the same samples are read or taken; the samples will no longer reflect the state that was received from the network.

Exceptions
Oneof the Standard Exceptions, dds::core::PreconditionNotMetError, dds::core::NotEnabledError.
See Also
dds::sub::DataReader::take
Accessing Received Data
select()
template<typename T>
LoanedSamples<T> dds::sub::DataReader< T >::take ( )
inline

Take all samples using the default filter state.

The operation will return the list of samples received by the dds::sub::DataReader since the last dds::sub::DataReader::take operation that matches the specified SampleStateMask, ViewStateMask and InstanceStateMask.

This operation may fail with dds::core::Error if the rti::core::policy::DataReaderResourceLimits::max_outstanding_reads limit has been exceeded.

The actual number of samples returned depends on the information that has been received by the middleware as well as the dds::core::policy::History, dds::core::policy::ResourceLimits, rti::core::policy::DataReaderResourceLimits and the characteristics of the data-type that is associated with the dds::sub::DataReader:

If the read or take succeeds and the number of samples returned has been limited (by means of a maximum limit, as listed above, or insufficient dds::sub::SampleInfo resources), the call will complete successfully and provide those samples the reader is able to return. The user may need to make additional calls, or return outstanding loaned buffers in the case of insufficient resources, in order to access remaining samples.

Note that in the case where the dds::topic::Topic associated with the dds::sub::DataReader is bound to a data-type that has no key definition, then there will be at most one instance in the dds::sub::DataReader. So the per-sample limits will apply.

The act of taking a sample removes it from RTI Connext so it cannot be read or taken again. If the sample belongs to the most recent generation of the instance, it will also set the view_state of the sample's instance to dds::sub::status::ViewState::not_new_view(). It will not affect the instance_state of the sample's instance.

Once the application completes its use of the samples it must 'return the loan' to the dds::sub::DataReader by calling the dds::sub::LoanedSamples::return_loan() operation. The dds::sub::LoanedSamples destructor also takes care of returning the loan for you, so calling dds::sub::LoanedSamples::return_loan() explicitly is not required.

Important: When you loan data from the middleware, you must not keep any pointers to any part of the data samples or the dds::sub::SampleInfo objects after the call to dds::sub::LoanedSamples::return_loan(). Returning the loan places the objects back into a pool, allowing the middleware to overwrite them with new data.

Note: While you must call dds::sub::LoanedSamples::return_loan() at some point, you do not have to do so before the next dds::sub::DataReader::take call. However, failure to return the loan will eventually deplete the dds::sub::DataReader of the buffers it needs to receive new samples and eventually samples will start to be lost. The total number of buffers available to the dds::sub::DataReader is specified by the dds::core::policy::ResourceLimits and the rti::core::policy::DataReaderResourceLimits.

To copy samples from the reader instead of taking a loan, you can use any of the read or take operations that receive an iterator to a container in which to copy the samples:

The order of the samples returned to the caller depends on the dds::core::policy::Presentation.

In any case, the relative order between the samples of one instance is consistent with the DESTINATION_ORDER policy:

  • If dds::core::policy::DestinationOrder::kind is dds::core::policy::DestinationOrderKind::BY_RECEPTION_TIMESTAMP, samples belonging to the same instances will appear in the relative order in which there were received (FIFO, earlier samples ahead of the later samples).
  • If dds::core::policy::DestinationOrder::kind is dds::core::policy::DestinationOrderKind::BY_SOURCE_TIMESTAMP, samples belonging to the same instances will appear in the relative order implied by the source_timestamp (FIFO, smaller values of source_timestamp ahead of the larger values).

If the dds::sub::DataReader has no samples that meet the constraints, the method will fail with SKIP::RETCODE_NO_DATA.

In addition to the collection of samples, the read and take operations also use a collection of dds::sub::SampleInfo structures.

SEQUENCES USAGE IN TAKE AND READ

Some elements in the returned collection may not have valid data. If the instance_state in the dds::sub::SampleInfo is dds::sub::status::InstanceState::not_alive_disposed() or dds::sub::status::InstanceState::not_alive_no_writers(), then the last sample for that instance in the collection (that is, the one whose dds::sub::SampleInfo has sample_rank==0) does not contain valid data.

Samples that contain no data do not count towards the limits imposed by the dds::core::policy::ResourceLimits. The act of reading/taking a sample sets its sample_state to dds::sub::status::SampleState::read().

If the sample belongs to the most recent generation of the instance, it will also set the view_state of the instance to dds::sub::status::ViewState::not_new_view(). It will not affect the instance_state of the instance.

For an example on how take can be used, please refer to the receive example.

Exceptions
Oneof the Standard Exceptions, dds::core::PreconditionNotMetError, dds::core::NotEnabledError.
See Also
dds::sub::DataReader::read
Accessing Received Data
select()
template<typename T>
template<typename SamplesFWIterator >
uint32_t dds::sub::DataReader< T >::read ( SamplesFWIterator  sfit,
int32_t  max_samples 
)
inline

Read up to max_samples samples using the default filter state.

The samples are copied into the application provided container using the forward iterator parameter.

Template Parameters
SamplesFWIteratorA forward iterator whose value type is dds::sub::Sample<T>
Parameters
sfitsamples forward iterator
max_samplesthe maximum number of samples to read
Returns
uint32_t the number of read samples.
See Also
read()
Accessing Received Data
template<typename T>
template<typename SamplesFWIterator >
uint32_t dds::sub::DataReader< T >::take ( SamplesFWIterator  sfit,
int32_t  max_samples 
)
inline

Take up to max_samples samples using the default filter state.

The samples are copied into the application provided container using the forward iterator parameter.

Template Parameters
SamplesFWIteratorA forward iterator whose value type is dds::sub::Sample<T>
Parameters
sfitsamples forward iterator.
max_samplesthe maximum number of samples to take.
Returns
uint32_t The number of taken samples.
See Also
take()
Accessing Received Data
template<typename T>
template<typename SamplesBIIterator >
uint32_t dds::sub::DataReader< T >::read ( SamplesBIIterator  sbit)
inline

Read all samples available in the reader cache using the default filter state.

The samples are copied into the application provided container using a back-inserting iterator. Notice that as a consequence of using a back-inserting iterator, this operation may allocate memory to resize the underlying container.

Template Parameters
SamplesBIIteratorA back-inserting iterator whose value type is dds::sub::Sample<T>
Parameters
sbitsamples back-inserting iterator.
Returns
uint32_t the number of read samples.
See Also
read()
Accessing Received Data
template<typename T>
template<typename SamplesBIIterator >
uint32_t dds::sub::DataReader< T >::take ( SamplesBIIterator  sbit)
inline

Take all samples available in the reader cache samples using the default filter state.

The samples are copied into the application provided container using a back-inserting iterator. Notice that as a consequence of using a back-inserting iterator, this operation may allocate memory to resize the underlying container.

Template Parameters
SamplesBIIteratorA back-inserting iterator whose value type is dds::sub::Sample<T>
Parameters
sbitsamples back-inserting iterator.
Returns
the number of taken samples.
See Also
take()
Accessing Received Data
template<typename T>
Selector dds::sub::DataReader< T >::select ( )
inline

Get a Selector to perform complex data selections, such as per-instance selection, content and status filtering.

The selector can be used as follows:

LoanedSamples<Foo> samples = reader.select()
.instance(handle)
.content(query)
.take();

This shows how samples can be taken by selecting a specific instance, then filtering by state and content.

Note that when the application wants to access all available samples it can simply call DataReader::read() or DataReader::take().

Returns
A Selector, typically used in-line to configure it and finally call Selector::read() or Selector::take().
See Also
Selector, for the different parameters that can be set to configure what samples to read or take.
Selecting what samples to read
template<typename T>
T& dds::sub::DataReader< 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.

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 DataReader.

Parameters
key_holderA user data type specific key holder of type T whose key fields are filled by this operation. If T has no key, this operation has no effect.
handleThe instance whose key is to be retrieved. If T has a key, handle must represent an existing instance of type T known to the DataReader. 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. If T has a key and handle represents an instance of another type or an instance of type T that has been unregistered, this method will fail with dds::core::InvalidArgumentError. If T has no key, this method has no effect.
template<typename T>
dds::topic::TopicInstance<T>& dds::sub::DataReader< 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.

Useful for keyed data types.

The operation will only fill the fields that form the key inside the key_holder instance.

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 DataReader.

Parameters
key_holderA TopicInstance whose sample's key fields are filled by this operation. If T does not have a key, this method has no effect.
handleThe instance whose key is to be retrieved. If T has a key, handle must represent an existing instance of type T known to the DataReader. 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. If T has a key and handle represents an instance of another type or an instance of type T that has been unregistered, this method will fail with dds::core::InvalidArgumentError. If T has no key, this method has no effect.
template<typename T>
const dds::core::InstanceHandle dds::sub::DataReader< T >::lookup_instance ( const T &  key_holder) const
inline

Retrieve the InstanceHandle 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 the Service is unable to provide an instance handle, the Service will return the special value dds::core::InstanceHandle::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::topic::TopicDescription<DataType> dds::sub::DataReader< T >::topic_description ( ) const
inline

Returns the dds::topic::TopicDescription associated with the DataReader.

Returns that same TopicDescription that was used to create the dds::sub::DataReader.

Returns
TopicDescription associated with the dds::sub::DataReader.
template<typename T>
const dds::sub::Subscriber& dds::sub::DataReader< T >::subscriber ( ) const
inline

Returns the Subscriber to which the DataReader belongs.

template<typename T>
void dds::sub::DataReader< T >::listener ( Listener the_listener,
const dds::core::status::StatusMask event_mask 
)
inline

Sets the listener associated with this reader.

Parameters
the_listenerThe DataReaderListener to set
event_maskThe dds::core::status::StatusMask associated with the listener
template<typename T>
Listener* dds::sub::DataReader< T >::listener ( ) const
inline

Returns the listener currently associated with this DataReader.

If there's no listener it returns NULL.

template<typename T>
dds::sub::qos::DataReaderQos dds::sub::DataReader< T >::qos ( ) const
inline

Get the QoS associated with this reader.

template<typename T>
void dds::sub::DataReader< T >::qos ( const dds::sub::qos::DataReaderQos qos)
inline

Set the QoS associated with this reader.

This operation modifies the QoS of the DataReader.

The dds::core::policy::UserData, dds::core::policy::Deadline, dds::core::policy::LatencyBudget, dds::core::policy::TimeBasedFilter, dds::core::policy::ReaderDataLifecycle can be changed. The other policies are immutable.

Parameters
qosThe DataReaderQos to be set to. Policies must be consistent. Immutable policies cannot be changed after the DataReader is enabled. dds::sub::Subscriber::default_datareader_qos() can be used to set the QoS of the DataReader to match the current default DataReaderQos set in the Subscriber.
Exceptions
dds::core::ImmutablePolicyError,ordds::core::InconsistentPolicyError.,
See Also
dds::sub::qos::DataReaderQos for rules on consistency among QoS
set_qos (abstract)
Operations Allowed in Listener Callbacks
template<typename T>
DataReader& dds::sub::DataReader< T >::operator<< ( const dds::sub::qos::DataReaderQos the_qos)
inline

Set the QoS associated with this reader.

Parameters
the_qosthe new qos for this DataReader.
See Also
qos(const dds::sub::qos::DataReaderQos& qos)
template<typename T>
DataReader& dds::sub::DataReader< T >::operator>> ( dds::sub::qos::DataReaderQos the_qos)
inline

Get the QoS associated with this reader.

Parameters
the_qosthe object to populate with the qos for this DataWriter.
See Also
qos()
template<typename T>
void dds::sub::DataReader< T >::wait_for_historical_data ( const dds::core::Duration max_wait)
inline

Waits until all "historical" data is received for DataReaders that have a non-VOLATILE Durability Qos kind.

This operation is intended only for dds::sub::DataReader entities that have a non-VOLATILE Durability QoS kind.

As soon as an application enables a non-VOLATILE dds::sub::DataReader, it will start receiving both "historical" data (i.e., the data that was written prior to the time the dds::sub::DataReader joined the domain) as well as any new data written by the dds::pub::DataWriter entities. 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 dds::sub::DataReader::wait_for_historical_data operations.

dds::sub::DataReader::wait_for_historical_data() blocks the calling thread until either all "historical" data is received, or until the duration specified by the max_wait parameter elapses, whichever happens first. It will return immediately if no DataWriters have been discovered at the time the operation is called; therefore it is advisable to make sure at least one dds::pub::DataWriter has been discovered before calling this operation. (One way to do this is by using dds::sub::DataReader::subscription_matched_status.)

A successful completion indicates that all the "historical" data was "received"; timing out indicates that max_wait elapsed before all the data was received.

Parameters
max_wait<<in>> Timeout value.
Exceptions
Oneof the Standard Exceptions, dds::core::TimeoutError or dds::core::NotEnabledError.
template<typename T>
dds::core::status::LivelinessChangedStatus dds::sub::DataReader< T >::liveliness_changed_status ( ) const
inline

Get the LivelinessChangedStatus for this DataReader.

See Also
dds::core::status::LivelinessChangedStatus
template<typename T>
dds::core::status::SampleRejectedStatus dds::sub::DataReader< T >::sample_rejected_status ( ) const
inline

Get the SampleRejectedStatus for this DataReader.

See Also
dds::core::status::SampleRejectedStatus
template<typename T>
dds::core::status::SampleLostStatus dds::sub::DataReader< T >::sample_lost_status ( ) const
inline

Get the SampleLostStatus for this DataReader.

See Also
dds::core::status::SampleLostStatus
template<typename T>
dds::core::status::RequestedDeadlineMissedStatus dds::sub::DataReader< T >::requested_deadline_missed_status ( )
inline

Get the RequestedDeadlineMissedStatus for this DataReader.

See Also
dds::core::status::RequestedDeadlineMissedStatus
template<typename T>
dds::core::status::RequestedIncompatibleQosStatus dds::sub::DataReader< T >::requested_incompatible_qos_status ( ) const
inline

Get the RequestedIncompatibleQosStatus for this DataReader.

See Also
dds::core::status::RequestedIncompatibleQosStatus
template<typename T>
dds::core::status::SubscriptionMatchedStatus dds::sub::DataReader< T >::subscription_matched_status ( ) const
inline

Get the SubscriptionMatchedStatus for this DataReader.

See Also
dds::core::status::SubscriptionMatchedStatus
template<typename T>
rti::core::status::DataReaderCacheStatus datareader_cache_status ( ) const

<<extension>> Get the DataReaderCacheStatus for this DataReader

See Also
rti::core::status::DataReaderCacheStatus
template<typename T>
rti::core::status::DataReaderProtocolStatus datareader_protocol_status ( ) const

<<extension>> Get the DataReaderProtocolStatus for this DataReader

See Also
rti::core::status::DataReaderProtocolStatus
template<typename T>
rti::core::status::DataReaderProtocolStatus matched_publication_datareader_protocol_status ( const dds::core::InstanceHandle publication_handle)

<<extension>> Get the DataReaderProtocolStatus for this DataReader

See Also
rti::core::status::DataReaderProtocolStatus
template<typename T>
void acknowledge_all ( )

<<extension>> Acknowledge all previously accessed samples

Applicable only when dds::core::policy::Reliability::acknowledgment_kind = rti::core::policy::AcknowledgmentKind_def::APPLICATION_EXPLICIT

A call to this method does not necessarily trigger the sending of an AppAck RTPS message from the DataReader to the DataWriter. How and when AppAck messages are sent can be configured using the QoS values rti::core::RtpsReliableReaderProtocol::samples_per_app_ack and rti::core::RtpsReliableReaderProtocol::app_ack_period.

Exceptions
Oneof the Standard Exceptions
template<typename T>
void acknowledge_all ( const AckResponseData &  response_data)

<<extension>> Acknowledge all previously accessed samples

Applicable only when dds::core::policy::Reliability::acknowledgment_kind = rti::core::policy::AcknowledgmentKind_def::APPLICATION_EXPLICIT

A call to this method does not necessarily trigger the sending of an AppAck RTPS message from the DataReader to the DataWriter. How and when AppAck messages are sent can be configured using the QoS values rti::core::RtpsReliableReaderProtocol::samples_per_app_ack and rti::core::RtpsReliableReaderProtocol::app_ack_period.

The maximum length of the response is configured using rti::core::policy::DataReaderResourceLimits::max_app_ack_response_length

Parameters
response_data<<in>> Response data sent to dds::pub::DataWriter upon acknowledgment
Exceptions
Oneof the Standard Exceptions
template<typename T>
void acknowledge_sample ( const dds::sub::SampleInfo sample_info)

<<extension>> Acknowledge a single sample explicitly

Applicable only when dds::core::policy::Reliability::acknowledgment_kind = rti::core::policy::AcknowledgmentKind_def::APPLICATION_EXPLICIT

A call to this method does not necessarily trigger the sending of an AppAck RTPS message from the DataReader to the DataWriter. How and when AppAck messages are sent can be configured using the QoS values rti::core::RtpsReliableReaderProtocol::samples_per_app_ack and rti::core::RtpsReliableReaderProtocol::app_ack_period.

Parameters
sample_info<<in>> dds::sub::SampleInfo identifying the sample being acknowledged.
Exceptions
Oneof the Standard Exceptions
template<typename T>
void acknowledge_sample ( const dds::sub::SampleInfo sample_info,
const AckResponseData &  response_data 
)

<<extension>> Acknowledge a single sample explicitly

Applicable only when dds::core::policy::Reliability::acknowledgment_kind = rti::core::policy::AcknowledgmentKind_def::APPLICATION_EXPLICIT

A call to this method does not necessarily trigger the sending of an AppAck RTPS message from the DataReader to the DataWriter. How and when AppAck messages are sent can be configured using the QoS values rti::core::RtpsReliableReaderProtocol::samples_per_app_ack and rti::core::RtpsReliableReaderProtocol::app_ack_period.

The maximum length of the response is configured using rti::core::policy::DataReaderResourceLimits::max_app_ack_response_length

Parameters
sample_info<<in>> dds::sub::SampleInfo identifying the sample being acknowledged.
response_data<<in>> Response data sent to dds::pub::DataWriter upon acknowledgment (via dds::pub::DataWriterListener::on_application_acknowledgment)
Exceptions
Oneof the Standard Exceptions
template<typename T>
void read ( T &  sample)

<<extension>> Copies the next not-previously-accessed data value from the DataReader via a read operation.

See Also
read(T& sample, dds::sub::SampleInfo& sample_info)
template<typename T>
void read ( T &  sample,
dds::sub::SampleInfo sample_info 
)

<<extension>> Copies the next not-previously-accessed data value from the DataReader via a read operation.

This operation copies the next not-previously-accessed data value from the dds::sub::DataReader. This operation also copies the corresponding dds::sub::SampleInfo. The implied order among the samples stored in the dds::sub::DataReader is the same as for the dds::sub::DataReader::read operation.

The dds::sub::DataReader::read(T& sample, dds::sub::SampleInfo& sample_info) operation is semantically equivalent to the dds::sub::DataReader::read operation, where the sample_states=NOT_READ, the view_states=ANY_VIEW_STATE, and the instance_states=ANY_INSTANCE_STATE.

The dds::sub::DataReader::read(T& sample, dds::sub::SampleInfo& sample_info) operation provides a simplified API to 'read' samples, avoiding the need for the application to manage sequences and specify states.

Exceptions
Oneof the Standard Exceptions, dds::core::NotEnabledError.
See Also
dds::sub::DataReader::read
template<typename T>
void take ( T &  sample)

<<extension>> Copies the next not-previously-accessed data value from the DataReader via a take operation.

See Also
take(T& sample, dds::sub::SampleInfo& sample_info)
template<typename T>
void take ( T &  sample,
dds::sub::SampleInfo sample_info 
)

<<extension>> Copies the next not-previously-accessed data value from the DataReader via a take operation.

This operation copies the next not-previously-accessed data value from the dds::sub::DataReader and 'removes' it from the dds::sub::DataReader so that it is no longer accessible. This operation also copies the corresponding dds::sub::SampleInfo. This operation is analogous to the dds::sub::DataReader::read(T& sample, dds::sub::SampleInfo& sample_info) except for the fact that the sample is removed from the dds::sub::DataReader.

The dds::sub::DataReader::take(T& sample, dds::sub::SampleInfo& sample_info) operation is semantically equivalent to the dds::sub::DataReader::take operation, where the sample_states=NOT_READ, the view_states=ANY_VIEW_STATE, and the instance_states=ANY_INSTANCE_STATE.

The dds::sub::DataReader::take(T& sample, dds::sub::SampleInfo& sample_info) operation provides a simplified API to 'take' samples, avoiding the need for the application to manage sequences and specify states.

Exceptions
Oneof the Standard Exceptions,

dds::core::NotEnabledError.

See Also
dds::sub::DataReader::take
template<typename T>
const std::string & topic_name ( ) const

<<extension>> Get the topic name associated with this DataReader

template<typename T>
const std::string & type_name ( ) const

<<extension>> Get the type name associated with this DataReader

template<typename T>
void close ( )

Close this DataReader.

Friends And Related Function Documentation

template<typename T>
bool read ( dds::sub::ReadModeDummyType  )
related

The stream manipulator to indicate that the reader should read samples as opposed to taking the samples.

Usage:

reader >> read >> loaned_samples;
See Also
dds::sub::DataReader::operator >>(bool(*manipulator)(ReadModeDummyType))
template<typename T>
bool take ( dds::sub::ReadModeDummyType  )
related

The stream manipulator to indicate that the reader should take samples as opposed to reading the samples.

Usage:

reader >> take >> loaned_samples;

The default mode to access samples is to take, so the above is equivalent to:

reader >> loaned_samples;
See Also
dds::sub::DataReader::operator >>(bool(*manipulator)(ReadModeDummyType))
template<typename T>
dds::sub::functors::MaxSamplesManipulatorFunctor max_samples ( uint32_t  n)
related

Stream manipulator to set the maximum number of samples to read or take.

Use this function to set the maximum number of samples to read/take by passing it to the DataReader::operator >>(Functor f) operator.

Parameters
nThe maximum number of samples to take
See Also
dds::sub::DataReader::operator >>(Functor f)
template<typename T>
dds::sub::functors::ContentFilterManipulatorFunctor content ( const dds::sub::Query query)
related

Stream manipulator to set a Query to use during the subsequent read/take operation.

The effect of using this manipulator is that the subsequent read/take will filter the samples based on the Query's expression. If the DataReader has no samples that meet the constraints, the read/take will not return any data.

If this stream manipulator comes before a call to the condition(const dds::sub::cond::QueryCondition& query_condition) manipulator then it will be overridden and will not have any effect on the read or take operation. Similarly, if this operation follows a call to condition(), then the previously set QueryCondition will be cleared.

Parameters
queryThe Query to use during the read/take
See Also
dds::sub::DataReader::operator >>(Functor f)
dds::sub::condition(const dds::sub::cond::QueryCondition& query_condition)
template<typename T>
dds::sub::functors::ConditionManipulatorFunctor condition ( const dds::sub::cond::QueryCondition query_condition)
related

Stream manipulator to set a QueryCondition to use during the subsequent read/take operation.

The effect of using this manipulator is that the subsequent read/take will filter the samples based on the QueryConditions's expression and state. If the DataReader has no samples that meet the constraints, the read/take will not return any data.

If this stream manipulator comes before a call to the content(const dds::sub::Query& query) manipulator then it will be overridden and will not have any effect on the read or take operation. Similarly, if this operation follows a call to content() and/or state(const dds::sub::status::DataState& s), then the previously set Query and DataState will be cleared.

This manipulator is effectively a combination of the content and state manipulators.

For example:

reader >> read
>> content(dds::sub::Query(system.reader, "foo = 7"))
>> samples;

is equivalent to:

reader >> read
>> condition(Query(system.reader, "foo = 7"), DataState()::new_data())
>> samples;
Parameters
query_conditionThe QueryCondition to use during the read/take
See Also
dds::sub::DataReader::operator >>(Functor f)
content(const dds::sub::Query& query)
template<typename T>
dds::sub::functors::StateFilterManipulatorFunctor state ( const dds::sub::status::DataState s)
related

Stream manipulator to specify the DataState of the samples that should be read/taken.

By setting the dds::sub::status::DataState you can specify the state of the samples that should be read or taken. The DataState of a sample encapsulates the dds::sub::status::SampleState, dds::sub::status::ViewState, and dds::sub::status::InstanceState of a sample.

If this stream manipulator comes before a call to the condition(const dds::sub::cond::QueryCondition& query_condition) manipulator then it will be overridden and will not have any effect on the read or take operation.

Parameters
sThe DataState of the samples to be read or taken
See Also
dds::sub::DataReader::operator >>(Functor f)
template<typename T>
dds::sub::functors::InstanceManipulatorFunctor instance ( const dds::core::InstanceHandle h)
related

Stream manipulator to specify the instance whose samples should be read or taken.

This operation causes the subsequent read or take operation to access only samples belonging the single specified instance whose handle is h.

Upon successful completion, the data collection will contain samples all belonging to the same instance. The corresponding SampleInfo verifies SampleInfo.instance_handle() == h.

The subsequent read/take operation will be semantically equivalent to a read or take without specifying the instance, except in building the collection, the DataReader will check that the sample belongs to the specified instance and otherwise it will not place the sample in the returned collection.

The subsequent read/take may operation may fail with dds::core::InvalidArgumentError if the InstanceHandle does not correspond to an existing data-object known to the DataReader.

Parameters
hThe handle of the instance to access
See Also
dds::sub::DataReader::operator >>(Functor f)
template<typename T>
dds::sub::functors::NextInstanceManipulatorFunctor next_instance ( const dds::core::InstanceHandle h)
related

Stream manipulator to specify the samples belonging to the 'next' instance after the provided instance handle should be accessed.

This operation causes the subsequent read or take operation to access only samples belonging a single instance whose handle is considered 'next' after the provided InstanceHandle h.

The accessed samples will all belong to the 'next' instance with InstanceHandle 'greater' than the specified previous handle that has available samples.

This operation implies the existence of a total order 'greater-than' relationship between the instance handles. The specifics of this relationship are not all important and are implementation specific. The important thing is that, according to the middleware, all instances are ordered relative to each other. This ordering is between the instance handles; It should not depend on the state of the instance (e.g. whether it has data or not) and must be defined even for instance handles that do not correspond to instances currently managed by the dds::sub::DataReader. For the purposes of the ordering, it should be 'as if' each instance handle was represented as unique integer.

The behavior of dds::sub::next_instance(const dds::core::InstanceHandle& h) is 'as if' the dds::sub::DataReader invoked dds::sub::instance(const dds::core::InstanceHandle& h), passing the smallest instance_handle among all the ones that: (a) are greater than previous_handle, and (b) have available samples (i.e. samples that meet the constraints imposed by the specified states).

The special value dds::core::InstanceHandle::nil() is guaranteed to be 'less than' any valid instance_handle. So the use of the parameter value previous_handle == dds::core::InstanceHandle::nil() will return the samples for the instance which has the smallest instance_handle among all the instances that contain available samples.

The operation dds::sub::next_instance(const dds::core::InstanceHandle& h) is intended to be used in an application-driven iteration, where the application starts by passing previous_handle == dds::core::InstanceHandle::nil(), examines the samples returned, and then uses the instance_handle returned in the dds::sub::SampleInfo as the value of the previous_handle argument to the next call to dds::sub::next_instance(const dds::core::InstanceHandle& h). The iteration continues until dds::sub::next_instance(const dds::core::InstanceHandle& h) fails .

Note that it is possible to call the dds::sub::next_instance(const dds::core::InstanceHandle& h) operation with a previous_handle that does not correspond to an instance currently managed by the dds::sub::DataReader. This is because as stated earlier the 'greater-than' relationship is defined even for handles not managed by the dds::sub::DataReader. One practical situation where this may occur is when an application is iterating though all the instances, takes all the samples of a dds::sub::status::InstanceState::not_alive_no_writers() instance, returns the loan (at which point the instance information may be removed, and thus the handle becomes invalid), and tries to read the next instance.

Exceptions
Oneof the Standard Exceptions, dds::core::PreconditionNotMetError dds::core::NotEnabledError.
See Also
dds::sub::DataReader::read
dds::core::LENGTH_UNLIMITED
Parameters
hThe reference instance. The instance after this one will be selected
See Also
dds::sub::DataReader::operator >>(Functor f)
template<typename T>
void ignore ( dds::domain::DomainParticipant participant,
const dds::core::InstanceHandle handle 
)
related

Instructs RTI Connext to locally ignore a publication.

A subscription is defined by the association of a topic name, user data, and partition set on the dds::sub::Subscriber (see dds::topic::SubscriptionBuiltinTopicData). After this call, any data received related to that subscription's dds::sub::DataReader will be ignored.

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

The subscription to ignore is identified by the handle argument.

There is no way to reverse this operation.

Exceptions
Oneof the Standard Exceptions, dds::core::OutOfResourcesError or dds::core::NotEnabledError
See Also
dds::topic::SubscriptionBuiltinTopicData
dds::topic::SUBSCRIPTION_TOPIC_NAME
dds::sub::builtin_subscriber
Parameters
participantThe DomainParticipant for which the remote entity will be ignored
handleThe InstanceHandle of the remote entity that has to be ignored
template<typename FwdIterator >
void ignore ( dds::domain::DomainParticipant participant,
FwdIterator  begin,
FwdIterator  end 
)
related

Instructs RTI Connext to locally ignore subscriptions.

Parameters
participantThe DomainParticipant for which the remote entity will be ignored
beginA forward iterator to the initial position in a dds::core::InstanceHandleSeq holding the handles to the remote DataReaders to be ignored.
endA forward iterator to the final position in a dds::core::InstanceHandleSeq holding the handles to the remote DataReaders to be ignored.
See Also
ignore(dds::domain::DomainParticipant&, const dds::core::InstanceHandle&);
template<typename T >
const ::dds::core::InstanceHandleSeq matched_publications ( const dds::sub::DataReader< T > &  reader)
related

Retrieve the list of publications currently "associated" with a DataReader.

Matching publications are those in the same domain that have a matching dds::topic::Topic, compatible QoS common partition that the dds::domain::DomainParticipant has not indicated should be "ignored" by means of the dds::pub::ignore operation.

The handles returned in the publication_handles list are the ones that are used by the RTI Connext implementation to locally identify the corresponding matched dds::pub::DataWriter entities. These handles match the ones that appear in the instance_handle field of the dds::sub::SampleInfo when reading the dds::topic::PUBLICATION_TOPIC_NAME builtin topic

Exceptions
Oneof the Standard Exceptions, or dds::core::OutOfResourcesError if the sequence is too small and the system can not resize it, or dds::core::NotEnabledError
Template Parameters
TThe topic-type that the DataReader subscribes to
Parameters
readerThe reader whose publications are being retrieved
Returns
An InstanceHandleSeq containing the InstanceHandles of the matched publications for the provided DataReader
template<typename T , typename FwdIterator >
FwdIterator matched_publications ( const dds::sub::DataReader< T > &  reader,
FwdIterator  begin,
FwdIterator  end 
)
related

Retrieve the list of publications currently "associated" with a DataReader.

Matching publications are those in the same domain that have a matching dds::topic::Topic, compatible QoS common partition that the dds::domain::DomainParticipant has not indicated should be "ignored" by means of the dds::pub::ignore operation.

The handles returned in the publication_handles list are the ones that are used by the RTI Connext implementation to locally identify the corresponding matched dds::pub::DataWriter entities. These handles match the ones that appear in the instance_handle field of the dds::sub::SampleInfo when reading the dds::topic::PUBLICATION_TOPIC_NAME builtin topic

Exceptions
Oneof the Standard Exceptions, or dds::core::OutOfResourcesError if the sequence is too small and the system can not resize it, or dds::core::NotEnabledError
Template Parameters
TThe topic-type that the DataReader subscribes to
FwdIteratorA forward iterator whose value type is dds::core::InstanceHandle
Parameters
readerThe reader whose publications are being retrieved
beginA forward iterator to the beginning position in the destination container of matching InstanceHandles
endA forward iterator to the ending position in the destination container of matching InstanceHandles
Returns
An iterator placed at the last position in the container where a InstanceHandle was inserted
template<typename T >
const dds::topic::PublicationBuiltinTopicData matched_publication_data ( const dds::sub::DataReader< T > &  reader,
const dds::core::InstanceHandle handle 
)
related

This operation retrieves the information on a publication that is currently "associated" with the DataReader.

Matched publications are those with a matching dds::topic::Topic, compatible QoS and common partition that the application has not indicated should be "ignored" by means of the dds::pub::ignore operation.

The publication_handle must correspond to a publication currently associated with the dds::sub::DataReader. Otherwise, the operation will fail with dds::core::InvalidArgumentError. Use the operation dds::sub::matched_publications to find the publications that are currently matched with the dds::sub::DataReader.

Note: This operation does not retrieve the following information in dds::topic::PublicationBuiltinTopicData:

The above information is available through dds::sub::DataReaderListener::on_data_available() (if a reader listener is installed on the PublicationBuiltinTopicDataDataReader).

.

Exceptions
Oneof the Standard Exceptions or dds::core::NotEnabledError
Template Parameters
TThe topic-type that the DataReader subscribes to
Parameters
readerThe reader associated with the publication whose data is being retrieved
handleThe InstanceHandle Handle to a specific publication associated with the DataWriter. Must correspond to a publication currently associated with the DataReader.
Returns
The dds::topic::PublicationBuiltinTopicData of the publication that is associated with the provided handle
template<typename T >
dds::topic::ParticipantBuiltinTopicData matched_publication_participant_data ( const dds::sub::DataReader< T > &  reader,
const dds::core::InstanceHandle handle 
)
related

<<extension>> This operation retrieves the information on the discovered dds::domain::DomainParticipant associated with the publication that is currently matching with the dds::sub::DataReader.

Matched Participants are those with a matching dds::topic::Topic, compatible QoS and common partition that the application has not indicated should be "ignored" by means of the dds::pub::ignore operation.

The publication_handle must correspond to a publication currently associated with the dds::sub::DataReader. Otherwise, the operation will fail with dds::core::InvalidArgumentError. The operation may also fail with dds::core::PreconditionNotMetError if the publication corresponds to the same dds::domain::DomainParticipant that the DataReader belongs to. Use the operation dds::sub::matched_publications to find the publications that are currently matched with the dds::sub::DataReader.

Note: This operation does not retrieve the dds::topic::ParticipantBuiltinTopicData::property.

The above information is available through dds::sub::DataReaderListener::on_data_available() (if a reader listener is installed on the PublicationBuiltinTopicDataDataReader).

.

Exceptions
Oneof the Standard Exceptions or dds::core::NotEnabledError
Template Parameters
TThe topic-type that the DataReader subscribes to
Parameters
readerThe reader to lookup the matched participant data of
handleThe InstanceHandle to a specific publication associated with a DataWriter. Must correspond to a publication currently associated with the DataReader. This handle is available in the dds::sub::SampleInfo::publication_handle()
Returns
The dds::topic::ParticipantBuiltinTopicData of the DomainParticipant of a matched publication of a dds::sub::DataReader
template<typename READER , typename FwdIterator >
uint32_t find ( const dds::sub::Subscriber subscriber,
const std::string &  topic_name,
FwdIterator  begin,
uint32_t  max_size 
)
related

This function retrieves a previously-created DataReader belonging to the Subscriber that is attached to a Topic with a matching topic name.

Use this operation on the built-in dds::sub::Subscriber (Built-in Topics) to access the built-in dds::sub::DataReader entities for the built-in topics.

The built-in dds::sub::DataReader is created when this operation is called on a built-in topic for the first time. The built-in dds::sub::DataReader is deleted automatically when the dds::domain::DomainParticipant is deleted.

To ensure that builtin dds::sub::DataReader entities receive all the discovery traffic, it is suggested that you lookup the builtin dds::sub::DataReader before the dds::domain::DomainParticipant is enabled. Looking up builtin dds::sub::DataReader may implicitly register builtin transports due to creation of dds::sub::DataReader (see Built-in Transport Plugins for details on when a builtin transport is registered). Therefore, if you are want to modify builtin transport properties, do so before using this operation.

Therefore the suggested sequence when looking up builtin DataReaders is:

Parameters
topic_name<<in>> Name of the TopicDescription that the retrieved dds::sub::DataReader is attached to. Cannot be NULL.
Returns
A dds::sub::DataReader that belongs to the dds::sub::Subscriber attached to the TopicDescription with topic_name. If no such dds::sub::DataReader exists, this operation returns NULL.

The returned dds::sub::DataReader may be enabled or disabled.

If more than one dds::sub::DataReader is attached to the dds::sub::Subscriber, this operation may return any one of them.

MT Safety:
UNSAFE. It is not safe to lookup a dds::sub::DataReader in one thread while another thread is simultaneously creating or destroying that dds::sub::DataReader.
Template Parameters
READERThe Typed DataReader that is being lookup up
FwdIteratorThe type of forward iterator passed to this function
Parameters
subThe dds::sub::Subscriber the DataReader belongs to
topic_nameName of the dds::topic::Topic associated with the DataReader that is to be looked up.
beginA forward iterator to the position in the destination container to insert the found DataReader into
max_sizeOnly 1 DataReader will be returned from this function
Returns
The number of DataReaders that were found (either 0 or 1)
template<typename READER , typename BinIterator >
uint32_t find ( const dds::sub::Subscriber subscriber,
const std::string &  topic_name,
BinIterator  begin 
)
related

This function retrieves a previously-created DataReader belonging to the Subscriber that is attached to a Topic with a matching topic name.

Use this operation on the built-in dds::sub::Subscriber (Built-in Topics) to access the built-in dds::sub::DataReader entities for the built-in topics.

The built-in dds::sub::DataReader is created when this operation is called on a built-in topic for the first time. The built-in dds::sub::DataReader is deleted automatically when the dds::domain::DomainParticipant is deleted.

To ensure that builtin dds::sub::DataReader entities receive all the discovery traffic, it is suggested that you lookup the builtin dds::sub::DataReader before the dds::domain::DomainParticipant is enabled. Looking up builtin dds::sub::DataReader may implicitly register builtin transports due to creation of dds::sub::DataReader (see Built-in Transport Plugins for details on when a builtin transport is registered). Therefore, if you are want to modify builtin transport properties, do so before using this operation.

Therefore the suggested sequence when looking up builtin DataReaders is:

Parameters
topic_name<<in>> Name of the TopicDescription that the retrieved dds::sub::DataReader is attached to. Cannot be NULL.
Returns
A dds::sub::DataReader that belongs to the dds::sub::Subscriber attached to the TopicDescription with topic_name. If no such dds::sub::DataReader exists, this operation returns NULL.

The returned dds::sub::DataReader may be enabled or disabled.

If more than one dds::sub::DataReader is attached to the dds::sub::Subscriber, this operation may return any one of them.

MT Safety:
UNSAFE. It is not safe to lookup a dds::sub::DataReader in one thread while another thread is simultaneously creating or destroying that dds::sub::DataReader.
Template Parameters
READERThe Typed DataReader that is being lookup up
BinIteratorThe type of back-inserting iterator passed to this function
Parameters
subscriberThe dds::sub::Subscriber the DataReader belongs to
topic_nameName of the dds::topic::Topic associated with the DataReader that is to be looked up.
beginA back-inserting iterator to the position in the destination container to insert the found DataReader into
Returns
The number of DataReaders that were found (either 0 or 1)
template<typename READER , typename T , typename FwdIterator >
uint32_t find ( const dds::sub::Subscriber subscriber,
const dds::topic::TopicDescription< T > &  topic_description,
FwdIterator  begin,
uint32_t  max_size 
)
related

This function retrieves a previously-created DataReader belonging to the Subscriber that is attached to a Topic with a matching TopicDescription.

See Also
find(const dds::sub::Subscriber& subscriber,const std::string& topic_name,FwdIterator begin,uint32_t max_size)
template<typename READER , typename T , typename BinIterator >
uint32_t find ( const dds::sub::Subscriber subscriber,
const dds::topic::TopicDescription< T > &  topic_description,
BinIterator  begin 
)
related

This function retrieves a previously-created DataReader belonging to the Subscriber that is attached to a Topic with a matching TopicDescription.

See Also
uint32_t find(const dds::sub::Subscriber& subscriber,const std::string& topic_name,BinIterator begin)
template<typename AnyDataReaderBackInsertIterator >
uint32_t find_datareaders ( dds::sub::Subscriber  subscriber,
AnyDataReaderBackInsertIterator  begin 
)
related

<<extension>> Retrieve all the dds::sub::DataReader created from this dds::sub::Subscriber

Template Parameters
AnyDataReaderBackInsertIteratorType of the back-inserting iterator passed into this function
Parameters
subscriberThe dds::sub::Subscriber the DataReaders belong to
beginA back-inserting iterator to the position in the destination container to insert the found DataReaders into
Returns
The number of found DataReaders
template<typename AnyDataReaderForwardIterator >
uint32_t find_datareaders ( dds::sub::Subscriber  subscriber,
AnyDataReaderForwardIterator  begin,
uint32_t  max_size 
)
related

<<extension>> Retrieve all the readers created from a subscriber.

Template Parameters
AnyDataReaderForwardIteratorA forward iterator whose value_type is dds::sub::AnyDataReader
Parameters
subscriberThe dds::sub::Subscriber the readers belong to
beginA forward iterator to the position in the destination container to insert the found readers in.
max_sizeThe maximum number of readers to return
Returns
The number of found readers
template<typename READER >
READER find_datareader_by_topic_name ( dds::sub::Subscriber  subscriber,
const std::string &  topic_name 
)
related

<<extension>> Retrieves a dds::sub::DataReader with the given topic name within the dds::sub::Subscriber

Use this operation on the built-in dds::sub::Subscriber (Built-in Topics) to access the built-in dds::sub::DataReader entities for the built-in topics.

The built-in dds::sub::DataReader is created when this operation is called on a built-in topic for the first time. The built-in dds::sub::DataReader is deleted automatically when the dds::domain::DomainParticipant is deleted.

To ensure that builtin dds::sub::DataReader entities receive all the discovery traffic, it is suggested that you lookup the builtin dds::sub::DataReader before the dds::domain::DomainParticipant is enabled. Looking up builtin dds::sub::DataReader may implicitly register builtin transports due to creation of dds::sub::DataReader (see Built-in Transport Plugins for details on when a builtin transport is registered). Therefore, if you are want to modify builtin transport properties, do so before using this operation.

Therefore the suggested sequence when looking up builtin DataReaders is:

Parameters
topic_name<<in>> Name of the TopicDescription that the retrieved dds::sub::DataReader is attached to. Cannot be NULL.
Returns
A dds::sub::DataReader that belongs to the dds::sub::Subscriber attached to the TopicDescription with topic_name. If no such dds::sub::DataReader exists, this operation returns NULL.

The returned dds::sub::DataReader may be enabled or disabled.

If more than one dds::sub::DataReader is attached to the dds::sub::Subscriber, this operation may return any one of them.

MT Safety:
UNSAFE. It is not safe to lookup a dds::sub::DataReader in one thread while another thread is simultaneously creating or destroying that dds::sub::DataReader.
Parameters
subscriberThe dds::sub::Subscriber that created the DataReader to find
topic_nameTopic name of the DataReader to find
Returns
The DataReader with the given topic name
template<typename READER >
READER find_datareader_by_name ( dds::sub::Subscriber  subscriber,
const std::string &  datareader_name 
)
related

<<extension>> Retrieves a dds::sub::DataReader with the given name within the dds::sub::Subscriber

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

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

Parameters
subscriberThe dds::sub::Subscriber that created the DataReader to find
datareader_nameEntity name of the DataReader to find
Returns
The DataReader with the given name
template<typename READER , typename T >
READER find_datareader_by_topic_description ( const dds::sub::Subscriber subscriber,
const dds::topic::TopicDescription< T > &  topic_description 
)
related

<<extension>> Retrieves a dds::sub::DataReader with the given TopicDescription within the dds::sub::Subscriber

Template Parameters
READERThe type of Reader that is being looked up
TThe topic-type
Parameters
subscriberThe Subscriber to which the DataReader belongs
topic_descriptionThe TopicDescription identifying the DataReader to find
Returns
The found DataReader
template<typename READER >
READER find_datareader_by_name ( dds::domain::DomainParticipant  participant,
const std::string &  datareader_name 
)
related

<<extension>> Retrieves a dds::sub::DataReader within the dds::domain::DomainParticipant with the given name

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

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

This operation retrieves a dds::sub::DataReader within a dds::sub::Subscriber given the specified name which encodes both to the dds::sub::DataReader and the dds::sub::Subscriber name.

If there are several dds::sub::DataReader with the same name within the corresponding dds::sub::Subscriber 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::sub::Subscriber to which the dds::sub::DataReader belongs and the entity name of of the dds::sub::DataReader itself, separated by a double colon "::". For example: MySubscriberName::MyDataReaderName

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

The dds::sub::DataReader is only looked up within the dds::sub::Subscriber specified in the fully qualified name, or within the implicit dds::sub::Subscriber if the name was not fully qualified.

Parameters
participantThe dds::domain::DomainParticipant within which the dds::sub::DataReader exists
datareader_nameEntityName of the DataReader to find
Returns
The first reader with the given name or dds::core::null if it is not found.
See Also
rti::sub::find_datareader_by_name(const dds::sub::Subscriber&, const std::string&)

RTI Connext Modern C++ API Version 5.2.0 Copyright © Sun Jun 21 2015 Real-Time Innovations, Inc