diff --git a/connectors/dds4ccm/tests/unkeyed_writer/components/sender/unkeyed_writer_sender_exec.cpp b/connectors/dds4ccm/tests/unkeyed_writer/components/sender/unkeyed_writer_sender_exec.cpp index a67d945c..c87f8916 100644 --- a/connectors/dds4ccm/tests/unkeyed_writer/components/sender/unkeyed_writer_sender_exec.cpp +++ b/connectors/dds4ccm/tests/unkeyed_writer/components/sender/unkeyed_writer_sender_exec.cpp @@ -16,7 +16,6 @@ //@@{__RIDL_REGEN_MARKER__} - END : UnkeyedWriterTest_Sender_Impl[user_includes] //@@{__RIDL_REGEN_MARKER__} - BEGIN : UnkeyedWriterTest_Sender_Impl[user_global_impl] -// Your declarations here //@@{__RIDL_REGEN_MARKER__} - END : UnkeyedWriterTest_Sender_Impl[user_global_impl] namespace UnkeyedWriterTest_Sender_Impl diff --git a/ddsx11/vendors/ndds/dds/ndds_base_traits.h b/ddsx11/vendors/ndds/dds/ndds_base_traits.h index abb34871..fa9ff8a7 100644 --- a/ddsx11/vendors/ndds/dds/ndds_base_traits.h +++ b/ddsx11/vendors/ndds/dds/ndds_base_traits.h @@ -21,7 +21,6 @@ constexpr uint32_t max_member_string_size () { return 255; } namespace DDSX11 { - /** * Standard type DDS traits for NDDS implementation */ @@ -459,6 +458,37 @@ namespace DDSX11 { return sequence_from_dds (to, from); } + + template + void optional_to_dds (DDS_DATA_TYPE*& to, DATA_TYPE& from) + { + if (from.has_value()) + { + if (to == nullptr) + { + to = new DDS_DATA_TYPE; + } + ::DDSX11::to_dds (*to, from.value()); + } + else + { + delete to; + to = nullptr; + } + } + + template + void optional_from_dds (DATA_TYPE& to, DDS_DATA_TYPE* from) + { + if (from != nullptr) + { + ::DDSX11::from_dds (to.emplace (), *from); + } + else + { + to.reset (); + } + } } #endif /* DDSX11_IMPL_NDDS_BASE_TRAITS_H_ */ diff --git a/ridlbe/ccmx11/facets/dds/templates/udt_traits/struct.erb b/ridlbe/ccmx11/facets/dds/templates/udt_traits/struct.erb index 665fb39d..31ecfbc9 100644 --- a/ridlbe/ccmx11/facets/dds/templates/udt_traits/struct.erb +++ b/ridlbe/ccmx11/facets/dds/templates/udt_traits/struct.erb @@ -15,7 +15,7 @@ namespace DDSX11 <%= native_scoped_cxxtype %> &to, const <%= scoped_cxxtype %> &from) { %members.each do |_m| - ::DDSX11::to_dds (to.<%= _m.cxxname %>, from.<%= _m.cxxname %> ()); + ::DDSX11::<%if _m.optional? %>optional_<% end %>to_dds (to.<%= _m.cxxname %>, from.<%= _m.cxxname %> ()); %end return to; } @@ -27,7 +27,7 @@ namespace DDSX11 <%= scoped_cxxtype %> &to, const <%= native_scoped_cxxtype %> &from) { %members.each do |_m| - ::DDSX11::from_dds (to.<%= _m.cxxname %> (), from.<%= _m.cxxname %>); + ::DDSX11::<%if _m.optional? %>optional_<% end %>from_dds (to.<%= _m.cxxname %> (), from.<%= _m.cxxname %>); %end return to; }