From 647b9e50cf2f79a0d91267f1d7e3f8ac364a1fdb Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Fri, 7 Feb 2020 16:22:14 -0600 Subject: [PATCH 1/6] Fix trailing whitespace and mixed indents --- README.md | 8 +++--- srcCxx/ShapeType_variants.h | 56 ++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index fc587ab..a5a75b9 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ These tests can be used to validate compliance with **OMG DDS-XTYPES** each DDS The test uses 25 different "versions" of a data-type. These variations are obtained by adding, removing or reordering different attributes. They are also obtained by declaring different extensibility kinds for the data type (Final, Extensible [the default], and Mutable). These types are declared in the *ShapeTypes.idl* file or the equivalent *ShapeTypes.xml* file. The 25 types defined there are: -Types with default extensibility | Types with final extensibility | Types with extensible extensibility | Types with mutable extensibility | Types with mutable extensibiity specifying explicit ID -------------- | ----------- | ---------------- | ------------- | ------------------------ +Types with default extensibility | Types with final extensibility | Types with extensible extensibility | Types with mutable extensibility | Types with mutable extensibiity specifying explicit ID +------------- | ----------- | ---------------- | ------------- | ------------------------ Shape1Default | Shape1Final | Shape1Extensible | Shape1Mutable | Shape1MutableExplicitID -Shape2Default | Shape2Final | Shape2Extensible | Shape2Mutable | Shape2MutableExplicitID +Shape2Default | Shape2Final | Shape2Extensible | Shape2Mutable | Shape2MutableExplicitID Shape3Default | Shape3Final | Shape3Extensible | Shape3Mutable | Shape3MutableExplicitID Shape4Default | Shape4Final | Shape4Extensible | Shape4Mutable | Shape4MutableExplicitID Shape5Default | Shape5Final | Shape5Extensible | Shape5Mutable | Shape5MutableExplicitID @@ -27,7 +27,7 @@ The following is an example execution: ON THE SUBSCRIBER COMPUTER: ``` -dds-xtypes$ ./rti_connext_dds_5.2_linux -sub -domain 0 -type Shape2Extensible +dds-xtypes$ ./rti_connext_dds_5.2_linux -sub -domain 0 -type Shape2Extensible Usage: ./rti_connext_dds_5.2_linux [-pub | -sub] [-domain ] [-type ] Info: Starting subscribing application. Domain: 0, Type: Shape2Extensible diff --git a/srcCxx/ShapeType_variants.h b/srcCxx/ShapeType_variants.h index 81f1310..3a4dacf 100644 --- a/srcCxx/ShapeType_variants.h +++ b/srcCxx/ShapeType_variants.h @@ -127,7 +127,7 @@ class Writer : public WriterBase { fprintf(stderr, "Failed to register type for topic \"%s\" retcode=%d\n", topic_name, (int)retcode); return false; } - + Publisher *publisher = participant->create_publisher( PUBLISHER_QOS_DEFAULT, NULL /* listener */, STATUS_MASK_NONE); if (publisher == NULL) { @@ -163,7 +163,7 @@ class Writer : public WriterBase { #if defined RTI_CONNEXT_DDS _data = TSupport::create_data(); #elif defined TWINOAKS_COREDX - _data = new T(); + _data = new T(); #endif return true; @@ -171,10 +171,10 @@ class Writer : public WriterBase { virtual bool write_data(const char *color, int count) { _shapeFiller.fill_data(_data, color, count); - printf("Writing Topic \"%s\", type \"%s\", count %d, data:", + printf("Writing Topic \"%s\", type \"%s\", count %d, data:", _writer->get_topic()->get_name(), _writer->get_topic()->get_type_name(), count); - + #if defined RTI_CONNEXT_DDS TSupport::print_data(_data); return _writer->write(*_data, HANDLE_NIL) == RETCODE_OK; @@ -207,13 +207,13 @@ class ReaderBase { class TheReaderListener : public DataReaderListener { - public: + public: virtual void on_requested_incompatible_qos( DataReader* reader, const RequestedIncompatibleQosStatus& status) { fprintf(stderr, "on_requested_incompatible_qos: topic \"%s\", type \"%s\" last_policy: %d, count: %d, change: %d\n", reader->get_topicdescription()->get_name(), - reader->get_topicdescription()->get_type_name(), + reader->get_topicdescription()->get_type_name(), status.last_policy_id, status.total_count, status.total_count_change); } @@ -223,7 +223,7 @@ class TheReaderListener : public DataReaderListener { const SubscriptionMatchedStatus& status) { fprintf(stderr, "on_subscription_matched: topic \"%s\", type \"%s\", count: %d, change: %d\n", reader->get_topicdescription()->get_name(), - reader->get_topicdescription()->get_type_name(), + reader->get_topicdescription()->get_type_name(), status.current_count, status.current_count_change); } }; @@ -239,7 +239,7 @@ class Reader : public ReaderBase { virtual ~Reader() { _reader->set_listener(NULL, 0); - _topic->set_listener(NULL, 0); + _topic->set_listener(NULL, 0); #if defined(TWINOAKS_COREDX) delete _reader_listener; delete _topic_listener; @@ -253,7 +253,7 @@ class Reader : public ReaderBase { fprintf(stderr, "Failed to register type for topic \"%s\" retcode=%d\n", topic_name, (int)retcode); return false; } - + Subscriber *subscriber = participant->create_subscriber( SUBSCRIBER_QOS_DEFAULT, NULL /* listener */, STATUS_MASK_NONE); if (subscriber == NULL) { @@ -271,7 +271,7 @@ class Reader : public ReaderBase { return false; } - + _reader_listener = new TheReaderListener(); DataReader *reader = subscriber->create_datareader( _topic, DATAREADER_QOS_DEFAULT, _reader_listener, @@ -287,9 +287,9 @@ class Reader : public ReaderBase { return false; } - ReadCondition *cond = _reader->create_readcondition( ANY_SAMPLE_STATE, - ANY_VIEW_STATE, - ANY_INSTANCE_STATE); + ReadCondition *cond = _reader->create_readcondition( ANY_SAMPLE_STATE, + ANY_VIEW_STATE, + ANY_INSTANCE_STATE); _waitset.attach_condition(cond); #if defined(RTI_CONNEXT_DDS) @@ -313,9 +313,9 @@ class Reader : public ReaderBase { #elif defined(TWINOAKS_COREDX) retcode = _reader->take_next_sample(_data, &info); #endif - + if ( (retcode == RETCODE_OK ) && info.valid_data ) { - printf("\nRead data for Topic %s", _reader->get_topicdescription()->get_name()); + printf("\nRead data for Topic %s", _reader->get_topicdescription()->get_name()); ++sample_count; #if defined(RTI_CONNEXT_DDS) @@ -323,15 +323,15 @@ class Reader : public ReaderBase { #elif defined(TWINOAKS_COREDX) T::print(stdout, _data); #endif - + } else if (retcode == RETCODE_NO_DATA) { return sample_count; // all done } } while ( retcode == RETCODE_OK ); - - fprintf(stderr, "Take error %d for Topic %s\n",(int)retcode, _reader->get_topicdescription()->get_name()); + + fprintf(stderr, "Take error %d for Topic %s\n",(int)retcode, _reader->get_topicdescription()->get_name()); return sample_count; // done reading } @@ -356,7 +356,7 @@ class ShapeTypeVariants { private: static const int TYPE_EXTENSIBILITY_KIND_COUNT=5; static const int TYPE_VERSION_COUNT=5; - + static const char *extensibility_kind(int i) { static const char *TYPE_EXTENSIBILITY_KIND[5] = { "Default", @@ -366,13 +366,13 @@ class ShapeTypeVariants { "MutableExplicitID" }; - + if ( i<0 || i >= 5) { return NULL; } return TYPE_EXTENSIBILITY_KIND[i]; } - + public: static void print_type_variants(FILE *fp) { for (int version=1; version<= TYPE_VERSION_COUNT; ++version) { @@ -382,7 +382,7 @@ class ShapeTypeVariants { fprintf(fp, "\n"); } } - + static bool check_type_variant(const char *type_name) { char typename_buffer[64]; for (int version=1; version<= TYPE_VERSION_COUNT; ++version) { @@ -392,10 +392,10 @@ class ShapeTypeVariants { return true; } } - } + } return false; } - + static ReaderBase *create_reader(const char *type_name) { if ( strcmp(type_name, "Shape1Default") == 0 ) { @@ -474,17 +474,17 @@ class ShapeTypeVariants { return new Reader(); } - // else + // else fprintf(stderr, "create_reader: Unrecognized type: \"%s\"\n", type_name); return NULL; } static WriterBase *create_writer(const char *type_name) { if ( strcmp(type_name, "Shape1Default") == 0 ) { - return new Writer, Shape1DefaultTypeSupport, Shape1DefaultDataWriter>(); + return new Writer, Shape1DefaultTypeSupport, Shape1DefaultDataWriter>(); } else if ( strcmp(type_name, "Shape1Final") == 0 ) { - return new Writer, Shape1FinalTypeSupport, Shape1FinalDataWriter>(); + return new Writer, Shape1FinalTypeSupport, Shape1FinalDataWriter>(); } else if ( strcmp(type_name, "Shape1Extensible") == 0 ) { return new Writer, Shape1ExtensibleTypeSupport, Shape1ExtensibleDataWriter>(); @@ -557,7 +557,7 @@ class ShapeTypeVariants { } - // else + // else fprintf(stderr, "create_Writer: Unrecognized type: \"%s\"\n", type_name); return NULL; } From 1f0ed5e8d58188ccf53343aaef32a10bc4cedccc Mon Sep 17 00:00:00 2001 From: Fred Hornsey Date: Thu, 10 Apr 2025 14:39:23 -0500 Subject: [PATCH 2/6] Committed Old OpenDDS Changes As Found --- .gitignore | 1 + CMakeLists.txt | 16 ++++ srcCxx/ShapeType_variants.h | 171 ++++++++++++++++++++++++++++++------ 3 files changed, 162 insertions(+), 26 deletions(-) create mode 100644 .gitignore create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..fc6005e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.10) + +project(shape_type_demo) + +list(APPEND CMAKE_MODULE_PATH "$ENV{DDS_ROOT}/cmake") +find_package(OpenDDS REQUIRED) + +set(OPENDDS_DEFAULT_NESTED OFF) +add_library(shape_type_idl) +OPENDDS_TARGET_SOURCES(shape_type_idl ShapeType.idl OPENDDS_IDL_OPTIONS -Gprinter) +target_link_libraries(shape_type_idl PUBLIC OpenDDS::Dcps) + +add_executable(shape_type ShapeType_main.cxx) +target_link_libraries(shape_type OpenDDS::Rtps_Udp) +target_link_libraries(shape_type shape_type_idl) +target_compile_definitions(shape_type PUBLIC OCI_OPENDDS) diff --git a/srcCxx/ShapeType_variants.h b/srcCxx/ShapeType_variants.h index 3a4dacf..b912b60 100644 --- a/srcCxx/ShapeType_variants.h +++ b/srcCxx/ShapeType_variants.h @@ -16,13 +16,80 @@ # error X-Types support requires CoreDX DDS v4.0 or newer # endif +#elif defined(OCI_OPENDDS) +# include "ShapeTypeTypeSupportImpl.h" +# include +# include +# include +# include +# include +# include +# include +# include +# include + #else # error No DDS vendor -define was provided. No DDS header files included. Compilation will fail -# error Please configure the makefile to define one for the following variables: RTI_CONNEXT_DDS, TWINOAKS_COREDX, or PRISMTECH_OPENSPLICE +# error Please configure the makefile to define one for the following variables: RTI_CONNEXT_DDS, TWINOAKS_COREDX, or OCI_OPENDDS #endif using namespace DDS; +#ifdef OCI_OPENDDS +const StatusMask STATUS_MASK_NONE = OpenDDS::DCPS::NO_STATUS_MASK; + +template +class StaticTypeSupport { +public: + static ReturnCode_t register_type(DomainParticipant* participant, const char* type_name) + { + return instance()->register_type(participant, type_name); + } + + static const char* get_type_name() + { + return instance()->get_type_name(); + } + +private: + typedef typename OpenDDS::DCPS::DDSTraits Traits; + typedef typename Traits::TypeSupportType TypeSupport; + typedef typename Traits::TypeSupportTypeImpl TypeSupportImpl; + + static TypeSupport* instance() { + static TypeSupportImpl tsimpl; + return dynamic_cast(&tsimpl); + } +}; + +void setup_rtps() +{ + TheServiceParticipant->set_default_discovery( + OpenDDS::DCPS::Discovery::DEFAULT_RTPS); + OpenDDS::DCPS::TransportConfig_rch transport_config = + TheTransportRegistry->create_config("default_rtps_transport_config"); + OpenDDS::DCPS::TransportInst_rch transport_inst = + TheTransportRegistry->create_inst("default_rtps_transport", "rtps_udp"); + transport_config->instances_.push_back(transport_inst); + TheTransportRegistry->global_config(transport_config); + OpenDDS::DCPS::DCPS_debug_level = 4; +} + +void strcpy(TAO::String_Manager_T& dst, const char* src) +{ + dst = src; +} +#endif + +DomainParticipantFactory* get_domain_participant_factory() +{ +#ifdef OCI_OPENDDS + return TheParticipantFactory; +#else + return DomainParticipantFactory::get_instance(); +#endif +} + class TheTopicListener : public TopicListener { public: virtual void on_inconsistent_topic( @@ -53,7 +120,7 @@ template class Shape2Filler { data->x = count % 250;; data->y = 2*count %250; data->shapesize = 30; - data->angle = (float)((5*count)%360); + /* data->angle = (float)((5*count)%360); */ }; }; @@ -78,6 +145,7 @@ template class Shape4Filler { } }; +#ifndef OCI_OPENDDS template class Shape5Filler { public: static void fill_data(T *data, const char *color, int count) { @@ -88,6 +156,7 @@ template class Shape5Filler { data->angle = (float)((5*count)%360); } }; +#endif template class GenericFiller { public: @@ -107,22 +176,28 @@ class WriterBase { template class Writer : public WriterBase { public: - typedef T data_type; - typedef TSupport type_support; - typedef TDataWriter data_writer; +#ifdef OCI_OPENDDS + typedef StaticTypeSupport TypeSupport; +#else + typedef TSupport TypeSupport; +#endif - public: virtual ~Writer() { _topic->set_listener(NULL, 0); -#if defined(TWINOAKS_COREDX) +#if defined(TWINOAKS_COREDX) || defined(OCI_OPENDDS) delete _data; +#endif +#ifdef TWINOAKS_COREDX delete _topic_listener; +#elif defined OCI_OPENDDS + TopicListener_var tl = _topic_listener; + tl = 0; #endif } virtual bool initialize(DomainParticipant *participant, const char *topic_name) { - ReturnCode_t retcode; - retcode = TSupport::register_type(participant, TSupport::get_type_name()); + ReturnCode_t retcode = TypeSupport::register_type( + participant, TypeSupport::get_type_name()); if ( retcode != RETCODE_OK) { fprintf(stderr, "Failed to register type for topic \"%s\" retcode=%d\n", topic_name, (int)retcode); return false; @@ -138,7 +213,7 @@ class Writer : public WriterBase { _topic_listener = new TheTopicListener(); _topic = participant->create_topic( - topic_name, TSupport::get_type_name(), + topic_name, TypeSupport::get_type_name(), TOPIC_QOS_DEFAULT, _topic_listener, INCONSISTENT_TOPIC_STATUS); if (_topic == NULL) { @@ -154,7 +229,11 @@ class Writer : public WriterBase { return false; } +#ifdef OCI_OPENDDS + _writer = TDataWriter::_narrow(writer); +#else _writer = TDataWriter::narrow(writer); +#endif if (_writer == NULL) { printf("DataWriter narrow error for topic \"%s\"\n", topic_name); return false; @@ -162,7 +241,7 @@ class Writer : public WriterBase { #if defined RTI_CONNEXT_DDS _data = TSupport::create_data(); -#elif defined TWINOAKS_COREDX +#elif defined TWINOAKS_COREDX || defined OCI_OPENDDS _data = new T(); #endif @@ -177,13 +256,17 @@ class Writer : public WriterBase { #if defined RTI_CONNEXT_DDS TSupport::print_data(_data); - return _writer->write(*_data, HANDLE_NIL) == RETCODE_OK; - #elif defined TWINOAKS_COREDX T::print(stdout, _data); - return _writer->write(_data, HANDLE_NIL) == RETCODE_OK; +#elif defined OCI_OPENDDS + std::cout << '\n' << OpenDDS::DCPS::Printer() << *_data; #endif +#ifdef TWINOAKS_COREDX + return _writer->write(_data, HANDLE_NIL) == RETCODE_OK; +#else + return _writer->write(*_data, HANDLE_NIL) == RETCODE_OK; +#endif } virtual Topic *get_topic() { return _topic; } @@ -207,7 +290,7 @@ class ReaderBase { class TheReaderListener : public DataReaderListener { - public: +public: virtual void on_requested_incompatible_qos( DataReader* reader, const RequestedIncompatibleQosStatus& status) { @@ -226,29 +309,49 @@ class TheReaderListener : public DataReaderListener { reader->get_topicdescription()->get_type_name(), status.current_count, status.current_count_change); } + +#ifdef OCI_OPENDDS + void on_requested_deadline_missed( + DataReader*, const RequestedDeadlineMissedStatus&) {} + void on_sample_rejected( + DataReader*, const SampleRejectedStatus&) {} + void on_liveliness_changed( + DataReader*, const LivelinessChangedStatus&) {} + void on_data_available(DataReader*) {} + void on_sample_lost(DataReader*, const SampleLostStatus&) {} +#endif }; template class Reader : public ReaderBase { public: - typedef T data_type; - typedef TSupport type_support_type; - typedef TDataReader data_reader_type; +#ifdef OCI_OPENDDS + typedef StaticTypeSupport TypeSupport; +#else + typedef TSupport TypeSupport; +#endif - public: virtual ~Reader() { _reader->set_listener(NULL, 0); _topic->set_listener(NULL, 0); -#if defined(TWINOAKS_COREDX) +#if defined(TWINOAKS_COREDX) || defined(OCI_OPENDDS) + delete _data; +#endif +#ifdef TWINOAKS_COREDX delete _reader_listener; delete _topic_listener; - delete _data; +#elif defined OCI_OPENDDS + TopicListener_var tl = _topic_listener; + tl = 0; + DataReaderListener_var rl = _reader_listener; + rl = 0; #endif } + bool initialize(DomainParticipant *participant, const char *topic_name) { ReturnCode_t retcode; - retcode = TSupport::register_type(participant, TSupport::get_type_name()); + retcode = TypeSupport::register_type(participant, TypeSupport::get_type_name()); if ( retcode != RETCODE_OK) { fprintf(stderr, "Failed to register type for topic \"%s\" retcode=%d\n", topic_name, (int)retcode); return false; @@ -263,7 +366,7 @@ class Reader : public ReaderBase { _topic_listener = new TheTopicListener(); _topic = participant->create_topic( - topic_name, TSupport::get_type_name(), + topic_name, TypeSupport::get_type_name(), TOPIC_QOS_DEFAULT, _topic_listener, INCONSISTENT_TOPIC_STATUS ); if (_topic == NULL) { @@ -281,7 +384,11 @@ class Reader : public ReaderBase { return false; } +#ifdef OCI_OPENDDS + _reader = TDataReader::_narrow(reader); +#else _reader = TDataReader::narrow(reader); +#endif if (_reader == NULL) { printf("DataWriter narrow error for topic \"%s\"\n", topic_name); return false; @@ -294,7 +401,7 @@ class Reader : public ReaderBase { #if defined(RTI_CONNEXT_DDS) _data = TSupport::create_data(); -#elif defined(TWINOAKS_COREDX) +#elif defined(TWINOAKS_COREDX) || defined(OCI_OPENDDS) _data = new T(); #endif @@ -308,20 +415,28 @@ class Reader : public ReaderBase { do { -#if defined(RTI_CONNEXT_DDS) +#if defined(RTI_CONNEXT_DDS) || defined(OCI_OPENDDS) retcode = _reader->take_next_sample(*_data, info); #elif defined(TWINOAKS_COREDX) retcode = _reader->take_next_sample(_data, &info); #endif if ( (retcode == RETCODE_OK ) && info.valid_data ) { - printf("\nRead data for Topic %s", _reader->get_topicdescription()->get_name()); + printf( +#if defined(RTI_CONNEXT_DDS) || defined(TWINOAKS_COREDX) + "\n" +#endif + "Reading Topic \"%s\", type \"%s\", data:", + _reader->get_topicdescription()->get_name(), + _reader->get_topicdescription()->get_type_name()); ++sample_count; #if defined(RTI_CONNEXT_DDS) TSupport::print_data(_data); #elif defined(TWINOAKS_COREDX) T::print(stdout, _data); +#elif defined(OCI_OPENDDS) + std::cout << '\n' << OpenDDS::DCPS::Printer() << *_data; #endif } @@ -458,6 +573,7 @@ class ShapeTypeVariants { else if (strcmp(type_name, "Shape4MutableExplicitID") == 0 ) { return new Reader(); } +#ifndef OCI_OPENDDS else if (strcmp(type_name, "Shape5Default") == 0 ) { return new Reader(); } @@ -473,6 +589,7 @@ class ShapeTypeVariants { else if (strcmp(type_name, "Shape5MutableExplicitID") == 0 ) { return new Reader(); } +#endif // else fprintf(stderr, "create_reader: Unrecognized type: \"%s\"\n", type_name); @@ -540,6 +657,7 @@ class ShapeTypeVariants { else if (strcmp(type_name, "Shape4MutableExplicitID") == 0 ) { return new Writer, Shape4MutableExplicitIDTypeSupport, Shape4MutableExplicitIDDataWriter>(); } +#ifndef OCI_OPENDDS else if (strcmp(type_name, "Shape5Default") == 0 ) { return new Writer, Shape5DefaultTypeSupport, Shape5DefaultDataWriter>(); } @@ -555,6 +673,7 @@ class ShapeTypeVariants { else if (strcmp(type_name, "Shape5MutableExplicitID") == 0 ) { return new Writer, Shape5MutableExplicitIDTypeSupport, Shape5MutableExplicitIDDataWriter>(); } +#endif // else From f13d460664927650dbd7d7a91ded2027d4ef19c0 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Tue, 24 Jun 2025 18:43:27 +0000 Subject: [PATCH 3/6] Updates for current OpenDDS Attempted to reduce #ifdef impact/scope --- CMakeLists.txt | 23 +++++++++++++---------- srcCxx/ShapeType_variants.h | 31 ++++++++++++++++++------------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc6005e..26ee1d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,15 +2,18 @@ cmake_minimum_required(VERSION 3.10) project(shape_type_demo) -list(APPEND CMAKE_MODULE_PATH "$ENV{DDS_ROOT}/cmake") -find_package(OpenDDS REQUIRED) +# This CMakeLists.txt is intended to be used with any DDS implementation that +# supports CMake. An example using OpenDDS is below, and other implementations +# can be added. In each case, if find_package() doesn't find the target +# implementation then processing should continue (REQUIRED is not used) to +# attempt to find other implementations. -set(OPENDDS_DEFAULT_NESTED OFF) -add_library(shape_type_idl) -OPENDDS_TARGET_SOURCES(shape_type_idl ShapeType.idl OPENDDS_IDL_OPTIONS -Gprinter) -target_link_libraries(shape_type_idl PUBLIC OpenDDS::Dcps) +find_package(OpenDDS) -add_executable(shape_type ShapeType_main.cxx) -target_link_libraries(shape_type OpenDDS::Rtps_Udp) -target_link_libraries(shape_type shape_type_idl) -target_compile_definitions(shape_type PUBLIC OCI_OPENDDS) +if(${OpenDDS_FOUND}) + add_executable(opendds_xtypes_test ShapeType_main.cxx) + opendds_target_sources(opendds_xtypes_test ShapeType.idl + OPENDDS_IDL_OPTIONS -Gxtypes-complete --no-default-nested) + target_link_libraries(opendds_xtypes_test OpenDDS::Rtps_Udp) + target_compile_definitions(opendds_xtypes_test PUBLIC OCI_OPENDDS) +endif() diff --git a/srcCxx/ShapeType_variants.h b/srcCxx/ShapeType_variants.h index b912b60..6c35768 100644 --- a/srcCxx/ShapeType_variants.h +++ b/srcCxx/ShapeType_variants.h @@ -19,15 +19,23 @@ #elif defined(OCI_OPENDDS) # include "ShapeTypeTypeSupportImpl.h" # include +# include +# include # include # include -# include -# include -# include # include # include +# include # include +template +void print(std::ostream& out, const T& data) +{ + OpenDDS::DCPS::PrinterValueWriter pvw; + vwrite(pvw, data); + out << '\n' << pvw.str() << '\n'; +} + #else # error No DDS vendor -define was provided. No DDS header files included. Compilation will fail # error Please configure the makefile to define one for the following variables: RTI_CONNEXT_DDS, TWINOAKS_COREDX, or OCI_OPENDDS @@ -54,7 +62,7 @@ class StaticTypeSupport { private: typedef typename OpenDDS::DCPS::DDSTraits Traits; typedef typename Traits::TypeSupportType TypeSupport; - typedef typename Traits::TypeSupportTypeImpl TypeSupportImpl; + typedef typename Traits::TypeSupportImplType TypeSupportImpl; static TypeSupport* instance() { static TypeSupportImpl tsimpl; @@ -150,7 +158,7 @@ template class Shape5Filler { public: static void fill_data(T *data, const char *color, int count) { strcpy(data->color, color); - data->x = count % 250;; + data->x = count % 250; data->y = 2*count %250; data->shapesize = 30; data->angle = (float)((5*count)%360); @@ -259,7 +267,7 @@ class Writer : public WriterBase { #elif defined TWINOAKS_COREDX T::print(stdout, _data); #elif defined OCI_OPENDDS - std::cout << '\n' << OpenDDS::DCPS::Printer() << *_data; + print(std::cout, *_data); #endif #ifdef TWINOAKS_COREDX @@ -310,7 +318,8 @@ class TheReaderListener : public DataReaderListener { status.current_count, status.current_count_change); } -#ifdef OCI_OPENDDS + // Some implementations require all overrides to be defined (they are pure virtual in the base class). + // For other implementations it won't hurt to have them here void on_requested_deadline_missed( DataReader*, const RequestedDeadlineMissedStatus&) {} void on_sample_rejected( @@ -319,7 +328,6 @@ class TheReaderListener : public DataReaderListener { DataReader*, const LivelinessChangedStatus&) {} void on_data_available(DataReader*) {} void on_sample_lost(DataReader*, const SampleLostStatus&) {} -#endif }; template @@ -423,9 +431,7 @@ class Reader : public ReaderBase { if ( (retcode == RETCODE_OK ) && info.valid_data ) { printf( -#if defined(RTI_CONNEXT_DDS) || defined(TWINOAKS_COREDX) "\n" -#endif "Reading Topic \"%s\", type \"%s\", data:", _reader->get_topicdescription()->get_name(), _reader->get_topicdescription()->get_type_name()); @@ -436,7 +442,7 @@ class Reader : public ReaderBase { #elif defined(TWINOAKS_COREDX) T::print(stdout, _data); #elif defined(OCI_OPENDDS) - std::cout << '\n' << OpenDDS::DCPS::Printer() << *_data; + print(std::cout, *_data); #endif } @@ -675,9 +681,8 @@ class ShapeTypeVariants { } #endif - // else - fprintf(stderr, "create_Writer: Unrecognized type: \"%s\"\n", type_name); + fprintf(stderr, "create_writer: Unrecognized type: \"%s\"\n", type_name); return NULL; } }; From a25ef83cd7c1316f479e778d903e5e00536d807f Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Tue, 24 Jun 2025 19:23:13 +0000 Subject: [PATCH 4/6] Updates for OpenDDS --- CLA/CLA_ObjectComputing.md | 60 +++++++++++++++++++++++++ CMakeLists.txt => srcCxx/CMakeLists.txt | 0 srcCxx/ShapeType.idl | 4 +- srcCxx/ShapeType_main.cxx | 15 +++++-- srcCxx/ShapeType_variants.h | 29 ++++++------ 5 files changed, 90 insertions(+), 18 deletions(-) create mode 100644 CLA/CLA_ObjectComputing.md rename CMakeLists.txt => srcCxx/CMakeLists.txt (100%) diff --git a/CLA/CLA_ObjectComputing.md b/CLA/CLA_ObjectComputing.md new file mode 100644 index 0000000..a16d38b --- /dev/null +++ b/CLA/CLA_ObjectComputing.md @@ -0,0 +1,60 @@ +# OMG DDS INTEROPERABILITY REPOSITORY - CONTRIBUTOR LICENSE AGREEMENT + +**This Contributor License Agreement ("Agreement") specifies the terms under which the individual or corporate entity specified in the signature block below (“You”) agree to make intellectual property contributions to the OMG DDS Interoperability Repository. BY SIGNING BELOW YOU ARE AGREEING TO BE BOUND BY THE TERMS OF THIS AGREEMENT. If You are signing this Agreement in Your capacity as an employee, THEN YOUR EMPLOYER AND YOU ARE BOTH BOUND BY THIS AGREEMENT.** + +1. Definitions + + 1. "OMG DDS Interoperability Repository" (or “Repository”) means the Git repository [https://github.com/omg-dds/dds-rtps](https://github.com/omg-dds/dds-rtps). + + 2. "Moderator" means an entity or individual responsible for authorizing changes to the Repository. + + 3. "Submit" (or “Submitted”) means any submission, including source code, binaries, code, pull requests, issue reports, comments, etc., made to the Moderators for inclusion in the Repository either through the Git repository interface or through electronic file transfer. + + 4. A "Contribution" is any original work of authorship, including any modifications or additions to an existing work, that You Submit to the DDS Interoperability Repository. + + 5. A "User" is anyone who accesses the Repository. + +2. Allowable Contribution Representations + + 1. You represent that You have the necessary rights to the Contribution(s) to meet the obligations of this Agreement. If You are employed, Your employer has authorized Contribution(s) under this Agreement. + + 2. You represent that you have no knowledge of third-party intellectual property rights that are likely to be infringed by the Contribution(s). You represent that you have no knowledge that such infringement or any allegation of misappropriation of intellectual property rights is likely to be claimed or has already been claimed. + +3. License + + You grant Moderators a perpetual, worldwide, non-exclusive, assignable, paid-up license to publish, display, and redistribute the Contribution as part of the Repository. You also license to Moderators under the same terms any other intellectual property rights required to publish, display, and redistribute the Contributions as part of the Repository. You further grant all Users of the Repository a license to the Contribution under the terms of the [OMG DDS Interoperability Testing License](../LICENSE.md) included in the Repository. Moderators are under no obligation to publish Contributions. + +4. No Warranty, Consequential Damages. Limited Liability + + Other than explicitly stated herein, You provide the Contribution(s) "as is" with no warranty nor claims of fitness to any purpose. Neither party shall be liable for consequential or special damages of any kind. Other than for breach of warranty or representations herein, the liability of either party to the other shall be limited to $1000. + +5. General + + 1. If You are an agency of the United States Government, then this Agreement will be governed by the United States federal common law. Otherwise, this Agreement will be governed by the laws of the State of California except with regard to its choice of law rules. + + 2. A party may assign this Agreement to an entity acquiring essentially all of the party’s relevant business. + +6. Electronic Signatures + + "Electronic Signature" means any electronic sound, symbol, or process attached to or logically associated with a record and executed and adopted by a party with the intent to sign such record. + + Each party agrees that the Electronic Signatures, whether digital or encrypted, of the parties included in this Agreement are intended to authenticate this writing and to have the same force and effect as manual signatures. + + +IN WITNESS WHEREOF, You, intending to be legally bound, have executed this Agreement or caused Your employer’s proper and duly authorized officer to execute and deliver this Agreement, for good and valuable consideration, the sufficiency of which is hereby acknowledged, as of the day and year first written below. + +**For:** + +Entity Name: Object Computing, Inc. + +Address: 12140 Woodcrest Exec. Dr., Ste 300, St. Louis, MO 63141 USA + + ("**You**") + +**By:** + +Name: Adam Mitz + +Title: Principal Software Engineer and Partner + +Date: June 24, 2025 diff --git a/CMakeLists.txt b/srcCxx/CMakeLists.txt similarity index 100% rename from CMakeLists.txt rename to srcCxx/CMakeLists.txt diff --git a/srcCxx/ShapeType.idl b/srcCxx/ShapeType.idl index 4163d6e..7fc171b 100644 --- a/srcCxx/ShapeType.idl +++ b/srcCxx/ShapeType.idl @@ -177,6 +177,8 @@ struct Shape4MutableExplicitID { long y; }; +#ifndef __TAO_IDL // OpenDDS doesn't have struct inheritance + /* -------------- Shape5 -----------------------------*/ struct Shape5Default : Shape1Default { float angle; @@ -202,4 +204,4 @@ struct Shape5MutableExplicitID : Shape1MutableExplicitID { @id(40) float angle; }; - +#endif diff --git a/srcCxx/ShapeType_main.cxx b/srcCxx/ShapeType_main.cxx index 21bd662..5ddef00 100644 --- a/srcCxx/ShapeType_main.cxx +++ b/srcCxx/ShapeType_main.cxx @@ -6,6 +6,7 @@ * The possibilities are: * RTI_CONNEXT_DDS * TWINOAKS_COREDX + * OCI_OPENDDS */ #include @@ -52,16 +53,22 @@ void setup_signal_handler() DomainParticipant *create_participant(int domain_id) { +#ifdef OCI_OPENDDS + setup_rtps(); + /* OpenDDS::DCPS::set_DCPS_debug_level(10); */ + /* OpenDDS::DCPS::Transport_debug_level = 6; */ +#endif + DomainParticipantQos pQos; - DomainParticipantFactory::get_instance()->get_default_participant_qos(pQos); + get_domain_participant_factory()->get_default_participant_qos(pQos); #if defined(RTI_CONNEXT_DDS) pQos.discovery_config.participant_message_reader_reliability_kind = DDS_RELIABLE_RELIABILITY_QOS; #endif - DomainParticipant *participant = DomainParticipantFactory::get_instance()->create_participant( + DomainParticipant *participant = get_domain_participant_factory()->create_participant( domain_id, pQos, - NULL /* listener */, DDS_STATUS_MASK_NONE); + NULL /* listener */, STATUS_MASK_NONE); return participant; } @@ -177,7 +184,7 @@ ExitStatus run(int domain_id, const char *topic_name, const char *type_name, boo /* Delete all entities */ participant->delete_contained_entities(); - DomainParticipantFactory::get_instance()->delete_participant(participant); + get_domain_participant_factory()->delete_participant(participant); return exit_status; } diff --git a/srcCxx/ShapeType_variants.h b/srcCxx/ShapeType_variants.h index 6c35768..60fa945 100644 --- a/srcCxx/ShapeType_variants.h +++ b/srcCxx/ShapeType_variants.h @@ -28,14 +28,6 @@ # include # include -template -void print(std::ostream& out, const T& data) -{ - OpenDDS::DCPS::PrinterValueWriter pvw; - vwrite(pvw, data); - out << '\n' << pvw.str() << '\n'; -} - #else # error No DDS vendor -define was provided. No DDS header files included. Compilation will fail # error Please configure the makefile to define one for the following variables: RTI_CONNEXT_DDS, TWINOAKS_COREDX, or OCI_OPENDDS @@ -46,6 +38,14 @@ using namespace DDS; #ifdef OCI_OPENDDS const StatusMask STATUS_MASK_NONE = OpenDDS::DCPS::NO_STATUS_MASK; +template +void print(std::ostream& out, const T& data) +{ + OpenDDS::DCPS::PrinterValueWriter pvw; + vwrite(pvw, data); + out << '\n' << pvw.str() << '\n'; +} + template class StaticTypeSupport { public: @@ -87,6 +87,9 @@ void strcpy(TAO::String_Manager_T& dst, const char* src) { dst = src; } + +#else +const StatusMask STATUS_MASK_NONE = DDS_STATUS_MASK_NONE; #endif DomainParticipantFactory* get_domain_participant_factory() @@ -115,7 +118,7 @@ template class Shape1Filler { public: static void fill_data(T *data, const char *color, int count) { strcpy(data->color, color); - data->x = count % 250;; + data->x = count % 250; data->y = 2*count %250; data->shapesize = 30; } @@ -125,10 +128,10 @@ template class Shape2Filler { public: static void fill_data(T *data, const char *color, int count) { strcpy(data->color, color); - data->x = count % 250;; + data->x = count % 250; data->y = 2*count %250; data->shapesize = 30; - /* data->angle = (float)((5*count)%360); */ + data->angle = (float)((5*count)%360); }; }; @@ -136,7 +139,7 @@ template class Shape3Filler { public: static void fill_data(T *data, const char *color, int count) { strcpy(data->color, color); - data->x = count % 250;; + data->x = count % 250; data->y = 2*count %250; data->shapesize = 30; data->z = 3*count %250; @@ -147,7 +150,7 @@ template class Shape4Filler { public: static void fill_data(T *data, const char *color, int count) { strcpy(data->color, color); - data->x = count % 250;; + data->x = count % 250; data->y = 2*count %250; data->shapesize = 30; } From 148d65a3ba2c8168ee6c018bf669587bc5e21e9f Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Tue, 24 Jun 2025 19:50:12 +0000 Subject: [PATCH 5/6] GitHub Actions CI --- .github/workflows/build.yml | 135 ++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..54908cc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,135 @@ +--- +name: CI +on: + pull_request: + push: + schedule: + - cron: '10 0 * * 0' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + strategy: + fail-fast: false + matrix: + dds: + - opendds + runner: + - ubuntu-24.04 + + runs-on: ${{ matrix.runner }} + + steps: + - name: 'Checkout dds-xtypes' + uses: actions/checkout@v4 + - name: 'Checkout MPC' + uses: actions/checkout@v4 + with: + repository: DOCGroup/MPC + path: MPC + fetch-depth: 1 + - name: 'Checkout ACE_TAO' + uses: actions/checkout@v4 + with: + repository: DOCGroup/ACE_TAO + ref: ace6tao2 + path: ACE_TAO + fetch-depth: 1 + - name: 'Checkout OpenDDS' + uses: actions/checkout@v4 + with: + repository: OpenDDS/OpenDDS + path: OpenDDS + fetch-depth: 1 + - name: 'Set environment variables (Linux / macOS)' + if: runner.os == 'Linux' || runner.os == 'macOS' + shell: bash + run: |- + echo "ACE_ROOT=$GITHUB_WORKSPACE/ACE_TAO/ACE" >> $GITHUB_ENV + echo "TAO_ROOT=$GITHUB_WORKSPACE/ACE_TAO/TAO" >> $GITHUB_ENV + echo "DDS_ROOT=$GITHUB_WORKSPACE/OpenDDS" >> $GITHUB_ENV + echo "MPC_ROOT=$GITHUB_WORKSPACE/MPC" >> $GITHUB_ENV + echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/ACE_TAO/ACE/lib:$GITHUB_WORKSPACE/OpenDDS/lib" >> $GITHUB_ENV + export COMPILER_VERSION=$(c++ --version 2>&1 | head -n 1) + echo "COMPILER_VERSION=$COMPILER_VERSION" >> $GITHUB_ENV + echo "OBJ_EXT=\\.o" >> $GITHUB_ENV + TAR_EXE="tar" + MD5_EXE="md5sum" + if [ '${{ runner.os }}' == 'macOS' ]; then + TAR_EXE="gtar" + MD5_EXE="md5 -r" + fi + echo "TAR_EXE=$TAR_EXE" >> $GITHUB_ENV + echo "MD5_EXE=$MD5_EXE" >> $GITHUB_ENV + - name: 'Set environment variables (Common)' + shell: bash + run: |- + cd ACE_TAO + export ACE_COMMIT=$(git rev-parse HEAD) + echo "ACE_COMMIT=$ACE_COMMIT" >> $GITHUB_ENV + cd ../OpenDDS + export DDS_COMMIT=$(git rev-parse HEAD) + echo "DDS_COMMIT=$DDS_COMMIT" >> $GITHUB_ENV + export MATRIX_MD5=$(echo "${{ matrix }}" | ${{ env.MD5_EXE }} | cut -d ' ' -f 1) + echo "MATRIX_MD5=$MATRIX_MD5" >> $GITHUB_ENV + export COMPILER_MD5=$(echo "$COMPILER_VERSION" | ${{ env.MD5_EXE }} | cut -d ' ' -f 1) + echo "COMPILER_MD5=$COMPILER_MD5" >> $GITHUB_ENV + export CONFIG_MD5=$(echo "$CONFIG_OPTIONS" | ${{ env.MD5_EXE }} | cut -d ' ' -f 1) + echo "CONFIG_MD5=$CONFIG_MD5" >> $GITHUB_ENV + - name: 'Check Build Cache' + id: cache-build + uses: actions/cache@v4 + with: + path: ${{ env.MATRIX_MD5 }}.tar.xz + key: c01_${{ env.MATRIX_MD5 }}_${{ env.COMPILER_MD5 }}_${{ env.ACE_COMMIT }}_${{ env.DDS_COMMIT }}_${{ env.CONFIG_MD5 }} + - name: 'Extract Build Cache' + if: steps.cache-build.outputs.cache-hit == 'true' + shell: bash + run: | + tar xvfJ ${{ env.MATRIX_MD5 }}.tar.xz + - name: 'Configure OpenDDS (Linux / macOS)' + if: steps.cache-build.outputs.cache-hit != 'true' && (runner.os == 'Linux' || runner.os == 'macOS') + shell: bash + run: |- + cd OpenDDS + ./configure ${{ env.CONFIG_OPTIONS }} + tools/scripts/show_build_config.pl + - name: 'Build OpenDDS (Linux / macOS)' + if: steps.cache-build.outputs.cache-hit != 'true' && (runner.os == 'Linux' || runner.os == 'macOS') + shell: bash + run: |- + cd OpenDDS + . setenv.sh + make -j3 + - name: 'Create Build Cache' + if: steps.cache-build.outputs.cache-hit != 'true' + shell: bash + run: | + cd ACE_TAO + find . -iname "*$OBJ_EXT" | xargs rm + git clean -xdfn | cut -d ' ' -f 3- | sed 's/^/ACE_TAO\//g' | tee ../ACE_TAO_files.txt + cd .. + $TAR_EXE cvf ${{ env.MATRIX_MD5 }}.tar ACE_TAO/ACE/ace/config.h + cat ACE_TAO_files.txt | xargs $TAR_EXE uvf ${{ env.MATRIX_MD5 }}.tar + cd OpenDDS + find . -iname "*$OBJ_EXT" | xargs rm + git clean -xdfn | cut -d ' ' -f 3- | sed 's/^/OpenDDS\//g' | tee ../OpenDDS_files.txt + cd .. + cat OpenDDS_files.txt | xargs $TAR_EXE uvf ${{ env.MATRIX_MD5 }}.tar + xz -3 ${{ env.MATRIX_MD5 }}.tar + - name: 'Set Up Problem Matcher (Linux / macOS)' + if: runner.os == 'Linux' || runner.os == 'macOS' + uses: ammaraskar/gcc-problem-matcher@0.3.0 + - name: 'Build Application (Linux / macOS)' + if: runner.os == 'Linux' || runner.os == 'macOS' + shell: bash + run: |- + cd OpenDDS + . setenv.sh + cd .. + cmake -G Ninja -S srcCxx -B build + cmake --build build From 2bb561d7625f17b7186af9759cf502eea1ce23de Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Thu, 26 Jun 2025 17:54:05 +0000 Subject: [PATCH 6/6] Updated pre-processor conditionals per review --- srcCxx/ShapeType.idl | 11 ++++++++++- srcCxx/ShapeType_variants.h | 13 ++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/srcCxx/ShapeType.idl b/srcCxx/ShapeType.idl index 7fc171b..97bc127 100644 --- a/srcCxx/ShapeType.idl +++ b/srcCxx/ShapeType.idl @@ -177,7 +177,16 @@ struct Shape4MutableExplicitID { long y; }; -#ifndef __TAO_IDL // OpenDDS doesn't have struct inheritance +// Specific to OpenDDS +#ifdef __TAO_IDL_FEATURES +# include __TAO_IDL_FEATURES +# if defined TAO_IDL_HAS_STRUCT_INHERITANCE && TAO_IDL_HAS_STRUCT_INHERITANCE +# define STRUCT_INHERITANCE TAO_IDL_HAS_STRUCT_INHERITANCE +# endif +#else +# define STRUCT_INHERITANCE 1 +#endif +#if STRUCT_INHERITANCE /* -------------- Shape5 -----------------------------*/ struct Shape5Default : Shape1Default { diff --git a/srcCxx/ShapeType_variants.h b/srcCxx/ShapeType_variants.h index 60fa945..95485ac 100644 --- a/srcCxx/ShapeType_variants.h +++ b/srcCxx/ShapeType_variants.h @@ -33,6 +33,13 @@ # error Please configure the makefile to define one for the following variables: RTI_CONNEXT_DDS, TWINOAKS_COREDX, or OCI_OPENDDS #endif +#ifdef OCI_OPENDDS +# include +# define HAS_SHAPE5_IDL TAO_IDL_HAS_STRUCT_INHERITANCE +#else +# define HAS_SHAPE5_IDL 1 +#endif + using namespace DDS; #ifdef OCI_OPENDDS @@ -156,7 +163,7 @@ template class Shape4Filler { } }; -#ifndef OCI_OPENDDS +#if HAS_SHAPE5_IDL template class Shape5Filler { public: static void fill_data(T *data, const char *color, int count) { @@ -582,7 +589,7 @@ class ShapeTypeVariants { else if (strcmp(type_name, "Shape4MutableExplicitID") == 0 ) { return new Reader(); } -#ifndef OCI_OPENDDS +#if HAS_SHAPE5_IDL else if (strcmp(type_name, "Shape5Default") == 0 ) { return new Reader(); } @@ -666,7 +673,7 @@ class ShapeTypeVariants { else if (strcmp(type_name, "Shape4MutableExplicitID") == 0 ) { return new Writer, Shape4MutableExplicitIDTypeSupport, Shape4MutableExplicitIDDataWriter>(); } -#ifndef OCI_OPENDDS +#if HAS_SHAPE5_IDL else if (strcmp(type_name, "Shape5Default") == 0 ) { return new Writer, Shape5DefaultTypeSupport, Shape5DefaultDataWriter>(); }