RTI Connext Traditional C++ API
Version 6.1.0
|
Allows receiving requests and sending replies. More...
Public Types | |
typedef TReq | Request |
The request type. More... | |
typedef TRep | Reply |
The reply type. More... | |
typedef dds_type_traits< TRep >::DataWriter | ReplyDataWriter |
The typed DataWriter for type TRep . More... | |
typedef dds_type_traits< TReq >::DataReader | RequestDataReader |
The typed DataReader for type TReq . More... | |
Public Member Functions | |
Replier (DDSDomainParticipant *participant, const std::string &service_name) | |
Creates a Replier with the minimum set of parameters. More... | |
Replier (const ReplierParams< TReq, TRep > ¶ms) | |
Creates a Replier with parameters. More... | |
virtual | ~Replier () |
Releases the internal entities created by this Replier. More... | |
template<typename URep > | |
void | send_reply (const URep &reply, const SampleIdentity_t &related_request_id) |
Sends a reply for a previous request. More... | |
template<typename URep > | |
void | send_reply (WriteSample< URep > &reply, const SampleIdentity_t &related_request_id) |
Sends a reply for a previous request. More... | |
template<typename URep > | |
void | send_reply (WriteSampleRef< URep > &reply, const SampleIdentity_t &related_request_id) |
Sends a reply for a previous request using a SampleRef. More... | |
bool | receive_request (connext::Sample< TReq > &request, const DDS_Duration_t &max_wait) |
Waits for a request and copies its contents into a Sample. More... | |
bool | receive_request (connext::SampleRef< TReq > request, const DDS_Duration_t &max_wait) |
Waits for a request and copies its contents into a SampleRef. More... | |
LoanedSamplesType | receive_requests (const DDS_Duration_t &max_wait) |
Waits for multiple requests and provides a loaned container to access them. More... | |
LoanedSamplesType | receive_requests (int min_request_count, int max_request_count, const DDS_Duration_t &max_wait) |
Waits for multiple requests and provides a loaned container to access them. More... | |
bool | wait_for_requests (const DDS_Duration_t &max_wait) |
Waits for requests. More... | |
bool | wait_for_requests (int min_count, const DDS_Duration_t &max_wait) |
Waits for requests. More... | |
bool | take_request (connext::Sample< TReq > &request) |
Copies the contents of a request into a Sample. More... | |
bool | take_request (connext::SampleRef< TReq > request) |
Copies the contents of a request into a SampleRef. More... | |
LoanedSamplesType | take_requests (int max_samples=DDS_LENGTH_UNLIMITED) |
Provides a loaned container to access the existing requests. More... | |
bool | read_request (connext::Sample< TReq > &request) |
Copies the contents of a request into a Sample. More... | |
bool | read_request (connext::SampleRef< TReq > request) |
Copies the contents of a request into a SampleRef. More... | |
LoanedSamplesType | read_requests (int max_samples=DDS_LENGTH_UNLIMITED) |
Provides a loaned container to access the existing requests. More... | |
RequestDataReader * | get_request_datareader () const |
Retrieves the underlying DDSDataReader. More... | |
ReplyDataWriter * | get_reply_datawriter () const |
Retrieves the underlying DDSDataWriter. More... | |
Allows receiving requests and sending replies.
A Replier is an entity with two associated topics: a request topic and a reply topic. It can receive requests by subscribing to the request topic and can send replies to those requests by publishing the reply topic.
Valid types for these topics (TReq
and TRep
)are: those generated by the rtiddsgen code generator, the DDS built-in types, and DDS_DynamicData. See Creating a Replier.
A Replier has four main types of operations:
For multi-reply scenarios in which a connext::Replier generates more than one reply for a request, the connext::Replier should mark all the intermediate replies (all but the last) using the DDS_INTERMEDIATE_REPLY_SEQUENCE_SAMPLE flag in DDS_WriteParams_t::flag.
Much like a Requester, a Replier has an associated DDSDomainParticipant, which can be shared with other Repliers or RTI Connext routines. All the other entities required for the request-reply interaction, including a DDSDataWriter for writing replies and a DDSDataReader for reading requests, are automatically created when the Replier is constructed.
Quality of Service for the underlying DataWriter and DataReader can be configured (see connext::RequesterParams::qos_profile). By default, they are created with DDS_RELIABLE_RELIABILITY_QOS. The exact default configuration is described here: Configuring Request-Reply QoS profiles
There are several ways to use a Replier:
TReq | The data type for the request topic |
TRep | The data type for the reply topic |
typedef TReq connext::Replier< TReq, TRep >::Request |
The request type.
typedef TRep connext::Replier< TReq, TRep >::Reply |
The reply type.
typedef dds_type_traits<TRep>::DataWriter connext::Replier< TReq, TRep >::ReplyDataWriter |
The typed DataWriter for type TRep
.
typedef dds_type_traits<TReq>::DataReader connext::Replier< TReq, TRep >::RequestDataReader |
The typed DataReader for type TReq
.
connext::Replier< TReq, TRep >::Replier | ( | DDSDomainParticipant * | participant, |
const std::string & | service_name | ||
) |
Creates a Replier with the minimum set of parameters.
participant | The DomainParticipant that this Replier uses to join a domain. |
service_name | The service name. See connext::ReplierParams::service_name |
One | of the RTI Connext Exceptions |
|
explicit |
Creates a Replier with parameters.
params | All the parameters that configure this Replier |
One | of the RTI Connext Exceptions |
|
virtual |
void connext::Replier< TReq, TRep >::send_reply | ( | const URep & | reply, |
const SampleIdentity_t & | related_request_id | ||
) |
Sends a reply for a previous request.
The related request identity can be retrieved from an existing request sample (connext::Sample).
reply | The reply to be sent. |
related_request_id | The identity of a previously received request |
One | of the RTI Connext Exceptions |
void connext::Replier< TReq, TRep >::send_reply | ( | WriteSample< URep > & | reply, |
const SampleIdentity_t & | related_request_id | ||
) |
Sends a reply for a previous request.
Allows you to set custom parameters for writing a reply.
Contrary to the connext::Requester, where retrieving the sample identity for correlation is common, on the Replier side using a WriteSample is only necessary when the default write parameters need to be overridden, and send_reply(const URep&, const SampleIdentity_t&) may be used if that is not necessary.
One reason to override the default write parameters is a multi-reply scenario in which a connext::Replier generates more than one reply for a request. In this case, all the intermediate replies (all but the last) should be marked with the DDS_INTERMEDIATE_REPLY_SEQUENCE_SAMPLE flag in DDS_WriteParams_t::flag within connext::WriteSample::info().
A connext::Requester can detect if a reply is the last reply of a sequence of replies by checking that the flag DDS_INTERMEDIATE_REPLY_SEQUENCE_SAMPLE is not set in DDS_SampleInfo::flag within connext::Sample::info().
void connext::Replier< TReq, TRep >::send_reply | ( | WriteSampleRef< URep > & | reply, |
const SampleIdentity_t & | related_request_id | ||
) |
Sends a reply for a previous request using a SampleRef.
bool connext::Replier< TReq, TRep >::receive_request | ( | connext::Sample< TReq > & | request, |
const DDS_Duration_t & | max_wait | ||
) |
Waits for a request and copies its contents into a Sample.
Equivalent to using wait_for_requests(int, const Duration_t&) and take_request(Sample<TReq>&)
bool connext::Replier< TReq, TRep >::receive_request | ( | connext::SampleRef< TReq > | request, |
const DDS_Duration_t & | max_wait | ||
) |
Waits for a request and copies its contents into a SampleRef.
Replier< TReq, TRep >::LoanedSamplesType connext::Replier< TReq, TRep >::receive_requests | ( | const DDS_Duration_t & | max_wait | ) |
Waits for multiple requests and provides a loaned container to access them.
Equivalent to using receive_requests(int, int, const Duration_t&) with min_count=1
and max_count=DDS_LENGTH_UNLIMITED
Replier< TReq, TRep >::LoanedSamplesType connext::Replier< TReq, TRep >::receive_requests | ( | int | min_request_count, |
int | max_request_count, | ||
const DDS_Duration_t & | max_wait | ||
) |
Waits for multiple requests and provides a loaned container to access them.
Equivalent to using wait_for_requests(int, const Duration_t&) and take_requests(int)
bool connext::Replier< TReq, TRep >::wait_for_requests | ( | const DDS_Duration_t & | max_wait | ) |
Waits for requests.
Equivalent to wait_for_requests(int, const Duration_t&) with min_count=1
bool connext::Replier< TReq, TRep >::wait_for_requests | ( | int | min_count, |
const DDS_Duration_t & | max_wait | ||
) |
Waits for requests.
This operation waits for min_count requests to be available. It will wait up to max_wait .
This operation is similar to connext::Requester::wait_for_replies(int, const Duration_t&).
min_count | Minimum number of requests that need to be available for this operation to unblock. |
max_wait | Maximum waiting time after which this operation unblocks regardless of how many requests are available. |
bool connext::Replier< TReq, TRep >::take_request | ( | connext::Sample< TReq > & | request | ) |
Copies the contents of a request into a Sample.
bool connext::Replier< TReq, TRep >::take_request | ( | connext::SampleRef< TReq > | request | ) |
Copies the contents of a request into a SampleRef.
Replier< TReq, TRep >::LoanedSamplesType connext::Replier< TReq, TRep >::take_requests | ( | int | max_samples = DDS_LENGTH_UNLIMITED | ) |
Provides a loaned container to access the existing requests.
bool connext::Replier< TReq, TRep >::read_request | ( | connext::Sample< TReq > & | request | ) |
Copies the contents of a request into a Sample.
This operation is equivalent to connext::Replier::take_request(Sample<TReq>&) except the request remains in the Replier and can be read or taken again.
bool connext::Replier< TReq, TRep >::read_request | ( | connext::SampleRef< TReq > | request | ) |
Copies the contents of a request into a SampleRef.
Replier< TReq, TRep >::LoanedSamplesType connext::Replier< TReq, TRep >::read_requests | ( | int | max_samples = DDS_LENGTH_UNLIMITED | ) |
Provides a loaned container to access the existing requests.
This operation is equivalent to connext::Replier::take_requests(int) except the requests remain in the Replier and can be read or taken again.
|
inline |
Retrieves the underlying DDSDataReader.
|
inline |
Retrieves the underlying DDSDataWriter.