From 49bcb5c1c4bbdec44f47652c8b59c41c9f4035c9 Mon Sep 17 00:00:00 2001 From: Andrea Sorbini Date: Mon, 5 Apr 2021 10:47:11 -0700 Subject: [PATCH 1/3] Allow sharing DomainParticipant with C++ applications Signed-off-by: Andrea Sorbini --- .../include/rmw_connextdds/static_config.hpp | 8 ++++++++ rmw_connextdds_common/src/ndds/dds_api_ndds.cpp | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/rmw_connextdds_common/include/rmw_connextdds/static_config.hpp b/rmw_connextdds_common/include/rmw_connextdds/static_config.hpp index 2ad1c9fc..41bac860 100644 --- a/rmw_connextdds_common/include/rmw_connextdds/static_config.hpp +++ b/rmw_connextdds_common/include/rmw_connextdds/static_config.hpp @@ -280,6 +280,14 @@ #define RMW_CONNEXT_FAST_ENDPOINT_DISCOVERY 1 #endif /* RMW_CONNEXT_FAST_ENDPOINT_DISCOVERY */ +/****************************************************************************** + * Modify DomainParticipantQos to allow sharing of DDS entities created with + * the Connext C API with applications using the C++11 API. + ******************************************************************************/ +#ifndef RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP +#define RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP 1 +#endif /* RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP */ + /****************************************************************************** * Override dds.transport.UDPv4.builtin.ignore_loopback_interface in * DomainParticipantQos to force communication over loopback (in addition to diff --git a/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp b/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp index 0e4dfc12..1c07e88a 100644 --- a/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp +++ b/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp @@ -207,6 +207,12 @@ rmw_connextdds_initialize_participant_qos_impl( } #endif /* RMW_CONNEXT_FAST_ENDPOINT_DISCOVERY */ +#if RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP + dp_qos->user_object.flow_controller_user_object.size = sizeof(void*); + dp_qos->user_object.topic_user_object.size = sizeof(void*); + dp_qos->user_object.content_filtered_topic_user_object.size = sizeof(void*); +#endif /* RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP */ + return RMW_RET_OK; } From 4627deba4e65401f6f99fc828fa7a4456f021a1d Mon Sep 17 00:00:00 2001 From: Andrea Sorbini Date: Fri, 9 Apr 2021 16:15:57 -0700 Subject: [PATCH 2/3] Add comment about UserObjectQosPolicy Signed-off-by: Andrea Sorbini --- rmw_connextdds_common/src/ndds/dds_api_ndds.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp b/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp index 1c07e88a..4e680c3a 100644 --- a/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp +++ b/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp @@ -208,6 +208,14 @@ rmw_connextdds_initialize_participant_qos_impl( #endif /* RMW_CONNEXT_FAST_ENDPOINT_DISCOVERY */ #if RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP + // UserObjectQosPolicy is an internal, undocumented Connext policy used by the + // implementations of different language bindings to control the memory + // representations of various objects created by user applications. In this + // case, the settings match the requirements of the "modern C++" API, and they + // allow the DomainParticipant to be used directly by applications that want + // to create new entities in C++11, even though the participant was created + // using the C API. If these settings are not specified, an application will + // receive a SIGSEGV when trying to create one of these entities. dp_qos->user_object.flow_controller_user_object.size = sizeof(void*); dp_qos->user_object.topic_user_object.size = sizeof(void*); dp_qos->user_object.content_filtered_topic_user_object.size = sizeof(void*); From cb90c7b879ed88bb9118f0cc4d63dc1742461be8 Mon Sep 17 00:00:00 2001 From: Andrea Sorbini Date: Mon, 12 Apr 2021 14:19:35 -0700 Subject: [PATCH 3/3] Resolve uncrustify errors Signed-off-by: Andrea Sorbini --- rmw_connextdds_common/src/ndds/dds_api_ndds.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp b/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp index 4e680c3a..3a093ab1 100644 --- a/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp +++ b/rmw_connextdds_common/src/ndds/dds_api_ndds.cpp @@ -216,9 +216,9 @@ rmw_connextdds_initialize_participant_qos_impl( // to create new entities in C++11, even though the participant was created // using the C API. If these settings are not specified, an application will // receive a SIGSEGV when trying to create one of these entities. - dp_qos->user_object.flow_controller_user_object.size = sizeof(void*); - dp_qos->user_object.topic_user_object.size = sizeof(void*); - dp_qos->user_object.content_filtered_topic_user_object.size = sizeof(void*); + dp_qos->user_object.flow_controller_user_object.size = sizeof(void *); + dp_qos->user_object.topic_user_object.size = sizeof(void *); + dp_qos->user_object.content_filtered_topic_user_object.size = sizeof(void *); #endif /* RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP */ return RMW_RET_OK;