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

update logic / patches to optionally support Connext 6 #374

Merged
merged 4 commits into from
Oct 18, 2019
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
31 changes: 25 additions & 6 deletions rmw_connext_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,33 @@ add_custom_command(
VERBATIM
)

# determine major version of Connext
find_file(connext_version_header "ndds_version.h"
PATHS ${Connext_INCLUDE_DIRS}
PATH_SUFFIXES "ndds"
NO_DEFAULT_PATH)
if(NOT connext_version_header)
message(FATAL_ERROR "Failed to find 'ndds/ndds_version.h' in '${Connext_INCLUDE_DIRS}'")
endif()
file(STRINGS "${connext_version_header}" connext_define_major_version LIMIT_COUNT 1 REGEX "#define RTI_DDS_VERSION_MAJOR [0-9]+")
if("${connext_define_major_version}" STREQUAL "")
message(FATAL_ERROR "Failed to find '#define RTI_DDS_VERSION_MAJOR' in '${connext_version_header}'")
endif()
string(REGEX REPLACE ".* ([0-9]+)" "\\1" connext_major_version "${connext_define_major_version}")

# patch the generate code for raw data
if("${connext_major_version}" LESS 6)
set(patch_files_subdirectory "patch_files")
else()
set(patch_files_subdirectory "patch_files_v6")
dirk-thomas marked this conversation as resolved.
Show resolved Hide resolved
endif()
set(patch_files
${CMAKE_CURRENT_SOURCE_DIR}/resources/patch_files/connext_static_serialized_data.cxx.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/patch_files/connext_static_serialized_data.h.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/patch_files/connext_static_serialized_dataPlugin.cxx.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/patch_files/connext_static_serialized_dataPlugin.h.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/patch_files/connext_static_serialized_dataSupport.cxx.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/patch_files/connext_static_serialized_dataSupport.h.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/${patch_files_subdirectory}/connext_static_serialized_data.cxx.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/${patch_files_subdirectory}/connext_static_serialized_data.h.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/${patch_files_subdirectory}/connext_static_serialized_dataPlugin.cxx.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/${patch_files_subdirectory}/connext_static_serialized_dataPlugin.h.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/${patch_files_subdirectory}/connext_static_serialized_dataSupport.cxx.patch
${CMAKE_CURRENT_SOURCE_DIR}/resources/${patch_files_subdirectory}/connext_static_serialized_dataSupport.h.patch
)
set(patched_directory "${CMAKE_CURRENT_BINARY_DIR}/resources/patched")
file(MAKE_DIRECTORY ${patched_directory})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_data.cxx
+++ b/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_data.cxx
@@ -11,7 +11,7 @@ or consult the RTI Connext manual.

#ifndef NDDS_STANDALONE_TYPE
#ifndef ndds_cpp_h
-#include "ndds/ndds_cpp.h"
+#include "rmw_connext_shared_cpp/ndds_include.hpp"
#endif
#ifndef dds_c_log_impl_h
#include "dds_c/dds_c_log_impl.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- a/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_data.h
+++ b/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_data.h
@@ -14,7 +14,7 @@ or consult the RTI Connext manual.

#ifndef NDDS_STANDALONE_TYPE
#ifndef ndds_cpp_h
-#include "ndds/ndds_cpp.h"
+#include "rmw_connext_shared_cpp/ndds_include.hpp"
#endif
#include "rti/xcdr/Interpreter.hpp"
#else
@@ -63,7 +63,14 @@ or consult the RTI Connext manual.
NDDSUSERDllExport RTIXCdrSampleAccessInfo *ConnextStaticSerializedData_get_sample_seq_access_info(void);
#endif

+#ifndef _WIN32
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wpedantic"
+#endif
DDS_SEQUENCE(ConnextStaticSerializedDataSeq, ConnextStaticSerializedData);
+#ifndef _WIN32
+# pragma GCC diagnostic pop
+#endif

