RTI Connext Modern C++ API Version 7.3.0
dds::sub::cond::ReadCondition Class Reference

<<reference-type>> Condition specifically dedicated to read operations and attached to one dds::sub::DataReader. More...

#include <dds/sub/cond/ReadCondition.hpp>

Inheritance diagram for dds::sub::cond::ReadCondition:
dds::core::cond::Condition dds::sub::cond::QueryCondition

Public Member Functions

template<typename T >
 ReadCondition (const dds::sub::DataReader< T > &reader, const dds::sub::status::DataState &status)
 Creates a ReadCondition. More...
 
template<typename T , typename Functor >
 ReadCondition (const dds::sub::DataReader< T > &reader, const dds::sub::status::DataState &status, const Functor &handler)
 Creates a ReadCondition with a handler. More...
 
const dds::sub::status::DataState state_filter () const
 Returns the DataState of this condition. More...
 
const AnyDataReaderdata_reader () const
 Returns the DataReader associated to this condition. More...
 
void close ()
 Closes the ReadCondition. More...
 
bool closed () const
 Indicates whether this ReadCondition has been closed with close(). More...
 
- Public Member Functions inherited from dds::core::cond::Condition
void dispatch ()
 Dispatches the functors that have been registered with the condition. More...
 
bool trigger_value () const
 This operation retrieves the trigger_value of the Condition. More...
 

Related Functions

(Note that these are not member functions.)

dds::sub::cond::detail::ReadCondition create_read_condition_ex (const dds::sub::AnyDataReader &reader, const ::rti::sub::status::DataStateEx &status)
 <<extension>> Creates a ReadCondition with the extended DataStateEx. More...
 
template<typename Functor >
dds::sub::cond::detail::ReadCondition create_read_condition_ex (const dds::sub::AnyDataReader &reader, const ::rti::sub::status::DataStateEx &status, const Functor &handler)
 <<extension>> Creates a ReadCondition with the extended DataStateEx and a handler. More...
 

Detailed Description

<<reference-type>> Condition specifically dedicated to read operations and attached to one dds::sub::DataReader.

dds::sub::cond::ReadCondition objects allow an application to specify the data samples it is interested in (by specifying the desired sample_states, view_states as well as instance_states in dds::sub::DataReader::read and dds::sub::DataReader::take variants.

This allows RTI Connext to enable the condition only when suitable information is available. They are to be used in conjunction with a WaitSet as normal conditions.

More than one dds::sub::cond::ReadCondition may be attached to the same dds::sub::DataReader.

Examples
Foo_subscriber.cxx.

Constructor & Destructor Documentation

◆ ReadCondition() [1/2]

template<typename T >
dds::sub::cond::ReadCondition::ReadCondition ( const dds::sub::DataReader< T > &  reader,
const dds::sub::status::DataState status 
)
inline

Creates a ReadCondition.

Template Parameters
TThe topic-type of the DataReader.
Parameters
readerThe reader associated to the condition. One reader can have multiple ReadConditions but one ReadCondition belongs to exactly one DataReader.
statusThe sample, view and instance states of interest.
See also
rti::sub::cond::create_read_condition_ex

◆ ReadCondition() [2/2]

template<typename T , typename Functor >
dds::sub::cond::ReadCondition::ReadCondition ( const dds::sub::DataReader< T > &  reader,
const dds::sub::status::DataState status,
const Functor &  handler 
)
inline

Creates a ReadCondition with a handler.

Template Parameters
TThe topic-type of the DataReader.
FunctorAny type whose instances can be called with a no-argument function call (i.e. f(), if f is an instance of Functor), or with a Condition argument (f(condition)) Examples are functions, types that override operator(), and lambdas.
Parameters
readerThe reader associated to the condition. One reader can have multiple ReadConditions but one ReadCondition belongs to exactly one DataReader.
statusThe sample, view and instance states of interest.
handlerThe handler that dds::core::cond::WaitSet::dispatch() will call when the condition is triggered. This argument is copied.

The following examples creates two ReadConditions with handlers. The first one receives a lambda function with no arguments. The second one receives a function with the condition as an argument.

// Example 1: lambda function with no arguments
reader,
[]()
{
std::cout << "condition has been triggered\n";
}
);
// Example 2: function with a condition argument
void function_handler(dds::core::cond::Condition c)
{
// function receiving the condition
std::cout << "condition has been triggered\n";
}
dds::sub::cond::ReadCondition my_read_condition2(
reader,
function_handler
);
<<reference-type>> Abstract base class of all the conditions
Definition: TCondition.hpp:58
<<reference-type>> Condition specifically dedicated to read operations and attached to one dds::sub::...
Definition: TReadCondition.hpp:40
static DataState any()
Create a DataState with InstanceState::any(), ViewState::any(), and SampleState::any()
Definition: status/DataState.hpp:470
See also
dds::core::cond::WaitSet::dispatch()
WaitSet wait and dispatch examples

Member Function Documentation

◆ state_filter()

const dds::sub::status::DataState dds::sub::cond::ReadCondition::state_filter ( ) const
inline

Returns the DataState of this condition.

◆ data_reader()

const AnyDataReader & dds::sub::cond::ReadCondition::data_reader ( ) const
inline

Returns the DataReader associated to this condition.

To obtain the actual typed DataReader, see AnyDataReader::get()

◆ close()

void dds::sub::cond::ReadCondition::close ( )
inline

Closes the ReadCondition.

This is a explicit deletion, which otherwise would occur when all references to this ReadCondition go out of scope.

Precondition
The ReadCondition must not be attached to any Waitsets.
Exceptions
dds::core::PreconditionNotMetErrorIf the ReadCondition is attached to a Waitset when it is closed.

◆ closed()

bool dds::sub::cond::ReadCondition::closed ( ) const
inline

Indicates whether this ReadCondition has been closed with close().

Friends And Related Function Documentation

◆ create_read_condition_ex() [1/2]

dds::sub::cond::detail::ReadCondition create_read_condition_ex ( const dds::sub::AnyDataReader reader,
const ::rti::sub::status::DataStateEx status 
)
related

<<extension>> Creates a ReadCondition with the extended DataStateEx.

Note
This is a standalone function in the namespace rti::sub::cond

The usual way to create a dds::sub::cond::ReadCondition is the constructor that receives a dds::sub::status::DataState. This extension function allows using rti::sub::status::DataStateEx, which includes additional state masks.

References dds::sub::condition().

◆ create_read_condition_ex() [2/2]

template<typename Functor >
dds::sub::cond::detail::ReadCondition create_read_condition_ex ( const dds::sub::AnyDataReader reader,
const ::rti::sub::status::DataStateEx status,
const Functor &  handler 
)
related

<<extension>> Creates a ReadCondition with the extended DataStateEx and a handler.

Note
This is a standalone function in the namespace rti::sub::cond

The usual way to create a dds::sub::cond::ReadCondition is the constructor that receives a dds::sub::status::DataState. This extension function allows using rti::sub::status::DataStateEx, which includes additional state masks.

References dds::sub::condition().