RTI Connext Traditional C++ API Version 7.3.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 > &params)
 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...
 
RequestDataReaderget_request_datareader () const
 Retrieves the underlying DDSDataReader. More...
 
ReplyDataWriterget_reply_datawriter () const
 Retrieves the underlying DDSDataWriter. More...
 

Detailed Description

template<typename TReq, typename TRep>
class connext::Replier< TReq, TRep >

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 rtiddsgen, the DDS built-in types, and DDS_DynamicData. See Creating a Replier.

A Replier has four main types of operations:

  • Waiting for requests to be received from the middleware
  • Getting those requests
  • Receiving requests (a convenience operation that is a combination of waiting and getting in a single operation)
  • Sending a reply for a previously received request (i.e., publishing a reply sample on the reply topic with special meta-data so that the orignal Requester can identify it)

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:

Template Parameters
TReqThe data type for the request topic
TRepThe data type for the reply topic
See also
connext::Requester
Request-Reply Examples
Basic Replier example

Member Typedef Documentation

◆ Request

template<typename TReq , typename TRep >
typedef TReq connext::Replier< TReq, TRep >::Request

The request type.

◆ Reply

template<typename TReq , typename TRep >
typedef TRep connext::Replier< TReq, TRep >::Reply

The reply type.

◆ ReplyDataWriter

template<typename TReq , typename TRep >
typedef dds_type_traits<TRep>::DataWriter connext::Replier< TReq, TRep >::ReplyDataWriter

The typed DataWriter for type TRep.

◆ RequestDataReader

template<typename TReq , typename TRep >
typedef dds_type_traits<TReq>::DataReader connext::Replier< TReq, TRep >::RequestDataReader

The typed DataReader for type TReq.

Constructor & Destructor Documentation

◆ Replier() [1/2]

template<typename TReq , typename TRep >
connext::Replier< TReq, TRep >::Replier ( DDSDomainParticipant participant,
const std::string &  service_name 
)

Creates a Replier with the minimum set of parameters.

Parameters
participantThe DomainParticipant that this Replier uses to join a domain.
service_nameThe service name. See connext::ReplierParams::service_name
Exceptions
Oneof the RTI Connext Exceptions

◆ Replier() [2/2]

template<typename TReq , typename TRep >
connext::Replier< TReq, TRep >::Replier ( const ReplierParams< TReq, TRep > &  params)
explicit

Creates a Replier with parameters.

Parameters
paramsAll the parameters that configure this Replier
Exceptions
Oneof the RTI Connext Exceptions
See also
connext::ReplierParams
Creating a Replier

◆ ~Replier()

template<typename TReq , typename TRep >
connext::Replier< TReq, TRep >::~Replier
virtual

Releases the internal entities created by this Replier.

Among other internal resources, it deletes the Replier's underlying DataReader and DataWriter.

See also
DDSSubscriber::delete_datareader
DDSPublisher::delete_datawriter

Member Function Documentation

◆ send_reply() [1/3]

template<typename TReq , typename TRep >
template<typename URep >
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).

Parameters
replyThe reply to be sent.
related_request_idThe identity of a previously received request
Exceptions
Oneof the RTI Connext Exceptions
See also
connext::Sample::identity()
receive_request(Sample<TReq>&, const Duration_t&)
receive_requests(int, int, const Duration_t&)
take_request(Sample<TReq>&)
take_requests(int)
Basic Replier example

◆ send_reply() [2/3]

template<typename TReq , typename TRep >
template<typename URep >
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().

See also
send_reply(const URep&, const SampleIdentity_t&)
connext::WriteSample

◆ send_reply() [3/3]

template<typename TReq , typename TRep >
template<typename URep >
void connext::Replier< TReq, TRep >::send_reply ( WriteSampleRef< URep > &  reply,
const SampleIdentity_t related_request_id 
)

◆ receive_request() [1/2]

template<typename TReq , typename TRep >
bool connext::Replier< TReq, TRep >::receive_request ( connext::Sample< TReq > &  request,
const DDS_Duration_t max_wait 
)

◆ receive_request() [2/2]

template<typename TReq , typename TRep >
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.

See also
connext::Requester::receive_reply(SampleRef<TRep>, const Duration_t&)

◆ receive_requests() [1/2]

template<typename TReq , typename TRep >
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

See also
connext::LoanedSamples
receive_requests(int, int, const Duration_t&)

◆ receive_requests() [2/2]

template<typename TReq , typename TRep >
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)

See also
connext::LoanedSamples
wait_for_requests(int, const Duration_t&)
take_requests(int)

◆ wait_for_requests() [1/2]

template<typename TReq , typename TRep >
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

See also
wait_for_requests(int, const Duration_t&)

◆ wait_for_requests() [2/2]

template<typename TReq , typename TRep >
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&).

Parameters
min_countMinimum number of requests that need to be available for this operation to unblock.
max_waitMaximum waiting time after which this operation unblocks regardless of how many requests are available.
Returns
true if at least min_count requests were available before max_wait elapsed, or false otherwise.
See also
take_requests(int)
connext::Requester::wait_for_replies(int, const Duration_t&)

◆ take_request() [1/2]

template<typename TReq , typename TRep >
bool connext::Replier< TReq, TRep >::take_request ( connext::Sample< TReq > &  request)

Copies the contents of a request into a Sample.

See also
connext::Requester::take_reply(Sample<TRep>&)

◆ take_request() [2/2]

template<typename TReq , typename TRep >
bool connext::Replier< TReq, TRep >::take_request ( connext::SampleRef< TReq >  request)

Copies the contents of a request into a SampleRef.

See also
connext::Requester::take_reply(SampleRef<TRep>)

◆ take_requests()

template<typename TReq , typename TRep >
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.

See also
connext::Requester::take_replies(int)

◆ read_request() [1/2]

template<typename TReq , typename TRep >
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.

◆ read_request() [2/2]

template<typename TReq , typename TRep >
bool connext::Replier< TReq, TRep >::read_request ( connext::SampleRef< TReq >  request)

Copies the contents of a request into a SampleRef.

See also
connext::Requester::read_reply(SampleRef<TRep>)

◆ read_requests()

template<typename TReq , typename TRep >
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.

◆ get_request_datareader()

template<typename TReq , typename TRep >
Replier< TReq, TRep >::RequestDataReader * connext::Replier< TReq, TRep >::get_request_datareader
inline

Retrieves the underlying DDSDataReader.

See also
connext::Requester::get_reply_datareader()

◆ get_reply_datawriter()

template<typename TReq , typename TRep >
Replier< TReq, TRep >::ReplyDataWriter * connext::Replier< TReq, TRep >::get_reply_datawriter
inline