NDDSUSERDllExport
RTIBool ConnextStaticSerializedData_initialize(
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
--- a/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_dataPlugin.cxx
+++ b/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_dataPlugin.cxx
@@ -11,7 +11,7 @@ or consult the RTI Connext manual.
#include <string.h>

#ifndef ndds_cpp_h
-#include "ndds/ndds_cpp.h"
+#include "rmw_connext_shared_cpp/ndds_include.hpp"
#endif

#ifndef osapi_type_h
@@ -655,7 +929,9 @@ Key Management functions:
PRESTypePluginKeyKind
ConnextStaticSerializedDataPlugin_get_key_kind(void)
{
- return PRES_TYPEPLUGIN_USER_KEY;
+ // TODO(karsten1987): Whenever we introduce keys for our data types
+ // this might have to change.
+ return PRES_TYPEPLUGIN_NO_KEY;
}

RTIBool ConnextStaticSerializedDataPlugin_deserialize_key(
@@ -895,6 +1368,11 @@ ConnextStaticSerializedDataPlugin_serialized_sample_to_keyhash(
* ------------------------------------------------------------------------ */
struct PRESTypePlugin *ConnextStaticSerializedDataPlugin_new(void)
{
+ return NULL;
+}
+
+struct PRESTypePlugin *ConnextStaticSerializedDataPlugin_new_external(struct DDS_TypeCode * external_type_code)
+{
struct PRESTypePlugin *plugin = NULL;
const struct PRESTypePluginVersion PLUGIN_VERSION =
PRES_TYPE_PLUGIN_VERSION_2_0;
@@ -990,9 +1468,7 @@ struct PRESTypePlugin *ConnextStaticSerializedDataPlugin_new(void)
(PRESTypePluginKeyToInstanceFunction)
ConnextStaticSerializedDataPlugin_key_to_instance;
plugin->serializedKeyToKeyHashFnc = NULL; /* Not supported yet */
- #ifdef NDDS_STANDALONE_TYPE
- plugin->typeCode = NULL;
- #else
- plugin->typeCode = (struct RTICdrTypeCode *)ConnextStaticSerializedData_get_typecode();
- #endif
+ plugin->typeCode = (struct RTICdrTypeCode *)external_type_code;
plugin->languageKind = PRES_TYPEPLUGIN_CPP_LANG;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_dataPlugin.h
+++ b/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_dataPlugin.h
@@ -258,6 +258,9 @@ extern "C" {
NDDSUSERDllExport extern struct PRESTypePlugin*
ConnextStaticSerializedDataPlugin_new(void);

+ NDDSUSERDllExport extern struct PRESTypePlugin*
+ ConnextStaticSerializedDataPlugin_new_external(struct DDS_TypeCode * external_type_code);
+
NDDSUSERDllExport extern void
ConnextStaticSerializedDataPlugin_delete(struct PRESTypePlugin *);
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
--- a/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_dataSupport.cxx
+++ b/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_dataSupport.cxx
@@ -123,3 +123,62 @@ Defines: TTypeSupport, TData, TDataReader, TDataWriter
#undef TPlugin_new
#undef TPlugin_delete

+DDS_ReturnCode_t
+ConnextStaticSerializedDataSupport_register_external_type(
+ DDSDomainParticipant * participant,
+ const char * type_name,
+ struct DDS_TypeCode * type_code)
+{
+ DDSTypeSupport * dds_data_type = NULL;
+ struct PRESTypePlugin * presTypePlugin = NULL;
+ DDS_ReturnCode_t retcode = DDS_RETCODE_ERROR;
+ DDS_Boolean delete_data_type = DDS_BOOLEAN_FALSE;
+ RTIBool already_registered = RTI_FALSE;
+
+ if (type_code == NULL) {
+ goto finError;
+ }
+
+ if (participant == NULL) {
+ goto finError;
+ }
+
+ /* TODO pass the type_code */
+ presTypePlugin = ConnextStaticSerializedDataPlugin_new_external(type_code);
+ if (presTypePlugin == NULL) {
+ goto finError;
+ }
+
+ dds_data_type = new ConnextStaticSerializedDataTypeSupport(true);
+ if (dds_data_type == NULL) {
+ fprintf(stderr, "Error while registering external type\n");
+ goto finError;
+ }
+ delete_data_type = RTI_TRUE;
dirk-thomas marked this conversation as resolved.
Show resolved Hide resolved
+
+ presTypePlugin->_userBuffer = (PRESWord *)dds_data_type;
+ already_registered = participant->is_type_registered(type_name);
+
+ retcode = participant->register_type(type_name, presTypePlugin, NULL, !already_registered);
+ if (retcode != DDS_RETCODE_OK) {
+ fprintf(stderr, "error while registering external type\n");
+ goto finError;
+ }
+
+ if (!already_registered) {
+ delete_data_type = DDS_BOOLEAN_FALSE;
+ }
+
+ retcode = DDS_RETCODE_OK;
+
+finError:
+ if (presTypePlugin != NULL) {
+ ConnextStaticSerializedDataPlugin_delete(presTypePlugin);
+ }
+ if (delete_data_type) {
+ delete (ConnextStaticSerializedDataTypeSupport *)dds_data_type;
+ dds_data_type = NULL;
dirk-thomas marked this conversation as resolved.
Show resolved Hide resolved
+ }
+
+ return retcode;
+}

Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
--- a/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_dataSupport.h
+++ b/rmw_connext_cpp/resources/patch_generated/connext_static_serialized_dataSupport.h
@@ -15,7 +15,7 @@ or consult the RTI Connext manual.
#include "connext_static_serialized_data.h"

#ifndef ndds_cpp_h
-#include "ndds/ndds_cpp.h"
+#include "rmw_connext_shared_cpp/ndds_include.hpp"
#endif

#if (defined(RTI_WIN32) || defined (RTI_WINCE) || defined(RTI_INTIME)) && defined(NDDS_USER_DLL_EXPORT)
@@ -44,13 +44,106 @@ implementing generics in C and C++.

#endif

-DDS_TYPESUPPORT_CPP(
- ConnextStaticSerializedDataTypeSupport,
- ConnextStaticSerializedData);
+class NDDSUSERDllExport DDSCPPDllExport ConnextStaticSerializedDataTypeSupport : public ::DDSTypeSupport
+{
+public:
+ ConnextStaticSerializedDataTypeSupport(bool osrf)
+ {
+ (void) osrf;
+ }
+
+ ~ConnextStaticSerializedDataTypeSupport();
+
+ static DDS_ReturnCode_t register_type(
+ DDSDomainParticipant * participant,
+ const char * type_name = "ConnextStaticSerializedData");
+
+ static DDS_ReturnCode_t unregister_type(
+ DDSDomainParticipant * participant,
+ const char * type_name = "ConnextStaticSerializedData");
+
+ static const char * get_type_name();
+
+ static ConnextStaticSerializedData * create_data_ex(DDS_Boolean allocatePointers);
+
+ static ConnextStaticSerializedData * create_data(
+ const DDS_TypeAllocationParams_t & alloc_params =
+ DDS_TYPE_ALLOCATION_PARAMS_DEFAULT);
+
+ static DDS_ReturnCode_t delete_data_ex(
+ ConnextStaticSerializedData * a_data,
+ DDS_Boolean deletePointers);
+
+ static DDS_ReturnCode_t delete_data(
+ ConnextStaticSerializedData * a_data,
+ const DDS_TypeDeallocationParams_t & dealloc_params =
+ DDS_TYPE_DEALLOCATION_PARAMS_DEFAULT);
+
+ static void print_data(const ConnextStaticSerializedData * a_data);
+
+ static DDS_ReturnCode_t copy_data(
+ ConnextStaticSerializedData * dst_data, const ConnextStaticSerializedData * src_data);
+
+ static DDS_ReturnCode_t initialize_data_ex(
+ ConnextStaticSerializedData * a_data,
+ DDS_Boolean allocatePointers);
+
+ static DDS_ReturnCode_t initialize_data(
+ ConnextStaticSerializedData * a_data,
+ const DDS_TypeAllocationParams_t & alloc_params =
+ DDS_TYPE_ALLOCATION_PARAMS_DEFAULT);
+
+ static DDS_ReturnCode_t finalize_data_ex(
+ ConnextStaticSerializedData * a_data,
+ DDS_Boolean deletePointers);
+
+ static DDS_ReturnCode_t finalize_data(
+ ConnextStaticSerializedData * a_data,
+ const DDS_TypeDeallocationParams_t & dealloc_params =
+ DDS_TYPE_DEALLOCATION_PARAMS_DEFAULT);
+
+ DDSDataReader * create_datareaderI(DDSDataReader * dataReader);
+
+ DDS_ReturnCode_t destroy_datareaderI(DDSDataReader * dataReader);
+
+ DDSDataWriter * create_datawriterI(DDSDataWriter * dataWriter);
+
+ DDS_ReturnCode_t destroy_datawriterI(DDSDataWriter * dataWriter);
+
+ static DDS_TypeCode * get_typecode();
+
+ static DDS_ReturnCode_t serialize_data_to_cdr_buffer(
+ char * buffer,
+ unsigned int & length,
+ const ConnextStaticSerializedData * a_data);
+
+ static DDS_ReturnCode_t serialize_data_to_cdr_buffer_ex(
+ char * buffer,
+ unsigned int & length,
+ const ConnextStaticSerializedData * a_data,
+ DDS_DataRepresentationId_t representation);
+
+ static DDS_ReturnCode_t deserialize_data_from_cdr_buffer(
+ ConnextStaticSerializedData * a_data,
+ const char * buffer,
+ unsigned int length);
+
+ static DDS_ReturnCode_t data_to_string(
+ ConnextStaticSerializedData * sample,
+ char * str,
+ DDS_UnsignedLong & str_size,
+ const DDS_PrintFormatProperty & property);
+
+ static void finalize();
+
+private:
+ ConnextStaticSerializedDataTypeSupport();
+};

#define ENABLE_TDATAWRITER_DATA_CONSTRUCTOR_METHODS
DDS_DATAWRITER_WITH_DATA_CONSTRUCTOR_METHODS_CPP(ConnextStaticSerializedDataDataWriter, ConnextStaticSerializedData);
#undef ENABLE_TDATAWRITER_DATA_CONSTRUCTOR_METHODS
#define ENABLE_TDATAREADER_DATA_CONSISTENCY_CHECK_METHOD
DDS_DATAREADER_W_DATA_CONSISTENCY_CHECK(ConnextStaticSerializedDataDataReader, ConnextStaticSerializedDataSeq, ConnextStaticSerializedData);
#undef ENABLE_TDATAREADER_DATA_CONSISTENCY_CHECK_METHOD

+NDDSUSERDllExport
+DDS_ReturnCode_t
+ConnextStaticSerializedDataSupport_register_external_type(
+ DDSDomainParticipant * participant,
+ const char * type_name,
+ struct DDS_TypeCode * type_code);
+
#if (defined(RTI_WIN32) || defined (RTI_WINCE) || defined(RTI_INTIME)) && defined(NDDS_USER_DLL_EXPORT)
/* If the code is building on Windows, stop exporting symbols.
*/
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#ifndef _WIN32
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpedantic"
# pragma GCC diagnostic ignored "-Wunused-parameter"
# ifdef __clang__
# pragma clang diagnostic ignored "-Wdeprecated-register"
Expand Down