Skip to content

Commit 92234d1

Browse files
authored
Allow sharing DomainParticipant with C++ applications (#25)
* Allow sharing DomainParticipant with C++ applications * Add comment about UserObjectQosPolicy * Resolve uncrustify errors Signed-off-by: Andrea Sorbini <[email protected]>
1 parent 148619e commit 92234d1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

rmw_connextdds_common/include/rmw_connextdds/static_config.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,14 @@
284284
#define RMW_CONNEXT_FAST_ENDPOINT_DISCOVERY 1
285285
#endif /* RMW_CONNEXT_FAST_ENDPOINT_DISCOVERY */
286286

287+
/******************************************************************************
288+
* Modify DomainParticipantQos to allow sharing of DDS entities created with
289+
* the Connext C API with applications using the C++11 API.
290+
******************************************************************************/
291+
#ifndef RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP
292+
#define RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP 1
293+
#endif /* RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP */
294+
287295
/******************************************************************************
288296
* Override dds.transport.UDPv4.builtin.ignore_loopback_interface in
289297
* DomainParticipantQos to force communication over loopback (in addition to

rmw_connextdds_common/src/ndds/dds_api_ndds.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ rmw_connextdds_initialize_participant_qos_impl(
208208
}
209209
#endif /* RMW_CONNEXT_FAST_ENDPOINT_DISCOVERY */
210210

211+
#if RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP
212+
// UserObjectQosPolicy is an internal, undocumented Connext policy used by the
213+
// implementations of different language bindings to control the memory
214+
// representations of various objects created by user applications. In this
215+
// case, the settings match the requirements of the "modern C++" API, and they
216+
// allow the DomainParticipant to be used directly by applications that want
217+
// to create new entities in C++11, even though the participant was created
218+
// using the C API. If these settings are not specified, an application will
219+
// receive a SIGSEGV when trying to create one of these entities.
220+
dp_qos->user_object.flow_controller_user_object.size = sizeof(void *);
221+
dp_qos->user_object.topic_user_object.size = sizeof(void *);
222+
dp_qos->user_object.content_filtered_topic_user_object.size = sizeof(void *);
223+
#endif /* RMW_CONNEXT_SHARE_DDS_ENTITIES_WITH_CPP */
224+
211225
return RMW_RET_OK;
212226
}
213227

0 commit comments

Comments
 (0)