Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Update service/client construction/destruction API return codes. #464

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 35 additions & 23 deletions rmw_connext_cpp/src/rmw_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "rmw/error_handling.h"
#include "rmw/impl/cpp/macros.hpp"
#include "rmw/rmw.h"
#include "rmw/validate_full_topic_name.h"

#include "rmw_connext_shared_cpp/types.hpp"
#include "rmw_connext_shared_cpp/qos.hpp"
Expand All @@ -41,21 +42,32 @@ rmw_create_client(
const char * service_name,
const rmw_qos_profile_t * qos_profile)
{
if (!node) {
RMW_SET_ERROR_MSG("node handle is null");
return NULL;
}
RMW_CHECK_ARGUMENT_FOR_NULL(node, NULL);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
node handle,
node->implementation_identifier, rti_connext_identifier,
return NULL)

RMW_CONNEXT_EXTRACT_SERVICE_TYPESUPPORT(type_supports, type_support, NULL)

if (!qos_profile) {
RMW_SET_ERROR_MSG("qos_profile is null");
node,
node->implementation_identifier,
rti_connext_identifier,
return NULL);
RMW_CHECK_ARGUMENT_FOR_NULL(type_supports, nullptr);
RMW_CONNEXT_EXTRACT_SERVICE_TYPESUPPORT(type_supports, type_support, NULL);
RMW_CHECK_ARGUMENT_FOR_NULL(service_name, nullptr);
if (0 == strlen(service_name)) {
RMW_SET_ERROR_MSG("service_name argument is an empty string");
return nullptr;
}
RMW_CHECK_ARGUMENT_FOR_NULL(qos_profile, nullptr);
if (!qos_profile->avoid_ros_namespace_conventions) {
int validation_result = RMW_TOPIC_VALID;
rmw_ret_t ret = rmw_validate_full_topic_name(service_name, &validation_result, nullptr);
if (RMW_RET_OK != ret) {
return nullptr;
}
if (RMW_TOPIC_VALID != validation_result) {
const char * reason = rmw_full_topic_name_validation_result_string(validation_result);
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING("service_name argument is invalid: %s", reason);
return nullptr;
}
}

auto node_info = static_cast<ConnextNodeInfo *>(node->data);
if (!node_info) {
Expand Down Expand Up @@ -277,18 +289,18 @@ rmw_create_client(
rmw_ret_t
rmw_destroy_client(rmw_node_t * node, rmw_client_t * client)
{
if (!node) {
RMW_SET_ERROR_MSG("node handle is null");
return RMW_RET_ERROR;
}
if (!client) {
RMW_SET_ERROR_MSG("client handle is null");
return RMW_RET_ERROR;
}
RMW_CHECK_ARGUMENT_FOR_NULL(node, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
node,
node->implementation_identifier,
rti_connext_identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(client, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
client handle,
client->implementation_identifier, rti_connext_identifier,
return RMW_RET_ERROR)
client,
client->implementation_identifier,
rti_connext_identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);

auto result = RMW_RET_OK;
ConnextStaticClientInfo * client_info = static_cast<ConnextStaticClientInfo *>(client->data);
Expand Down
59 changes: 36 additions & 23 deletions rmw_connext_cpp/src/rmw_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

#include "rmw/allocators.h"
#include "rmw/error_handling.h"
#include "rmw/impl/cpp/macros.hpp"
#include "rmw/rmw.h"
#include "rmw/validate_full_topic_name.h"

#include "rmw_connext_shared_cpp/qos.hpp"
#include "rmw_connext_shared_cpp/types.hpp"
Expand All @@ -40,21 +42,32 @@ rmw_create_service(
const char * service_name,
const rmw_qos_profile_t * qos_profile)
{
if (!node) {
RMW_SET_ERROR_MSG("node handle is null");
return NULL;
}
RMW_CHECK_ARGUMENT_FOR_NULL(node, NULL);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
node handle,
node->implementation_identifier, rti_connext_identifier,
return NULL)

RMW_CONNEXT_EXTRACT_SERVICE_TYPESUPPORT(type_supports, type_support, NULL)

if (!qos_profile) {
RMW_SET_ERROR_MSG("qos_profile is null");
node,
node->implementation_identifier,
rti_connext_identifier,
return NULL);
RMW_CHECK_ARGUMENT_FOR_NULL(type_supports, nullptr);
RMW_CONNEXT_EXTRACT_SERVICE_TYPESUPPORT(type_supports, type_support, NULL);
RMW_CHECK_ARGUMENT_FOR_NULL(service_name, nullptr);
if (0 == strlen(service_name)) {
RMW_SET_ERROR_MSG("service_name argument is an empty string");
return nullptr;
}
RMW_CHECK_ARGUMENT_FOR_NULL(qos_profile, nullptr);
if (!qos_profile->avoid_ros_namespace_conventions) {
int validation_result = RMW_TOPIC_VALID;
rmw_ret_t ret = rmw_validate_full_topic_name(service_name, &validation_result, nullptr);
if (RMW_RET_OK != ret) {
return nullptr;
}
if (RMW_TOPIC_VALID != validation_result) {
const char * reason = rmw_full_topic_name_validation_result_string(validation_result);
RMW_SET_ERROR_MSG_WITH_FORMAT_STRING("service_name argument is invalid: %s", reason);
return nullptr;
}
}

auto node_info = static_cast<ConnextNodeInfo *>(node->data);
if (!node_info) {
Expand Down Expand Up @@ -288,18 +301,18 @@ rmw_create_service(
rmw_ret_t
rmw_destroy_service(rmw_node_t * node, rmw_service_t * service)
{
if (!node) {
RMW_SET_ERROR_MSG("node handle is null");
return RMW_RET_ERROR;
}
if (!service) {
RMW_SET_ERROR_MSG("service handle is null");
return RMW_RET_ERROR;
}
RMW_CHECK_ARGUMENT_FOR_NULL(node, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
node,
node->implementation_identifier,
rti_connext_identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);
RMW_CHECK_ARGUMENT_FOR_NULL(service, RMW_RET_INVALID_ARGUMENT);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
service handle,
service->implementation_identifier, rti_connext_identifier,
return RMW_RET_ERROR)
service,
service->implementation_identifier,
rti_connext_identifier,
return RMW_RET_INCORRECT_RMW_IMPLEMENTATION);

auto result = RMW_RET_OK;
ConnextStaticServiceInfo * service_info = static_cast<ConnextStaticServiceInfo *>(service->data);
Expand Down