RTI Connext Modern C++ API  Version 6.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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.
 
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.
 
const dds::sub::status::DataState state_filter () const
 Returns the DataState of this condition.
 
const AnyDataReaderdata_reader () const
 Returns the DataReader associated to this condition.
 
void close ()
 Closes the ReadCondition.
 
bool closed () const
 Indicates whether this ReadCondition has been closed with close().
 
- Public Member Functions inherited from dds::core::cond::Condition
void dispatch ()
 Dispatches the functors that have been registered with the condition.
 
bool trigger_value () const
 This operation retrieves the trigger_value of the Condition.
 

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

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

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

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
);
See Also
dds::core::cond::WaitSet::dispatch()
WaitSet wait and dispatch examples

Member Function Documentation

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

Returns the DataState of this condition.

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()

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.
bool dds::sub::cond::ReadCondition::closed ( ) const
inline

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

Friends And Related Function Documentation

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 function is in the rti::sub::cond namespace)

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.

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 function is in the rti::sub::cond namespace)

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.


RTI Connext Modern C++ API Version 6.0.1 Copyright © Sat Nov 23 2019 Real-Time Innovations, Inc