Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Binary entity creation mode #224

Merged
merged 15 commits into from
Apr 30, 2021
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ set(SRCS
src/c/core/session/common_create_entities.c
src/c/core/session/create_entities_ref.c
src/c/core/session/create_entities_xml.c
src/c/core/session/create_entities_bin.c
src/c/core/session/read_access.c
src/c/core/session/write_access.c
$<$<BOOL:${UCLIENT_PROFILE_STREAM_FRAMING}>:src/c/profile/transport/stream_framing/stream_framing_protocol.c>
Expand Down
1 change: 1 addition & 0 deletions include/uxr/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <uxr/client/core/session/read_access.h>
#include <uxr/client/core/session/create_entities_ref.h>
#include <uxr/client/core/session/create_entities_xml.h>
#include <uxr/client/core/session/create_entities_bin.h>

#include <uxr/client/transport.h>

Expand Down
250 changes: 250 additions & 0 deletions include/uxr/client/core/session/create_entities_bin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
// Copyright 2018 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef UXR_CLIENT_CORE_SESSION_CREATE_ENTITIES_BIN_H_
#define UXR_CLIENT_CORE_SESSION_CREATE_ENTITIES_BIN_H_

#ifdef __cplusplus
extern "C"
{
#endif // ifdef __cplusplus

#include <uxr/client/core/session/common_create_entities.h>
#include <uxr/client/core/type/xrce_types.h>

//==================================================================
// PUBLIC
//==================================================================

/**
* @brief Buffers into the stream identified by `stream_id` an XRCE CREATE submessage with an XRCE Participant payload.
* The submessage will be sent when `uxr_flash_output_streams` or `uxr_run_session` function are called.
* As a result of the reception of this submessage, the Agent will create an XRCE Participant according to
* the binary provides in the CREATE submessage.
pablogs9 marked this conversation as resolved.
Show resolved Hide resolved
* @param session A uxrSession structure previously initialized.
* @param stream_id The output stream identifier where the CREATE submessage will be buffered.
* @param object_id The identifier of the XRCE Participant.
* @param domain_id The identifier of the Domain to which the XRCE Participant belongs.
* @param mode The set of flags that determines the entity creation mode.
* The Creation Mode Table describes the entities creation behaviour according to the
* `UXR_REUSE` and `UXR_REPLACE` flags.
* @return A `request_id` that identifies the request made by the Client.
* This could be used in the `uxr_run_session_until_one_status` or `uxr_run_session_until_all_status` functions.
*/
UXRDLLAPI uint16_t uxr_buffer_create_participant_bin(
uxrSession* session,
uxrStreamId stream_id,
uxrObjectId object_id,
uint16_t domain_id,
uint8_t mode);
/**
* @brief Buffers into the stream identified by `stream_id` an XRCE CREATE submessage with an XRCE Topic payload.
* The submessage will be sent when `uxr_flash_output_streams` or `uxr_run_session` function are called.
* As a result of the reception of this submessage, the Agent will create an XRCE Topic according to
* the binary provides in the CREATE submessage.
pablogs9 marked this conversation as resolved.
Show resolved Hide resolved
* @param session A uxrSession structure previously initialized.
* @param stream_id The output stream identifier where the CREATE submessage will be buffered.
* @param object_id The identifier of the XRCE Topic.
* @param participant_id The identifier of the associated XRCE Participant.
* @param topic_name The XRCE Topic name.
* @param type_name The XRCE Topic type.
* @param mode The set of flags that determines the entity creation mode.
* The Creation Mode Table describes the entities creation behaviour according to the
* `UXR_REUSE` and `UXR_REPLACE` flags.
* @return A `request_id` that identifies the request made by the Client.
* This could be used in the `uxr_run_session_until_one_status` or `uxr_run_session_until_all_status` functions.
*/
UXRDLLAPI uint16_t uxr_buffer_create_topic_bin(
uxrSession* session,
uxrStreamId stream_id,
uxrObjectId object_id,
uxrObjectId participant_id,
const char* topic_name,
const char* type_name,
uint8_t mode);

/**
* @brief Buffers into the stream identified by `stream_id` an XRCE CREATE submessage with an XRCE Subscriber payload.
* The submessage will be sent when `uxr_flash_output_streams` or `uxr_run_session` function are called.
* As a result of the reception of this submessage, the Agent will create an XRCE Publisher according to
* the binary provides in the CREATE submessage.
pablogs9 marked this conversation as resolved.
Show resolved Hide resolved
* @param session A uxrSession structure previously initialized.
* @param stream_id The output stream identifier where the CREATE submessage will be buffered.
* @param object_id The identifier of the XRCE Publisher.
* @param participant_id The identifier of the associated XRCE Participant.
* @param mode The set of flags that determines the entity creation mode.
* The Creation Mode Table describes the entities creation behaviour according to the
* `UXR_REUSE` and `UXR_REPLACE` flags.
* @return A `request_id` that identifies the request made by the Client.
* This could be used in the `uxr_run_session_until_one_status` or `uxr_run_session_until_all_status` functions.
*/
UXRDLLAPI uint16_t uxr_buffer_create_publisher_bin(
uxrSession* session,
uxrStreamId stream_id,
uxrObjectId object_id,
uxrObjectId participant_id,
uint8_t mode);

/**
* @brief Buffers into the stream identified by `stream_id` an XRCE CREATE submessage with an XRCE Subscriber payload.
* The submessage will be sent when `uxr_flash_output_streams` or `uxr_run_session` function are called.
* As a result of the reception of this submessage, the Agent will create an XRCE Subscriber according to
* the binary provides in the CREATE submessage.
pablogs9 marked this conversation as resolved.
Show resolved Hide resolved
* @param session A uxrSession structure previously initialized.
* @param stream_id The output stream identifier where the CREATE submessage will be buffered.
* @param object_id The identifier of the XRCE Subscriber.
* @param participant_id The identifier of the associated XRCE Participant.
* @param mode The set of flags that determines the entity creation mode.
* The Creation Mode Table describes the entities creation behaviour according to the
* `UXR_REUSE` and `UXR_REPLACE` flags.
* @return A `request_id` that identifies the request made by the Client.
* This could be used in the `uxr_run_session_until_one_status` or `uxr_run_session_until_all_status` functions.
*/
UXRDLLAPI uint16_t uxr_buffer_create_subscriber_bin(
uxrSession* session,
uxrStreamId stream_id,
uxrObjectId object_id,
uxrObjectId participant_id,
uint8_t mode);

/**
* @brief Buffers into the stream identified by `stream_id` an XRCE CREATE submessage with an XRCE DataWriter payload.
* The submessage will be sent when `uxr_flash_output_streams` or `uxr_run_session` function are called.
* As a result of the reception of this submessage, the Agent will create an XRCE DataWriter according to
* the binary provides in the CREATE submessage.
pablogs9 marked this conversation as resolved.
Show resolved Hide resolved
* @param session A uxrSession structure previously initialized.
* @param stream_id The output stream identifier where the CREATE submessage will be buffered.
* @param object_id The identifier of the XRCE DataWriter.
* @param publisher_id The identifier of the associated XRCE Publisher.
* @param topic_id The identifier of the associated XRCE Topic.
* @param reliable Reliability flag.
* @param keep_last Keep last flag.
* @param transient_local Transient local flag.
* @param mode The set of flags that determines the entity creation mode.
* The Creation Mode Table describes the entities creation behaviour according to the
* `UXR_REUSE` and `UXR_REPLACE` flags.
* @return A `request_id` that identifies the request made by the Client.
* This could be used in the `uxr_run_session_until_one_status` or `uxr_run_session_until_all_status` functions.
*/
UXRDLLAPI uint16_t uxr_buffer_create_datawriter_bin(
uxrSession* session,
uxrStreamId stream_id,
uxrObjectId object_id,
uxrObjectId publisher_id,
uxrObjectId topic_id,
bool reliable,
bool keep_last,
bool transient_local,
uint8_t mode);

/**
* @brief Buffers into the stream identified by `stream_id` an XRCE CREATE submessage with an XRCE DataReader payload.
* The submessage will be sent when `uxr_flash_output_streams` or `uxr_run_session` function are called.
* As a result of the reception of this submessage, the Agent will create an XRCE DataReader according to
* the binary provides in the CREATE submessage.
pablogs9 marked this conversation as resolved.
Show resolved Hide resolved
* @param session A uxrSession structure previously initialized.
* @param stream_id The output stream identifier where the CREATE submessage will be buffered.
* @param object_id The identifier of the XRCE DataReader.
* @param subscriber_id The identifier of the associated XRCE Subscriber.
* @param topic_id The identifier of the associated XRCE Topic.
* @param reliable Reliability flag.
* @param keep_last Keep last flag.
* @param transient_local Transient local flag.
* @param mode The set of flags that determines the entity creation mode.
* The Creation Mode Table describes the entities creation behaviour according to the
* `UXR_REUSE` and `UXR_REPLACE` flags.
* @return A `request_id` that identifies the request made by the Client.
* This could be used in the `uxr_run_session_until_one_status` or `uxr_run_session_until_all_status` functions.
*/
UXRDLLAPI uint16_t uxr_buffer_create_datareader_bin(
uxrSession* session,
uxrStreamId stream_id,
uxrObjectId object_id,
uxrObjectId subscriber_id,
uxrObjectId topic_id,
bool reliable,
bool keep_last,
bool transient_local,
uint8_t mode);
/**
* @brief Buffers into the stream identified by `stream_id` an XRCE CREATE submessage with an XRCE Requester payload.
* The submessage will be sent when `uxr_flag_output_streams` or `uxr_run_session` functions are called.
* As a result of the reception of this submessage, the Agent will create an XRCE Requester according to
* the binary provided in the CREATE submessage.
*
* @param session A uxrSession structure previously initialized.
* @param stream_id The output stream identifier where the CREATE submessage will be buffered.
* @param object_id The identifier of the XRCE Requester.
* @param participant_id The identifier of the associated XRCE Participant.
* @param service_name Requester service name.
* @param request_type Requester request type.
* @param reply_type Requester reply type.
* @param request_topic_name Requester request topic name.
* @param reply_topic_name Requester reply topic name.
* @param mode The set of flags that determines the entitiy creation mode.
* the Creation Mode Table describes the entities creation behaviour according to the
* `UXR_REUSE` and `UXR_REPLACE` flags.
* @return A `request_id` that identifies the request made by the Client.
* This could be used in the `uxr_run_session_until_one_status` or `uxr_run_session_until_all_status` functions.
*/
UXRDLLAPI uint16_t uxr_buffer_create_requester_bin(
uxrSession* session,
uxrStreamId stream_id,
uxrObjectId object_id,
uxrObjectId participant_id,
const char* service_name,
const char* request_type,
const char* reply_type,
const char* request_topic_name,
const char* reply_topic_name,
uint8_t mode);

/**
* @brief Buffers into the stream identified by `stream_id` an XRCE CREATE submessage with an XRCE Replier payload.
* The submessage will be sent when `uxr_flag_output_streams` or `uxr_run_session` functions are called.
* As a result of the reception of this submessage, the Agent will create an XRCE Replier according to
* the binary provided in the CREATE submessage.
*
* @param session A uxrSession structure previously initialized.
* @param stream_id The output stream identifier where the CREATE submessage will be buffered.
* @param object_id The identifier of the XRCE Requester.
* @param participant_id The identifier of the associated XRCE Participant.
* @param service_name Replier service name.
* @param request_type Replier request type.
* @param reply_type Replier reply type.
* @param request_topic_name Replier request topic name.
* @param reply_topic_name Replier reply topic name.
* @param mode The set of flags that determines the entitiy creation mode.
* the Creation Mode Table describes the entities creation behaviour according to the
* `UXR_REUSE` and `UXR_REPLACE` flags.
* @return A `request_id` that identifies the request made by the Client.
* This could be used in the `uxr_run_session_until_one_status` or `uxr_run_session_until_all_status` functions.
*/
UXRDLLAPI uint16_t uxr_buffer_create_replier_bin(
uxrSession* session,
uxrStreamId stream_id,
uxrObjectId object_id,
uxrObjectId participant_id,
const char* service_name,
const char* request_type,
const char* reply_type,
const char* request_topic_name,
const char* reply_topic_name,
uint8_t mode);

#ifdef __cplusplus
}
#endif // ifdef __cplusplus

#endif // UXR_CLIENT_CORE_SESSION_CREATE_ENTITIES_BIN_H_
55 changes: 50 additions & 5 deletions include/uxr/client/core/type/xrce_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ extern "C"
#define UXR_STRING_SIZE_MAX 512
#define UXR_SAMPLE_DATA_SIZE_MAX 512
#define UXR_STRING_SEQUENCE_MAX 8
#define UXR_BINARY_SEQUENCE_MAX 8
#define UXR_BINARY_SEQUENCE_MAX 512
#define UXR_BINARY_SEQUENCE_SMALL_MAX 8
#define UXR_SAMPLE_SEQUENCE_MAX 8
#define UXR_SAMPLE_DATA_SEQUENCE_MAX 8
#define UXR_SAMPLE_DELTA_SEQUENCE_MAX 8
Expand All @@ -55,6 +56,13 @@ typedef struct BinarySequence_t

} BinarySequence_t;

