RTI Connext C API
Version 6.0.0
|
FooBarRequester and associated elements More...
Data Structures | |
struct | RTI_Connext_Requester |
The type-independent version of a Requester. More... | |
struct | RTI_Connext_RequesterParams |
Contains the parameters for creating a FooBarRequester. More... | |
struct | FooBarRequester |
Allows sending requests and receiving replies. More... | |
Macros | |
#define | RTI_CONNEXT_REQUESTER_DECL(TReq, TRep, TRequester) |
Instantiates the declaration of a typed requester and its operations. | |
Typedefs | |
typedef struct RTI_Connext_RequesterParams | RTI_Connext_RequesterParams |
Contains the parameters for creating a FooBarRequester. | |
typedef struct FooBarRequester | FooBarRequester |
Allows sending requests and receiving replies. | |
Functions | |
DDS_ReturnCode_t | RTI_Connext_Requester_delete (RTI_Connext_Requester *self) |
Releases the internal entities created by this object. | |
DDS_ReturnCode_t | RTI_Connext_Requester_wait_for_replies (RTI_Connext_Requester *self, DDS_Long min_count, const struct DDS_Duration_t *max_wait) |
Waits for replies to any request. | |
DDS_ReturnCode_t | RTI_Connext_Requester_wait_for_replies_for_related_request (RTI_Connext_Requester *self, DDS_Long min_count, const struct DDS_Duration_t *max_wait, const struct DDS_SampleIdentity_t *related_request_id) |
Waits for replies to a specific request. | |
FooBarRequester * | FooBarRequester_create (DDS_DomainParticipant *participant, const char *service_name) |
Creates a Requester with the minimum set of parameters. | |
FooBarRequester * | FooBarRequester_create_w_params (const RTI_Connext_RequesterParams *params) |
Creates a Requester with parameters. | |
DDS_ReturnCode_t | FooBarRequester_send_request (FooBarRequester *self, const Foo *request) |
Sends a request. | |
DDS_ReturnCode_t | FooBarRequester_send_request_w_params (FooBarRequester *self, const Foo *request, struct DDS_WriteParams_t *request_info) |
Sends a request and gets back information about it that allows correlation with future replies. | |
DDS_ReturnCode_t | FooBarRequester_receive_reply (FooBarRequester *self, Bar *reply, struct DDS_SampleInfo *sample_info, const struct DDS_Duration_t *max_wait) |
Waits for a reply and copies its contents into a Sample. | |
DDS_ReturnCode_t | FooBarRequester_receive_replies (FooBarRequester *self, struct BarSeq *received_data, struct DDS_SampleInfoSeq *info_seq, DDS_Long min_count, DDS_Long max_count, const struct DDS_Duration_t *max_wait) |
Waits for multiple replies and provides a loaned sequence to access them. | |
DDS_ReturnCode_t | FooBarRequester_take_reply (FooBarRequester *self, Bar *reply, struct DDS_SampleInfo *sample_info) |
Copies the contents of a reply into a Sample. | |
DDS_ReturnCode_t | FooBarRequester_take_replies (FooBarRequester *self, struct BarSeq *reply_seq, struct DDS_SampleInfoSeq *sample_info_seq, DDS_Long max_count) |
Provides a loaned sequence to access the existing replies. | |
DDS_ReturnCode_t | FooBarRequester_take_reply_for_related_request (FooBarRequester *self, Bar *reply, struct DDS_SampleInfo *sample_info, const struct DDS_SampleIdentity_t *related_request_id) |
Copies the contents of a reply for a specific request. | |
DDS_ReturnCode_t | FooBarRequester_take_replies_for_related_request (FooBarRequester *self, struct BarSeq *reply_seq, struct DDS_SampleInfoSeq *sample_info_seq, DDS_Long max_count, const struct DDS_SampleIdentity_t *related_request_id) |
Provides a loaned sequence to access the existing replies for a specific request. | |
DDS_ReturnCode_t | FooBarRequester_read_reply (FooBarRequester *self, Bar *reply, struct DDS_SampleInfo *sample_info) |
Copies the contents of a reply into a Sample. | |
DDS_ReturnCode_t | FooBarRequester_read_replies (FooBarRequester *self, struct BarSeq *reply_seq, struct DDS_SampleInfoSeq *sample_info_seq, DDS_Long max_count) |
Provides a loaned sequence to access the existing replies. | |
DDS_ReturnCode_t | FooBarRequester_read_reply_for_related_request (FooBarRequester *self, Bar *reply, struct DDS_SampleInfo *sample_info, const struct DDS_SampleIdentity_t *related_request_id) |
Copies the contents of a reply for a specific request. | |
DDS_ReturnCode_t | FooBarRequester_read_replies_for_related_request (FooBarRequester *self, struct BarSeq *reply_seq, struct DDS_SampleInfoSeq *sample_info_seq, DDS_Long max_count, const struct DDS_SampleIdentity_t *related_request_id) |
Provides a loaned sequence to access the existing replies for a specific request. | |
FooDataWriter * | FooBarRequester_get_request_datawriter (FooBarRequester *self) |
Retrieves the underlying DDS_DataWriter. | |
BarDataReader * | FooBarRequester_get_reply_datareader (FooBarRequester *self) |
Retrieves the underlying DDS_DataReader. | |
DDS_ReturnCode_t | FooBarRequester_return_loan (FooBarRequester *self, struct BarSeq *received_data, struct DDS_SampleInfoSeq *info_seq) |
Returns samples previously received from the middleware. | |
FooBarRequester and associated elements
#define RTI_CONNEXT_REQUESTER_DECL | ( | TReq, | |
TRep, | |||
TRequester | |||
) |
Instantiates the declaration of a typed requester and its operations.
TReq | The request type name |
TRep | The reply type name |
TRequester | The type name for the typed requester and the prefix for all the operations. |
typedef struct RTI_Connext_RequesterParams RTI_Connext_RequesterParams |
Contains the parameters for creating a FooBarRequester.
The following parameters are required to create a Requester:
The rest of the parameters that can be set in a RequesterParams object are optional.
typedef struct FooBarRequester FooBarRequester |
Allows sending requests and receiving replies.
A requester is an entity with two associated topics: a request topic and a reply topic. It can send requests by publishing samples of the request topic and receive replies to those requests by subscribing to 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. Note: At this moment, in the C version of this API, only rtiddsgen-generated types are supported.
To create a Requester for two types, a request type TReq=Foo
and a reply type TRep=Bar
, your application needs to instantiate the data structure FooBarRequester
and the specific operations that can publish and subscribe to those types. In this documentation we refer to the type-dependent operations as FooBarRequester_
(for example, FooBarRequester_take_replies). Some operations are type-independent and their name always begins with RTI_Connext_Requester_
(for example, RTI_Connext_Requester_wait_for_replies).
See Creating a Requester to see how to instantiate a FooBarRequester
.
A Replier and a Requester communicate when they use the same topics for requests and replies (see RTI_Connext_RequesterParams::service_name) on the same domain.
A Requester can send requests and receive one or multiple replies. It does that using the following operations:
In all cases, the middleware guarantees that a requester only receives reply samples that are associated with those requests that it sends.
For multi-reply scenarios, in which a Requester receives multiple replies from a Replier for a given request, the Requester can check if a reply is the last reply of a sequence of replies. To do so, see if the bit DDS_INTERMEDIATE_REPLY_SEQUENCE_SAMPLE is set in DDS_SampleInfo::flag after receiving each reply. This indicates it is NOT the last reply.
A requester has an associated DDS_DomainParticipant, which can be shared with other requesters or RTI Connext routines. All the other RTI Connext entities required for the request-reply interaction, including a DDS_DataWriter for writing requests and a DDS_DataReader for reading replies, are automatically created when the requester is constructed.
Quality of Service for the underlying DataWriter and DataReader can be configured (see RTI_Connext_RequesterParams::qos_profile_name). By default, they are created with DDS_RELIABLE_RELIABILITY_QOS. The exact default configuration is described here: Configuring Request-Reply QoS profiles
DDS_ReturnCode_t RTI_Connext_Requester_delete | ( | RTI_Connext_Requester * | self | ) |
Releases the internal entities created by this object.
Among other internal resources, it deletes the underlying DataReader and DataWriter.
self | <<in>> Cannot be NULL. |
DDS_ReturnCode_t RTI_Connext_Requester_wait_for_replies | ( | RTI_Connext_Requester * | self, |
DDS_Long | min_count, | ||
const struct DDS_Duration_t * | max_wait | ||
) |
Waits for replies to any request.
This operation waits for min_count requests to be available for up to max_wait .
If this operation is called several times but the available replies are not taken (with FooBarRequester_take_replies), this operation may return immediately and will not wait for new replies. New replies may replace existing ones if they are not taken, depending on the DDS_HistoryQosPolicy used to configure this Requester.
self | <<in>> Cannot be NULL. |
min_count | Minimum number of replies that need to be available for this operation to unblock. |
max_wait | Maximum waiting time after which this operation unblocks, regardless of how many replies are available. |
If at least min_count replies were available before max_wait elapsed, it returns DDS_RETCODE_OK, otherwise it returns DDS_RETCODE_TIMEOUT. Another Standard Return Codes may be returned in case of error.
DDS_ReturnCode_t RTI_Connext_Requester_wait_for_replies_for_related_request | ( | RTI_Connext_Requester * | self, |
DDS_Long | min_count, | ||
const struct DDS_Duration_t * | max_wait, | ||
const struct DDS_SampleIdentity_t * | related_request_id | ||
) |
Waits for replies to a specific request.
This operation is analogous to RTI_Connext_Requester_wait_for_replies except this operation waits for replies for a specific request.
self | <<in>> Cannot be NULL. |
min_count | Minimum number of replies for the related request that need to be available for this operation to unblock. |
max_wait | Maximum wait time after which this operation unblocks, regardless of how many replies are available. |
related_request_id | The identity of a request previously sent by this Requester |
FooBarRequester* FooBarRequester_create | ( | DDS_DomainParticipant * | participant, |
const char * | service_name | ||
) |
Creates a Requester with the minimum set of parameters.
participant | The DomainParticipant this requester uses to join a DDS domain |
service_name | The service name. See RTI_Connext_RequesterParams::service_name |
FooBarRequester* FooBarRequester_create_w_params | ( | const RTI_Connext_RequesterParams * | params | ) |
Creates a Requester with parameters.
params | All the parameters that configure this requester. See RTI_Connext_RequesterParams for the list of mandatory parameters. |
DDS_ReturnCode_t FooBarRequester_send_request | ( | FooBarRequester * | self, |
const Foo * | request | ||
) |
Sends a request.
If a future reply needs to be correlated to exactly this request, use FooBarRequester_send_request_w_params.
self | <<in>> Cannot be NULL. |
request | The request to be sent |
DDS_ReturnCode_t FooBarRequester_send_request_w_params | ( | FooBarRequester * | self, |
const Foo * | request, | ||
struct DDS_WriteParams_t * | request_info | ||
) |
Sends a request and gets back information about it that allows correlation with future replies.
After calling this operation, the sample contains a valid identity that can be used for correlation with future replies.
See example code in Correlating requests and replies.
self | <<in>> Cannot be NULL. |
request | <<inout>> The request data |
request_info | <<inout>> Optional write parameters. When this call ends succesfully, DDS_WriteParams_t::identity contains a valid identity that can be used for correlation with future replies. |
DDS_ReturnCode_t FooBarRequester_receive_reply | ( | FooBarRequester * | self, |
Bar * | reply, | ||
struct DDS_SampleInfo * | sample_info, | ||
const struct DDS_Duration_t * | max_wait | ||
) |
Waits for a reply and copies its contents into a Sample.
This operation is equivalent to using RTI_Connext_Requester_wait_for_replies and FooBarRequester_take_reply.
DDS_ReturnCode_t FooBarRequester_receive_replies | ( | FooBarRequester * | self, |
struct BarSeq * | received_data, | ||
struct DDS_SampleInfoSeq * | info_seq, | ||
DDS_Long | min_count, | ||
DDS_Long | max_count, | ||
const struct DDS_Duration_t * | max_wait | ||
) |
Waits for multiple replies and provides a loaned sequence to access them.
This operation is equivalent to using RTI_Connext_Requester_wait_for_replies and FooBarRequester_take_replies.
DDS_ReturnCode_t FooBarRequester_take_reply | ( | FooBarRequester * | self, |
Bar * | reply, | ||
struct DDS_SampleInfo * | sample_info | ||
) |
Copies the contents of a reply into a Sample.
Takes a reply sample from the Requester and makes a copy.
This operation may be used after a call to RTI_Connext_Requester_wait_for_replies.
To avoid copies, you can use FooBarRequester_take_replies.
self | <<in>> Cannot be NULL. |
reply | <<inout>> user data type-specific Foo object where the next received reply sample will be returned. The received_data must have been fully allocated. Otherwise, this operation may fail. |
sample_info | <<inout>> a DDS_SampleInfo object where the info associated to the received reply will be returned. Must be a valid non-NULL DDS_SampleInfo. The function will fail with DDS_RETCODE_BAD_PARAMETER if it is NULL. |
DDS_ReturnCode_t FooBarRequester_take_replies | ( | FooBarRequester * | self, |
struct BarSeq * | reply_seq, | ||
struct DDS_SampleInfoSeq * | sample_info_seq, | ||
DDS_Long | max_count | ||
) |
Provides a loaned sequence to access the existing replies.
Takes all the existing replies up to max_count
and provides a loaned sequence to access them.
This operation does not make a copy of the data. It is similar to FooDataReader_take.
The loan is returned with FooBarRequester_return_loan
This operation may be used after a call to RTI_Connext_Requester_wait_for_replies
See an example here: Taking loaned samples
self | <<in>> Cannot be NULL. |
reply_seq | The data sequence |
sample_info_seq | The associated sample info sequence |
max_count | The maximum number of samples that are taken at a time. The special value DDS_LENGTH_UNLIMITED may be used. This value will read up to the limit specified by DDS_DataReaderResourceLimitsQosPolicy::max_samples_per_read |
with up to elements. May be empty if there were no replies to get.
DDS_ReturnCode_t FooBarRequester_take_reply_for_related_request | ( | FooBarRequester * | self, |
Bar * | reply, | ||
struct DDS_SampleInfo * | sample_info, | ||
const struct DDS_SampleIdentity_t * | related_request_id | ||
) |
Copies the contents of a reply for a specific request.
This operation is analogous to FooBarRequester_take_reply except the reply corresponds to a specific request.
self | <<in>> Cannot be NULL. |
reply | The sample where a reply is copied into |
sample_info | <<inout>> a DDS_SampleInfo object where the info associated to the received reply will be returned. Must be a valid non-NULL DDS_SampleInfo. The function will fail with DDS_RETCODE_BAD_PARAMETER if it is NULL. |
related_request_id | The identity of a request previously sent by this Requester |
DDS_ReturnCode_t FooBarRequester_take_replies_for_related_request | ( | FooBarRequester * | self, |
struct BarSeq * | reply_seq, | ||
struct DDS_SampleInfoSeq * | sample_info_seq, | ||
DDS_Long | max_count, | ||
const struct DDS_SampleIdentity_t * | related_request_id | ||
) |
Provides a loaned sequence to access the existing replies for a specific request.
This operation is analogous to FooBarRequester_take_replies except the replies this operation provides correspond to a specific request.
self | <<in>> Cannot be NULL. |
reply_seq | The data sequence |
sample_info_seq | The associated sample info sequence |
max_count | The maximum number of samples that are taken at a time. The special value DDS_LENGTH_UNLIMITED may be used. |
related_request_id | The identity of a request previously sent by this Requester |
DDS_ReturnCode_t FooBarRequester_read_reply | ( | FooBarRequester * | self, |
Bar * | reply, | ||
struct DDS_SampleInfo * | sample_info | ||
) |
Copies the contents of a reply into a Sample.
This operation is equivalent to FooBarRequester_take_reply except the reply remains in the Requester and can be read or taken again.
DDS_ReturnCode_t FooBarRequester_read_replies | ( | FooBarRequester * | self, |
struct BarSeq * | reply_seq, | ||
struct DDS_SampleInfoSeq * | sample_info_seq, | ||
DDS_Long | max_count | ||
) |
Provides a loaned sequence to access the existing replies.
This operation is equivalent to FooBarRequester_take_replies except the replies remain in the Requester and can be read or taken again.
DDS_ReturnCode_t FooBarRequester_read_reply_for_related_request | ( | FooBarRequester * | self, |
Bar * | reply, | ||
struct DDS_SampleInfo * | sample_info, | ||
const struct DDS_SampleIdentity_t * | related_request_id | ||
) |
Copies the contents of a reply for a specific request.
This operation is equivalent to FooBarRequester_take_reply_for_related_request except the reply remains in the Requester and can be read or taken again.
DDS_ReturnCode_t FooBarRequester_read_replies_for_related_request | ( | FooBarRequester * | self, |
struct BarSeq * | reply_seq, | ||
struct DDS_SampleInfoSeq * | sample_info_seq, | ||
DDS_Long | max_count, | ||
const struct DDS_SampleIdentity_t * | related_request_id | ||
) |
Provides a loaned sequence to access the existing replies for a specific request.
This operation is equivalent to FooBarRequester_take_replies_for_related_request except the replies remain in the Requester and can be read or taken again.
FooDataWriter* FooBarRequester_get_request_datawriter | ( | FooBarRequester * | self | ) |
Retrieves the underlying DDS_DataWriter.
Accessing the request DataWriter may be useful for a number of advanced use cases, such as:
BarDataReader* FooBarRequester_get_reply_datareader | ( | FooBarRequester * | self | ) |
Retrieves the underlying DDS_DataReader.
Accessing the reply DataReader may be useful for a number of advanced use cases, such as:
DDS_ReturnCode_t FooBarRequester_return_loan | ( | FooBarRequester * | self, |
struct BarSeq * | received_data, | ||
struct DDS_SampleInfoSeq * | info_seq | ||
) |
Returns samples previously received from the middleware.
This operation needs to be called at some point after: