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

Commit

Permalink
deduplicate code (#312)
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodall <william@osrfoundation.org>
  • Loading branch information
wjwwood authored and dirk-thomas committed Jan 10, 2019
1 parent 858ac29 commit e71347b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 35 deletions.
9 changes: 1 addition & 8 deletions rmw_connext_cpp/src/rmw_guard_condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,7 @@ extern "C"
rmw_guard_condition_t *
rmw_create_guard_condition(rmw_context_t * context)
{
RCUTILS_CHECK_ARGUMENT_FOR_NULL(context, NULL);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
init context,
context->implementation_identifier,
rti_connext_identifier,
// TODO(wjwwood): replace this with RMW_RET_INCORRECT_RMW_IMPLEMENTATION when refactored
return NULL);
return create_guard_condition(rti_connext_identifier);
return create_guard_condition(rti_connext_identifier, context);
}

rmw_ret_t
Expand Down
9 changes: 1 addition & 8 deletions rmw_connext_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,8 @@ rmw_create_node(
size_t domain_id,
const rmw_node_security_options_t * security_options)
{
RCUTILS_CHECK_ARGUMENT_FOR_NULL(context, NULL);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
init context,
context->implementation_identifier,
rti_connext_identifier,
// TODO(wjwwood): replace this with RMW_RET_INCORRECT_RMW_IMPLEMENTATION when refactored
return NULL);
return create_node(
rti_connext_identifier, name, namespace_, domain_id, security_options);
rti_connext_identifier, context, name, namespace_, domain_id, security_options);
}

rmw_ret_t
Expand Down
18 changes: 2 additions & 16 deletions rmw_connext_dynamic_cpp/src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,15 +289,8 @@ rmw_create_node(
size_t domain_id,
const rmw_node_security_options_t * security_options)
{
RCUTILS_CHECK_ARGUMENT_FOR_NULL(context, NULL);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
init context,
context->implementation_identifier,
rti_connext_dynamic_identifier,
// TODO(wjwwood): replace this with RMW_RET_INCORRECT_RMW_IMPLEMENTATION when refactored
return NULL);
return create_node(
rti_connext_dynamic_identifier, name, namespace_, domain_id, security_options);
rti_connext_dynamic_identifier, context, name, namespace_, domain_id, security_options);
}

rmw_ret_t
Expand Down Expand Up @@ -1471,14 +1464,7 @@ rmw_deserialize(
rmw_guard_condition_t *
rmw_create_guard_condition(rmw_context_t * context)
{
RCUTILS_CHECK_ARGUMENT_FOR_NULL(context, NULL);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
init context,
context->implementation_identifier,
rti_connext_dynamic_identifier,
// TODO(wjwwood): replace this with RMW_RET_INCORRECT_RMW_IMPLEMENTATION when refactored
return NULL);
return create_guard_condition(rti_connext_dynamic_identifier);
return create_guard_condition(rti_connext_dynamic_identifier, context);
}

rmw_ret_t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

RMW_CONNEXT_SHARED_CPP_PUBLIC
rmw_guard_condition_t *
create_guard_condition(const char * implementation_identifier);
create_guard_condition(const char * implementation_identifier, rmw_context_t * context);

RMW_CONNEXT_SHARED_CPP_PUBLIC
rmw_ret_t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RMW_CONNEXT_SHARED_CPP_PUBLIC
rmw_node_t *
create_node(
const char * implementation_identifier,
rmw_context_t * context,
const char * name,
const char * namespace_,
size_t domain_id,
Expand Down
9 changes: 8 additions & 1 deletion rmw_connext_shared_cpp/src/guard_condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@
#include "rmw/impl/cpp/macros.hpp"

rmw_guard_condition_t *
create_guard_condition(const char * implementation_identifier)
create_guard_condition(const char * implementation_identifier, rmw_context_t * context)
{
RCUTILS_CHECK_ARGUMENT_FOR_NULL(context, NULL);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
init context,
context->implementation_identifier,
implementation_identifier,
// TODO(wjwwood): replace this with RMW_RET_INCORRECT_RMW_IMPLEMENTATION when refactored
return NULL);
rmw_guard_condition_t * guard_condition = rmw_guard_condition_allocate();
if (!guard_condition) {
RMW_SET_ERROR_MSG("failed to allocate guard condition");
Expand Down
10 changes: 9 additions & 1 deletion rmw_connext_shared_cpp/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@
rmw_node_t *
create_node(
const char * implementation_identifier,
rmw_context_t * context,
const char * name,
const char * namespace_,
size_t domain_id,
const rmw_node_security_options_t * security_options)
{
RCUTILS_CHECK_ARGUMENT_FOR_NULL(context, NULL);
RMW_CHECK_TYPE_IDENTIFIERS_MATCH(
init context,
context->implementation_identifier,
implementation_identifier,
// TODO(wjwwood): replace this with RMW_RET_INCORRECT_RMW_IMPLEMENTATION when refactored
return NULL);
if (!security_options) {
RMW_SET_ERROR_MSG("security_options is null");
return nullptr;
Expand Down Expand Up @@ -277,7 +285,7 @@ create_node(
goto fail;
}

graph_guard_condition = create_guard_condition(implementation_identifier);
graph_guard_condition = create_guard_condition(implementation_identifier, context);
if (!graph_guard_condition) {
RMW_SET_ERROR_MSG("failed to create graph guard condition");
goto fail;
Expand Down

0 comments on commit e71347b

Please sign in to comment.