typedef struct BinarySequenceSmall_t
{
uint32_t size;
uint8_t data[UXR_BINARY_SEQUENCE_SMALL_MAX];

} BinarySequenceSmall_t;

typedef struct StringSequence_t
{
uint32_t size;
Expand Down Expand Up @@ -471,7 +479,7 @@ typedef struct OBJK_Subscriber_Binary

typedef enum EndpointQosFlags
{
is_reliabel = 0x01 << 0,
is_reliable = 0x01 << 0,
is_history_keep_last = 0x01 << 1,
is_ownership_exclusive = 0x01 << 2,
is_durability_transient_local = 0x01 << 3,
Expand All @@ -491,7 +499,7 @@ typedef struct OBJK_Endpoint_QosBinary
bool optional_lifespan_msec;
uint32_t lifespan_msec;
bool optional_user_data;
BinarySequence_t user_data;
BinarySequenceSmall_t user_data;

} OBJK_Endpoint_QosBinary;

Expand All @@ -518,7 +526,7 @@ typedef struct OBJK_DataReader_Binary_Qos

typedef struct OBJK_DataReader_Binary
{
char* topic_name;
ObjectId topic_id;
bool optional_qos;
OBJK_DataReader_Binary_Qos qos;

Expand All @@ -527,12 +535,35 @@ typedef struct OBJK_DataReader_Binary

typedef struct OBJK_DataWriter_Binary
{
char* topic_name;
ObjectId topic_id;
bool optional_qos;
OBJK_DataWriter_Binary_Qos qos;

} OBJK_DataWriter_Binary;

typedef struct OBJK_Requester_Binary
{
char* service_name;
char* request_type;
char* reply_type;
bool optional_request_topic_name;
char* request_topic_name;
bool optional_reply_topic_name;
char* reply_topic_name;

} OBJK_Requester_Binary;

typedef struct OBJK_Replier_Binary
{
char* service_name;
char* request_type;
char* reply_type;
bool optional_request_topic_name;
char* request_topic_name;
bool optional_reply_topic_name;
char* reply_topic_name;

} OBJK_Replier_Binary;

typedef union ObjectVariantU
{
Expand Down Expand Up @@ -1390,6 +1421,20 @@ bool uxr_deserialize_OBJK_DataWriter_Binary(
ucdrBuffer* buffer,
OBJK_DataWriter_Binary* output);

bool uxr_serialize_OBJK_Requester_Binary(
ucdrBuffer* buffer,
const OBJK_Requester_Binary* input);
bool uxr_deserialize_OBJK_Requester_Binary(
ucdrBuffer* buffer,
OBJK_Requester_Binary* output);

bool uxr_serialize_OBJK_Replier_Binary(
ucdrBuffer* buffer,
const OBJK_Replier_Binary* input);
bool uxr_deserialize_OBJK_Replier_Binary(
ucdrBuffer* buffer,
OBJK_Replier_Binary* output);

bool uxr_serialize_ObjectVariant(
ucdrBuffer* buffer,
const ObjectVariant* input);
Expand Down
Loading