From 9e6d5aa9e81ab1fe68c89d43e6912e97a7f71f46 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Wed, 10 Jan 2024 20:02:36 +0100 Subject: [PATCH 1/7] Add support for FastDDS versions earlier than 2.13 Signed-off-by: Irene Bandera --- ddspipe_core/CMakeLists.txt | 17 +- .../types/dynamic_types/CMakeLists.txt | 15 +- .../types/dynamic_types/dtypes_idl_tests.cpp | 12 +- .../types/dynamic_types/dtypes_msg_tests.cpp | 12 +- .../types/{ => v1}/all_types.hpp | 0 .../{ => v1}/idls/arrays_and_sequences.idl | 0 .../{ => v1}/idls/basic_array_struct.idl | 0 .../types/{ => v1}/idls/basic_struct.idl | 0 .../types/{ => v1}/idls/char_sequence.idl | 0 .../{ => v1}/idls/complex_nested_arrays.idl | 0 .../types/{ => v1}/idls/enum_struct.idl | 0 .../{ => v1}/idls/float_bounded_sequence.idl | 0 .../types/{ => v1}/idls/hello_world.idl | 0 .../types/{ => v1}/idls/map_struct.idl | 0 .../types/{ => v1}/idls/numeric_array.idl | 0 .../types/{ => v1}/idls/union_struct.idl | 0 .../{ => v1}/msgs/arrays_and_sequences.msg | 0 .../{ => v1}/msgs/basic_array_struct.msg | 0 .../types/{ => v1}/msgs/basic_struct.msg | 0 .../types/{ => v1}/msgs/char_sequence.msg | 0 .../{ => v1}/msgs/complex_nested_arrays.msg | 0 .../{ => v1}/msgs/float_bounded_sequence.msg | 0 .../types/{ => v1}/msgs/hello_world.msg | 0 .../types/{ => v1}/msgs/numeric_array.msg | 0 .../v1/type_objects/arrays_and_sequences.cxx | 520 +++++++++++ .../v1/type_objects/arrays_and_sequences.h | 427 +++++++++ .../arrays_and_sequencesPubSubTypes.cxx | 309 ++++++ .../arrays_and_sequencesPubSubTypes.h | 165 ++++ .../arrays_and_sequencesTypeObject.cxx | 487 ++++++++++ .../arrays_and_sequencesTypeObject.h | 487 ++++++++++ .../v1/type_objects/basic_array_struct.cxx | 442 +++++++++ .../v1/type_objects/basic_array_struct.h | 395 ++++++++ .../basic_array_structPubSubTypes.cxx | 309 ++++++ .../basic_array_structPubSubTypes.h | 165 ++++ .../basic_array_structTypeObject.cxx | 450 +++++++++ .../basic_array_structTypeObject.h | 72 ++ .../types/v1/type_objects/basic_struct.cxx | 339 +++++++ .../types/v1/type_objects/basic_struct.h | 355 +++++++ .../type_objects/basic_structPubSubTypes.cxx | 309 ++++++ .../v1/type_objects/basic_structPubSubTypes.h | 165 ++++ .../type_objects/basic_structTypeObject.cxx | 380 ++++++++ .../v1/type_objects/basic_structTypeObject.h | 72 ++ .../types/v1/type_objects/char_sequence.cxx | 200 ++++ .../types/v1/type_objects/char_sequence.h | 214 +++++ .../type_objects/char_sequencePubSubTypes.cxx | 169 ++++ .../type_objects/char_sequencePubSubTypes.h | 101 ++ .../type_objects/char_sequenceTypeObject.cxx | 215 +++++ .../v1/type_objects/char_sequenceTypeObject.h | 65 ++ .../v1/type_objects/complex_nested_arrays.cxx | 881 ++++++++++++++++++ .../v1/type_objects/complex_nested_arrays.h | 747 +++++++++++++++ .../complex_nested_arraysPubSubTypes.cxx | 589 ++++++++++++ .../complex_nested_arraysPubSubTypes.h | 293 ++++++ .../complex_nested_arraysTypeObject.cxx | 856 +++++++++++++++++ .../complex_nested_arraysTypeObject.h | 86 ++ .../types/v1/type_objects/enum_struct.cxx | 229 +++++ .../types/v1/type_objects/enum_struct.h | 239 +++++ .../type_objects/enum_structPubSubTypes.cxx | 170 ++++ .../v1/type_objects/enum_structPubSubTypes.h | 105 +++ .../v1/type_objects/enum_structTypeObject.cxx | 470 ++++++++++ .../v1/type_objects/enum_structTypeObject.h | 68 ++ .../type_objects/float_bounded_sequence.cxx | 200 ++++ .../v1/type_objects/float_bounded_sequence.h | 214 +++++ .../float_bounded_sequencePubSubTypes.cxx | 169 ++++ .../float_bounded_sequencePubSubTypes.h | 101 ++ .../float_bounded_sequenceTypeObject.cxx | 215 +++++ .../float_bounded_sequenceTypeObject.h | 65 ++ .../types/v1/type_objects/hello_world.cxx | 239 +++++ .../types/v1/type_objects/hello_world.h | 234 +++++ .../type_objects/hello_worldPubSubTypes.cxx | 169 ++++ .../v1/type_objects/hello_worldPubSubTypes.h | 101 ++ .../v1/type_objects/hello_worldTypeObject.cxx | 248 +++++ .../v1/type_objects/hello_worldTypeObject.h | 65 ++ .../types/v1/type_objects/map_struct.cxx | 194 ++++ .../types/v1/type_objects/map_struct.h | 215 +++++ .../v1/type_objects/map_structPubSubTypes.cxx | 169 ++++ .../v1/type_objects/map_structPubSubTypes.h | 104 +++ .../v1/type_objects/map_structTypeObject.cxx | 220 +++++ .../v1/type_objects/map_structTypeObject.h | 63 ++ .../types/v1/type_objects/numeric_array.cxx | 197 ++++ .../types/v1/type_objects/numeric_array.h | 214 +++++ .../type_objects/numeric_arrayPubSubTypes.cxx | 169 ++++ .../type_objects/numeric_arrayPubSubTypes.h | 101 ++ .../type_objects/numeric_arrayTypeObject.cxx | 215 +++++ .../v1/type_objects/numeric_arrayTypeObject.h | 65 ++ .../types/v1/type_objects/union_struct.cxx | 642 +++++++++++++ .../types/v1/type_objects/union_struct.h | 421 +++++++++ .../type_objects/union_structPubSubTypes.cxx | 170 ++++ .../v1/type_objects/union_structPubSubTypes.h | 170 ++++ .../type_objects/union_structTypeObject.cxx | 512 ++++++++++ .../v1/type_objects/union_structTypeObject.h | 512 ++++++++++ .../dynamic_types/types/v2/all_types.hpp | 97 ++ .../types/v2/idls/arrays_and_sequences.idl | 12 + .../types/v2/idls/basic_array_struct.idl | 11 + .../types/v2/idls/basic_struct.idl | 9 + .../types/v2/idls/char_sequence.idl | 4 + .../types/v2/idls/complex_nested_arrays.idl | 23 + .../types/v2/idls/enum_struct.idl | 12 + .../types/v2/idls/float_bounded_sequence.idl | 4 + .../types/v2/idls/hello_world.idl | 5 + .../types/v2/idls/map_struct.idl | 4 + .../types/v2/idls/numeric_array.idl | 4 + .../types/v2/idls/union_struct.idl | 15 + .../types/v2/msgs/arrays_and_sequences.msg | 7 + .../types/v2/msgs/basic_array_struct.msg | 6 + .../types/v2/msgs/basic_struct.msg | 4 + .../types/v2/msgs/char_sequence.msg | 1 + .../types/v2/msgs/complex_nested_arrays.msg | 14 + .../types/v2/msgs/float_bounded_sequence.msg | 1 + .../types/v2/msgs/hello_world.msg | 2 + .../types/v2/msgs/numeric_array.msg | 1 + .../type_objects/arrays_and_sequences.cxx | 0 .../type_objects/arrays_and_sequences.h | 0 .../arrays_and_sequencesCdrAux.hpp | 0 .../arrays_and_sequencesCdrAux.ipp | 0 .../arrays_and_sequencesPubSubTypes.cxx | 0 .../arrays_and_sequencesPubSubTypes.h | 0 .../arrays_and_sequencesTypeObject.cxx | 0 .../arrays_and_sequencesTypeObject.h | 0 .../type_objects/arrays_and_sequencesv1.cxx | 0 .../type_objects/arrays_and_sequencesv1.h | 0 .../type_objects/basic_array_struct.cxx | 0 .../type_objects/basic_array_struct.h | 0 .../type_objects/basic_array_structCdrAux.hpp | 0 .../type_objects/basic_array_structCdrAux.ipp | 0 .../basic_array_structPubSubTypes.cxx | 0 .../basic_array_structPubSubTypes.h | 0 .../basic_array_structTypeObject.cxx | 0 .../basic_array_structTypeObject.h | 0 .../type_objects/basic_array_structv1.cxx | 0 .../type_objects/basic_array_structv1.h | 0 .../{ => v2}/type_objects/basic_struct.cxx | 0 .../{ => v2}/type_objects/basic_struct.h | 0 .../type_objects/basic_structCdrAux.hpp | 0 .../type_objects/basic_structCdrAux.ipp | 0 .../type_objects/basic_structPubSubTypes.cxx | 0 .../type_objects/basic_structPubSubTypes.h | 0 .../type_objects/basic_structTypeObject.cxx | 0 .../type_objects/basic_structTypeObject.h | 0 .../{ => v2}/type_objects/basic_structv1.cxx | 0 .../{ => v2}/type_objects/basic_structv1.h | 0 .../{ => v2}/type_objects/char_sequence.cxx | 0 .../{ => v2}/type_objects/char_sequence.h | 0 .../type_objects/char_sequenceCdrAux.hpp | 0 .../type_objects/char_sequenceCdrAux.ipp | 0 .../type_objects/char_sequencePubSubTypes.cxx | 0 .../type_objects/char_sequencePubSubTypes.h | 0 .../type_objects/char_sequenceTypeObject.cxx | 0 .../type_objects/char_sequenceTypeObject.h | 0 .../{ => v2}/type_objects/char_sequencev1.cxx | 0 .../{ => v2}/type_objects/char_sequencev1.h | 0 .../type_objects/complex_nested_arrays.cxx | 0 .../type_objects/complex_nested_arrays.h | 0 .../complex_nested_arraysCdrAux.hpp | 0 .../complex_nested_arraysCdrAux.ipp | 0 .../complex_nested_arraysPubSubTypes.cxx | 0 .../complex_nested_arraysPubSubTypes.h | 0 .../complex_nested_arraysTypeObject.cxx | 0 .../complex_nested_arraysTypeObject.h | 0 .../type_objects/complex_nested_arraysv1.cxx | 0 .../type_objects/complex_nested_arraysv1.h | 0 .../{ => v2}/type_objects/enum_struct.cxx | 0 .../types/{ => v2}/type_objects/enum_struct.h | 0 .../type_objects/enum_structCdrAux.hpp | 0 .../type_objects/enum_structCdrAux.ipp | 0 .../type_objects/enum_structPubSubTypes.cxx | 0 .../type_objects/enum_structPubSubTypes.h | 0 .../type_objects/enum_structTypeObject.cxx | 0 .../type_objects/enum_structTypeObject.h | 0 .../{ => v2}/type_objects/enum_structv1.cxx | 0 .../{ => v2}/type_objects/enum_structv1.h | 0 .../type_objects/float_bounded_sequence.cxx | 0 .../type_objects/float_bounded_sequence.h | 0 .../float_bounded_sequenceCdrAux.hpp | 0 .../float_bounded_sequenceCdrAux.ipp | 0 .../float_bounded_sequencePubSubTypes.cxx | 0 .../float_bounded_sequencePubSubTypes.h | 0 .../float_bounded_sequenceTypeObject.cxx | 0 .../float_bounded_sequenceTypeObject.h | 0 .../type_objects/float_bounded_sequencev1.cxx | 0 .../type_objects/float_bounded_sequencev1.h | 0 .../{ => v2}/type_objects/hello_world.cxx | 0 .../types/{ => v2}/type_objects/hello_world.h | 0 .../type_objects/hello_worldCdrAux.hpp | 0 .../type_objects/hello_worldCdrAux.ipp | 0 .../type_objects/hello_worldPubSubTypes.cxx | 0 .../type_objects/hello_worldPubSubTypes.h | 0 .../type_objects/hello_worldTypeObject.cxx | 0 .../type_objects/hello_worldTypeObject.h | 0 .../{ => v2}/type_objects/hello_worldv1.cxx | 0 .../{ => v2}/type_objects/hello_worldv1.h | 0 .../{ => v2}/type_objects/map_struct.cxx | 0 .../types/{ => v2}/type_objects/map_struct.h | 0 .../type_objects/map_structCdrAux.hpp | 0 .../type_objects/map_structCdrAux.ipp | 0 .../type_objects/map_structPubSubTypes.cxx | 0 .../type_objects/map_structPubSubTypes.h | 0 .../type_objects/map_structTypeObject.cxx | 0 .../type_objects/map_structTypeObject.h | 0 .../{ => v2}/type_objects/map_structv1.cxx | 0 .../{ => v2}/type_objects/map_structv1.h | 0 .../{ => v2}/type_objects/numeric_array.cxx | 0 .../{ => v2}/type_objects/numeric_array.h | 0 .../type_objects/numeric_arrayCdrAux.hpp | 0 .../type_objects/numeric_arrayCdrAux.ipp | 0 .../type_objects/numeric_arrayPubSubTypes.cxx | 0 .../type_objects/numeric_arrayPubSubTypes.h | 0 .../type_objects/numeric_arrayTypeObject.cxx | 0 .../type_objects/numeric_arrayTypeObject.h | 0 .../{ => v2}/type_objects/numeric_arrayv1.cxx | 0 .../{ => v2}/type_objects/numeric_arrayv1.h | 0 .../{ => v2}/type_objects/union_struct.cxx | 0 .../{ => v2}/type_objects/union_struct.h | 0 .../type_objects/union_structCdrAux.hpp | 0 .../type_objects/union_structCdrAux.ipp | 0 .../type_objects/union_structPubSubTypes.cxx | 0 .../type_objects/union_structPubSubTypes.h | 0 .../type_objects/union_structTypeObject.cxx | 0 .../type_objects/union_structTypeObject.h | 0 .../{ => v2}/type_objects/union_structv1.cxx | 0 .../{ => v2}/type_objects/union_structv1.h | 0 .../src/cpp/reader/dds/CommonReader.cpp | 19 +- .../src/cpp/writer/dds/CommonWriter.cpp | 19 +- 222 files changed, 18225 insertions(+), 23 deletions(-) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/all_types.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/arrays_and_sequences.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/basic_array_struct.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/basic_struct.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/char_sequence.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/complex_nested_arrays.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/enum_struct.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/float_bounded_sequence.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/hello_world.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/map_struct.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/numeric_array.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/idls/union_struct.idl (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/msgs/arrays_and_sequences.msg (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/msgs/basic_array_struct.msg (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/msgs/basic_struct.msg (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/msgs/char_sequence.msg (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/msgs/complex_nested_arrays.msg (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/msgs/float_bounded_sequence.msg (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/msgs/hello_world.msg (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v1}/msgs/numeric_array.msg (100%) create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.cxx create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/all_types.hpp create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/arrays_and_sequences.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_array_struct.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_struct.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/char_sequence.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/complex_nested_arrays.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/enum_struct.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/float_bounded_sequence.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/hello_world.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/map_struct.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/numeric_array.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/union_struct.idl create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/arrays_and_sequences.msg create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_array_struct.msg create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_struct.msg create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/char_sequence.msg create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/complex_nested_arrays.msg create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/float_bounded_sequence.msg create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/hello_world.msg create mode 100644 ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/numeric_array.msg rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/arrays_and_sequences.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/arrays_and_sequences.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/arrays_and_sequencesCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/arrays_and_sequencesCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/arrays_and_sequencesPubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/arrays_and_sequencesPubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/arrays_and_sequencesTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/arrays_and_sequencesTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/arrays_and_sequencesv1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/arrays_and_sequencesv1.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_array_struct.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_array_struct.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_array_structCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_array_structCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_array_structPubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_array_structPubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_array_structTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_array_structTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_array_structv1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_array_structv1.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_struct.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_struct.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_structCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_structCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_structPubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_structPubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_structTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_structTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_structv1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/basic_structv1.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/char_sequence.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/char_sequence.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/char_sequenceCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/char_sequenceCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/char_sequencePubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/char_sequencePubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/char_sequenceTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/char_sequenceTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/char_sequencev1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/char_sequencev1.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/complex_nested_arrays.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/complex_nested_arrays.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/complex_nested_arraysCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/complex_nested_arraysCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/complex_nested_arraysPubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/complex_nested_arraysPubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/complex_nested_arraysTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/complex_nested_arraysTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/complex_nested_arraysv1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/complex_nested_arraysv1.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/enum_struct.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/enum_struct.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/enum_structCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/enum_structCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/enum_structPubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/enum_structPubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/enum_structTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/enum_structTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/enum_structv1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/enum_structv1.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/float_bounded_sequence.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/float_bounded_sequence.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/float_bounded_sequenceCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/float_bounded_sequenceCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/float_bounded_sequencePubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/float_bounded_sequencePubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/float_bounded_sequenceTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/float_bounded_sequenceTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/float_bounded_sequencev1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/float_bounded_sequencev1.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/hello_world.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/hello_world.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/hello_worldCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/hello_worldCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/hello_worldPubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/hello_worldPubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/hello_worldTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/hello_worldTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/hello_worldv1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/hello_worldv1.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/map_struct.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/map_struct.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/map_structCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/map_structCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/map_structPubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/map_structPubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/map_structTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/map_structTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/map_structv1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/map_structv1.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/numeric_array.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/numeric_array.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/numeric_arrayCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/numeric_arrayCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/numeric_arrayPubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/numeric_arrayPubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/numeric_arrayTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/numeric_arrayTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/numeric_arrayv1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/numeric_arrayv1.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/union_struct.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/union_struct.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/union_structCdrAux.hpp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/union_structCdrAux.ipp (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/union_structPubSubTypes.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/union_structPubSubTypes.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/union_structTypeObject.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/union_structTypeObject.h (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/union_structv1.cxx (100%) rename ddspipe_core/test/unittest/types/dynamic_types/types/{ => v2}/type_objects/union_structv1.h (100%) diff --git a/ddspipe_core/CMakeLists.txt b/ddspipe_core/CMakeLists.txt index 331486f9..8e5d51c8 100644 --- a/ddspipe_core/CMakeLists.txt +++ b/ddspipe_core/CMakeLists.txt @@ -70,9 +70,20 @@ compile_library( # Test ############################################################################### # Compile tests if CMake options requires it -compile_test_library( - "${PROJECT_SOURCE_DIR}/test" # Test directory -) + +# Determine Fast DDS version +if ("${fastrtps_VERSION}" VERSION_LESS 2.13) + set(FASTDDS_SUBDIRECTORY "/v2/") +else() + set(FASTDDS_SUBDIRECTORY "/v1/") +endif() + +file(GLOB_RECURSE TEST_FILES "${PROJECT_SOURCE_DIR}/test/") +foreach(TEST_FILE ${TEST_FILES}) + if(NOT TEST_FILE MATCHES ${FASTDDS_SUBDIRECTORY}) + compile_test_tool(${TEST_FILE}) + endif() +endforeach() ############################################################################### # Packaging diff --git a/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt b/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt index 22b8f36c..18e87ad9 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt +++ b/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt @@ -18,8 +18,15 @@ set(TEST_NAME dtypes_idl_tests) +# Determine Fast DDS version +if ("${fastrtps_VERSION}" VERSION_LESS 2.13) + set(FASTDDS_SUBDIRECTORY "v1") +else() + set(FASTDDS_SUBDIRECTORY "v2") +endif() + # Add to test sources every FastDDSGen file generated -file(GLOB DATATYPE_SOURCES_CXX "types/**/*.cxx") +file(GLOB DATATYPE_SOURCES_CXX "types/${FASTDDS_SUBDIRECTORY}/**/*.cxx") set(TEST_SOURCES dtypes_idl_tests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/types/dynamic_types/schema_idl.cpp @@ -42,7 +49,7 @@ file( RESULT_SOURCES_IDL RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - "types/idls/*.idl") + "types/${FASTDDS_SUBDIRECTORY}/idls/*.idl") set(TEST_NEEDED_SOURCES ${RESULT_SOURCES_IDL} @@ -63,7 +70,7 @@ add_unittest_executable( set(TEST_NAME dtypes_msg_tests) # Add to test sources every FastDDSGen file generated -file(GLOB DATATYPE_SOURCES_CXX "types/**/*.cxx") +file(GLOB DATATYPE_SOURCES_CXX "types/${FASTDDS_SUBDIRECTORY}/**/*.cxx") set(TEST_SOURCES dtypes_msg_tests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/types/dynamic_types/schema_msg.cpp @@ -86,7 +93,7 @@ file( RESULT_SOURCES_MSG RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - "types/msgs/*.msg") + "types/${FASTDDS_SUBDIRECTORY}/msgs/*.msg") set(TEST_NEEDED_SOURCES ${RESULT_SOURCES_MSG} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp index da96ed59..215c706c 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp @@ -24,7 +24,11 @@ #include -#include "types/all_types.hpp" +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include "types/v1/all_types.hpp" +#else + #include "types/v2/all_types.hpp" +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 using namespace eprosima; @@ -39,7 +43,11 @@ std::string read_idl_from_file_( std::string file_name_by_type( SupportedType type) { - return std::string("types/idls/") + to_string(type) + ".idl"; + #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + return std::string("types/v1/idls/") + to_string(type) + ".idl"; + #else + return std::string("types/v2/idls/") + to_string(type) + ".idl"; + #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 } void compare_schemas( diff --git a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp index 1bce3080..fd41cf44 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp @@ -19,7 +19,11 @@ #include #include #include -#include "types/all_types.hpp" +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include "types/v1/all_types.hpp" +#else + #include "types/v2/all_types.hpp" +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 using namespace eprosima; @@ -34,7 +38,11 @@ std::string read_msg_from_file_( std::string file_name_by_type( SupportedType type) { - return std::string("types/msgs/") + to_string(type) + ".msg"; + #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + return std::string("types/v1/msgs/") + to_string(type) + ".msg"; + #else + return std::string("types/v2/msgs/") + to_string(type) + ".msg"; + #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 } void compare_schemas( diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/all_types.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/all_types.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/all_types.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/all_types.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/arrays_and_sequences.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/arrays_and_sequences.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/arrays_and_sequences.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/arrays_and_sequences.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/basic_array_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/basic_array_struct.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/basic_array_struct.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/basic_array_struct.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/basic_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/basic_struct.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/basic_struct.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/basic_struct.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/char_sequence.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/char_sequence.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/char_sequence.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/char_sequence.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/complex_nested_arrays.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/complex_nested_arrays.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/complex_nested_arrays.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/complex_nested_arrays.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/enum_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/enum_struct.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/enum_struct.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/enum_struct.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/float_bounded_sequence.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/float_bounded_sequence.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/float_bounded_sequence.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/float_bounded_sequence.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/hello_world.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/hello_world.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/hello_world.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/hello_world.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/map_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/map_struct.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/map_struct.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/map_struct.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/numeric_array.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/numeric_array.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/numeric_array.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/numeric_array.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/idls/union_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/union_struct.idl similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/idls/union_struct.idl rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/idls/union_struct.idl diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/arrays_and_sequences.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/arrays_and_sequences.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/msgs/arrays_and_sequences.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/arrays_and_sequences.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/basic_array_struct.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/basic_array_struct.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/msgs/basic_array_struct.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/basic_array_struct.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/basic_struct.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/basic_struct.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/msgs/basic_struct.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/basic_struct.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/char_sequence.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/char_sequence.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/msgs/char_sequence.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/char_sequence.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/complex_nested_arrays.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/complex_nested_arrays.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/msgs/complex_nested_arrays.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/complex_nested_arrays.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/float_bounded_sequence.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/float_bounded_sequence.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/msgs/float_bounded_sequence.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/float_bounded_sequence.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/hello_world.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/hello_world.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/msgs/hello_world.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/hello_world.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/msgs/numeric_array.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/numeric_array.msg similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/msgs/numeric_array.msg rename to ddspipe_core/test/unittest/types/dynamic_types/types/v1/msgs/numeric_array.msg diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.cxx new file mode 100644 index 00000000..da1b66da --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.cxx @@ -0,0 +1,520 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file arrays_and_sequences.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "arrays_and_sequences.h" +#include "arrays_and_sequencesTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +AnInternalObject::AnInternalObject() +{ + // m_x com.eprosima.idl.parser.typecode.PrimitiveTypeCode@47ef968d + m_x = 0.0; + // m_positive com.eprosima.idl.parser.typecode.PrimitiveTypeCode@23e028a9 + m_positive = false; + + // Just to register all known types + registerarrays_and_sequencesTypes(); +} + +AnInternalObject::~AnInternalObject() +{ + + +} + +AnInternalObject::AnInternalObject( + const AnInternalObject& x) +{ + m_x = x.m_x; + m_positive = x.m_positive; +} + +AnInternalObject::AnInternalObject( + AnInternalObject&& x) noexcept +{ + m_x = x.m_x; + m_positive = x.m_positive; +} + +AnInternalObject& AnInternalObject::operator =( + const AnInternalObject& x) +{ + + m_x = x.m_x; + m_positive = x.m_positive; + + return *this; +} + +AnInternalObject& AnInternalObject::operator =( + AnInternalObject&& x) noexcept +{ + + m_x = x.m_x; + m_positive = x.m_positive; + + return *this; +} + +bool AnInternalObject::operator ==( + const AnInternalObject& x) const +{ + + return (m_x == x.m_x && m_positive == x.m_positive); +} + +bool AnInternalObject::operator !=( + const AnInternalObject& x) const +{ + return !(*this == x); +} + +size_t AnInternalObject::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + + + + return current_alignment - initial_alignment; +} + +size_t AnInternalObject::getCdrSerializedSize( + const AnInternalObject& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + + + + return current_alignment - initial_alignment; +} + +void AnInternalObject::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_x; + scdr << m_positive; + +} + +void AnInternalObject::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_x; + dcdr >> m_positive; +} + +/*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ +void AnInternalObject::x( + float _x) +{ + m_x = _x; +} + +/*! + * @brief This function returns the value of member x + * @return Value of member x + */ +float AnInternalObject::x() const +{ + return m_x; +} + +/*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ +float& AnInternalObject::x() +{ + return m_x; +} + +/*! + * @brief This function sets a value in member positive + * @param _positive New value for member positive + */ +void AnInternalObject::positive( + bool _positive) +{ + m_positive = _positive; +} + +/*! + * @brief This function returns the value of member positive + * @return Value of member positive + */ +bool AnInternalObject::positive() const +{ + return m_positive; +} + +/*! + * @brief This function returns a reference to member positive + * @return Reference to member positive + */ +bool& AnInternalObject::positive() +{ + return m_positive; +} + + +size_t AnInternalObject::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + return current_align; +} + +bool AnInternalObject::isKeyDefined() +{ + return false; +} + +void AnInternalObject::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} + +arrays_and_sequences::arrays_and_sequences() +{ + // m_unlimited_vector com.eprosima.idl.parser.typecode.SequenceTypeCode@42eca56e + + // m_limited_vector com.eprosima.idl.parser.typecode.SequenceTypeCode@52f759d7 + + // m_limited_array com.eprosima.idl.parser.typecode.ArrayTypeCode@7cbd213e + + + // Just to register all known types + registerarrays_and_sequencesTypes(); +} + +arrays_and_sequences::~arrays_and_sequences() +{ + + + +} + +arrays_and_sequences::arrays_and_sequences( + const arrays_and_sequences& x) +{ + m_unlimited_vector = x.m_unlimited_vector; + m_limited_vector = x.m_limited_vector; + m_limited_array = x.m_limited_array; +} + +arrays_and_sequences::arrays_and_sequences( + arrays_and_sequences&& x) noexcept +{ + m_unlimited_vector = std::move(x.m_unlimited_vector); + m_limited_vector = std::move(x.m_limited_vector); + m_limited_array = std::move(x.m_limited_array); +} + +arrays_and_sequences& arrays_and_sequences::operator =( + const arrays_and_sequences& x) +{ + + m_unlimited_vector = x.m_unlimited_vector; + m_limited_vector = x.m_limited_vector; + m_limited_array = x.m_limited_array; + + return *this; +} + +arrays_and_sequences& arrays_and_sequences::operator =( + arrays_and_sequences&& x) noexcept +{ + + m_unlimited_vector = std::move(x.m_unlimited_vector); + m_limited_vector = std::move(x.m_limited_vector); + m_limited_array = std::move(x.m_limited_array); + + return *this; +} + +bool arrays_and_sequences::operator ==( + const arrays_and_sequences& x) const +{ + + return (m_unlimited_vector == x.m_unlimited_vector && m_limited_vector == x.m_limited_vector && m_limited_array == x.m_limited_array); +} + +bool arrays_and_sequences::operator !=( + const arrays_and_sequences& x) const +{ + return !(*this == x); +} + +size_t arrays_and_sequences::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + for(size_t a = 0; a < 100; ++a) + { + current_alignment += AnInternalObject::getMaxCdrSerializedSize(current_alignment);} + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + for(size_t a = 0; a < 10; ++a) + { + current_alignment += AnInternalObject::getMaxCdrSerializedSize(current_alignment);} + + + for(size_t a = 0; a < (10); ++a) + { + current_alignment += AnInternalObject::getMaxCdrSerializedSize(current_alignment);} + + return current_alignment - initial_alignment; +} + +size_t arrays_and_sequences::getCdrSerializedSize( + const arrays_and_sequences& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + for(size_t a = 0; a < data.unlimited_vector().size(); ++a) + { + current_alignment += AnInternalObject::getCdrSerializedSize(data.unlimited_vector().at(a), current_alignment);} + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + for(size_t a = 0; a < data.limited_vector().size(); ++a) + { + current_alignment += AnInternalObject::getCdrSerializedSize(data.limited_vector().at(a), current_alignment);} + + + for(size_t a = 0; a < data.limited_array().size(); ++a) + { + current_alignment += AnInternalObject::getCdrSerializedSize(data.limited_array().at(a), current_alignment); + } + + return current_alignment - initial_alignment; +} + +void arrays_and_sequences::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_unlimited_vector; + scdr << m_limited_vector; + scdr << m_limited_array; + + +} + +void arrays_and_sequences::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_unlimited_vector; + dcdr >> m_limited_vector; + dcdr >> m_limited_array; + +} + +/*! + * @brief This function copies the value in member unlimited_vector + * @param _unlimited_vector New value to be copied in member unlimited_vector + */ +void arrays_and_sequences::unlimited_vector( + const std::vector& _unlimited_vector) +{ + m_unlimited_vector = _unlimited_vector; +} + +/*! + * @brief This function moves the value in member unlimited_vector + * @param _unlimited_vector New value to be moved in member unlimited_vector + */ +void arrays_and_sequences::unlimited_vector( + std::vector&& _unlimited_vector) +{ + m_unlimited_vector = std::move(_unlimited_vector); +} + +/*! + * @brief This function returns a constant reference to member unlimited_vector + * @return Constant reference to member unlimited_vector + */ +const std::vector& arrays_and_sequences::unlimited_vector() const +{ + return m_unlimited_vector; +} + +/*! + * @brief This function returns a reference to member unlimited_vector + * @return Reference to member unlimited_vector + */ +std::vector& arrays_and_sequences::unlimited_vector() +{ + return m_unlimited_vector; +} +/*! + * @brief This function copies the value in member limited_vector + * @param _limited_vector New value to be copied in member limited_vector + */ +void arrays_and_sequences::limited_vector( + const std::vector& _limited_vector) +{ + m_limited_vector = _limited_vector; +} + +/*! + * @brief This function moves the value in member limited_vector + * @param _limited_vector New value to be moved in member limited_vector + */ +void arrays_and_sequences::limited_vector( + std::vector&& _limited_vector) +{ + m_limited_vector = std::move(_limited_vector); +} + +/*! + * @brief This function returns a constant reference to member limited_vector + * @return Constant reference to member limited_vector + */ +const std::vector& arrays_and_sequences::limited_vector() const +{ + return m_limited_vector; +} + +/*! + * @brief This function returns a reference to member limited_vector + * @return Reference to member limited_vector + */ +std::vector& arrays_and_sequences::limited_vector() +{ + return m_limited_vector; +} +/*! + * @brief This function copies the value in member limited_array + * @param _limited_array New value to be copied in member limited_array + */ +void arrays_and_sequences::limited_array( + const std::array& _limited_array) +{ + m_limited_array = _limited_array; +} + +/*! + * @brief This function moves the value in member limited_array + * @param _limited_array New value to be moved in member limited_array + */ +void arrays_and_sequences::limited_array( + std::array&& _limited_array) +{ + m_limited_array = std::move(_limited_array); +} + +/*! + * @brief This function returns a constant reference to member limited_array + * @return Constant reference to member limited_array + */ +const std::array& arrays_and_sequences::limited_array() const +{ + return m_limited_array; +} + +/*! + * @brief This function returns a reference to member limited_array + * @return Reference to member limited_array + */ +std::array& arrays_and_sequences::limited_array() +{ + return m_limited_array; +} + +size_t arrays_and_sequences::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + + return current_align; +} + +bool arrays_and_sequences::isKeyDefined() +{ + return false; +} + +void arrays_and_sequences::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.h new file mode 100644 index 00000000..32b71e9c --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequences.h @@ -0,0 +1,427 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file arrays_and_sequences.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ +#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(arrays_and_sequences_SOURCE) +#define arrays_and_sequences_DllAPI __declspec( dllexport ) +#else +#define arrays_and_sequences_DllAPI __declspec( dllimport ) +#endif // arrays_and_sequences_SOURCE +#else +#define arrays_and_sequences_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define arrays_and_sequences_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure AnInternalObject defined by the user in the IDL file. + * @ingroup ARRAYS_AND_SEQUENCES + */ +class AnInternalObject +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport AnInternalObject(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~AnInternalObject(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object AnInternalObject that will be copied. + */ + eProsima_user_DllExport AnInternalObject( + const AnInternalObject& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object AnInternalObject that will be copied. + */ + eProsima_user_DllExport AnInternalObject( + AnInternalObject&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object AnInternalObject that will be copied. + */ + eProsima_user_DllExport AnInternalObject& operator =( + const AnInternalObject& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object AnInternalObject that will be copied. + */ + eProsima_user_DllExport AnInternalObject& operator =( + AnInternalObject&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x AnInternalObject object to compare. + */ + eProsima_user_DllExport bool operator ==( + const AnInternalObject& x) const; + + /*! + * @brief Comparison operator. + * @param x AnInternalObject object to compare. + */ + eProsima_user_DllExport bool operator !=( + const AnInternalObject& x) const; + + /*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ + eProsima_user_DllExport void x( + float _x); + + /*! + * @brief This function returns the value of member x + * @return Value of member x + */ + eProsima_user_DllExport float x() const; + + /*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ + eProsima_user_DllExport float& x(); + + /*! + * @brief This function sets a value in member positive + * @param _positive New value for member positive + */ + eProsima_user_DllExport void positive( + bool _positive); + + /*! + * @brief This function returns the value of member positive + * @return Value of member positive + */ + eProsima_user_DllExport bool positive() const; + + /*! + * @brief This function returns a reference to member positive + * @return Reference to member positive + */ + eProsima_user_DllExport bool& positive(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const AnInternalObject& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + float m_x; + bool m_positive; +}; +/*! + * @brief This class represents the structure arrays_and_sequences defined by the user in the IDL file. + * @ingroup ARRAYS_AND_SEQUENCES + */ +class arrays_and_sequences +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport arrays_and_sequences(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~arrays_and_sequences(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object arrays_and_sequences that will be copied. + */ + eProsima_user_DllExport arrays_and_sequences( + const arrays_and_sequences& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object arrays_and_sequences that will be copied. + */ + eProsima_user_DllExport arrays_and_sequences( + arrays_and_sequences&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object arrays_and_sequences that will be copied. + */ + eProsima_user_DllExport arrays_and_sequences& operator =( + const arrays_and_sequences& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object arrays_and_sequences that will be copied. + */ + eProsima_user_DllExport arrays_and_sequences& operator =( + arrays_and_sequences&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x arrays_and_sequences object to compare. + */ + eProsima_user_DllExport bool operator ==( + const arrays_and_sequences& x) const; + + /*! + * @brief Comparison operator. + * @param x arrays_and_sequences object to compare. + */ + eProsima_user_DllExport bool operator !=( + const arrays_and_sequences& x) const; + + /*! + * @brief This function copies the value in member unlimited_vector + * @param _unlimited_vector New value to be copied in member unlimited_vector + */ + eProsima_user_DllExport void unlimited_vector( + const std::vector& _unlimited_vector); + + /*! + * @brief This function moves the value in member unlimited_vector + * @param _unlimited_vector New value to be moved in member unlimited_vector + */ + eProsima_user_DllExport void unlimited_vector( + std::vector&& _unlimited_vector); + + /*! + * @brief This function returns a constant reference to member unlimited_vector + * @return Constant reference to member unlimited_vector + */ + eProsima_user_DllExport const std::vector& unlimited_vector() const; + + /*! + * @brief This function returns a reference to member unlimited_vector + * @return Reference to member unlimited_vector + */ + eProsima_user_DllExport std::vector& unlimited_vector(); + /*! + * @brief This function copies the value in member limited_vector + * @param _limited_vector New value to be copied in member limited_vector + */ + eProsima_user_DllExport void limited_vector( + const std::vector& _limited_vector); + + /*! + * @brief This function moves the value in member limited_vector + * @param _limited_vector New value to be moved in member limited_vector + */ + eProsima_user_DllExport void limited_vector( + std::vector&& _limited_vector); + + /*! + * @brief This function returns a constant reference to member limited_vector + * @return Constant reference to member limited_vector + */ + eProsima_user_DllExport const std::vector& limited_vector() const; + + /*! + * @brief This function returns a reference to member limited_vector + * @return Reference to member limited_vector + */ + eProsima_user_DllExport std::vector& limited_vector(); + /*! + * @brief This function copies the value in member limited_array + * @param _limited_array New value to be copied in member limited_array + */ + eProsima_user_DllExport void limited_array( + const std::array& _limited_array); + + /*! + * @brief This function moves the value in member limited_array + * @param _limited_array New value to be moved in member limited_array + */ + eProsima_user_DllExport void limited_array( + std::array&& _limited_array); + + /*! + * @brief This function returns a constant reference to member limited_array + * @return Constant reference to member limited_array + */ + eProsima_user_DllExport const std::array& limited_array() const; + + /*! + * @brief This function returns a reference to member limited_array + * @return Reference to member limited_array + */ + eProsima_user_DllExport std::array& limited_array(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const arrays_and_sequences& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + std::vector m_unlimited_vector; + std::vector m_limited_vector; + std::array m_limited_array; +}; + +#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.cxx new file mode 100644 index 00000000..56d15be3 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.cxx @@ -0,0 +1,309 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file arrays_and_sequencesPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "arrays_and_sequencesPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +AnInternalObjectPubSubType::AnInternalObjectPubSubType() +{ + setName("AnInternalObject"); + auto type_size = AnInternalObject::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = AnInternalObject::isKeyDefined(); + size_t keyLength = AnInternalObject::getKeyMaxCdrSerializedSize() > 16 ? + AnInternalObject::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +AnInternalObjectPubSubType::~AnInternalObjectPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool AnInternalObjectPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + AnInternalObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool AnInternalObjectPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + AnInternalObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function AnInternalObjectPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* AnInternalObjectPubSubType::createData() +{ + return reinterpret_cast(new AnInternalObject()); +} + +void AnInternalObjectPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool AnInternalObjectPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + AnInternalObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + AnInternalObject::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || AnInternalObject::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} + +arrays_and_sequencesPubSubType::arrays_and_sequencesPubSubType() +{ + setName("arrays_and_sequences"); + auto type_size = arrays_and_sequences::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = arrays_and_sequences::isKeyDefined(); + size_t keyLength = arrays_and_sequences::getKeyMaxCdrSerializedSize() > 16 ? + arrays_and_sequences::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +arrays_and_sequencesPubSubType::~arrays_and_sequencesPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool arrays_and_sequencesPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + arrays_and_sequences* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool arrays_and_sequencesPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + arrays_and_sequences* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function arrays_and_sequencesPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* arrays_and_sequencesPubSubType::createData() +{ + return reinterpret_cast(new arrays_and_sequences()); +} + +void arrays_and_sequencesPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool arrays_and_sequencesPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + arrays_and_sequences* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + arrays_and_sequences::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || arrays_and_sequences::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.h new file mode 100644 index 00000000..0ef7d1b9 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesPubSubTypes.h @@ -0,0 +1,165 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file arrays_and_sequencesPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_PUBSUBTYPES_H_ + +#include +#include + +#include "arrays_and_sequences.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated arrays_and_sequences is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +/*! + * @brief This class represents the TopicDataType of the type AnInternalObject defined by the user in the IDL file. + * @ingroup ARRAYS_AND_SEQUENCES + */ +class AnInternalObjectPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef AnInternalObject type; + + eProsima_user_DllExport AnInternalObjectPubSubType(); + + eProsima_user_DllExport virtual ~AnInternalObjectPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + new (memory) AnInternalObject(); + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; +/*! + * @brief This class represents the TopicDataType of the type arrays_and_sequences defined by the user in the IDL file. + * @ingroup ARRAYS_AND_SEQUENCES + */ +class arrays_and_sequencesPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef arrays_and_sequences type; + + eProsima_user_DllExport arrays_and_sequencesPubSubType(); + + eProsima_user_DllExport virtual ~arrays_and_sequencesPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + (void)memory; + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.cxx new file mode 100644 index 00000000..b6e19eaf --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.cxx @@ -0,0 +1,487 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file arrays_and_sequencesTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "arrays_and_sequences.h" +#include "arrays_and_sequencesTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerarrays_and_sequencesTypes() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(true), + GetAnInternalObjectObject(true)); + factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(false), + GetAnInternalObjectObject(false)); + + factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(true), + Getarrays_and_sequencesObject(true)); + factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(false), + Getarrays_and_sequencesObject(false)); + +} + +const TypeIdentifier* GetAnInternalObjectIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetAnInternalObjectObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); +} + +const TypeObject* GetAnInternalObjectObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteAnInternalObjectObject(); + } + //else + return GetMinimalAnInternalObjectObject(); +} + +const TypeObject* GetMinimalAnInternalObjectObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_x; + mst_x.common().member_id(memberId++); + mst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_x.common().member_flags().IS_OPTIONAL(false); + mst_x.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_x.common().member_flags().IS_KEY(false); + mst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); + + MD5 x_hash("x"); + for(int i = 0; i < 4; ++i) + { + mst_x.detail().name_hash()[i] = x_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_x); + + MinimalStructMember mst_positive; + mst_positive.common().member_id(memberId++); + mst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_positive.common().member_flags().IS_OPTIONAL(false); + mst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_positive.common().member_flags().IS_KEY(false); + mst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); + + MD5 positive_hash("positive"); + for(int i = 0; i < 4; ++i) + { + mst_positive.detail().name_hash()[i] = positive_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_positive); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); +} + +const TypeObject* GetCompleteAnInternalObjectObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_x; + cst_x.common().member_id(memberId++); + cst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_x.common().member_flags().IS_OPTIONAL(false); + cst_x.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_x.common().member_flags().IS_KEY(false); + cst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); + + cst_x.detail().name("x"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_x); + + CompleteStructMember cst_positive; + cst_positive.common().member_id(memberId++); + cst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_positive.common().member_flags().IS_OPTIONAL(false); + cst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_positive.common().member_flags().IS_KEY(false); + cst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); + + cst_positive.detail().name("positive"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_positive); + + + // Header + type_object->complete().struct_type().header().detail().type_name("AnInternalObject"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); +} + +const TypeIdentifier* Getarrays_and_sequencesIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getarrays_and_sequencesObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); +} + +const TypeObject* Getarrays_and_sequencesObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompletearrays_and_sequencesObject(); + } + //else + return GetMinimalarrays_and_sequencesObject(); +} + +const TypeObject* GetMinimalarrays_and_sequencesObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_unlimited_vector; + mst_unlimited_vector.common().member_id(memberId++); + mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); + mst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_unlimited_vector.common().member_flags().IS_KEY(false); + mst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, false)); + + + MD5 unlimited_vector_hash("unlimited_vector"); + for(int i = 0; i < 4; ++i) + { + mst_unlimited_vector.detail().name_hash()[i] = unlimited_vector_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_unlimited_vector); + + MinimalStructMember mst_limited_vector; + mst_limited_vector.common().member_id(memberId++); + mst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_limited_vector.common().member_flags().IS_OPTIONAL(false); + mst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_limited_vector.common().member_flags().IS_KEY(false); + mst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, false)); + + + MD5 limited_vector_hash("limited_vector"); + for(int i = 0; i < 4; ++i) + { + mst_limited_vector.detail().name_hash()[i] = limited_vector_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_vector); + + MinimalStructMember mst_limited_array; + mst_limited_array.common().member_id(memberId++); + mst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_limited_array.common().member_flags().IS_OPTIONAL(false); + mst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_limited_array.common().member_flags().IS_KEY(false); + mst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, false)); + + + MD5 limited_array_hash("limited_array"); + for(int i = 0; i < 4; ++i) + { + mst_limited_array.detail().name_hash()[i] = limited_array_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_array); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); +} + +const TypeObject* GetCompletearrays_and_sequencesObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_unlimited_vector; + cst_unlimited_vector.common().member_id(memberId++); + cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); + cst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_unlimited_vector.common().member_flags().IS_KEY(false); + cst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, true)); + + + cst_unlimited_vector.detail().name("unlimited_vector"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_unlimited_vector); + + CompleteStructMember cst_limited_vector; + cst_limited_vector.common().member_id(memberId++); + cst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_limited_vector.common().member_flags().IS_OPTIONAL(false); + cst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_limited_vector.common().member_flags().IS_KEY(false); + cst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, true)); + + + cst_limited_vector.detail().name("limited_vector"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_limited_vector); + + CompleteStructMember cst_limited_array; + cst_limited_array.common().member_id(memberId++); + cst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_limited_array.common().member_flags().IS_OPTIONAL(false); + cst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_limited_array.common().member_flags().IS_KEY(false); + cst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, true)); + + + cst_limited_array.detail().name("limited_array"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_limited_array); + + + // Header + type_object->complete().struct_type().header().detail().type_name("arrays_and_sequences"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h new file mode 100644 index 00000000..b6e19eaf --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h @@ -0,0 +1,487 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file arrays_and_sequencesTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "arrays_and_sequences.h" +#include "arrays_and_sequencesTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerarrays_and_sequencesTypes() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(true), + GetAnInternalObjectObject(true)); + factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(false), + GetAnInternalObjectObject(false)); + + factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(true), + Getarrays_and_sequencesObject(true)); + factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(false), + Getarrays_and_sequencesObject(false)); + +} + +const TypeIdentifier* GetAnInternalObjectIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetAnInternalObjectObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); +} + +const TypeObject* GetAnInternalObjectObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteAnInternalObjectObject(); + } + //else + return GetMinimalAnInternalObjectObject(); +} + +const TypeObject* GetMinimalAnInternalObjectObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_x; + mst_x.common().member_id(memberId++); + mst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_x.common().member_flags().IS_OPTIONAL(false); + mst_x.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_x.common().member_flags().IS_KEY(false); + mst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); + + MD5 x_hash("x"); + for(int i = 0; i < 4; ++i) + { + mst_x.detail().name_hash()[i] = x_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_x); + + MinimalStructMember mst_positive; + mst_positive.common().member_id(memberId++); + mst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_positive.common().member_flags().IS_OPTIONAL(false); + mst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_positive.common().member_flags().IS_KEY(false); + mst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); + + MD5 positive_hash("positive"); + for(int i = 0; i < 4; ++i) + { + mst_positive.detail().name_hash()[i] = positive_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_positive); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); +} + +const TypeObject* GetCompleteAnInternalObjectObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_x; + cst_x.common().member_id(memberId++); + cst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_x.common().member_flags().IS_OPTIONAL(false); + cst_x.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_x.common().member_flags().IS_KEY(false); + cst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); + + cst_x.detail().name("x"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_x); + + CompleteStructMember cst_positive; + cst_positive.common().member_id(memberId++); + cst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_positive.common().member_flags().IS_OPTIONAL(false); + cst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_positive.common().member_flags().IS_KEY(false); + cst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); + + cst_positive.detail().name("positive"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_positive); + + + // Header + type_object->complete().struct_type().header().detail().type_name("AnInternalObject"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); +} + +const TypeIdentifier* Getarrays_and_sequencesIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getarrays_and_sequencesObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); +} + +const TypeObject* Getarrays_and_sequencesObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompletearrays_and_sequencesObject(); + } + //else + return GetMinimalarrays_and_sequencesObject(); +} + +const TypeObject* GetMinimalarrays_and_sequencesObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_unlimited_vector; + mst_unlimited_vector.common().member_id(memberId++); + mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); + mst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_unlimited_vector.common().member_flags().IS_KEY(false); + mst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, false)); + + + MD5 unlimited_vector_hash("unlimited_vector"); + for(int i = 0; i < 4; ++i) + { + mst_unlimited_vector.detail().name_hash()[i] = unlimited_vector_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_unlimited_vector); + + MinimalStructMember mst_limited_vector; + mst_limited_vector.common().member_id(memberId++); + mst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_limited_vector.common().member_flags().IS_OPTIONAL(false); + mst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_limited_vector.common().member_flags().IS_KEY(false); + mst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, false)); + + + MD5 limited_vector_hash("limited_vector"); + for(int i = 0; i < 4; ++i) + { + mst_limited_vector.detail().name_hash()[i] = limited_vector_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_vector); + + MinimalStructMember mst_limited_array; + mst_limited_array.common().member_id(memberId++); + mst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_limited_array.common().member_flags().IS_OPTIONAL(false); + mst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_limited_array.common().member_flags().IS_KEY(false); + mst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, false)); + + + MD5 limited_array_hash("limited_array"); + for(int i = 0; i < 4; ++i) + { + mst_limited_array.detail().name_hash()[i] = limited_array_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_array); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); +} + +const TypeObject* GetCompletearrays_and_sequencesObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_unlimited_vector; + cst_unlimited_vector.common().member_id(memberId++); + cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); + cst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_unlimited_vector.common().member_flags().IS_KEY(false); + cst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, true)); + + + cst_unlimited_vector.detail().name("unlimited_vector"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_unlimited_vector); + + CompleteStructMember cst_limited_vector; + cst_limited_vector.common().member_id(memberId++); + cst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_limited_vector.common().member_flags().IS_OPTIONAL(false); + cst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_limited_vector.common().member_flags().IS_KEY(false); + cst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, true)); + + + cst_limited_vector.detail().name("limited_vector"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_limited_vector); + + CompleteStructMember cst_limited_array; + cst_limited_array.common().member_id(memberId++); + cst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_limited_array.common().member_flags().IS_OPTIONAL(false); + cst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_limited_array.common().member_flags().IS_KEY(false); + cst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, true)); + + + cst_limited_array.detail().name("limited_array"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_limited_array); + + + // Header + type_object->complete().struct_type().header().detail().type_name("arrays_and_sequences"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.cxx new file mode 100644 index 00000000..0d39bc85 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.cxx @@ -0,0 +1,442 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_array_struct.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "basic_array_struct.h" +#include "basic_array_structTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +TheOtherObjectInArray::TheOtherObjectInArray() +{ + // m_some_num com.eprosima.idl.parser.typecode.PrimitiveTypeCode@32709393 + m_some_num = 0; + // m_positive com.eprosima.idl.parser.typecode.PrimitiveTypeCode@3d99d22e + m_positive = false; + + // Just to register all known types + registerbasic_array_structTypes(); +} + +TheOtherObjectInArray::~TheOtherObjectInArray() +{ + + +} + +TheOtherObjectInArray::TheOtherObjectInArray( + const TheOtherObjectInArray& x) +{ + m_some_num = x.m_some_num; + m_positive = x.m_positive; +} + +TheOtherObjectInArray::TheOtherObjectInArray( + TheOtherObjectInArray&& x) noexcept +{ + m_some_num = x.m_some_num; + m_positive = x.m_positive; +} + +TheOtherObjectInArray& TheOtherObjectInArray::operator =( + const TheOtherObjectInArray& x) +{ + + m_some_num = x.m_some_num; + m_positive = x.m_positive; + + return *this; +} + +TheOtherObjectInArray& TheOtherObjectInArray::operator =( + TheOtherObjectInArray&& x) noexcept +{ + + m_some_num = x.m_some_num; + m_positive = x.m_positive; + + return *this; +} + +bool TheOtherObjectInArray::operator ==( + const TheOtherObjectInArray& x) const +{ + + return (m_some_num == x.m_some_num && m_positive == x.m_positive); +} + +bool TheOtherObjectInArray::operator !=( + const TheOtherObjectInArray& x) const +{ + return !(*this == x); +} + +size_t TheOtherObjectInArray::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + + + + return current_alignment - initial_alignment; +} + +size_t TheOtherObjectInArray::getCdrSerializedSize( + const TheOtherObjectInArray& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + + + + return current_alignment - initial_alignment; +} + +void TheOtherObjectInArray::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_some_num; + scdr << m_positive; + +} + +void TheOtherObjectInArray::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_some_num; + dcdr >> m_positive; +} + +/*! + * @brief This function sets a value in member some_num + * @param _some_num New value for member some_num + */ +void TheOtherObjectInArray::some_num( + int32_t _some_num) +{ + m_some_num = _some_num; +} + +/*! + * @brief This function returns the value of member some_num + * @return Value of member some_num + */ +int32_t TheOtherObjectInArray::some_num() const +{ + return m_some_num; +} + +/*! + * @brief This function returns a reference to member some_num + * @return Reference to member some_num + */ +int32_t& TheOtherObjectInArray::some_num() +{ + return m_some_num; +} + +/*! + * @brief This function sets a value in member positive + * @param _positive New value for member positive + */ +void TheOtherObjectInArray::positive( + bool _positive) +{ + m_positive = _positive; +} + +/*! + * @brief This function returns the value of member positive + * @return Value of member positive + */ +bool TheOtherObjectInArray::positive() const +{ + return m_positive; +} + +/*! + * @brief This function returns a reference to member positive + * @return Reference to member positive + */ +bool& TheOtherObjectInArray::positive() +{ + return m_positive; +} + + +size_t TheOtherObjectInArray::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + return current_align; +} + +bool TheOtherObjectInArray::isKeyDefined() +{ + return false; +} + +void TheOtherObjectInArray::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} + +basic_array_struct::basic_array_struct() +{ + // m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@50d0686 + m_index = 0; + // m_sub_structs com.eprosima.idl.parser.typecode.ArrayTypeCode@1e7c7811 + + + // Just to register all known types + registerbasic_array_structTypes(); +} + +basic_array_struct::~basic_array_struct() +{ + + +} + +basic_array_struct::basic_array_struct( + const basic_array_struct& x) +{ + m_index = x.m_index; + m_sub_structs = x.m_sub_structs; +} + +basic_array_struct::basic_array_struct( + basic_array_struct&& x) noexcept +{ + m_index = x.m_index; + m_sub_structs = std::move(x.m_sub_structs); +} + +basic_array_struct& basic_array_struct::operator =( + const basic_array_struct& x) +{ + + m_index = x.m_index; + m_sub_structs = x.m_sub_structs; + + return *this; +} + +basic_array_struct& basic_array_struct::operator =( + basic_array_struct&& x) noexcept +{ + + m_index = x.m_index; + m_sub_structs = std::move(x.m_sub_structs); + + return *this; +} + +bool basic_array_struct::operator ==( + const basic_array_struct& x) const +{ + + return (m_index == x.m_index && m_sub_structs == x.m_sub_structs); +} + +bool basic_array_struct::operator !=( + const basic_array_struct& x) const +{ + return !(*this == x); +} + +size_t basic_array_struct::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + + for(size_t a = 0; a < (5); ++a) + { + current_alignment += TheOtherObjectInArray::getMaxCdrSerializedSize(current_alignment);} + + return current_alignment - initial_alignment; +} + +size_t basic_array_struct::getCdrSerializedSize( + const basic_array_struct& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + + for(size_t a = 0; a < data.sub_structs().size(); ++a) + { + current_alignment += TheOtherObjectInArray::getCdrSerializedSize(data.sub_structs().at(a), current_alignment); + } + + return current_alignment - initial_alignment; +} + +void basic_array_struct::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_index; + scdr << m_sub_structs; + + +} + +void basic_array_struct::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_index; + dcdr >> m_sub_structs; + +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void basic_array_struct::index( + uint32_t _index) +{ + m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t basic_array_struct::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& basic_array_struct::index() +{ + return m_index; +} + +/*! + * @brief This function copies the value in member sub_structs + * @param _sub_structs New value to be copied in member sub_structs + */ +void basic_array_struct::sub_structs( + const std::array& _sub_structs) +{ + m_sub_structs = _sub_structs; +} + +/*! + * @brief This function moves the value in member sub_structs + * @param _sub_structs New value to be moved in member sub_structs + */ +void basic_array_struct::sub_structs( + std::array&& _sub_structs) +{ + m_sub_structs = std::move(_sub_structs); +} + +/*! + * @brief This function returns a constant reference to member sub_structs + * @return Constant reference to member sub_structs + */ +const std::array& basic_array_struct::sub_structs() const +{ + return m_sub_structs; +} + +/*! + * @brief This function returns a reference to member sub_structs + * @return Reference to member sub_structs + */ +std::array& basic_array_struct::sub_structs() +{ + return m_sub_structs; +} + +size_t basic_array_struct::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + return current_align; +} + +bool basic_array_struct::isKeyDefined() +{ + return false; +} + +void basic_array_struct::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.h new file mode 100644 index 00000000..920978d7 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_struct.h @@ -0,0 +1,395 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_array_struct.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ +#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(basic_array_struct_SOURCE) +#define basic_array_struct_DllAPI __declspec( dllexport ) +#else +#define basic_array_struct_DllAPI __declspec( dllimport ) +#endif // basic_array_struct_SOURCE +#else +#define basic_array_struct_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define basic_array_struct_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure TheOtherObjectInArray defined by the user in the IDL file. + * @ingroup BASIC_ARRAY_STRUCT + */ +class TheOtherObjectInArray +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport TheOtherObjectInArray(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~TheOtherObjectInArray(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object TheOtherObjectInArray that will be copied. + */ + eProsima_user_DllExport TheOtherObjectInArray( + const TheOtherObjectInArray& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object TheOtherObjectInArray that will be copied. + */ + eProsima_user_DllExport TheOtherObjectInArray( + TheOtherObjectInArray&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object TheOtherObjectInArray that will be copied. + */ + eProsima_user_DllExport TheOtherObjectInArray& operator =( + const TheOtherObjectInArray& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object TheOtherObjectInArray that will be copied. + */ + eProsima_user_DllExport TheOtherObjectInArray& operator =( + TheOtherObjectInArray&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x TheOtherObjectInArray object to compare. + */ + eProsima_user_DllExport bool operator ==( + const TheOtherObjectInArray& x) const; + + /*! + * @brief Comparison operator. + * @param x TheOtherObjectInArray object to compare. + */ + eProsima_user_DllExport bool operator !=( + const TheOtherObjectInArray& x) const; + + /*! + * @brief This function sets a value in member some_num + * @param _some_num New value for member some_num + */ + eProsima_user_DllExport void some_num( + int32_t _some_num); + + /*! + * @brief This function returns the value of member some_num + * @return Value of member some_num + */ + eProsima_user_DllExport int32_t some_num() const; + + /*! + * @brief This function returns a reference to member some_num + * @return Reference to member some_num + */ + eProsima_user_DllExport int32_t& some_num(); + + /*! + * @brief This function sets a value in member positive + * @param _positive New value for member positive + */ + eProsima_user_DllExport void positive( + bool _positive); + + /*! + * @brief This function returns the value of member positive + * @return Value of member positive + */ + eProsima_user_DllExport bool positive() const; + + /*! + * @brief This function returns a reference to member positive + * @return Reference to member positive + */ + eProsima_user_DllExport bool& positive(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const TheOtherObjectInArray& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + int32_t m_some_num; + bool m_positive; +}; +/*! + * @brief This class represents the structure basic_array_struct defined by the user in the IDL file. + * @ingroup BASIC_ARRAY_STRUCT + */ +class basic_array_struct +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport basic_array_struct(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~basic_array_struct(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object basic_array_struct that will be copied. + */ + eProsima_user_DllExport basic_array_struct( + const basic_array_struct& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object basic_array_struct that will be copied. + */ + eProsima_user_DllExport basic_array_struct( + basic_array_struct&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object basic_array_struct that will be copied. + */ + eProsima_user_DllExport basic_array_struct& operator =( + const basic_array_struct& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object basic_array_struct that will be copied. + */ + eProsima_user_DllExport basic_array_struct& operator =( + basic_array_struct&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x basic_array_struct object to compare. + */ + eProsima_user_DllExport bool operator ==( + const basic_array_struct& x) const; + + /*! + * @brief Comparison operator. + * @param x basic_array_struct object to compare. + */ + eProsima_user_DllExport bool operator !=( + const basic_array_struct& x) const; + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + /*! + * @brief This function copies the value in member sub_structs + * @param _sub_structs New value to be copied in member sub_structs + */ + eProsima_user_DllExport void sub_structs( + const std::array& _sub_structs); + + /*! + * @brief This function moves the value in member sub_structs + * @param _sub_structs New value to be moved in member sub_structs + */ + eProsima_user_DllExport void sub_structs( + std::array&& _sub_structs); + + /*! + * @brief This function returns a constant reference to member sub_structs + * @return Constant reference to member sub_structs + */ + eProsima_user_DllExport const std::array& sub_structs() const; + + /*! + * @brief This function returns a reference to member sub_structs + * @return Reference to member sub_structs + */ + eProsima_user_DllExport std::array& sub_structs(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const basic_array_struct& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + uint32_t m_index; + std::array m_sub_structs; +}; + +#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.cxx new file mode 100644 index 00000000..dd4dff4e --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.cxx @@ -0,0 +1,309 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_array_structPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "basic_array_structPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +TheOtherObjectInArrayPubSubType::TheOtherObjectInArrayPubSubType() +{ + setName("TheOtherObjectInArray"); + auto type_size = TheOtherObjectInArray::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = TheOtherObjectInArray::isKeyDefined(); + size_t keyLength = TheOtherObjectInArray::getKeyMaxCdrSerializedSize() > 16 ? + TheOtherObjectInArray::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +TheOtherObjectInArrayPubSubType::~TheOtherObjectInArrayPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool TheOtherObjectInArrayPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + TheOtherObjectInArray* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool TheOtherObjectInArrayPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + TheOtherObjectInArray* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function TheOtherObjectInArrayPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* TheOtherObjectInArrayPubSubType::createData() +{ + return reinterpret_cast(new TheOtherObjectInArray()); +} + +void TheOtherObjectInArrayPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool TheOtherObjectInArrayPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + TheOtherObjectInArray* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + TheOtherObjectInArray::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || TheOtherObjectInArray::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} + +basic_array_structPubSubType::basic_array_structPubSubType() +{ + setName("basic_array_struct"); + auto type_size = basic_array_struct::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = basic_array_struct::isKeyDefined(); + size_t keyLength = basic_array_struct::getKeyMaxCdrSerializedSize() > 16 ? + basic_array_struct::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +basic_array_structPubSubType::~basic_array_structPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool basic_array_structPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + basic_array_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool basic_array_structPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + basic_array_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function basic_array_structPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* basic_array_structPubSubType::createData() +{ + return reinterpret_cast(new basic_array_struct()); +} + +void basic_array_structPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool basic_array_structPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + basic_array_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + basic_array_struct::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || basic_array_struct::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.h new file mode 100644 index 00000000..e382e8d4 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structPubSubTypes.h @@ -0,0 +1,165 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_array_structPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_PUBSUBTYPES_H_ + +#include +#include + +#include "basic_array_struct.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated basic_array_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +/*! + * @brief This class represents the TopicDataType of the type TheOtherObjectInArray defined by the user in the IDL file. + * @ingroup BASIC_ARRAY_STRUCT + */ +class TheOtherObjectInArrayPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef TheOtherObjectInArray type; + + eProsima_user_DllExport TheOtherObjectInArrayPubSubType(); + + eProsima_user_DllExport virtual ~TheOtherObjectInArrayPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + new (memory) TheOtherObjectInArray(); + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; +/*! + * @brief This class represents the TopicDataType of the type basic_array_struct defined by the user in the IDL file. + * @ingroup BASIC_ARRAY_STRUCT + */ +class basic_array_structPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef basic_array_struct type; + + eProsima_user_DllExport basic_array_structPubSubType(); + + eProsima_user_DllExport virtual ~basic_array_structPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + new (memory) basic_array_struct(); + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.cxx new file mode 100644 index 00000000..29f15c6f --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.cxx @@ -0,0 +1,450 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_array_structTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "basic_array_struct.h" +#include "basic_array_structTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerbasic_array_structTypes() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("TheOtherObjectInArray", GetTheOtherObjectInArrayIdentifier(true), + GetTheOtherObjectInArrayObject(true)); + factory->add_type_object("TheOtherObjectInArray", GetTheOtherObjectInArrayIdentifier(false), + GetTheOtherObjectInArrayObject(false)); + + factory->add_type_object("basic_array_struct", Getbasic_array_structIdentifier(true), + Getbasic_array_structObject(true)); + factory->add_type_object("basic_array_struct", Getbasic_array_structIdentifier(false), + Getbasic_array_structObject(false)); + +} + +const TypeIdentifier* GetTheOtherObjectInArrayIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObjectInArray", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetTheOtherObjectInArrayObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObjectInArray", complete); +} + +const TypeObject* GetTheOtherObjectInArrayObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteTheOtherObjectInArrayObject(); + } + //else + return GetMinimalTheOtherObjectInArrayObject(); +} + +const TypeObject* GetMinimalTheOtherObjectInArrayObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_some_num; + mst_some_num.common().member_id(memberId++); + mst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_some_num.common().member_flags().IS_OPTIONAL(false); + mst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_some_num.common().member_flags().IS_KEY(false); + mst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + + MD5 some_num_hash("some_num"); + for(int i = 0; i < 4; ++i) + { + mst_some_num.detail().name_hash()[i] = some_num_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_some_num); + + MinimalStructMember mst_positive; + mst_positive.common().member_id(memberId++); + mst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_positive.common().member_flags().IS_OPTIONAL(false); + mst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_positive.common().member_flags().IS_KEY(false); + mst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); + + MD5 positive_hash("positive"); + for(int i = 0; i < 4; ++i) + { + mst_positive.detail().name_hash()[i] = positive_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_positive); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("TheOtherObjectInArray", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", false); +} + +const TypeObject* GetCompleteTheOtherObjectInArrayObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_some_num; + cst_some_num.common().member_id(memberId++); + cst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_some_num.common().member_flags().IS_OPTIONAL(false); + cst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_some_num.common().member_flags().IS_KEY(false); + cst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + + cst_some_num.detail().name("some_num"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_some_num); + + CompleteStructMember cst_positive; + cst_positive.common().member_id(memberId++); + cst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_positive.common().member_flags().IS_OPTIONAL(false); + cst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_positive.common().member_flags().IS_KEY(false); + cst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); + + cst_positive.detail().name("positive"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_positive); + + + // Header + type_object->complete().struct_type().header().detail().type_name("TheOtherObjectInArray"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("TheOtherObjectInArray", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("TheOtherObjectInArray", true); +} + +const TypeIdentifier* Getbasic_array_structIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("basic_array_struct", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getbasic_array_structObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("basic_array_struct", complete); +} + +const TypeObject* Getbasic_array_structObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompletebasic_array_structObject(); + } + //else + return GetMinimalbasic_array_structObject(); +} + +const TypeObject* GetMinimalbasic_array_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_index; + mst_index.common().member_id(memberId++); + mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_index.common().member_flags().IS_OPTIONAL(false); + mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_index.common().member_flags().IS_KEY(false); + mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); + + MD5 index_hash("index"); + for(int i = 0; i < 4; ++i) + { + mst_index.detail().name_hash()[i] = index_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_index); + + MinimalStructMember mst_sub_structs; + mst_sub_structs.common().member_id(memberId++); + mst_sub_structs.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_sub_structs.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_sub_structs.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_sub_structs.common().member_flags().IS_OPTIONAL(false); + mst_sub_structs.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_sub_structs.common().member_flags().IS_KEY(false); + mst_sub_structs.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_sub_structs.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("TheOtherObjectInArray", {5}, false)); + + + MD5 sub_structs_hash("sub_structs"); + for(int i = 0; i < 4; ++i) + { + mst_sub_structs.detail().name_hash()[i] = sub_structs_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_sub_structs); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("basic_array_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", false); +} + +const TypeObject* GetCompletebasic_array_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_index; + cst_index.common().member_id(memberId++); + cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_index.common().member_flags().IS_OPTIONAL(false); + cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_index.common().member_flags().IS_KEY(false); + cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); + + cst_index.detail().name("index"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_index); + + CompleteStructMember cst_sub_structs; + cst_sub_structs.common().member_id(memberId++); + cst_sub_structs.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_sub_structs.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_sub_structs.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_sub_structs.common().member_flags().IS_OPTIONAL(false); + cst_sub_structs.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_sub_structs.common().member_flags().IS_KEY(false); + cst_sub_structs.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_sub_structs.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("TheOtherObjectInArray", {5}, true)); + + + cst_sub_structs.detail().name("sub_structs"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_sub_structs); + + + // Header + type_object->complete().struct_type().header().detail().type_name("basic_array_struct"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("basic_array_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("basic_array_struct", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.h new file mode 100644 index 00000000..097559ae --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_array_structTypeObject.h @@ -0,0 +1,72 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_array_structTypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define eProsima_user_DllExport +#endif // if defined(_WIN32) + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(basic_array_struct_SOURCE) +#define basic_array_struct_DllAPI __declspec( dllexport ) +#else +#define basic_array_struct_DllAPI __declspec( dllimport ) +#endif // basic_array_struct_SOURCE +#else +#define basic_array_struct_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define basic_array_struct_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registerbasic_array_structTypes(); + +eProsima_user_DllExport const TypeIdentifier* GetTheOtherObjectInArrayIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetTheOtherObjectInArrayObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalTheOtherObjectInArrayObject(); +eProsima_user_DllExport const TypeObject* GetCompleteTheOtherObjectInArrayObject(); + +eProsima_user_DllExport const TypeIdentifier* Getbasic_array_structIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* Getbasic_array_structObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalbasic_array_structObject(); +eProsima_user_DllExport const TypeObject* GetCompletebasic_array_structObject(); + + +#endif // _FAST_DDS_GENERATED_BASIC_ARRAY_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.cxx new file mode 100644 index 00000000..009a888b --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.cxx @@ -0,0 +1,339 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_struct.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "basic_struct.h" +#include "basic_structTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +TheOtherObject::TheOtherObject() +{ + // m_some_num com.eprosima.idl.parser.typecode.PrimitiveTypeCode@3cef309d + m_some_num = 0; + + // Just to register all known types + registerbasic_structTypes(); +} + +TheOtherObject::~TheOtherObject() +{ +} + +TheOtherObject::TheOtherObject( + const TheOtherObject& x) +{ + m_some_num = x.m_some_num; +} + +TheOtherObject::TheOtherObject( + TheOtherObject&& x) noexcept +{ + m_some_num = x.m_some_num; +} + +TheOtherObject& TheOtherObject::operator =( + const TheOtherObject& x) +{ + + m_some_num = x.m_some_num; + + return *this; +} + +TheOtherObject& TheOtherObject::operator =( + TheOtherObject&& x) noexcept +{ + + m_some_num = x.m_some_num; + + return *this; +} + +bool TheOtherObject::operator ==( + const TheOtherObject& x) const +{ + + return (m_some_num == x.m_some_num); +} + +bool TheOtherObject::operator !=( + const TheOtherObject& x) const +{ + return !(*this == x); +} + +size_t TheOtherObject::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + return current_alignment - initial_alignment; +} + +size_t TheOtherObject::getCdrSerializedSize( + const TheOtherObject& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + return current_alignment - initial_alignment; +} + +void TheOtherObject::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_some_num; + +} + +void TheOtherObject::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_some_num; +} + +/*! + * @brief This function sets a value in member some_num + * @param _some_num New value for member some_num + */ +void TheOtherObject::some_num( + int32_t _some_num) +{ + m_some_num = _some_num; +} + +/*! + * @brief This function returns the value of member some_num + * @return Value of member some_num + */ +int32_t TheOtherObject::some_num() const +{ + return m_some_num; +} + +/*! + * @brief This function returns a reference to member some_num + * @return Reference to member some_num + */ +int32_t& TheOtherObject::some_num() +{ + return m_some_num; +} + + +size_t TheOtherObject::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + return current_align; +} + +bool TheOtherObject::isKeyDefined() +{ + return false; +} + +void TheOtherObject::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} + +basic_struct::basic_struct() +{ + // m_sub_struct com.eprosima.fastdds.idl.parser.typecode.StructTypeCode@5bcea91b + + + // Just to register all known types + registerbasic_structTypes(); +} + +basic_struct::~basic_struct() +{ +} + +basic_struct::basic_struct( + const basic_struct& x) +{ + m_sub_struct = x.m_sub_struct; +} + +basic_struct::basic_struct( + basic_struct&& x) noexcept +{ + m_sub_struct = std::move(x.m_sub_struct); +} + +basic_struct& basic_struct::operator =( + const basic_struct& x) +{ + + m_sub_struct = x.m_sub_struct; + + return *this; +} + +basic_struct& basic_struct::operator =( + basic_struct&& x) noexcept +{ + + m_sub_struct = std::move(x.m_sub_struct); + + return *this; +} + +bool basic_struct::operator ==( + const basic_struct& x) const +{ + + return (m_sub_struct == x.m_sub_struct); +} + +bool basic_struct::operator !=( + const basic_struct& x) const +{ + return !(*this == x); +} + +size_t basic_struct::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += TheOtherObject::getMaxCdrSerializedSize(current_alignment); + + return current_alignment - initial_alignment; +} + +size_t basic_struct::getCdrSerializedSize( + const basic_struct& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += TheOtherObject::getCdrSerializedSize(data.sub_struct(), current_alignment); + + return current_alignment - initial_alignment; +} + +void basic_struct::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_sub_struct; + +} + +void basic_struct::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_sub_struct; +} + +/*! + * @brief This function copies the value in member sub_struct + * @param _sub_struct New value to be copied in member sub_struct + */ +void basic_struct::sub_struct( + const TheOtherObject& _sub_struct) +{ + m_sub_struct = _sub_struct; +} + +/*! + * @brief This function moves the value in member sub_struct + * @param _sub_struct New value to be moved in member sub_struct + */ +void basic_struct::sub_struct( + TheOtherObject&& _sub_struct) +{ + m_sub_struct = std::move(_sub_struct); +} + +/*! + * @brief This function returns a constant reference to member sub_struct + * @return Constant reference to member sub_struct + */ +const TheOtherObject& basic_struct::sub_struct() const +{ + return m_sub_struct; +} + +/*! + * @brief This function returns a reference to member sub_struct + * @return Reference to member sub_struct + */ +TheOtherObject& basic_struct::sub_struct() +{ + return m_sub_struct; +} + +size_t basic_struct::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + return current_align; +} + +bool basic_struct::isKeyDefined() +{ + return false; +} + +void basic_struct::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.h new file mode 100644 index 00000000..53e1fe9e --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_struct.h @@ -0,0 +1,355 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_struct.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_BASIC_STRUCT_H_ +#define _FAST_DDS_GENERATED_BASIC_STRUCT_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(basic_struct_SOURCE) +#define basic_struct_DllAPI __declspec( dllexport ) +#else +#define basic_struct_DllAPI __declspec( dllimport ) +#endif // basic_struct_SOURCE +#else +#define basic_struct_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define basic_struct_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure TheOtherObject defined by the user in the IDL file. + * @ingroup BASIC_STRUCT + */ +class TheOtherObject +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport TheOtherObject(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~TheOtherObject(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object TheOtherObject that will be copied. + */ + eProsima_user_DllExport TheOtherObject( + const TheOtherObject& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object TheOtherObject that will be copied. + */ + eProsima_user_DllExport TheOtherObject( + TheOtherObject&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object TheOtherObject that will be copied. + */ + eProsima_user_DllExport TheOtherObject& operator =( + const TheOtherObject& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object TheOtherObject that will be copied. + */ + eProsima_user_DllExport TheOtherObject& operator =( + TheOtherObject&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x TheOtherObject object to compare. + */ + eProsima_user_DllExport bool operator ==( + const TheOtherObject& x) const; + + /*! + * @brief Comparison operator. + * @param x TheOtherObject object to compare. + */ + eProsima_user_DllExport bool operator !=( + const TheOtherObject& x) const; + + /*! + * @brief This function sets a value in member some_num + * @param _some_num New value for member some_num + */ + eProsima_user_DllExport void some_num( + int32_t _some_num); + + /*! + * @brief This function returns the value of member some_num + * @return Value of member some_num + */ + eProsima_user_DllExport int32_t some_num() const; + + /*! + * @brief This function returns a reference to member some_num + * @return Reference to member some_num + */ + eProsima_user_DllExport int32_t& some_num(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const TheOtherObject& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + int32_t m_some_num; +}; +/*! + * @brief This class represents the structure basic_struct defined by the user in the IDL file. + * @ingroup BASIC_STRUCT + */ +class basic_struct +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport basic_struct(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~basic_struct(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object basic_struct that will be copied. + */ + eProsima_user_DllExport basic_struct( + const basic_struct& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object basic_struct that will be copied. + */ + eProsima_user_DllExport basic_struct( + basic_struct&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object basic_struct that will be copied. + */ + eProsima_user_DllExport basic_struct& operator =( + const basic_struct& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object basic_struct that will be copied. + */ + eProsima_user_DllExport basic_struct& operator =( + basic_struct&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x basic_struct object to compare. + */ + eProsima_user_DllExport bool operator ==( + const basic_struct& x) const; + + /*! + * @brief Comparison operator. + * @param x basic_struct object to compare. + */ + eProsima_user_DllExport bool operator !=( + const basic_struct& x) const; + + /*! + * @brief This function copies the value in member sub_struct + * @param _sub_struct New value to be copied in member sub_struct + */ + eProsima_user_DllExport void sub_struct( + const TheOtherObject& _sub_struct); + + /*! + * @brief This function moves the value in member sub_struct + * @param _sub_struct New value to be moved in member sub_struct + */ + eProsima_user_DllExport void sub_struct( + TheOtherObject&& _sub_struct); + + /*! + * @brief This function returns a constant reference to member sub_struct + * @return Constant reference to member sub_struct + */ + eProsima_user_DllExport const TheOtherObject& sub_struct() const; + + /*! + * @brief This function returns a reference to member sub_struct + * @return Reference to member sub_struct + */ + eProsima_user_DllExport TheOtherObject& sub_struct(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const basic_struct& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + TheOtherObject m_sub_struct; +}; + +#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.cxx new file mode 100644 index 00000000..04cc05b7 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.cxx @@ -0,0 +1,309 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_structPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "basic_structPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +TheOtherObjectPubSubType::TheOtherObjectPubSubType() +{ + setName("TheOtherObject"); + auto type_size = TheOtherObject::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = TheOtherObject::isKeyDefined(); + size_t keyLength = TheOtherObject::getKeyMaxCdrSerializedSize() > 16 ? + TheOtherObject::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +TheOtherObjectPubSubType::~TheOtherObjectPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool TheOtherObjectPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + TheOtherObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool TheOtherObjectPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + TheOtherObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function TheOtherObjectPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* TheOtherObjectPubSubType::createData() +{ + return reinterpret_cast(new TheOtherObject()); +} + +void TheOtherObjectPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool TheOtherObjectPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + TheOtherObject* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + TheOtherObject::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || TheOtherObject::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} + +basic_structPubSubType::basic_structPubSubType() +{ + setName("basic_struct"); + auto type_size = basic_struct::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = basic_struct::isKeyDefined(); + size_t keyLength = basic_struct::getKeyMaxCdrSerializedSize() > 16 ? + basic_struct::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +basic_structPubSubType::~basic_structPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool basic_structPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + basic_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool basic_structPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + basic_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function basic_structPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* basic_structPubSubType::createData() +{ + return reinterpret_cast(new basic_struct()); +} + +void basic_structPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool basic_structPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + basic_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + basic_struct::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || basic_struct::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.h new file mode 100644 index 00000000..cec5fc93 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structPubSubTypes.h @@ -0,0 +1,165 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_structPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_BASIC_STRUCT_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_BASIC_STRUCT_PUBSUBTYPES_H_ + +#include +#include + +#include "basic_struct.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated basic_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +/*! + * @brief This class represents the TopicDataType of the type TheOtherObject defined by the user in the IDL file. + * @ingroup BASIC_STRUCT + */ +class TheOtherObjectPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef TheOtherObject type; + + eProsima_user_DllExport TheOtherObjectPubSubType(); + + eProsima_user_DllExport virtual ~TheOtherObjectPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + new (memory) TheOtherObject(); + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; +/*! + * @brief This class represents the TopicDataType of the type basic_struct defined by the user in the IDL file. + * @ingroup BASIC_STRUCT + */ +class basic_structPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef basic_struct type; + + eProsima_user_DllExport basic_structPubSubType(); + + eProsima_user_DllExport virtual ~basic_structPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + new (memory) basic_struct(); + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.cxx new file mode 100644 index 00000000..b881ad94 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.cxx @@ -0,0 +1,380 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_structTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "basic_struct.h" +#include "basic_structTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerbasic_structTypes() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("TheOtherObject", GetTheOtherObjectIdentifier(true), + GetTheOtherObjectObject(true)); + factory->add_type_object("TheOtherObject", GetTheOtherObjectIdentifier(false), + GetTheOtherObjectObject(false)); + + factory->add_type_object("basic_struct", Getbasic_structIdentifier(true), + Getbasic_structObject(true)); + factory->add_type_object("basic_struct", Getbasic_structIdentifier(false), + Getbasic_structObject(false)); + +} + +const TypeIdentifier* GetTheOtherObjectIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObject", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetTheOtherObjectObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("TheOtherObject", complete); +} + +const TypeObject* GetTheOtherObjectObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteTheOtherObjectObject(); + } + //else + return GetMinimalTheOtherObjectObject(); +} + +const TypeObject* GetMinimalTheOtherObjectObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_some_num; + mst_some_num.common().member_id(memberId++); + mst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_some_num.common().member_flags().IS_OPTIONAL(false); + mst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_some_num.common().member_flags().IS_KEY(false); + mst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + + MD5 some_num_hash("some_num"); + for(int i = 0; i < 4; ++i) + { + mst_some_num.detail().name_hash()[i] = some_num_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_some_num); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("TheOtherObject", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", false); +} + +const TypeObject* GetCompleteTheOtherObjectObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_some_num; + cst_some_num.common().member_id(memberId++); + cst_some_num.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_some_num.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_some_num.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_some_num.common().member_flags().IS_OPTIONAL(false); + cst_some_num.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_some_num.common().member_flags().IS_KEY(false); + cst_some_num.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_some_num.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + + cst_some_num.detail().name("some_num"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_some_num); + + + // Header + type_object->complete().struct_type().header().detail().type_name("TheOtherObject"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("TheOtherObject", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("TheOtherObject", true); +} + +const TypeIdentifier* Getbasic_structIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("basic_struct", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getbasic_structObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("basic_struct", complete); +} + +const TypeObject* Getbasic_structObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_struct", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompletebasic_structObject(); + } + //else + return GetMinimalbasic_structObject(); +} + +const TypeObject* GetMinimalbasic_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_struct", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_sub_struct; + mst_sub_struct.common().member_id(memberId++); + mst_sub_struct.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_sub_struct.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_sub_struct.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_sub_struct.common().member_flags().IS_OPTIONAL(false); + mst_sub_struct.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_sub_struct.common().member_flags().IS_KEY(false); + mst_sub_struct.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_sub_struct.common().member_type_id(*GetTheOtherObjectIdentifier(false)); + MD5 sub_struct_hash("sub_struct"); + for(int i = 0; i < 4; ++i) + { + mst_sub_struct.detail().name_hash()[i] = sub_struct_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_sub_struct); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("basic_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("basic_struct", false); +} + +const TypeObject* GetCompletebasic_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("basic_struct", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_sub_struct; + cst_sub_struct.common().member_id(memberId++); + cst_sub_struct.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_sub_struct.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_sub_struct.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_sub_struct.common().member_flags().IS_OPTIONAL(false); + cst_sub_struct.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_sub_struct.common().member_flags().IS_KEY(false); + cst_sub_struct.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_sub_struct.common().member_type_id(*GetTheOtherObjectIdentifier(true)); + cst_sub_struct.detail().name("sub_struct"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_sub_struct); + + + // Header + type_object->complete().struct_type().header().detail().type_name("basic_struct"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("basic_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("basic_struct", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.h new file mode 100644 index 00000000..04ad8848 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/basic_structTypeObject.h @@ -0,0 +1,72 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file basic_structTypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_BASIC_STRUCT_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_BASIC_STRUCT_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define eProsima_user_DllExport +#endif // if defined(_WIN32) + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(basic_struct_SOURCE) +#define basic_struct_DllAPI __declspec( dllexport ) +#else +#define basic_struct_DllAPI __declspec( dllimport ) +#endif // basic_struct_SOURCE +#else +#define basic_struct_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define basic_struct_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registerbasic_structTypes(); + +eProsima_user_DllExport const TypeIdentifier* GetTheOtherObjectIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetTheOtherObjectObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalTheOtherObjectObject(); +eProsima_user_DllExport const TypeObject* GetCompleteTheOtherObjectObject(); + +eProsima_user_DllExport const TypeIdentifier* Getbasic_structIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* Getbasic_structObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalbasic_structObject(); +eProsima_user_DllExport const TypeObject* GetCompletebasic_structObject(); + + +#endif // _FAST_DDS_GENERATED_BASIC_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.cxx new file mode 100644 index 00000000..14eefab1 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.cxx @@ -0,0 +1,200 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file char_sequence.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "char_sequence.h" +#include "char_sequenceTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +char_sequence::char_sequence() +{ + // m_chars com.eprosima.idl.parser.typecode.SequenceTypeCode@3fd7a715 + + + // Just to register all known types + registerchar_sequenceTypes(); +} + +char_sequence::~char_sequence() +{ +} + +char_sequence::char_sequence( + const char_sequence& x) +{ + m_chars = x.m_chars; +} + +char_sequence::char_sequence( + char_sequence&& x) noexcept +{ + m_chars = std::move(x.m_chars); +} + +char_sequence& char_sequence::operator =( + const char_sequence& x) +{ + + m_chars = x.m_chars; + + return *this; +} + +char_sequence& char_sequence::operator =( + char_sequence&& x) noexcept +{ + + m_chars = std::move(x.m_chars); + + return *this; +} + +bool char_sequence::operator ==( + const char_sequence& x) const +{ + + return (m_chars == x.m_chars); +} + +bool char_sequence::operator !=( + const char_sequence& x) const +{ + return !(*this == x); +} + +size_t char_sequence::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + current_alignment += (100 * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + + + + return current_alignment - initial_alignment; +} + +size_t char_sequence::getCdrSerializedSize( + const char_sequence& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + if (data.chars().size() > 0) + { + current_alignment += (data.chars().size() * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + } + + + + return current_alignment - initial_alignment; +} + +void char_sequence::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_chars; +} + +void char_sequence::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_chars;} + +/*! + * @brief This function copies the value in member chars + * @param _chars New value to be copied in member chars + */ +void char_sequence::chars( + const std::vector& _chars) +{ + m_chars = _chars; +} + +/*! + * @brief This function moves the value in member chars + * @param _chars New value to be moved in member chars + */ +void char_sequence::chars( + std::vector&& _chars) +{ + m_chars = std::move(_chars); +} + +/*! + * @brief This function returns a constant reference to member chars + * @return Constant reference to member chars + */ +const std::vector& char_sequence::chars() const +{ + return m_chars; +} + +/*! + * @brief This function returns a reference to member chars + * @return Reference to member chars + */ +std::vector& char_sequence::chars() +{ + return m_chars; +} + +size_t char_sequence::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + return current_align; +} + +bool char_sequence::isKeyDefined() +{ + return false; +} + +void char_sequence::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.h new file mode 100644 index 00000000..51c2bd1a --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequence.h @@ -0,0 +1,214 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file char_sequence.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ +#define _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(char_sequence_SOURCE) +#define char_sequence_DllAPI __declspec( dllexport ) +#else +#define char_sequence_DllAPI __declspec( dllimport ) +#endif // char_sequence_SOURCE +#else +#define char_sequence_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define char_sequence_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure char_sequence defined by the user in the IDL file. + * @ingroup CHAR_SEQUENCE + */ +class char_sequence +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport char_sequence(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~char_sequence(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object char_sequence that will be copied. + */ + eProsima_user_DllExport char_sequence( + const char_sequence& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object char_sequence that will be copied. + */ + eProsima_user_DllExport char_sequence( + char_sequence&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object char_sequence that will be copied. + */ + eProsima_user_DllExport char_sequence& operator =( + const char_sequence& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object char_sequence that will be copied. + */ + eProsima_user_DllExport char_sequence& operator =( + char_sequence&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x char_sequence object to compare. + */ + eProsima_user_DllExport bool operator ==( + const char_sequence& x) const; + + /*! + * @brief Comparison operator. + * @param x char_sequence object to compare. + */ + eProsima_user_DllExport bool operator !=( + const char_sequence& x) const; + + /*! + * @brief This function copies the value in member chars + * @param _chars New value to be copied in member chars + */ + eProsima_user_DllExport void chars( + const std::vector& _chars); + + /*! + * @brief This function moves the value in member chars + * @param _chars New value to be moved in member chars + */ + eProsima_user_DllExport void chars( + std::vector&& _chars); + + /*! + * @brief This function returns a constant reference to member chars + * @return Constant reference to member chars + */ + eProsima_user_DllExport const std::vector& chars() const; + + /*! + * @brief This function returns a reference to member chars + * @return Reference to member chars + */ + eProsima_user_DllExport std::vector& chars(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const char_sequence& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + std::vector m_chars; +}; + +#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.cxx new file mode 100644 index 00000000..d0fb01af --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file char_sequencePubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "char_sequencePubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +char_sequencePubSubType::char_sequencePubSubType() +{ + setName("char_sequence"); + auto type_size = char_sequence::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = char_sequence::isKeyDefined(); + size_t keyLength = char_sequence::getKeyMaxCdrSerializedSize() > 16 ? + char_sequence::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +char_sequencePubSubType::~char_sequencePubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool char_sequencePubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + char_sequence* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool char_sequencePubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + char_sequence* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function char_sequencePubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* char_sequencePubSubType::createData() +{ + return reinterpret_cast(new char_sequence()); +} + +void char_sequencePubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool char_sequencePubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + char_sequence* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + char_sequence::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || char_sequence::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.h new file mode 100644 index 00000000..bfd9912d --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequencePubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file char_sequencePubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCE_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_CHAR_SEQUENCE_PUBSUBTYPES_H_ + +#include +#include + +#include "char_sequence.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated char_sequence is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +/*! + * @brief This class represents the TopicDataType of the type char_sequence defined by the user in the IDL file. + * @ingroup CHAR_SEQUENCE + */ +class char_sequencePubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef char_sequence type; + + eProsima_user_DllExport char_sequencePubSubType(); + + eProsima_user_DllExport virtual ~char_sequencePubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + (void)memory; + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.cxx new file mode 100644 index 00000000..2bb805f5 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.cxx @@ -0,0 +1,215 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file char_sequenceTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "char_sequence.h" +#include "char_sequenceTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerchar_sequenceTypes() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("char_sequence", Getchar_sequenceIdentifier(true), + Getchar_sequenceObject(true)); + factory->add_type_object("char_sequence", Getchar_sequenceIdentifier(false), + Getchar_sequenceObject(false)); + +} + +const TypeIdentifier* Getchar_sequenceIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("char_sequence", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getchar_sequenceObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("char_sequence", complete); +} + +const TypeObject* Getchar_sequenceObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("char_sequence", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompletechar_sequenceObject(); + } + //else + return GetMinimalchar_sequenceObject(); +} + +const TypeObject* GetMinimalchar_sequenceObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("char_sequence", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_chars; + mst_chars.common().member_id(memberId++); + mst_chars.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_chars.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_chars.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_chars.common().member_flags().IS_OPTIONAL(false); + mst_chars.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_chars.common().member_flags().IS_KEY(false); + mst_chars.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_chars.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("char", 0, false)); + + + MD5 chars_hash("chars"); + for(int i = 0; i < 4; ++i) + { + mst_chars.detail().name_hash()[i] = chars_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_chars); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("char_sequence", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("char_sequence", false); +} + +const TypeObject* GetCompletechar_sequenceObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("char_sequence", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_chars; + cst_chars.common().member_id(memberId++); + cst_chars.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_chars.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_chars.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_chars.common().member_flags().IS_OPTIONAL(false); + cst_chars.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_chars.common().member_flags().IS_KEY(false); + cst_chars.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_chars.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("char", 0, true)); + + + cst_chars.detail().name("chars"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_chars); + + + // Header + type_object->complete().struct_type().header().detail().type_name("char_sequence"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("char_sequence", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("char_sequence", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.h new file mode 100644 index 00000000..82e51f80 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/char_sequenceTypeObject.h @@ -0,0 +1,65 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file char_sequenceTypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_CHAR_SEQUENCE_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_CHAR_SEQUENCE_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define eProsima_user_DllExport +#endif // if defined(_WIN32) + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(char_sequence_SOURCE) +#define char_sequence_DllAPI __declspec( dllexport ) +#else +#define char_sequence_DllAPI __declspec( dllimport ) +#endif // char_sequence_SOURCE +#else +#define char_sequence_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define char_sequence_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registerchar_sequenceTypes(); + +eProsima_user_DllExport const TypeIdentifier* Getchar_sequenceIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* Getchar_sequenceObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalchar_sequenceObject(); +eProsima_user_DllExport const TypeObject* GetCompletechar_sequenceObject(); + + +#endif // _FAST_DDS_GENERATED_CHAR_SEQUENCE_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.cxx new file mode 100644 index 00000000..2814386f --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.cxx @@ -0,0 +1,881 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file complex_nested_arrays.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "complex_nested_arrays.h" +#include "complex_nested_arraysTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +ThirdLevelElement::ThirdLevelElement() +{ + // m_x com.eprosima.idl.parser.typecode.PrimitiveTypeCode@47ef968d + m_x = 0.0; + // m_y com.eprosima.idl.parser.typecode.PrimitiveTypeCode@23e028a9 + m_y = 0.0; + + // Just to register all known types + registercomplex_nested_arraysTypes(); +} + +ThirdLevelElement::~ThirdLevelElement() +{ + + +} + +ThirdLevelElement::ThirdLevelElement( + const ThirdLevelElement& x) +{ + m_x = x.m_x; + m_y = x.m_y; +} + +ThirdLevelElement::ThirdLevelElement( + ThirdLevelElement&& x) noexcept +{ + m_x = x.m_x; + m_y = x.m_y; +} + +ThirdLevelElement& ThirdLevelElement::operator =( + const ThirdLevelElement& x) +{ + + m_x = x.m_x; + m_y = x.m_y; + + return *this; +} + +ThirdLevelElement& ThirdLevelElement::operator =( + ThirdLevelElement&& x) noexcept +{ + + m_x = x.m_x; + m_y = x.m_y; + + return *this; +} + +bool ThirdLevelElement::operator ==( + const ThirdLevelElement& x) const +{ + + return (m_x == x.m_x && m_y == x.m_y); +} + +bool ThirdLevelElement::operator !=( + const ThirdLevelElement& x) const +{ + return !(*this == x); +} + +size_t ThirdLevelElement::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); + + + current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); + + + + return current_alignment - initial_alignment; +} + +size_t ThirdLevelElement::getCdrSerializedSize( + const ThirdLevelElement& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); + + + current_alignment += 8 + eprosima::fastcdr::Cdr::alignment(current_alignment, 8); + + + + return current_alignment - initial_alignment; +} + +void ThirdLevelElement::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_x; + scdr << m_y; + +} + +void ThirdLevelElement::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_x; + dcdr >> m_y; +} + +/*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ +void ThirdLevelElement::x( + double _x) +{ + m_x = _x; +} + +/*! + * @brief This function returns the value of member x + * @return Value of member x + */ +double ThirdLevelElement::x() const +{ + return m_x; +} + +/*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ +double& ThirdLevelElement::x() +{ + return m_x; +} + +/*! + * @brief This function sets a value in member y + * @param _y New value for member y + */ +void ThirdLevelElement::y( + double _y) +{ + m_y = _y; +} + +/*! + * @brief This function returns the value of member y + * @return Value of member y + */ +double ThirdLevelElement::y() const +{ + return m_y; +} + +/*! + * @brief This function returns a reference to member y + * @return Reference to member y + */ +double& ThirdLevelElement::y() +{ + return m_y; +} + + +size_t ThirdLevelElement::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + return current_align; +} + +bool ThirdLevelElement::isKeyDefined() +{ + return false; +} + +void ThirdLevelElement::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} + +SecondLevelElement::SecondLevelElement() +{ + // m_an_element_alone com.eprosima.fastdds.idl.parser.typecode.StructTypeCode@2db7a79b + + // m_a_limited_other_value com.eprosima.idl.parser.typecode.SequenceTypeCode@6950e31 + + + // Just to register all known types + registercomplex_nested_arraysTypes(); +} + +SecondLevelElement::~SecondLevelElement() +{ + + +} + +SecondLevelElement::SecondLevelElement( + const SecondLevelElement& x) +{ + m_an_element_alone = x.m_an_element_alone; + m_a_limited_other_value = x.m_a_limited_other_value; +} + +SecondLevelElement::SecondLevelElement( + SecondLevelElement&& x) noexcept +{ + m_an_element_alone = std::move(x.m_an_element_alone); + m_a_limited_other_value = std::move(x.m_a_limited_other_value); +} + +SecondLevelElement& SecondLevelElement::operator =( + const SecondLevelElement& x) +{ + + m_an_element_alone = x.m_an_element_alone; + m_a_limited_other_value = x.m_a_limited_other_value; + + return *this; +} + +SecondLevelElement& SecondLevelElement::operator =( + SecondLevelElement&& x) noexcept +{ + + m_an_element_alone = std::move(x.m_an_element_alone); + m_a_limited_other_value = std::move(x.m_a_limited_other_value); + + return *this; +} + +bool SecondLevelElement::operator ==( + const SecondLevelElement& x) const +{ + + return (m_an_element_alone == x.m_an_element_alone && m_a_limited_other_value == x.m_a_limited_other_value); +} + +bool SecondLevelElement::operator !=( + const SecondLevelElement& x) const +{ + return !(*this == x); +} + +size_t SecondLevelElement::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += ThirdLevelElement::getMaxCdrSerializedSize(current_alignment); + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + for(size_t a = 0; a < 1; ++a) + { + current_alignment += ThirdLevelElement::getMaxCdrSerializedSize(current_alignment);} + + + return current_alignment - initial_alignment; +} + +size_t SecondLevelElement::getCdrSerializedSize( + const SecondLevelElement& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += ThirdLevelElement::getCdrSerializedSize(data.an_element_alone(), current_alignment); + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + for(size_t a = 0; a < data.a_limited_other_value().size(); ++a) + { + current_alignment += ThirdLevelElement::getCdrSerializedSize(data.a_limited_other_value().at(a), current_alignment);} + + + return current_alignment - initial_alignment; +} + +void SecondLevelElement::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_an_element_alone; + scdr << m_a_limited_other_value; + +} + +void SecondLevelElement::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_an_element_alone; + dcdr >> m_a_limited_other_value; +} + +/*! + * @brief This function copies the value in member an_element_alone + * @param _an_element_alone New value to be copied in member an_element_alone + */ +void SecondLevelElement::an_element_alone( + const ThirdLevelElement& _an_element_alone) +{ + m_an_element_alone = _an_element_alone; +} + +/*! + * @brief This function moves the value in member an_element_alone + * @param _an_element_alone New value to be moved in member an_element_alone + */ +void SecondLevelElement::an_element_alone( + ThirdLevelElement&& _an_element_alone) +{ + m_an_element_alone = std::move(_an_element_alone); +} + +/*! + * @brief This function returns a constant reference to member an_element_alone + * @return Constant reference to member an_element_alone + */ +const ThirdLevelElement& SecondLevelElement::an_element_alone() const +{ + return m_an_element_alone; +} + +/*! + * @brief This function returns a reference to member an_element_alone + * @return Reference to member an_element_alone + */ +ThirdLevelElement& SecondLevelElement::an_element_alone() +{ + return m_an_element_alone; +} +/*! + * @brief This function copies the value in member a_limited_other_value + * @param _a_limited_other_value New value to be copied in member a_limited_other_value + */ +void SecondLevelElement::a_limited_other_value( + const std::vector& _a_limited_other_value) +{ + m_a_limited_other_value = _a_limited_other_value; +} + +/*! + * @brief This function moves the value in member a_limited_other_value + * @param _a_limited_other_value New value to be moved in member a_limited_other_value + */ +void SecondLevelElement::a_limited_other_value( + std::vector&& _a_limited_other_value) +{ + m_a_limited_other_value = std::move(_a_limited_other_value); +} + +/*! + * @brief This function returns a constant reference to member a_limited_other_value + * @return Constant reference to member a_limited_other_value + */ +const std::vector& SecondLevelElement::a_limited_other_value() const +{ + return m_a_limited_other_value; +} + +/*! + * @brief This function returns a reference to member a_limited_other_value + * @return Reference to member a_limited_other_value + */ +std::vector& SecondLevelElement::a_limited_other_value() +{ + return m_a_limited_other_value; +} + +size_t SecondLevelElement::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + return current_align; +} + +bool SecondLevelElement::isKeyDefined() +{ + return false; +} + +void SecondLevelElement::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} + +FirstLevelElement::FirstLevelElement() +{ + // m_useless_name com.eprosima.idl.parser.typecode.StringTypeCode@5891e32e + m_useless_name =""; + // m_sub com.eprosima.idl.parser.typecode.SequenceTypeCode@cb0ed20 + + // m_an_element_alone com.eprosima.fastdds.idl.parser.typecode.StructTypeCode@2db7a79b + + + // Just to register all known types + registercomplex_nested_arraysTypes(); +} + +FirstLevelElement::~FirstLevelElement() +{ + + + +} + +FirstLevelElement::FirstLevelElement( + const FirstLevelElement& x) +{ + m_useless_name = x.m_useless_name; + m_sub = x.m_sub; + m_an_element_alone = x.m_an_element_alone; +} + +FirstLevelElement::FirstLevelElement( + FirstLevelElement&& x) noexcept +{ + m_useless_name = std::move(x.m_useless_name); + m_sub = std::move(x.m_sub); + m_an_element_alone = std::move(x.m_an_element_alone); +} + +FirstLevelElement& FirstLevelElement::operator =( + const FirstLevelElement& x) +{ + + m_useless_name = x.m_useless_name; + m_sub = x.m_sub; + m_an_element_alone = x.m_an_element_alone; + + return *this; +} + +FirstLevelElement& FirstLevelElement::operator =( + FirstLevelElement&& x) noexcept +{ + + m_useless_name = std::move(x.m_useless_name); + m_sub = std::move(x.m_sub); + m_an_element_alone = std::move(x.m_an_element_alone); + + return *this; +} + +bool FirstLevelElement::operator ==( + const FirstLevelElement& x) const +{ + + return (m_useless_name == x.m_useless_name && m_sub == x.m_sub && m_an_element_alone == x.m_an_element_alone); +} + +bool FirstLevelElement::operator !=( + const FirstLevelElement& x) const +{ + return !(*this == x); +} + +size_t FirstLevelElement::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + for(size_t a = 0; a < 100; ++a) + { + current_alignment += SecondLevelElement::getMaxCdrSerializedSize(current_alignment);} + + current_alignment += ThirdLevelElement::getMaxCdrSerializedSize(current_alignment); + + return current_alignment - initial_alignment; +} + +size_t FirstLevelElement::getCdrSerializedSize( + const FirstLevelElement& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.useless_name().size() + 1; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + for(size_t a = 0; a < data.sub().size(); ++a) + { + current_alignment += SecondLevelElement::getCdrSerializedSize(data.sub().at(a), current_alignment);} + + current_alignment += ThirdLevelElement::getCdrSerializedSize(data.an_element_alone(), current_alignment); + + return current_alignment - initial_alignment; +} + +void FirstLevelElement::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_useless_name.c_str(); + scdr << m_sub; + scdr << m_an_element_alone; + +} + +void FirstLevelElement::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_useless_name; + dcdr >> m_sub; + dcdr >> m_an_element_alone; +} + +/*! + * @brief This function copies the value in member useless_name + * @param _useless_name New value to be copied in member useless_name + */ +void FirstLevelElement::useless_name( + const std::string& _useless_name) +{ + m_useless_name = _useless_name; +} + +/*! + * @brief This function moves the value in member useless_name + * @param _useless_name New value to be moved in member useless_name + */ +void FirstLevelElement::useless_name( + std::string&& _useless_name) +{ + m_useless_name = std::move(_useless_name); +} + +/*! + * @brief This function returns a constant reference to member useless_name + * @return Constant reference to member useless_name + */ +const std::string& FirstLevelElement::useless_name() const +{ + return m_useless_name; +} + +/*! + * @brief This function returns a reference to member useless_name + * @return Reference to member useless_name + */ +std::string& FirstLevelElement::useless_name() +{ + return m_useless_name; +} +/*! + * @brief This function copies the value in member sub + * @param _sub New value to be copied in member sub + */ +void FirstLevelElement::sub( + const std::vector& _sub) +{ + m_sub = _sub; +} + +/*! + * @brief This function moves the value in member sub + * @param _sub New value to be moved in member sub + */ +void FirstLevelElement::sub( + std::vector&& _sub) +{ + m_sub = std::move(_sub); +} + +/*! + * @brief This function returns a constant reference to member sub + * @return Constant reference to member sub + */ +const std::vector& FirstLevelElement::sub() const +{ + return m_sub; +} + +/*! + * @brief This function returns a reference to member sub + * @return Reference to member sub + */ +std::vector& FirstLevelElement::sub() +{ + return m_sub; +} +/*! + * @brief This function copies the value in member an_element_alone + * @param _an_element_alone New value to be copied in member an_element_alone + */ +void FirstLevelElement::an_element_alone( + const ThirdLevelElement& _an_element_alone) +{ + m_an_element_alone = _an_element_alone; +} + +/*! + * @brief This function moves the value in member an_element_alone + * @param _an_element_alone New value to be moved in member an_element_alone + */ +void FirstLevelElement::an_element_alone( + ThirdLevelElement&& _an_element_alone) +{ + m_an_element_alone = std::move(_an_element_alone); +} + +/*! + * @brief This function returns a constant reference to member an_element_alone + * @return Constant reference to member an_element_alone + */ +const ThirdLevelElement& FirstLevelElement::an_element_alone() const +{ + return m_an_element_alone; +} + +/*! + * @brief This function returns a reference to member an_element_alone + * @return Reference to member an_element_alone + */ +ThirdLevelElement& FirstLevelElement::an_element_alone() +{ + return m_an_element_alone; +} + +size_t FirstLevelElement::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + + return current_align; +} + +bool FirstLevelElement::isKeyDefined() +{ + return false; +} + +void FirstLevelElement::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} + +complex_nested_arrays::complex_nested_arrays() +{ + // m_array_of_elements com.eprosima.idl.parser.typecode.ArrayTypeCode@1fc2b765 + + + // Just to register all known types + registercomplex_nested_arraysTypes(); +} + +complex_nested_arrays::~complex_nested_arrays() +{ +} + +complex_nested_arrays::complex_nested_arrays( + const complex_nested_arrays& x) +{ + m_array_of_elements = x.m_array_of_elements; +} + +complex_nested_arrays::complex_nested_arrays( + complex_nested_arrays&& x) noexcept +{ + m_array_of_elements = std::move(x.m_array_of_elements); +} + +complex_nested_arrays& complex_nested_arrays::operator =( + const complex_nested_arrays& x) +{ + + m_array_of_elements = x.m_array_of_elements; + + return *this; +} + +complex_nested_arrays& complex_nested_arrays::operator =( + complex_nested_arrays&& x) noexcept +{ + + m_array_of_elements = std::move(x.m_array_of_elements); + + return *this; +} + +bool complex_nested_arrays::operator ==( + const complex_nested_arrays& x) const +{ + + return (m_array_of_elements == x.m_array_of_elements); +} + +bool complex_nested_arrays::operator !=( + const complex_nested_arrays& x) const +{ + return !(*this == x); +} + +size_t complex_nested_arrays::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + + for(size_t a = 0; a < (3); ++a) + { + current_alignment += FirstLevelElement::getMaxCdrSerializedSize(current_alignment);} + return current_alignment - initial_alignment; +} + +size_t complex_nested_arrays::getCdrSerializedSize( + const complex_nested_arrays& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + + for(size_t a = 0; a < data.array_of_elements().size(); ++a) + { + current_alignment += FirstLevelElement::getCdrSerializedSize(data.array_of_elements().at(a), current_alignment); + } + return current_alignment - initial_alignment; +} + +void complex_nested_arrays::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_array_of_elements; + + +} + +void complex_nested_arrays::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_array_of_elements; + +} + +/*! + * @brief This function copies the value in member array_of_elements + * @param _array_of_elements New value to be copied in member array_of_elements + */ +void complex_nested_arrays::array_of_elements( + const std::array& _array_of_elements) +{ + m_array_of_elements = _array_of_elements; +} + +/*! + * @brief This function moves the value in member array_of_elements + * @param _array_of_elements New value to be moved in member array_of_elements + */ +void complex_nested_arrays::array_of_elements( + std::array&& _array_of_elements) +{ + m_array_of_elements = std::move(_array_of_elements); +} + +/*! + * @brief This function returns a constant reference to member array_of_elements + * @return Constant reference to member array_of_elements + */ +const std::array& complex_nested_arrays::array_of_elements() const +{ + return m_array_of_elements; +} + +/*! + * @brief This function returns a reference to member array_of_elements + * @return Reference to member array_of_elements + */ +std::array& complex_nested_arrays::array_of_elements() +{ + return m_array_of_elements; +} + +size_t complex_nested_arrays::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + return current_align; +} + +bool complex_nested_arrays::isKeyDefined() +{ + return false; +} + +void complex_nested_arrays::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.h new file mode 100644 index 00000000..dd1b58ff --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arrays.h @@ -0,0 +1,747 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file complex_nested_arrays.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ +#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(complex_nested_arrays_SOURCE) +#define complex_nested_arrays_DllAPI __declspec( dllexport ) +#else +#define complex_nested_arrays_DllAPI __declspec( dllimport ) +#endif // complex_nested_arrays_SOURCE +#else +#define complex_nested_arrays_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define complex_nested_arrays_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure ThirdLevelElement defined by the user in the IDL file. + * @ingroup COMPLEX_NESTED_ARRAYS + */ +class ThirdLevelElement +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport ThirdLevelElement(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~ThirdLevelElement(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object ThirdLevelElement that will be copied. + */ + eProsima_user_DllExport ThirdLevelElement( + const ThirdLevelElement& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object ThirdLevelElement that will be copied. + */ + eProsima_user_DllExport ThirdLevelElement( + ThirdLevelElement&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object ThirdLevelElement that will be copied. + */ + eProsima_user_DllExport ThirdLevelElement& operator =( + const ThirdLevelElement& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object ThirdLevelElement that will be copied. + */ + eProsima_user_DllExport ThirdLevelElement& operator =( + ThirdLevelElement&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x ThirdLevelElement object to compare. + */ + eProsima_user_DllExport bool operator ==( + const ThirdLevelElement& x) const; + + /*! + * @brief Comparison operator. + * @param x ThirdLevelElement object to compare. + */ + eProsima_user_DllExport bool operator !=( + const ThirdLevelElement& x) const; + + /*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ + eProsima_user_DllExport void x( + double _x); + + /*! + * @brief This function returns the value of member x + * @return Value of member x + */ + eProsima_user_DllExport double x() const; + + /*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ + eProsima_user_DllExport double& x(); + + /*! + * @brief This function sets a value in member y + * @param _y New value for member y + */ + eProsima_user_DllExport void y( + double _y); + + /*! + * @brief This function returns the value of member y + * @return Value of member y + */ + eProsima_user_DllExport double y() const; + + /*! + * @brief This function returns a reference to member y + * @return Reference to member y + */ + eProsima_user_DllExport double& y(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const ThirdLevelElement& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + double m_x; + double m_y; +}; +/*! + * @brief This class represents the structure SecondLevelElement defined by the user in the IDL file. + * @ingroup COMPLEX_NESTED_ARRAYS + */ +class SecondLevelElement +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport SecondLevelElement(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~SecondLevelElement(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object SecondLevelElement that will be copied. + */ + eProsima_user_DllExport SecondLevelElement( + const SecondLevelElement& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object SecondLevelElement that will be copied. + */ + eProsima_user_DllExport SecondLevelElement( + SecondLevelElement&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object SecondLevelElement that will be copied. + */ + eProsima_user_DllExport SecondLevelElement& operator =( + const SecondLevelElement& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object SecondLevelElement that will be copied. + */ + eProsima_user_DllExport SecondLevelElement& operator =( + SecondLevelElement&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x SecondLevelElement object to compare. + */ + eProsima_user_DllExport bool operator ==( + const SecondLevelElement& x) const; + + /*! + * @brief Comparison operator. + * @param x SecondLevelElement object to compare. + */ + eProsima_user_DllExport bool operator !=( + const SecondLevelElement& x) const; + + /*! + * @brief This function copies the value in member an_element_alone + * @param _an_element_alone New value to be copied in member an_element_alone + */ + eProsima_user_DllExport void an_element_alone( + const ThirdLevelElement& _an_element_alone); + + /*! + * @brief This function moves the value in member an_element_alone + * @param _an_element_alone New value to be moved in member an_element_alone + */ + eProsima_user_DllExport void an_element_alone( + ThirdLevelElement&& _an_element_alone); + + /*! + * @brief This function returns a constant reference to member an_element_alone + * @return Constant reference to member an_element_alone + */ + eProsima_user_DllExport const ThirdLevelElement& an_element_alone() const; + + /*! + * @brief This function returns a reference to member an_element_alone + * @return Reference to member an_element_alone + */ + eProsima_user_DllExport ThirdLevelElement& an_element_alone(); + /*! + * @brief This function copies the value in member a_limited_other_value + * @param _a_limited_other_value New value to be copied in member a_limited_other_value + */ + eProsima_user_DllExport void a_limited_other_value( + const std::vector& _a_limited_other_value); + + /*! + * @brief This function moves the value in member a_limited_other_value + * @param _a_limited_other_value New value to be moved in member a_limited_other_value + */ + eProsima_user_DllExport void a_limited_other_value( + std::vector&& _a_limited_other_value); + + /*! + * @brief This function returns a constant reference to member a_limited_other_value + * @return Constant reference to member a_limited_other_value + */ + eProsima_user_DllExport const std::vector& a_limited_other_value() const; + + /*! + * @brief This function returns a reference to member a_limited_other_value + * @return Reference to member a_limited_other_value + */ + eProsima_user_DllExport std::vector& a_limited_other_value(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const SecondLevelElement& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + ThirdLevelElement m_an_element_alone; + std::vector m_a_limited_other_value; +}; +/*! + * @brief This class represents the structure FirstLevelElement defined by the user in the IDL file. + * @ingroup COMPLEX_NESTED_ARRAYS + */ +class FirstLevelElement +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport FirstLevelElement(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~FirstLevelElement(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object FirstLevelElement that will be copied. + */ + eProsima_user_DllExport FirstLevelElement( + const FirstLevelElement& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object FirstLevelElement that will be copied. + */ + eProsima_user_DllExport FirstLevelElement( + FirstLevelElement&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object FirstLevelElement that will be copied. + */ + eProsima_user_DllExport FirstLevelElement& operator =( + const FirstLevelElement& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object FirstLevelElement that will be copied. + */ + eProsima_user_DllExport FirstLevelElement& operator =( + FirstLevelElement&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x FirstLevelElement object to compare. + */ + eProsima_user_DllExport bool operator ==( + const FirstLevelElement& x) const; + + /*! + * @brief Comparison operator. + * @param x FirstLevelElement object to compare. + */ + eProsima_user_DllExport bool operator !=( + const FirstLevelElement& x) const; + + /*! + * @brief This function copies the value in member useless_name + * @param _useless_name New value to be copied in member useless_name + */ + eProsima_user_DllExport void useless_name( + const std::string& _useless_name); + + /*! + * @brief This function moves the value in member useless_name + * @param _useless_name New value to be moved in member useless_name + */ + eProsima_user_DllExport void useless_name( + std::string&& _useless_name); + + /*! + * @brief This function returns a constant reference to member useless_name + * @return Constant reference to member useless_name + */ + eProsima_user_DllExport const std::string& useless_name() const; + + /*! + * @brief This function returns a reference to member useless_name + * @return Reference to member useless_name + */ + eProsima_user_DllExport std::string& useless_name(); + /*! + * @brief This function copies the value in member sub + * @param _sub New value to be copied in member sub + */ + eProsima_user_DllExport void sub( + const std::vector& _sub); + + /*! + * @brief This function moves the value in member sub + * @param _sub New value to be moved in member sub + */ + eProsima_user_DllExport void sub( + std::vector&& _sub); + + /*! + * @brief This function returns a constant reference to member sub + * @return Constant reference to member sub + */ + eProsima_user_DllExport const std::vector& sub() const; + + /*! + * @brief This function returns a reference to member sub + * @return Reference to member sub + */ + eProsima_user_DllExport std::vector& sub(); + /*! + * @brief This function copies the value in member an_element_alone + * @param _an_element_alone New value to be copied in member an_element_alone + */ + eProsima_user_DllExport void an_element_alone( + const ThirdLevelElement& _an_element_alone); + + /*! + * @brief This function moves the value in member an_element_alone + * @param _an_element_alone New value to be moved in member an_element_alone + */ + eProsima_user_DllExport void an_element_alone( + ThirdLevelElement&& _an_element_alone); + + /*! + * @brief This function returns a constant reference to member an_element_alone + * @return Constant reference to member an_element_alone + */ + eProsima_user_DllExport const ThirdLevelElement& an_element_alone() const; + + /*! + * @brief This function returns a reference to member an_element_alone + * @return Reference to member an_element_alone + */ + eProsima_user_DllExport ThirdLevelElement& an_element_alone(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const FirstLevelElement& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + std::string m_useless_name; + std::vector m_sub; + ThirdLevelElement m_an_element_alone; +}; +/*! + * @brief This class represents the structure complex_nested_arrays defined by the user in the IDL file. + * @ingroup COMPLEX_NESTED_ARRAYS + */ +class complex_nested_arrays +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport complex_nested_arrays(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~complex_nested_arrays(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object complex_nested_arrays that will be copied. + */ + eProsima_user_DllExport complex_nested_arrays( + const complex_nested_arrays& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object complex_nested_arrays that will be copied. + */ + eProsima_user_DllExport complex_nested_arrays( + complex_nested_arrays&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object complex_nested_arrays that will be copied. + */ + eProsima_user_DllExport complex_nested_arrays& operator =( + const complex_nested_arrays& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object complex_nested_arrays that will be copied. + */ + eProsima_user_DllExport complex_nested_arrays& operator =( + complex_nested_arrays&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x complex_nested_arrays object to compare. + */ + eProsima_user_DllExport bool operator ==( + const complex_nested_arrays& x) const; + + /*! + * @brief Comparison operator. + * @param x complex_nested_arrays object to compare. + */ + eProsima_user_DllExport bool operator !=( + const complex_nested_arrays& x) const; + + /*! + * @brief This function copies the value in member array_of_elements + * @param _array_of_elements New value to be copied in member array_of_elements + */ + eProsima_user_DllExport void array_of_elements( + const std::array& _array_of_elements); + + /*! + * @brief This function moves the value in member array_of_elements + * @param _array_of_elements New value to be moved in member array_of_elements + */ + eProsima_user_DllExport void array_of_elements( + std::array&& _array_of_elements); + + /*! + * @brief This function returns a constant reference to member array_of_elements + * @return Constant reference to member array_of_elements + */ + eProsima_user_DllExport const std::array& array_of_elements() const; + + /*! + * @brief This function returns a reference to member array_of_elements + * @return Reference to member array_of_elements + */ + eProsima_user_DllExport std::array& array_of_elements(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const complex_nested_arrays& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + std::array m_array_of_elements; +}; + +#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.cxx new file mode 100644 index 00000000..1b7c758f --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.cxx @@ -0,0 +1,589 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file complex_nested_arraysPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "complex_nested_arraysPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +ThirdLevelElementPubSubType::ThirdLevelElementPubSubType() +{ + setName("ThirdLevelElement"); + auto type_size = ThirdLevelElement::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = ThirdLevelElement::isKeyDefined(); + size_t keyLength = ThirdLevelElement::getKeyMaxCdrSerializedSize() > 16 ? + ThirdLevelElement::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +ThirdLevelElementPubSubType::~ThirdLevelElementPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool ThirdLevelElementPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + ThirdLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool ThirdLevelElementPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + ThirdLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function ThirdLevelElementPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* ThirdLevelElementPubSubType::createData() +{ + return reinterpret_cast(new ThirdLevelElement()); +} + +void ThirdLevelElementPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool ThirdLevelElementPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + ThirdLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + ThirdLevelElement::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || ThirdLevelElement::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} + +SecondLevelElementPubSubType::SecondLevelElementPubSubType() +{ + setName("SecondLevelElement"); + auto type_size = SecondLevelElement::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = SecondLevelElement::isKeyDefined(); + size_t keyLength = SecondLevelElement::getKeyMaxCdrSerializedSize() > 16 ? + SecondLevelElement::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +SecondLevelElementPubSubType::~SecondLevelElementPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool SecondLevelElementPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + SecondLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool SecondLevelElementPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + SecondLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function SecondLevelElementPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* SecondLevelElementPubSubType::createData() +{ + return reinterpret_cast(new SecondLevelElement()); +} + +void SecondLevelElementPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool SecondLevelElementPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + SecondLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + SecondLevelElement::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || SecondLevelElement::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} + +FirstLevelElementPubSubType::FirstLevelElementPubSubType() +{ + setName("FirstLevelElement"); + auto type_size = FirstLevelElement::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = FirstLevelElement::isKeyDefined(); + size_t keyLength = FirstLevelElement::getKeyMaxCdrSerializedSize() > 16 ? + FirstLevelElement::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +FirstLevelElementPubSubType::~FirstLevelElementPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool FirstLevelElementPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + FirstLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool FirstLevelElementPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + FirstLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function FirstLevelElementPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* FirstLevelElementPubSubType::createData() +{ + return reinterpret_cast(new FirstLevelElement()); +} + +void FirstLevelElementPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool FirstLevelElementPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + FirstLevelElement* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + FirstLevelElement::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || FirstLevelElement::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} + +complex_nested_arraysPubSubType::complex_nested_arraysPubSubType() +{ + setName("complex_nested_arrays"); + auto type_size = complex_nested_arrays::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = complex_nested_arrays::isKeyDefined(); + size_t keyLength = complex_nested_arrays::getKeyMaxCdrSerializedSize() > 16 ? + complex_nested_arrays::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +complex_nested_arraysPubSubType::~complex_nested_arraysPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool complex_nested_arraysPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + complex_nested_arrays* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool complex_nested_arraysPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + complex_nested_arrays* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function complex_nested_arraysPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* complex_nested_arraysPubSubType::createData() +{ + return reinterpret_cast(new complex_nested_arrays()); +} + +void complex_nested_arraysPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool complex_nested_arraysPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + complex_nested_arrays* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + complex_nested_arrays::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || complex_nested_arrays::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.h new file mode 100644 index 00000000..93e214af --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysPubSubTypes.h @@ -0,0 +1,293 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file complex_nested_arraysPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_H_ + +#include +#include + +#include "complex_nested_arrays.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated complex_nested_arrays is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +/*! + * @brief This class represents the TopicDataType of the type ThirdLevelElement defined by the user in the IDL file. + * @ingroup COMPLEX_NESTED_ARRAYS + */ +class ThirdLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef ThirdLevelElement type; + + eProsima_user_DllExport ThirdLevelElementPubSubType(); + + eProsima_user_DllExport virtual ~ThirdLevelElementPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + new (memory) ThirdLevelElement(); + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; +/*! + * @brief This class represents the TopicDataType of the type SecondLevelElement defined by the user in the IDL file. + * @ingroup COMPLEX_NESTED_ARRAYS + */ +class SecondLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef SecondLevelElement type; + + eProsima_user_DllExport SecondLevelElementPubSubType(); + + eProsima_user_DllExport virtual ~SecondLevelElementPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + (void)memory; + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; +/*! + * @brief This class represents the TopicDataType of the type FirstLevelElement defined by the user in the IDL file. + * @ingroup COMPLEX_NESTED_ARRAYS + */ +class FirstLevelElementPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef FirstLevelElement type; + + eProsima_user_DllExport FirstLevelElementPubSubType(); + + eProsima_user_DllExport virtual ~FirstLevelElementPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + (void)memory; + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; +/*! + * @brief This class represents the TopicDataType of the type complex_nested_arrays defined by the user in the IDL file. + * @ingroup COMPLEX_NESTED_ARRAYS + */ +class complex_nested_arraysPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef complex_nested_arrays type; + + eProsima_user_DllExport complex_nested_arraysPubSubType(); + + eProsima_user_DllExport virtual ~complex_nested_arraysPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + (void)memory; + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.cxx new file mode 100644 index 00000000..2862811e --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.cxx @@ -0,0 +1,856 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file complex_nested_arraysTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "complex_nested_arrays.h" +#include "complex_nested_arraysTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registercomplex_nested_arraysTypes() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("ThirdLevelElement", GetThirdLevelElementIdentifier(true), + GetThirdLevelElementObject(true)); + factory->add_type_object("ThirdLevelElement", GetThirdLevelElementIdentifier(false), + GetThirdLevelElementObject(false)); + + factory->add_type_object("SecondLevelElement", GetSecondLevelElementIdentifier(true), + GetSecondLevelElementObject(true)); + factory->add_type_object("SecondLevelElement", GetSecondLevelElementIdentifier(false), + GetSecondLevelElementObject(false)); + + factory->add_type_object("FirstLevelElement", GetFirstLevelElementIdentifier(true), + GetFirstLevelElementObject(true)); + factory->add_type_object("FirstLevelElement", GetFirstLevelElementIdentifier(false), + GetFirstLevelElementObject(false)); + + factory->add_type_object("complex_nested_arrays", Getcomplex_nested_arraysIdentifier(true), + Getcomplex_nested_arraysObject(true)); + factory->add_type_object("complex_nested_arrays", Getcomplex_nested_arraysIdentifier(false), + Getcomplex_nested_arraysObject(false)); + +} + +const TypeIdentifier* GetThirdLevelElementIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("ThirdLevelElement", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetThirdLevelElementObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("ThirdLevelElement", complete); +} + +const TypeObject* GetThirdLevelElementObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteThirdLevelElementObject(); + } + //else + return GetMinimalThirdLevelElementObject(); +} + +const TypeObject* GetMinimalThirdLevelElementObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_x; + mst_x.common().member_id(memberId++); + mst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_x.common().member_flags().IS_OPTIONAL(false); + mst_x.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_x.common().member_flags().IS_KEY(false); + mst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); + + MD5 x_hash("x"); + for(int i = 0; i < 4; ++i) + { + mst_x.detail().name_hash()[i] = x_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_x); + + MinimalStructMember mst_y; + mst_y.common().member_id(memberId++); + mst_y.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_y.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_y.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_y.common().member_flags().IS_OPTIONAL(false); + mst_y.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_y.common().member_flags().IS_KEY(false); + mst_y.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_y.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); + + MD5 y_hash("y"); + for(int i = 0; i < 4; ++i) + { + mst_y.detail().name_hash()[i] = y_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_y); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("ThirdLevelElement", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", false); +} + +const TypeObject* GetCompleteThirdLevelElementObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_x; + cst_x.common().member_id(memberId++); + cst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_x.common().member_flags().IS_OPTIONAL(false); + cst_x.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_x.common().member_flags().IS_KEY(false); + cst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); + + cst_x.detail().name("x"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_x); + + CompleteStructMember cst_y; + cst_y.common().member_id(memberId++); + cst_y.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_y.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_y.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_y.common().member_flags().IS_OPTIONAL(false); + cst_y.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_y.common().member_flags().IS_KEY(false); + cst_y.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_y.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("double", false)); + + cst_y.detail().name("y"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_y); + + + // Header + type_object->complete().struct_type().header().detail().type_name("ThirdLevelElement"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("ThirdLevelElement", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("ThirdLevelElement", true); +} + +const TypeIdentifier* GetSecondLevelElementIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("SecondLevelElement", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetSecondLevelElementObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("SecondLevelElement", complete); +} + +const TypeObject* GetSecondLevelElementObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteSecondLevelElementObject(); + } + //else + return GetMinimalSecondLevelElementObject(); +} + +const TypeObject* GetMinimalSecondLevelElementObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_an_element_alone; + mst_an_element_alone.common().member_id(memberId++); + mst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_an_element_alone.common().member_flags().IS_OPTIONAL(false); + mst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_an_element_alone.common().member_flags().IS_KEY(false); + mst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(false)); + MD5 an_element_alone_hash("an_element_alone"); + for(int i = 0; i < 4; ++i) + { + mst_an_element_alone.detail().name_hash()[i] = an_element_alone_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_an_element_alone); + + MinimalStructMember mst_a_limited_other_value; + mst_a_limited_other_value.common().member_id(memberId++); + mst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_a_limited_other_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_a_limited_other_value.common().member_flags().IS_OPTIONAL(false); + mst_a_limited_other_value.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_a_limited_other_value.common().member_flags().IS_KEY(false); + mst_a_limited_other_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_a_limited_other_value.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("ThirdLevelElement", 1, false)); + + + MD5 a_limited_other_value_hash("a_limited_other_value"); + for(int i = 0; i < 4; ++i) + { + mst_a_limited_other_value.detail().name_hash()[i] = a_limited_other_value_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_a_limited_other_value); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("SecondLevelElement", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", false); +} + +const TypeObject* GetCompleteSecondLevelElementObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_an_element_alone; + cst_an_element_alone.common().member_id(memberId++); + cst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_an_element_alone.common().member_flags().IS_OPTIONAL(false); + cst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_an_element_alone.common().member_flags().IS_KEY(false); + cst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(true)); + cst_an_element_alone.detail().name("an_element_alone"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_an_element_alone); + + CompleteStructMember cst_a_limited_other_value; + cst_a_limited_other_value.common().member_id(memberId++); + cst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_a_limited_other_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_a_limited_other_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_a_limited_other_value.common().member_flags().IS_OPTIONAL(false); + cst_a_limited_other_value.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_a_limited_other_value.common().member_flags().IS_KEY(false); + cst_a_limited_other_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_a_limited_other_value.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("ThirdLevelElement", 1, true)); + + + cst_a_limited_other_value.detail().name("a_limited_other_value"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_a_limited_other_value); + + + // Header + type_object->complete().struct_type().header().detail().type_name("SecondLevelElement"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("SecondLevelElement", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("SecondLevelElement", true); +} + +const TypeIdentifier* GetFirstLevelElementIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("FirstLevelElement", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetFirstLevelElementObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("FirstLevelElement", complete); +} + +const TypeObject* GetFirstLevelElementObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteFirstLevelElementObject(); + } + //else + return GetMinimalFirstLevelElementObject(); +} + +const TypeObject* GetMinimalFirstLevelElementObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_useless_name; + mst_useless_name.common().member_id(memberId++); + mst_useless_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_useless_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_useless_name.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_useless_name.common().member_flags().IS_OPTIONAL(false); + mst_useless_name.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_useless_name.common().member_flags().IS_KEY(false); + mst_useless_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_useless_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); + + + MD5 useless_name_hash("useless_name"); + for(int i = 0; i < 4; ++i) + { + mst_useless_name.detail().name_hash()[i] = useless_name_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_useless_name); + + MinimalStructMember mst_sub; + mst_sub.common().member_id(memberId++); + mst_sub.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_sub.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_sub.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_sub.common().member_flags().IS_OPTIONAL(false); + mst_sub.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_sub.common().member_flags().IS_KEY(false); + mst_sub.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_sub.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("SecondLevelElement", 0, false)); + + + MD5 sub_hash("sub"); + for(int i = 0; i < 4; ++i) + { + mst_sub.detail().name_hash()[i] = sub_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_sub); + + MinimalStructMember mst_an_element_alone; + mst_an_element_alone.common().member_id(memberId++); + mst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_an_element_alone.common().member_flags().IS_OPTIONAL(false); + mst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_an_element_alone.common().member_flags().IS_KEY(false); + mst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(false)); + MD5 an_element_alone_hash("an_element_alone"); + for(int i = 0; i < 4; ++i) + { + mst_an_element_alone.detail().name_hash()[i] = an_element_alone_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_an_element_alone); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("FirstLevelElement", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", false); +} + +const TypeObject* GetCompleteFirstLevelElementObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_useless_name; + cst_useless_name.common().member_id(memberId++); + cst_useless_name.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_useless_name.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_useless_name.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_useless_name.common().member_flags().IS_OPTIONAL(false); + cst_useless_name.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_useless_name.common().member_flags().IS_KEY(false); + cst_useless_name.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_useless_name.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); + + + cst_useless_name.detail().name("useless_name"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_useless_name); + + CompleteStructMember cst_sub; + cst_sub.common().member_id(memberId++); + cst_sub.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_sub.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_sub.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_sub.common().member_flags().IS_OPTIONAL(false); + cst_sub.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_sub.common().member_flags().IS_KEY(false); + cst_sub.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_sub.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("SecondLevelElement", 0, true)); + + + cst_sub.detail().name("sub"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_sub); + + CompleteStructMember cst_an_element_alone; + cst_an_element_alone.common().member_id(memberId++); + cst_an_element_alone.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_an_element_alone.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_an_element_alone.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_an_element_alone.common().member_flags().IS_OPTIONAL(false); + cst_an_element_alone.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_an_element_alone.common().member_flags().IS_KEY(false); + cst_an_element_alone.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_an_element_alone.common().member_type_id(*GetThirdLevelElementIdentifier(true)); + cst_an_element_alone.detail().name("an_element_alone"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_an_element_alone); + + + // Header + type_object->complete().struct_type().header().detail().type_name("FirstLevelElement"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("FirstLevelElement", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("FirstLevelElement", true); +} + +const TypeIdentifier* Getcomplex_nested_arraysIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("complex_nested_arrays", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getcomplex_nested_arraysObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("complex_nested_arrays", complete); +} + +const TypeObject* Getcomplex_nested_arraysObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompletecomplex_nested_arraysObject(); + } + //else + return GetMinimalcomplex_nested_arraysObject(); +} + +const TypeObject* GetMinimalcomplex_nested_arraysObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_array_of_elements; + mst_array_of_elements.common().member_id(memberId++); + mst_array_of_elements.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_array_of_elements.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_array_of_elements.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_array_of_elements.common().member_flags().IS_OPTIONAL(false); + mst_array_of_elements.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_array_of_elements.common().member_flags().IS_KEY(false); + mst_array_of_elements.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_array_of_elements.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("FirstLevelElement", {3}, false)); + + + MD5 array_of_elements_hash("array_of_elements"); + for(int i = 0; i < 4; ++i) + { + mst_array_of_elements.detail().name_hash()[i] = array_of_elements_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_array_of_elements); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("complex_nested_arrays", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", false); +} + +const TypeObject* GetCompletecomplex_nested_arraysObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_array_of_elements; + cst_array_of_elements.common().member_id(memberId++); + cst_array_of_elements.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_array_of_elements.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_array_of_elements.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_array_of_elements.common().member_flags().IS_OPTIONAL(false); + cst_array_of_elements.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_array_of_elements.common().member_flags().IS_KEY(false); + cst_array_of_elements.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_array_of_elements.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("FirstLevelElement", {3}, true)); + + + cst_array_of_elements.detail().name("array_of_elements"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_array_of_elements); + + + // Header + type_object->complete().struct_type().header().detail().type_name("complex_nested_arrays"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("complex_nested_arrays", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("complex_nested_arrays", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.h new file mode 100644 index 00000000..6f071275 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/complex_nested_arraysTypeObject.h @@ -0,0 +1,86 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file complex_nested_arraysTypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define eProsima_user_DllExport +#endif // if defined(_WIN32) + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(complex_nested_arrays_SOURCE) +#define complex_nested_arrays_DllAPI __declspec( dllexport ) +#else +#define complex_nested_arrays_DllAPI __declspec( dllimport ) +#endif // complex_nested_arrays_SOURCE +#else +#define complex_nested_arrays_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define complex_nested_arrays_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registercomplex_nested_arraysTypes(); + +eProsima_user_DllExport const TypeIdentifier* GetThirdLevelElementIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetThirdLevelElementObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalThirdLevelElementObject(); +eProsima_user_DllExport const TypeObject* GetCompleteThirdLevelElementObject(); + +eProsima_user_DllExport const TypeIdentifier* GetSecondLevelElementIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetSecondLevelElementObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalSecondLevelElementObject(); +eProsima_user_DllExport const TypeObject* GetCompleteSecondLevelElementObject(); + +eProsima_user_DllExport const TypeIdentifier* GetFirstLevelElementIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetFirstLevelElementObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalFirstLevelElementObject(); +eProsima_user_DllExport const TypeObject* GetCompleteFirstLevelElementObject(); + +eProsima_user_DllExport const TypeIdentifier* Getcomplex_nested_arraysIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* Getcomplex_nested_arraysObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalcomplex_nested_arraysObject(); +eProsima_user_DllExport const TypeObject* GetCompletecomplex_nested_arraysObject(); + + +#endif // _FAST_DDS_GENERATED_COMPLEX_NESTED_ARRAYS_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.cxx new file mode 100644 index 00000000..92a88b0a --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.cxx @@ -0,0 +1,229 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file enum_struct.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "enum_struct.h" +#include "enum_structTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +#define enum_struct_max_cdr_typesize 8ULL; + +#define enum_struct_max_key_cdr_typesize 0ULL; + + + +enum_struct::enum_struct() +{ + // unsigned long m_index + m_index = 0; + // ColorEnum m_enum_value + m_enum_value = ::RED; + + // Just to register all known types + registerenum_structTypes(); +} + +enum_struct::~enum_struct() +{ + + +} + +enum_struct::enum_struct( + const enum_struct& x) +{ + m_index = x.m_index; + m_enum_value = x.m_enum_value; +} + +enum_struct::enum_struct( + enum_struct&& x) noexcept +{ + m_index = x.m_index; + m_enum_value = x.m_enum_value; +} + +enum_struct& enum_struct::operator =( + const enum_struct& x) +{ + + m_index = x.m_index; + m_enum_value = x.m_enum_value; + + return *this; +} + +enum_struct& enum_struct::operator =( + enum_struct&& x) noexcept +{ + + m_index = x.m_index; + m_enum_value = x.m_enum_value; + + return *this; +} + +bool enum_struct::operator ==( + const enum_struct& x) const +{ + + return (m_index == x.m_index && m_enum_value == x.m_enum_value); +} + +bool enum_struct::operator !=( + const enum_struct& x) const +{ + return !(*this == x); +} + +size_t enum_struct::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return enum_struct_max_cdr_typesize; +} + +size_t enum_struct::getCdrSerializedSize( + const enum_struct& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + + return current_alignment - initial_alignment; +} + +void enum_struct::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_index; + scdr << (uint32_t)m_enum_value; + +} + +void enum_struct::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_index; + { + uint32_t enum_value = 0; + dcdr >> enum_value; + m_enum_value = (ColorEnum)enum_value; + } + +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void enum_struct::index( + uint32_t _index) +{ + m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t enum_struct::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& enum_struct::index() +{ + return m_index; +} + +/*! + * @brief This function sets a value in member enum_value + * @param _enum_value New value for member enum_value + */ +void enum_struct::enum_value( + ColorEnum _enum_value) +{ + m_enum_value = _enum_value; +} + +/*! + * @brief This function returns the value of member enum_value + * @return Value of member enum_value + */ +ColorEnum enum_struct::enum_value() const +{ + return m_enum_value; +} + +/*! + * @brief This function returns a reference to member enum_value + * @return Reference to member enum_value + */ +ColorEnum& enum_struct::enum_value() +{ + return m_enum_value; +} + + + +size_t enum_struct::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return enum_struct_max_key_cdr_typesize; +} + +bool enum_struct::isKeyDefined() +{ + return false; +} + +void enum_struct::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.h new file mode 100644 index 00000000..1c0a770d --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_struct.h @@ -0,0 +1,239 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file enum_struct.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_ENUM_STRUCT_H_ +#define _FAST_DDS_GENERATED_ENUM_STRUCT_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(ENUM_STRUCT_SOURCE) +#define ENUM_STRUCT_DllAPI __declspec( dllexport ) +#else +#define ENUM_STRUCT_DllAPI __declspec( dllimport ) +#endif // ENUM_STRUCT_SOURCE +#else +#define ENUM_STRUCT_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define ENUM_STRUCT_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the enumeration ColorEnum defined by the user in the IDL file. + * @ingroup enum_struct + */ +enum ColorEnum : uint32_t +{ + RED, + GREEN, + BLUE +}; +/*! + * @brief This class represents the structure enum_struct defined by the user in the IDL file. + * @ingroup enum_struct + */ +class enum_struct +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport enum_struct(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~enum_struct(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object enum_struct that will be copied. + */ + eProsima_user_DllExport enum_struct( + const enum_struct& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object enum_struct that will be copied. + */ + eProsima_user_DllExport enum_struct( + enum_struct&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object enum_struct that will be copied. + */ + eProsima_user_DllExport enum_struct& operator =( + const enum_struct& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object enum_struct that will be copied. + */ + eProsima_user_DllExport enum_struct& operator =( + enum_struct&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x enum_struct object to compare. + */ + eProsima_user_DllExport bool operator ==( + const enum_struct& x) const; + + /*! + * @brief Comparison operator. + * @param x enum_struct object to compare. + */ + eProsima_user_DllExport bool operator !=( + const enum_struct& x) const; + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + /*! + * @brief This function sets a value in member enum_value + * @param _enum_value New value for member enum_value + */ + eProsima_user_DllExport void enum_value( + ColorEnum _enum_value); + + /*! + * @brief This function returns the value of member enum_value + * @return Value of member enum_value + */ + eProsima_user_DllExport ColorEnum enum_value() const; + + /*! + * @brief This function returns a reference to member enum_value + * @return Reference to member enum_value + */ + eProsima_user_DllExport ColorEnum& enum_value(); + + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const enum_struct& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + uint32_t m_index; + ColorEnum m_enum_value; + +}; + +#endif // _FAST_DDS_GENERATED_ENUM_STRUCT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.cxx new file mode 100644 index 00000000..e93d8f5d --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.cxx @@ -0,0 +1,170 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file enum_structPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "enum_structPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + + +enum_structPubSubType::enum_structPubSubType() +{ + setName("enum_struct"); + auto type_size = enum_struct::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = enum_struct::isKeyDefined(); + size_t keyLength = enum_struct::getKeyMaxCdrSerializedSize() > 16 ? + enum_struct::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +enum_structPubSubType::~enum_structPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool enum_structPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + enum_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool enum_structPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + enum_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function enum_structPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* enum_structPubSubType::createData() +{ + return reinterpret_cast(new enum_struct()); +} + +void enum_structPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool enum_structPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + enum_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + enum_struct::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || enum_struct::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.h new file mode 100644 index 00000000..f85486a8 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structPubSubTypes.h @@ -0,0 +1,105 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file enum_structPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_ENUM_STRUCT_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_ENUM_STRUCT_PUBSUBTYPES_H_ + +#include +#include + +#include "enum_struct.h" + + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated enum_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + + + +/*! + * @brief This class represents the TopicDataType of the type enum_struct defined by the user in the IDL file. + * @ingroup enum_struct + */ +class enum_structPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef enum_struct type; + + eProsima_user_DllExport enum_structPubSubType(); + + eProsima_user_DllExport virtual ~enum_structPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + (void)memory; + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; + +}; + +#endif // _FAST_DDS_GENERATED_ENUM_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.cxx new file mode 100644 index 00000000..109026e6 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.cxx @@ -0,0 +1,470 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file enum_structTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "enum_struct.h" +#include "enum_structTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerenum_structTypes() +{ + static std::once_flag once_flag; + std::call_once(once_flag, []() + { + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("ColorEnum", GetColorEnumIdentifier(true), + GetColorEnumObject(true)); + factory->add_type_object("ColorEnum", GetColorEnumIdentifier(false), + GetColorEnumObject(false)); + + factory->add_type_object("enum_struct", Getenum_structIdentifier(true), + Getenum_structObject(true)); + factory->add_type_object("enum_struct", Getenum_structIdentifier(false), + Getenum_structObject(false)); + + }); +} + +const TypeIdentifier* GetColorEnumIdentifier(bool complete) +{ + const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("ColorEnum", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetColorEnumObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("ColorEnum", complete); +} + +const TypeObject* GetColorEnumObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ColorEnum", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteColorEnumObject(); + } + // else + return GetMinimalColorEnumObject(); +} + +const TypeObject* GetMinimalColorEnumObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ColorEnum", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_ENUM); + + // No flags apply + //type_object->minimal().enumerated_type().enum_flags().IS_FINAL(false); + //type_object->minimal().enumerated_type().enum_flags().IS_APPENDABLE(false); + //type_object->minimal().enumerated_type().enum_flags().IS_MUTABLE(false); + //type_object->minimal().enumerated_type().enum_flags().IS_NESTED(false); + //type_object->minimal().enumerated_type().enum_flags().IS_AUTOID_HASH(false); + + type_object->minimal().enumerated_type().header().common().bit_bound(32); // TODO fixed by IDL, isn't? + + uint32_t value = 0; + MinimalEnumeratedLiteral mel_RED; + mel_RED.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply + mel_RED.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply + mel_RED.common().flags().IS_EXTERNAL(false); // Doesn't apply + mel_RED.common().flags().IS_OPTIONAL(false); // Doesn't apply + mel_RED.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + mel_RED.common().flags().IS_KEY(false); // Doesn't apply + mel_RED.common().flags().IS_DEFAULT(false); + mel_RED.common().value(value++); + MD5 RED_hash("RED"); + for(int i = 0; i < 4; ++i) + { + mel_RED.detail().name_hash()[i] = RED_hash.digest[i]; + } + type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_RED); + + MinimalEnumeratedLiteral mel_GREEN; + mel_GREEN.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply + mel_GREEN.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply + mel_GREEN.common().flags().IS_EXTERNAL(false); // Doesn't apply + mel_GREEN.common().flags().IS_OPTIONAL(false); // Doesn't apply + mel_GREEN.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + mel_GREEN.common().flags().IS_KEY(false); // Doesn't apply + mel_GREEN.common().flags().IS_DEFAULT(false); + mel_GREEN.common().value(value++); + MD5 GREEN_hash("GREEN"); + for(int i = 0; i < 4; ++i) + { + mel_GREEN.detail().name_hash()[i] = GREEN_hash.digest[i]; + } + type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_GREEN); + + MinimalEnumeratedLiteral mel_BLUE; + mel_BLUE.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply + mel_BLUE.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply + mel_BLUE.common().flags().IS_EXTERNAL(false); // Doesn't apply + mel_BLUE.common().flags().IS_OPTIONAL(false); // Doesn't apply + mel_BLUE.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + mel_BLUE.common().flags().IS_KEY(false); // Doesn't apply + mel_BLUE.common().flags().IS_DEFAULT(false); + mel_BLUE.common().value(value++); + MD5 BLUE_hash("BLUE"); + for(int i = 0; i < 4; ++i) + { + mel_BLUE.detail().name_hash()[i] = BLUE_hash.digest[i]; + } + type_object->minimal().enumerated_type().literal_seq().emplace_back(mel_BLUE); + + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalEnumeratedType::getCdrSerializedSize(type_object->minimal().enumerated_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("ColorEnum", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("ColorEnum", false); +} + +const TypeObject* GetCompleteColorEnumObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("ColorEnum", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_ENUM); + + // No flags apply + //type_object->complete().enumerated_type().enum_flags().IS_FINAL(false); + //type_object->complete().enumerated_type().enum_flags().IS_APPENDABLE(false); + //type_object->complete().enumerated_type().enum_flags().IS_MUTABLE(false); + //type_object->complete().enumerated_type().enum_flags().IS_NESTED(false); + //type_object->complete().enumerated_type().enum_flags().IS_AUTOID_HASH(false); + + type_object->complete().enumerated_type().header().common().bit_bound(32); // TODO fixed by IDL, isn't? + type_object->complete().enumerated_type().header().detail().type_name("ColorEnum"); + + + uint32_t value = 0; + CompleteEnumeratedLiteral cel_RED; + cel_RED.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply + cel_RED.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply + cel_RED.common().flags().IS_EXTERNAL(false); // Doesn't apply + cel_RED.common().flags().IS_OPTIONAL(false); // Doesn't apply + cel_RED.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + cel_RED.common().flags().IS_KEY(false); // Doesn't apply + cel_RED.common().flags().IS_DEFAULT(false); + cel_RED.common().value(value++); + cel_RED.detail().name("RED"); + + type_object->complete().enumerated_type().literal_seq().emplace_back(cel_RED); + + CompleteEnumeratedLiteral cel_GREEN; + cel_GREEN.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply + cel_GREEN.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply + cel_GREEN.common().flags().IS_EXTERNAL(false); // Doesn't apply + cel_GREEN.common().flags().IS_OPTIONAL(false); // Doesn't apply + cel_GREEN.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + cel_GREEN.common().flags().IS_KEY(false); // Doesn't apply + cel_GREEN.common().flags().IS_DEFAULT(false); + cel_GREEN.common().value(value++); + cel_GREEN.detail().name("GREEN"); + + type_object->complete().enumerated_type().literal_seq().emplace_back(cel_GREEN); + + CompleteEnumeratedLiteral cel_BLUE; + cel_BLUE.common().flags().TRY_CONSTRUCT1(false); // Doesn't apply + cel_BLUE.common().flags().TRY_CONSTRUCT2(false); // Doesn't apply + cel_BLUE.common().flags().IS_EXTERNAL(false); // Doesn't apply + cel_BLUE.common().flags().IS_OPTIONAL(false); // Doesn't apply + cel_BLUE.common().flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + cel_BLUE.common().flags().IS_KEY(false); // Doesn't apply + cel_BLUE.common().flags().IS_DEFAULT(false); + cel_BLUE.common().value(value++); + cel_BLUE.detail().name("BLUE"); + + type_object->complete().enumerated_type().literal_seq().emplace_back(cel_BLUE); + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteEnumeratedType::getCdrSerializedSize(type_object->complete().enumerated_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("ColorEnum", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("ColorEnum", true); +} + +const TypeIdentifier* Getenum_structIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("enum_struct", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getenum_structObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("enum_struct", complete); +} + +const TypeObject* Getenum_structObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("enum_struct", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteenum_structObject(); + } + //else + return GetMinimalenum_structObject(); +} + +const TypeObject* GetMinimalenum_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("enum_struct", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_index; + mst_index.common().member_id(memberId++); + mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_index.common().member_flags().IS_OPTIONAL(false); + mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_index.common().member_flags().IS_KEY(false); + mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); + + MD5 index_hash("index"); + for(int i = 0; i < 4; ++i) + { + mst_index.detail().name_hash()[i] = index_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_index); + + MinimalStructMember mst_enum_value; + mst_enum_value.common().member_id(memberId++); + mst_enum_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_enum_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_enum_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_enum_value.common().member_flags().IS_OPTIONAL(false); + mst_enum_value.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_enum_value.common().member_flags().IS_KEY(false); + mst_enum_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_enum_value.common().member_type_id(*GetColorEnumIdentifier(false)); + MD5 enum_value_hash("enum_value"); + for(int i = 0; i < 4; ++i) + { + mst_enum_value.detail().name_hash()[i] = enum_value_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_enum_value); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("enum_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("enum_struct", false); +} + +const TypeObject* GetCompleteenum_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("enum_struct", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_index; + cst_index.common().member_id(memberId++); + cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_index.common().member_flags().IS_OPTIONAL(false); + cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_index.common().member_flags().IS_KEY(false); + cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); + + cst_index.detail().name("index"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_index); + + CompleteStructMember cst_enum_value; + cst_enum_value.common().member_id(memberId++); + cst_enum_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_enum_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_enum_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_enum_value.common().member_flags().IS_OPTIONAL(false); + cst_enum_value.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_enum_value.common().member_flags().IS_KEY(false); + cst_enum_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_enum_value.common().member_type_id(*GetColorEnumIdentifier(true)); + cst_enum_value.detail().name("enum_value"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_enum_value); + + + // Header + type_object->complete().struct_type().header().detail().type_name("enum_struct"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("enum_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("enum_struct", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.h new file mode 100644 index 00000000..ab841f64 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/enum_structTypeObject.h @@ -0,0 +1,68 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file enum_structTypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_ENUM_STRUCT_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_ENUM_STRUCT_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif +#else +#define eProsima_user_DllExport +#endif + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(enum_struct_SOURCE) +#define enum_struct_DllAPI __declspec( dllexport ) +#else +#define enum_struct_DllAPI __declspec( dllimport ) +#endif // enum_struct_SOURCE +#else +#define enum_struct_DllAPI +#endif +#else +#define enum_struct_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registerenum_structTypes(); + +eProsima_user_DllExport const TypeIdentifier* GetColorEnumIdentifier(bool complete = false); +eProsima_user_DllExport const TypeObject* GetColorEnumObject(bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalColorEnumObject(); +eProsima_user_DllExport const TypeObject* GetCompleteColorEnumObject(); + +eProsima_user_DllExport const TypeIdentifier* Getenum_structIdentifier(bool complete = false); +eProsima_user_DllExport const TypeObject* Getenum_structObject(bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalenum_structObject(); +eProsima_user_DllExport const TypeObject* GetCompleteenum_structObject(); + + +#endif // _FAST_DDS_GENERATED_ENUM_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.cxx new file mode 100644 index 00000000..7179606c --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.cxx @@ -0,0 +1,200 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file float_bounded_sequence.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "float_bounded_sequence.h" +#include "float_bounded_sequenceTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +float_bounded_sequence::float_bounded_sequence() +{ + // m_numbers com.eprosima.idl.parser.typecode.SequenceTypeCode@3fd7a715 + + + // Just to register all known types + registerfloat_bounded_sequenceTypes(); +} + +float_bounded_sequence::~float_bounded_sequence() +{ +} + +float_bounded_sequence::float_bounded_sequence( + const float_bounded_sequence& x) +{ + m_numbers = x.m_numbers; +} + +float_bounded_sequence::float_bounded_sequence( + float_bounded_sequence&& x) noexcept +{ + m_numbers = std::move(x.m_numbers); +} + +float_bounded_sequence& float_bounded_sequence::operator =( + const float_bounded_sequence& x) +{ + + m_numbers = x.m_numbers; + + return *this; +} + +float_bounded_sequence& float_bounded_sequence::operator =( + float_bounded_sequence&& x) noexcept +{ + + m_numbers = std::move(x.m_numbers); + + return *this; +} + +bool float_bounded_sequence::operator ==( + const float_bounded_sequence& x) const +{ + + return (m_numbers == x.m_numbers); +} + +bool float_bounded_sequence::operator !=( + const float_bounded_sequence& x) const +{ + return !(*this == x); +} + +size_t float_bounded_sequence::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + current_alignment += (13 * 4) + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + + return current_alignment - initial_alignment; +} + +size_t float_bounded_sequence::getCdrSerializedSize( + const float_bounded_sequence& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + if (data.numbers().size() > 0) + { + current_alignment += (data.numbers().size() * 4) + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + } + + + + return current_alignment - initial_alignment; +} + +void float_bounded_sequence::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_numbers; +} + +void float_bounded_sequence::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_numbers;} + +/*! + * @brief This function copies the value in member numbers + * @param _numbers New value to be copied in member numbers + */ +void float_bounded_sequence::numbers( + const std::vector& _numbers) +{ + m_numbers = _numbers; +} + +/*! + * @brief This function moves the value in member numbers + * @param _numbers New value to be moved in member numbers + */ +void float_bounded_sequence::numbers( + std::vector&& _numbers) +{ + m_numbers = std::move(_numbers); +} + +/*! + * @brief This function returns a constant reference to member numbers + * @return Constant reference to member numbers + */ +const std::vector& float_bounded_sequence::numbers() const +{ + return m_numbers; +} + +/*! + * @brief This function returns a reference to member numbers + * @return Reference to member numbers + */ +std::vector& float_bounded_sequence::numbers() +{ + return m_numbers; +} + +size_t float_bounded_sequence::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + return current_align; +} + +bool float_bounded_sequence::isKeyDefined() +{ + return false; +} + +void float_bounded_sequence::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.h new file mode 100644 index 00000000..b25178db --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequence.h @@ -0,0 +1,214 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file float_bounded_sequence.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ +#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(float_bounded_sequence_SOURCE) +#define float_bounded_sequence_DllAPI __declspec( dllexport ) +#else +#define float_bounded_sequence_DllAPI __declspec( dllimport ) +#endif // float_bounded_sequence_SOURCE +#else +#define float_bounded_sequence_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define float_bounded_sequence_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure float_bounded_sequence defined by the user in the IDL file. + * @ingroup FLOAT_BOUNDED_SEQUENCE + */ +class float_bounded_sequence +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport float_bounded_sequence(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~float_bounded_sequence(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object float_bounded_sequence that will be copied. + */ + eProsima_user_DllExport float_bounded_sequence( + const float_bounded_sequence& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object float_bounded_sequence that will be copied. + */ + eProsima_user_DllExport float_bounded_sequence( + float_bounded_sequence&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object float_bounded_sequence that will be copied. + */ + eProsima_user_DllExport float_bounded_sequence& operator =( + const float_bounded_sequence& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object float_bounded_sequence that will be copied. + */ + eProsima_user_DllExport float_bounded_sequence& operator =( + float_bounded_sequence&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x float_bounded_sequence object to compare. + */ + eProsima_user_DllExport bool operator ==( + const float_bounded_sequence& x) const; + + /*! + * @brief Comparison operator. + * @param x float_bounded_sequence object to compare. + */ + eProsima_user_DllExport bool operator !=( + const float_bounded_sequence& x) const; + + /*! + * @brief This function copies the value in member numbers + * @param _numbers New value to be copied in member numbers + */ + eProsima_user_DllExport void numbers( + const std::vector& _numbers); + + /*! + * @brief This function moves the value in member numbers + * @param _numbers New value to be moved in member numbers + */ + eProsima_user_DllExport void numbers( + std::vector&& _numbers); + + /*! + * @brief This function returns a constant reference to member numbers + * @return Constant reference to member numbers + */ + eProsima_user_DllExport const std::vector& numbers() const; + + /*! + * @brief This function returns a reference to member numbers + * @return Reference to member numbers + */ + eProsima_user_DllExport std::vector& numbers(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const float_bounded_sequence& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + std::vector m_numbers; +}; + +#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.cxx new file mode 100644 index 00000000..e0176475 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file float_bounded_sequencePubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "float_bounded_sequencePubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +float_bounded_sequencePubSubType::float_bounded_sequencePubSubType() +{ + setName("float_bounded_sequence"); + auto type_size = float_bounded_sequence::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = float_bounded_sequence::isKeyDefined(); + size_t keyLength = float_bounded_sequence::getKeyMaxCdrSerializedSize() > 16 ? + float_bounded_sequence::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +float_bounded_sequencePubSubType::~float_bounded_sequencePubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool float_bounded_sequencePubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + float_bounded_sequence* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool float_bounded_sequencePubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + float_bounded_sequence* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function float_bounded_sequencePubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* float_bounded_sequencePubSubType::createData() +{ + return reinterpret_cast(new float_bounded_sequence()); +} + +void float_bounded_sequencePubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool float_bounded_sequencePubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + float_bounded_sequence* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + float_bounded_sequence::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || float_bounded_sequence::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.h new file mode 100644 index 00000000..80661b58 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequencePubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file float_bounded_sequencePubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_H_ + +#include +#include + +#include "float_bounded_sequence.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated float_bounded_sequence is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +/*! + * @brief This class represents the TopicDataType of the type float_bounded_sequence defined by the user in the IDL file. + * @ingroup FLOAT_BOUNDED_SEQUENCE + */ +class float_bounded_sequencePubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef float_bounded_sequence type; + + eProsima_user_DllExport float_bounded_sequencePubSubType(); + + eProsima_user_DllExport virtual ~float_bounded_sequencePubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + (void)memory; + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.cxx new file mode 100644 index 00000000..a329d1c0 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.cxx @@ -0,0 +1,215 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file float_bounded_sequenceTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "float_bounded_sequence.h" +#include "float_bounded_sequenceTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerfloat_bounded_sequenceTypes() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("float_bounded_sequence", Getfloat_bounded_sequenceIdentifier(true), + Getfloat_bounded_sequenceObject(true)); + factory->add_type_object("float_bounded_sequence", Getfloat_bounded_sequenceIdentifier(false), + Getfloat_bounded_sequenceObject(false)); + +} + +const TypeIdentifier* Getfloat_bounded_sequenceIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("float_bounded_sequence", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getfloat_bounded_sequenceObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("float_bounded_sequence", complete); +} + +const TypeObject* Getfloat_bounded_sequenceObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompletefloat_bounded_sequenceObject(); + } + //else + return GetMinimalfloat_bounded_sequenceObject(); +} + +const TypeObject* GetMinimalfloat_bounded_sequenceObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_numbers; + mst_numbers.common().member_id(memberId++); + mst_numbers.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_numbers.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_numbers.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_numbers.common().member_flags().IS_OPTIONAL(false); + mst_numbers.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_numbers.common().member_flags().IS_KEY(false); + mst_numbers.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_numbers.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("float", 13, false)); + + + MD5 numbers_hash("numbers"); + for(int i = 0; i < 4; ++i) + { + mst_numbers.detail().name_hash()[i] = numbers_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_numbers); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("float_bounded_sequence", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", false); +} + +const TypeObject* GetCompletefloat_bounded_sequenceObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_numbers; + cst_numbers.common().member_id(memberId++); + cst_numbers.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_numbers.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_numbers.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_numbers.common().member_flags().IS_OPTIONAL(false); + cst_numbers.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_numbers.common().member_flags().IS_KEY(false); + cst_numbers.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_numbers.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("float", 13, true)); + + + cst_numbers.detail().name("numbers"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_numbers); + + + // Header + type_object->complete().struct_type().header().detail().type_name("float_bounded_sequence"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("float_bounded_sequence", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("float_bounded_sequence", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.h new file mode 100644 index 00000000..65d62243 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/float_bounded_sequenceTypeObject.h @@ -0,0 +1,65 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file float_bounded_sequenceTypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define eProsima_user_DllExport +#endif // if defined(_WIN32) + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(float_bounded_sequence_SOURCE) +#define float_bounded_sequence_DllAPI __declspec( dllexport ) +#else +#define float_bounded_sequence_DllAPI __declspec( dllimport ) +#endif // float_bounded_sequence_SOURCE +#else +#define float_bounded_sequence_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define float_bounded_sequence_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registerfloat_bounded_sequenceTypes(); + +eProsima_user_DllExport const TypeIdentifier* Getfloat_bounded_sequenceIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* Getfloat_bounded_sequenceObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalfloat_bounded_sequenceObject(); +eProsima_user_DllExport const TypeObject* GetCompletefloat_bounded_sequenceObject(); + + +#endif // _FAST_DDS_GENERATED_FLOAT_BOUNDED_SEQUENCE_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.cxx new file mode 100644 index 00000000..40a12463 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.cxx @@ -0,0 +1,239 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file hello_world.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "hello_world.h" +#include "hello_worldTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +hello_world::hello_world() +{ + // m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@1dfe2924 + m_index = 0; + // m_message com.eprosima.idl.parser.typecode.StringTypeCode@6ebc05a6 + m_message =""; + + // Just to register all known types + registerhello_worldTypes(); +} + +hello_world::~hello_world() +{ + + +} + +hello_world::hello_world( + const hello_world& x) +{ + m_index = x.m_index; + m_message = x.m_message; +} + +hello_world::hello_world( + hello_world&& x) noexcept +{ + m_index = x.m_index; + m_message = std::move(x.m_message); +} + +hello_world& hello_world::operator =( + const hello_world& x) +{ + + m_index = x.m_index; + m_message = x.m_message; + + return *this; +} + +hello_world& hello_world::operator =( + hello_world&& x) noexcept +{ + + m_index = x.m_index; + m_message = std::move(x.m_message); + + return *this; +} + +bool hello_world::operator ==( + const hello_world& x) const +{ + + return (m_index == x.m_index && m_message == x.m_message); +} + +bool hello_world::operator !=( + const hello_world& x) const +{ + return !(*this == x); +} + +size_t hello_world::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + 255 + 1; + + + return current_alignment - initial_alignment; +} + +size_t hello_world::getCdrSerializedSize( + const hello_world& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; + + + return current_alignment - initial_alignment; +} + +void hello_world::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_index; + scdr << m_message.c_str(); + +} + +void hello_world::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_index; + dcdr >> m_message; +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void hello_world::index( + uint32_t _index) +{ + m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t hello_world::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& hello_world::index() +{ + return m_index; +} + +/*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ +void hello_world::message( + const std::string& _message) +{ + m_message = _message; +} + +/*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ +void hello_world::message( + std::string&& _message) +{ + m_message = std::move(_message); +} + +/*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ +const std::string& hello_world::message() const +{ + return m_message; +} + +/*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ +std::string& hello_world::message() +{ + return m_message; +} + +size_t hello_world::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + + + return current_align; +} + +bool hello_world::isKeyDefined() +{ + return false; +} + +void hello_world::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.h new file mode 100644 index 00000000..678a59f0 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_world.h @@ -0,0 +1,234 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file hello_world.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLO_WORLD_H_ +#define _FAST_DDS_GENERATED_HELLO_WORLD_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(hello_world_SOURCE) +#define hello_world_DllAPI __declspec( dllexport ) +#else +#define hello_world_DllAPI __declspec( dllimport ) +#endif // hello_world_SOURCE +#else +#define hello_world_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define hello_world_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure hello_world defined by the user in the IDL file. + * @ingroup HELLO_WORLD + */ +class hello_world +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport hello_world(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~hello_world(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object hello_world that will be copied. + */ + eProsima_user_DllExport hello_world( + const hello_world& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object hello_world that will be copied. + */ + eProsima_user_DllExport hello_world( + hello_world&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object hello_world that will be copied. + */ + eProsima_user_DllExport hello_world& operator =( + const hello_world& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object hello_world that will be copied. + */ + eProsima_user_DllExport hello_world& operator =( + hello_world&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x hello_world object to compare. + */ + eProsima_user_DllExport bool operator ==( + const hello_world& x) const; + + /*! + * @brief Comparison operator. + * @param x hello_world object to compare. + */ + eProsima_user_DllExport bool operator !=( + const hello_world& x) const; + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + /*! + * @brief This function copies the value in member message + * @param _message New value to be copied in member message + */ + eProsima_user_DllExport void message( + const std::string& _message); + + /*! + * @brief This function moves the value in member message + * @param _message New value to be moved in member message + */ + eProsima_user_DllExport void message( + std::string&& _message); + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::string& message() const; + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::string& message(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const hello_world& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + uint32_t m_index; + std::string m_message; +}; + +#endif // _FAST_DDS_GENERATED_HELLO_WORLD_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.cxx new file mode 100644 index 00000000..8717497c --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file hello_worldPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "hello_worldPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +hello_worldPubSubType::hello_worldPubSubType() +{ + setName("hello_world"); + auto type_size = hello_world::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = hello_world::isKeyDefined(); + size_t keyLength = hello_world::getKeyMaxCdrSerializedSize() > 16 ? + hello_world::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +hello_worldPubSubType::~hello_worldPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool hello_worldPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + hello_world* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool hello_worldPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + hello_world* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function hello_worldPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* hello_worldPubSubType::createData() +{ + return reinterpret_cast(new hello_world()); +} + +void hello_worldPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool hello_worldPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + hello_world* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + hello_world::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || hello_world::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.h new file mode 100644 index 00000000..d261d555 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldPubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file hello_worldPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_HELLO_WORLD_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_HELLO_WORLD_PUBSUBTYPES_H_ + +#include +#include + +#include "hello_world.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated hello_world is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +/*! + * @brief This class represents the TopicDataType of the type hello_world defined by the user in the IDL file. + * @ingroup HELLO_WORLD + */ +class hello_worldPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef hello_world type; + + eProsima_user_DllExport hello_worldPubSubType(); + + eProsima_user_DllExport virtual ~hello_worldPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + (void)memory; + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _FAST_DDS_GENERATED_HELLO_WORLD_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.cxx new file mode 100644 index 00000000..aac863c3 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.cxx @@ -0,0 +1,248 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file hello_worldTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "hello_world.h" +#include "hello_worldTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerhello_worldTypes() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("hello_world", Gethello_worldIdentifier(true), + Gethello_worldObject(true)); + factory->add_type_object("hello_world", Gethello_worldIdentifier(false), + Gethello_worldObject(false)); + +} + +const TypeIdentifier* Gethello_worldIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("hello_world", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Gethello_worldObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("hello_world", complete); +} + +const TypeObject* Gethello_worldObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("hello_world", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompletehello_worldObject(); + } + //else + return GetMinimalhello_worldObject(); +} + +const TypeObject* GetMinimalhello_worldObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("hello_world", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_index; + mst_index.common().member_id(memberId++); + mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_index.common().member_flags().IS_OPTIONAL(false); + mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_index.common().member_flags().IS_KEY(false); + mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); + + MD5 index_hash("index"); + for(int i = 0; i < 4; ++i) + { + mst_index.detail().name_hash()[i] = index_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_index); + + MinimalStructMember mst_message; + mst_message.common().member_id(memberId++); + mst_message.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_message.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_message.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_message.common().member_flags().IS_OPTIONAL(false); + mst_message.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_message.common().member_flags().IS_KEY(false); + mst_message.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_message.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); + + + MD5 message_hash("message"); + for(int i = 0; i < 4; ++i) + { + mst_message.detail().name_hash()[i] = message_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_message); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("hello_world", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("hello_world", false); +} + +const TypeObject* GetCompletehello_worldObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("hello_world", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_index; + cst_index.common().member_id(memberId++); + cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_index.common().member_flags().IS_OPTIONAL(false); + cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_index.common().member_flags().IS_KEY(false); + cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); + + cst_index.detail().name("index"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_index); + + CompleteStructMember cst_message; + cst_message.common().member_id(memberId++); + cst_message.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_message.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_message.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_message.common().member_flags().IS_OPTIONAL(false); + cst_message.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_message.common().member_flags().IS_KEY(false); + cst_message.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_message.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); + + + cst_message.detail().name("message"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_message); + + + // Header + type_object->complete().struct_type().header().detail().type_name("hello_world"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("hello_world", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("hello_world", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.h new file mode 100644 index 00000000..7774c87b --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/hello_worldTypeObject.h @@ -0,0 +1,65 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file hello_worldTypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLO_WORLD_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_HELLO_WORLD_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define eProsima_user_DllExport +#endif // if defined(_WIN32) + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(hello_world_SOURCE) +#define hello_world_DllAPI __declspec( dllexport ) +#else +#define hello_world_DllAPI __declspec( dllimport ) +#endif // hello_world_SOURCE +#else +#define hello_world_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define hello_world_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registerhello_worldTypes(); + +eProsima_user_DllExport const TypeIdentifier* Gethello_worldIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* Gethello_worldObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalhello_worldObject(); +eProsima_user_DllExport const TypeObject* GetCompletehello_worldObject(); + + +#endif // _FAST_DDS_GENERATED_HELLO_WORLD_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.cxx new file mode 100644 index 00000000..b48a5d98 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.cxx @@ -0,0 +1,194 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file map_struct.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "map_struct.h" +#include "map_structTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +#define map_struct_max_cdr_typesize 26401ULL; +#define map_struct_max_key_cdr_typesize 0ULL; + +map_struct::map_struct() +{ + // map m_my_map + + + // Just to register all known types + registermap_structTypes(); +} + +map_struct::~map_struct() +{ +} + +map_struct::map_struct( + const map_struct& x) +{ + m_my_map = x.m_my_map; +} + +map_struct::map_struct( + map_struct&& x) noexcept +{ + m_my_map = std::move(x.m_my_map); +} + +map_struct& map_struct::operator =( + const map_struct& x) +{ + + m_my_map = x.m_my_map; + + return *this; +} + +map_struct& map_struct::operator =( + map_struct&& x) noexcept +{ + + m_my_map = std::move(x.m_my_map); + + return *this; +} + +bool map_struct::operator ==( + const map_struct& x) const +{ + + return (m_my_map == x.m_my_map); +} + +bool map_struct::operator !=( + const map_struct& x) const +{ + return !(*this == x); +} + +size_t map_struct::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return map_struct_max_cdr_typesize; +} + +size_t map_struct::getCdrSerializedSize( + const map_struct& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + for(auto a : data.my_map()) + { + (void)a; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + a.first.size() + 1; + current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + + } + + return current_alignment - initial_alignment; +} + +void map_struct::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_my_map; +} + +void map_struct::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_my_map;} + +/*! + * @brief This function copies the value in member my_map + * @param _my_map New value to be copied in member my_map + */ +void map_struct::my_map( + const std::map& _my_map) +{ + m_my_map = _my_map; +} + +/*! + * @brief This function moves the value in member my_map + * @param _my_map New value to be moved in member my_map + */ +void map_struct::my_map( + std::map&& _my_map) +{ + m_my_map = std::move(_my_map); +} + +/*! + * @brief This function returns a constant reference to member my_map + * @return Constant reference to member my_map + */ +const std::map& map_struct::my_map() const +{ + return m_my_map; +} + +/*! + * @brief This function returns a reference to member my_map + * @return Reference to member my_map + */ +std::map& map_struct::my_map() +{ + return m_my_map; +} + + +size_t map_struct::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return map_struct_max_key_cdr_typesize; +} + +bool map_struct::isKeyDefined() +{ + return false; +} + +void map_struct::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.h new file mode 100644 index 00000000..232aea44 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_struct.h @@ -0,0 +1,215 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file map_struct.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_MAP_STRUCT_H_ +#define _FAST_DDS_GENERATED_MAP_STRUCT_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(MAP_STRUCT_SOURCE) +#define MAP_STRUCT_DllAPI __declspec( dllexport ) +#else +#define MAP_STRUCT_DllAPI __declspec( dllimport ) +#endif // MAP_STRUCT_SOURCE +#else +#define MAP_STRUCT_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define MAP_STRUCT_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure map_struct defined by the user in the IDL file. + * @ingroup map_struct + */ +class map_struct +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport map_struct(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~map_struct(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object map_struct that will be copied. + */ + eProsima_user_DllExport map_struct( + const map_struct& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object map_struct that will be copied. + */ + eProsima_user_DllExport map_struct( + map_struct&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object map_struct that will be copied. + */ + eProsima_user_DllExport map_struct& operator =( + const map_struct& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object map_struct that will be copied. + */ + eProsima_user_DllExport map_struct& operator =( + map_struct&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x map_struct object to compare. + */ + eProsima_user_DllExport bool operator ==( + const map_struct& x) const; + + /*! + * @brief Comparison operator. + * @param x map_struct object to compare. + */ + eProsima_user_DllExport bool operator !=( + const map_struct& x) const; + + /*! + * @brief This function copies the value in member my_map + * @param _my_map New value to be copied in member my_map + */ + eProsima_user_DllExport void my_map( + const std::map& _my_map); + + /*! + * @brief This function moves the value in member my_map + * @param _my_map New value to be moved in member my_map + */ + eProsima_user_DllExport void my_map( + std::map&& _my_map); + + /*! + * @brief This function returns a constant reference to member my_map + * @return Constant reference to member my_map + */ + eProsima_user_DllExport const std::map& my_map() const; + + /*! + * @brief This function returns a reference to member my_map + * @return Reference to member my_map + */ + eProsima_user_DllExport std::map& my_map(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const map_struct& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + std::map m_my_map; + +}; + +#endif // _FAST_DDS_GENERATED_MAP_STRUCT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.cxx new file mode 100644 index 00000000..c6e6e006 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file map_structPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "map_structPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +map_structPubSubType::map_structPubSubType() +{ + setName("map_struct"); + auto type_size = map_struct::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = map_struct::isKeyDefined(); + size_t keyLength = map_struct::getKeyMaxCdrSerializedSize() > 16 ? + map_struct::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +map_structPubSubType::~map_structPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool map_structPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + map_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool map_structPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + map_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function map_structPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* map_structPubSubType::createData() +{ + return reinterpret_cast(new map_struct()); +} + +void map_structPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool map_structPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + map_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + map_struct::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || map_struct::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.h new file mode 100644 index 00000000..80aa0787 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structPubSubTypes.h @@ -0,0 +1,104 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file map_structPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_MAP_STRUCT_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_MAP_STRUCT_PUBSUBTYPES_H_ + +#include +#include + +#include "map_struct.h" + + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated map_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + + +/*! + * @brief This class represents the TopicDataType of the type map_struct defined by the user in the IDL file. + * @ingroup map_struct + */ +class map_structPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef map_struct type; + + eProsima_user_DllExport map_structPubSubType(); + + eProsima_user_DllExport virtual ~map_structPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + (void)memory; + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; + +}; + +#endif // _FAST_DDS_GENERATED_MAP_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.cxx new file mode 100644 index 00000000..397ce137 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.cxx @@ -0,0 +1,220 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file map_structTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "map_struct.h" +#include "map_structTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registermap_structTypes() +{ + static std::once_flag once_flag; + std::call_once(once_flag, []() + { + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("map_struct", Getmap_structIdentifier(true), + Getmap_structObject(true)); + factory->add_type_object("map_struct", Getmap_structIdentifier(false), + Getmap_structObject(false)); + + }); +} + +const TypeIdentifier* Getmap_structIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("map_struct", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getmap_structObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("map_struct", complete); +} + +const TypeObject* Getmap_structObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("map_struct", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompletemap_structObject(); + } + //else + return GetMinimalmap_structObject(); +} + +const TypeObject* GetMinimalmap_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("map_struct", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_my_map; + mst_my_map.common().member_id(memberId++); + mst_my_map.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_my_map.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_my_map.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_my_map.common().member_flags().IS_OPTIONAL(false); + mst_my_map.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_my_map.common().member_flags().IS_KEY(false); + mst_my_map.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_my_map.common().member_type_id(*TypeObjectFactory::get_instance()->get_map_identifier(TypeNamesGenerator::get_string_type_name(255, false), "bool", 100, false)); + + + MD5 my_map_hash("my_map"); + for(int i = 0; i < 4; ++i) + { + mst_my_map.detail().name_hash()[i] = my_map_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_my_map); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("map_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("map_struct", false); +} + +const TypeObject* GetCompletemap_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("map_struct", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_my_map; + cst_my_map.common().member_id(memberId++); + cst_my_map.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_my_map.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_my_map.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_my_map.common().member_flags().IS_OPTIONAL(false); + cst_my_map.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_my_map.common().member_flags().IS_KEY(false); + cst_my_map.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_my_map.common().member_type_id(*TypeObjectFactory::get_instance()->get_map_identifier(TypeNamesGenerator::get_string_type_name(255, false), "bool", 100, true)); + + + cst_my_map.detail().name("my_map"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_my_map); + + + // Header + type_object->complete().struct_type().header().detail().type_name("map_struct"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("map_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("map_struct", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.h new file mode 100644 index 00000000..07559e37 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/map_structTypeObject.h @@ -0,0 +1,63 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file map_structTypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_MAP_STRUCT_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_MAP_STRUCT_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif +#else +#define eProsima_user_DllExport +#endif + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(map_struct_SOURCE) +#define map_struct_DllAPI __declspec( dllexport ) +#else +#define map_struct_DllAPI __declspec( dllimport ) +#endif // map_struct_SOURCE +#else +#define map_struct_DllAPI +#endif +#else +#define map_struct_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registermap_structTypes(); + +eProsima_user_DllExport const TypeIdentifier* Getmap_structIdentifier(bool complete = false); +eProsima_user_DllExport const TypeObject* Getmap_structObject(bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalmap_structObject(); +eProsima_user_DllExport const TypeObject* GetCompletemap_structObject(); + + +#endif // _FAST_DDS_GENERATED_MAP_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.cxx new file mode 100644 index 00000000..6ec457f2 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.cxx @@ -0,0 +1,197 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file numeric_array.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "numeric_array.h" +#include "numeric_arrayTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +numeric_array::numeric_array() +{ + // m_points com.eprosima.idl.parser.typecode.ArrayTypeCode@cd2dae5 + memset(&m_points, 0, (3) * 4); + + // Just to register all known types + registernumeric_arrayTypes(); +} + +numeric_array::~numeric_array() +{ +} + +numeric_array::numeric_array( + const numeric_array& x) +{ + m_points = x.m_points; +} + +numeric_array::numeric_array( + numeric_array&& x) noexcept +{ + m_points = std::move(x.m_points); +} + +numeric_array& numeric_array::operator =( + const numeric_array& x) +{ + + m_points = x.m_points; + + return *this; +} + +numeric_array& numeric_array::operator =( + numeric_array&& x) noexcept +{ + + m_points = std::move(x.m_points); + + return *this; +} + +bool numeric_array::operator ==( + const numeric_array& x) const +{ + + return (m_points == x.m_points); +} + +bool numeric_array::operator !=( + const numeric_array& x) const +{ + return !(*this == x); +} + +size_t numeric_array::getMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t initial_alignment = current_alignment; + + + current_alignment += ((3) * 4) + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + return current_alignment - initial_alignment; +} + +size_t numeric_array::getCdrSerializedSize( + const numeric_array& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + if ((3) > 0) + { + current_alignment += ((3) * 4) + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + } + + return current_alignment - initial_alignment; +} + +void numeric_array::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_points; + + +} + +void numeric_array::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_points; + +} + +/*! + * @brief This function copies the value in member points + * @param _points New value to be copied in member points + */ +void numeric_array::points( + const std::array& _points) +{ + m_points = _points; +} + +/*! + * @brief This function moves the value in member points + * @param _points New value to be moved in member points + */ +void numeric_array::points( + std::array&& _points) +{ + m_points = std::move(_points); +} + +/*! + * @brief This function returns a constant reference to member points + * @return Constant reference to member points + */ +const std::array& numeric_array::points() const +{ + return m_points; +} + +/*! + * @brief This function returns a reference to member points + * @return Reference to member points + */ +std::array& numeric_array::points() +{ + return m_points; +} + +size_t numeric_array::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + size_t current_align = current_alignment; + + + + return current_align; +} + +bool numeric_array::isKeyDefined() +{ + return false; +} + +void numeric_array::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.h new file mode 100644 index 00000000..5d23be32 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_array.h @@ -0,0 +1,214 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file numeric_array.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ +#define _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(numeric_array_SOURCE) +#define numeric_array_DllAPI __declspec( dllexport ) +#else +#define numeric_array_DllAPI __declspec( dllimport ) +#endif // numeric_array_SOURCE +#else +#define numeric_array_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define numeric_array_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the structure numeric_array defined by the user in the IDL file. + * @ingroup NUMERIC_ARRAY + */ +class numeric_array +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport numeric_array(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~numeric_array(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object numeric_array that will be copied. + */ + eProsima_user_DllExport numeric_array( + const numeric_array& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object numeric_array that will be copied. + */ + eProsima_user_DllExport numeric_array( + numeric_array&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object numeric_array that will be copied. + */ + eProsima_user_DllExport numeric_array& operator =( + const numeric_array& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object numeric_array that will be copied. + */ + eProsima_user_DllExport numeric_array& operator =( + numeric_array&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x numeric_array object to compare. + */ + eProsima_user_DllExport bool operator ==( + const numeric_array& x) const; + + /*! + * @brief Comparison operator. + * @param x numeric_array object to compare. + */ + eProsima_user_DllExport bool operator !=( + const numeric_array& x) const; + + /*! + * @brief This function copies the value in member points + * @param _points New value to be copied in member points + */ + eProsima_user_DllExport void points( + const std::array& _points); + + /*! + * @brief This function moves the value in member points + * @param _points New value to be moved in member points + */ + eProsima_user_DllExport void points( + std::array&& _points); + + /*! + * @brief This function returns a constant reference to member points + * @return Constant reference to member points + */ + eProsima_user_DllExport const std::array& points() const; + + /*! + * @brief This function returns a reference to member points + * @return Reference to member points + */ + eProsima_user_DllExport std::array& points(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const numeric_array& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + std::array m_points; +}; + +#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.cxx new file mode 100644 index 00000000..1f6aa132 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file numeric_arrayPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "numeric_arrayPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + +numeric_arrayPubSubType::numeric_arrayPubSubType() +{ + setName("numeric_array"); + auto type_size = numeric_array::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = numeric_array::isKeyDefined(); + size_t keyLength = numeric_array::getKeyMaxCdrSerializedSize() > 16 ? + numeric_array::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +numeric_arrayPubSubType::~numeric_arrayPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool numeric_arrayPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + numeric_array* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + // Serialize encapsulation + ser.serialize_encapsulation(); + + try + { + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool numeric_arrayPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + //Convert DATA to pointer of your type + numeric_array* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::NotEnoughMemoryException& /*exception*/) + { + return false; + } + + return true; +} + +std::function numeric_arrayPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* numeric_arrayPubSubType::createData() +{ + return reinterpret_cast(new numeric_array()); +} + +void numeric_arrayPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool numeric_arrayPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + numeric_array* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + numeric_array::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || numeric_array::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.h new file mode 100644 index 00000000..b975cd5e --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayPubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file numeric_arrayPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAY_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_NUMERIC_ARRAY_PUBSUBTYPES_H_ + +#include +#include + +#include "numeric_array.h" + +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated numeric_array is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +/*! + * @brief This class represents the TopicDataType of the type numeric_array defined by the user in the IDL file. + * @ingroup NUMERIC_ARRAY + */ +class numeric_arrayPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef numeric_array type; + + eProsima_user_DllExport numeric_arrayPubSubType(); + + eProsima_user_DllExport virtual ~numeric_arrayPubSubType() override; + + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; + + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; + + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override + { + new (memory) numeric_array(); + return true; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; +}; + +#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.cxx new file mode 100644 index 00000000..aaab64ae --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.cxx @@ -0,0 +1,215 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file numeric_arrayTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "numeric_array.h" +#include "numeric_arrayTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registernumeric_arrayTypes() +{ + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("numeric_array", Getnumeric_arrayIdentifier(true), + Getnumeric_arrayObject(true)); + factory->add_type_object("numeric_array", Getnumeric_arrayIdentifier(false), + Getnumeric_arrayObject(false)); + +} + +const TypeIdentifier* Getnumeric_arrayIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("numeric_array", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getnumeric_arrayObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("numeric_array", complete); +} + +const TypeObject* Getnumeric_arrayObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("numeric_array", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompletenumeric_arrayObject(); + } + //else + return GetMinimalnumeric_arrayObject(); +} + +const TypeObject* GetMinimalnumeric_arrayObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("numeric_array", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_points; + mst_points.common().member_id(memberId++); + mst_points.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_points.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_points.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_points.common().member_flags().IS_OPTIONAL(false); + mst_points.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_points.common().member_flags().IS_KEY(false); + mst_points.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_points.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("int32_t", {3}, false)); + + + MD5 points_hash("points"); + for(int i = 0; i < 4; ++i) + { + mst_points.detail().name_hash()[i] = points_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_points); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("numeric_array", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("numeric_array", false); +} + +const TypeObject* GetCompletenumeric_arrayObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("numeric_array", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_points; + cst_points.common().member_id(memberId++); + cst_points.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_points.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_points.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_points.common().member_flags().IS_OPTIONAL(false); + cst_points.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_points.common().member_flags().IS_KEY(false); + cst_points.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_points.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("int32_t", {3}, true)); + + + cst_points.detail().name("points"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_points); + + + // Header + type_object->complete().struct_type().header().detail().type_name("numeric_array"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("numeric_array", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("numeric_array", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.h new file mode 100644 index 00000000..30c2eef2 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/numeric_arrayTypeObject.h @@ -0,0 +1,65 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file numeric_arrayTypeObject.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_NUMERIC_ARRAY_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_NUMERIC_ARRAY_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define eProsima_user_DllExport +#endif // if defined(_WIN32) + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(numeric_array_SOURCE) +#define numeric_array_DllAPI __declspec( dllexport ) +#else +#define numeric_array_DllAPI __declspec( dllimport ) +#endif // numeric_array_SOURCE +#else +#define numeric_array_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define numeric_array_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registernumeric_arrayTypes(); + +eProsima_user_DllExport const TypeIdentifier* Getnumeric_arrayIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* Getnumeric_arrayObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalnumeric_arrayObject(); +eProsima_user_DllExport const TypeObject* GetCompletenumeric_arrayObject(); + + +#endif // _FAST_DDS_GENERATED_NUMERIC_ARRAY_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.cxx new file mode 100644 index 00000000..8531c9f8 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.cxx @@ -0,0 +1,642 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file union_struct.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "union_struct.h" +#include "union_structTypeObject.h" +#include + +#include +using namespace eprosima::fastcdr::exception; + +#include + +#define union_struct_max_cdr_typesize 268ULL; + +#define union_struct_max_key_cdr_typesize 0ULL; + + +MyUnion::MyUnion() +{ + m__d = 1; + // octet m_octet_value + m_octet_value = 0; + // long m_long_value + m_long_value = 0; + // string m_string_value + m_string_value =""; +} + +MyUnion::~MyUnion() +{ +} + +MyUnion::MyUnion( + const MyUnion& x) +{ + m__d = x.m__d; + + switch(m__d) + { + case 1: + m_octet_value = x.m_octet_value; + break; + case 2: + m_long_value = x.m_long_value; + break; + case 3: + m_string_value = x.m_string_value; + break; + default: + break; + } +} + +MyUnion::MyUnion( + MyUnion&& x) noexcept +{ + m__d = x.m__d; + + switch(m__d) + { + case 1: + m_octet_value = x.m_octet_value; + break; + case 2: + m_long_value = x.m_long_value; + break; + case 3: + m_string_value = std::move(x.m_string_value); + break; + default: + break; + } +} + +MyUnion& MyUnion::operator =( + const MyUnion& x) +{ + m__d = x.m__d; + + switch(m__d) + { + case 1: + m_octet_value = x.m_octet_value; + break; + case 2: + m_long_value = x.m_long_value; + break; + case 3: + m_string_value = x.m_string_value; + break; + default: + break; + } + + return *this; +} + +MyUnion& MyUnion::operator =( + MyUnion&& x) noexcept +{ + m__d = x.m__d; + + switch(m__d) + { + case 1: + m_octet_value = x.m_octet_value; + break; + case 2: + m_long_value = x.m_long_value; + break; + case 3: + m_string_value = std::move(x.m_string_value); + break; + default: + break; + } + + return *this; +} + +bool MyUnion::operator ==( + const MyUnion& x) const +{ + if (m__d != x.m__d) + { + return false; + } + + switch(m__d) + { + case 1: + return (m_octet_value == x.m_octet_value); + break; + case 2: + return (m_long_value == x.m_long_value); + break; + case 3: + return (m_string_value == x.m_string_value); + break; + default: + break; + } + return false; +} + +bool MyUnion::operator !=( + const MyUnion& x) const +{ + return !(*this == x); +} + +void MyUnion::_d( + int32_t __d) +{ + bool b = false; + + switch(m__d) + { + case 1: + switch(__d) + { + case 1: + b = true; + break; + default: + break; + } + break; + case 2: + switch(__d) + { + case 2: + b = true; + break; + default: + break; + } + break; + case 3: + switch(__d) + { + case 3: + b = true; + break; + default: + break; + } + break; + } + + if(!b) + { + throw BadParamException("Discriminator doesn't correspond with the selected union member"); + } + + m__d = __d; +} + +int32_t MyUnion::_d() const +{ + return m__d; +} + +int32_t& MyUnion::_d() +{ + return m__d; +} + +void MyUnion::octet_value( + uint8_t _octet_value) +{ + m_octet_value = _octet_value; + m__d = 1; +} + +uint8_t MyUnion::octet_value() const +{ + bool b = false; + + switch(m__d) + { + case 1: + b = true; + break; + default: + break; + } + if(!b) + { + throw BadParamException("This member is not been selected"); + } + + return m_octet_value; +} + +uint8_t& MyUnion::octet_value() +{ + bool b = false; + + switch(m__d) + { + case 1: + b = true; + break; + default: + break; + } + if(!b) + { + throw BadParamException("This member is not been selected"); + } + + return m_octet_value; +} +void MyUnion::long_value( + int32_t _long_value) +{ + m_long_value = _long_value; + m__d = 2; +} + +int32_t MyUnion::long_value() const +{ + bool b = false; + + switch(m__d) + { + case 2: + b = true; + break; + default: + break; + } + if(!b) + { + throw BadParamException("This member is not been selected"); + } + + return m_long_value; +} + +int32_t& MyUnion::long_value() +{ + bool b = false; + + switch(m__d) + { + case 2: + b = true; + break; + default: + break; + } + if(!b) + { + throw BadParamException("This member is not been selected"); + } + + return m_long_value; +} +void MyUnion::string_value( + const std::string& _string_value) +{ + m_string_value = _string_value; + m__d = 3; +} + +void MyUnion::string_value( + std::string&& _string_value) +{ + m_string_value = std::move(_string_value); + m__d = 3; +} + +const std::string& MyUnion::string_value() const +{ + bool b = false; + + switch(m__d) + { + case 3: + b = true; + break; + default: + break; + } + if(!b) + { + throw BadParamException("This member is not been selected"); + } + + return m_string_value; +} + +std::string& MyUnion::string_value() +{ + bool b = false; + + switch(m__d) + { + case 3: + b = true; + break; + default: + break; + } + if(!b) + { + throw BadParamException("This member is not been selected"); + } + + return m_string_value; +} + +// TODO(Ricardo) Review +size_t MyUnion::getCdrSerializedSize( + const MyUnion& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + switch(data.m__d) + { + case 1: + current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); + + break; + case 2: + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + break; + case 3: + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.string_value().size() + 1; + break; + default: + break; + } + + return current_alignment - initial_alignment; +} + +void MyUnion::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m__d; + + switch(m__d) + { + case 1: + scdr << m_octet_value; + + break; + case 2: + scdr << m_long_value; + + break; + case 3: + scdr << m_string_value.c_str(); + + break; + default: + break; + } +} + +void MyUnion::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m__d; + + switch(m__d) + { + case 1: + dcdr >> m_octet_value; + break; + case 2: + dcdr >> m_long_value; + break; + case 3: + dcdr >> m_string_value;break; + default: + break; + } +} + + +union_struct::union_struct() +{ + // unsigned long m_index + m_index = 0; + // MyUnion m_union_value + + + // Just to register all known types + registerunion_structTypes(); +} + +union_struct::~union_struct() +{ + + +} + +union_struct::union_struct( + const union_struct& x) +{ + m_index = x.m_index; + m_union_value = x.m_union_value; +} + +union_struct::union_struct( + union_struct&& x) noexcept +{ + m_index = x.m_index; + m_union_value = std::move(x.m_union_value); +} + +union_struct& union_struct::operator =( + const union_struct& x) +{ + + m_index = x.m_index; + m_union_value = x.m_union_value; + + return *this; +} + +union_struct& union_struct::operator =( + union_struct&& x) noexcept +{ + + m_index = x.m_index; + m_union_value = std::move(x.m_union_value); + + return *this; +} + +bool union_struct::operator ==( + const union_struct& x) const +{ + + return (m_index == x.m_index && m_union_value == x.m_union_value); +} + +bool union_struct::operator !=( + const union_struct& x) const +{ + return !(*this == x); +} + +size_t union_struct::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return union_struct_max_cdr_typesize; +} + +size_t union_struct::getCdrSerializedSize( + const union_struct& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += MyUnion::getCdrSerializedSize(data.union_value(), current_alignment); + + return current_alignment - initial_alignment; +} + +void union_struct::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + + scdr << m_index; + scdr << m_union_value; + +} + +void union_struct::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + + dcdr >> m_index; + dcdr >> m_union_value; +} + +/*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ +void union_struct::index( + uint32_t _index) +{ + m_index = _index; +} + +/*! + * @brief This function returns the value of member index + * @return Value of member index + */ +uint32_t union_struct::index() const +{ + return m_index; +} + +/*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ +uint32_t& union_struct::index() +{ + return m_index; +} + +/*! + * @brief This function copies the value in member union_value + * @param _union_value New value to be copied in member union_value + */ +void union_struct::union_value( + const MyUnion& _union_value) +{ + m_union_value = _union_value; +} + +/*! + * @brief This function moves the value in member union_value + * @param _union_value New value to be moved in member union_value + */ +void union_struct::union_value( + MyUnion&& _union_value) +{ + m_union_value = std::move(_union_value); +} + +/*! + * @brief This function returns a constant reference to member union_value + * @return Constant reference to member union_value + */ +const MyUnion& union_struct::union_value() const +{ + return m_union_value; +} + +/*! + * @brief This function returns a reference to member union_value + * @return Reference to member union_value + */ +MyUnion& union_struct::union_value() +{ + return m_union_value; +} + + +size_t union_struct::getKeyMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast(current_alignment); + return union_struct_max_key_cdr_typesize; +} + +bool union_struct::isKeyDefined() +{ + return false; +} + +void union_struct::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.h new file mode 100644 index 00000000..26739ce2 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_struct.h @@ -0,0 +1,421 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file union_struct.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_H_ +#define _FAST_DDS_GENERATED_UNION_STRUCT_H_ + + +#include + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define eProsima_user_DllExport +#endif // _WIN32 + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(UNION_STRUCT_SOURCE) +#define UNION_STRUCT_DllAPI __declspec( dllexport ) +#else +#define UNION_STRUCT_DllAPI __declspec( dllimport ) +#endif // UNION_STRUCT_SOURCE +#else +#define UNION_STRUCT_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define UNION_STRUCT_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + +/*! + * @brief This class represents the union MyUnion defined by the user in the IDL file. + * @ingroup union_struct + */ +class MyUnion +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport MyUnion(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~MyUnion(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object MyUnion that will be copied. + */ + eProsima_user_DllExport MyUnion( + const MyUnion& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object MyUnion that will be copied. + */ + eProsima_user_DllExport MyUnion( + MyUnion&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object MyUnion that will be copied. + */ + eProsima_user_DllExport MyUnion& operator =( + const MyUnion& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object MyUnion that will be copied. + */ + eProsima_user_DllExport MyUnion& operator =( + MyUnion&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x MyUnion object to compare. + */ + eProsima_user_DllExport bool operator ==( + const MyUnion& x) const; + + /*! + * @brief Comparison operator. + * @param x MyUnion object to compare. + */ + eProsima_user_DllExport bool operator !=( + const MyUnion& x) const; + + /*! + * @brief This function sets the discriminator value. + * @param __d New value for the discriminator. + * @exception eprosima::fastcdr::BadParamException This exception is thrown if the new value doesn't correspond to the selected union member. + */ + eProsima_user_DllExport void _d( + int32_t __d); + + /*! + * @brief This function returns the value of the discriminator. + * @return Value of the discriminator + */ + eProsima_user_DllExport int32_t _d() const; + + /*! + * @brief This function returns a reference to the discriminator. + * @return Reference to the discriminator. + */ + eProsima_user_DllExport int32_t& _d(); + + /*! + * @brief This function sets a value in member octet_value + * @param _octet_value New value for member octet_value + */ + eProsima_user_DllExport void octet_value( + uint8_t _octet_value); + + /*! + * @brief This function returns the value of member octet_value + * @return Value of member octet_value + * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. + */ + eProsima_user_DllExport uint8_t octet_value() const; + + /*! + * @brief This function returns a reference to member octet_value + * @return Reference to member octet_value + * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. + */ + eProsima_user_DllExport uint8_t& octet_value(); + + /*! + * @brief This function sets a value in member long_value + * @param _long_value New value for member long_value + */ + eProsima_user_DllExport void long_value( + int32_t _long_value); + + /*! + * @brief This function returns the value of member long_value + * @return Value of member long_value + * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. + */ + eProsima_user_DllExport int32_t long_value() const; + + /*! + * @brief This function returns a reference to member long_value + * @return Reference to member long_value + * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. + */ + eProsima_user_DllExport int32_t& long_value(); + + /*! + * @brief This function copies the value in member string_value + * @param _string_value New value to be copied in member string_value + */ + eProsima_user_DllExport void string_value( + const std::string& _string_value); + + /*! + * @brief This function moves the value in member string_value + * @param _string_value New value to be moved in member string_value + */ + eProsima_user_DllExport void string_value( + std::string&& _string_value); + + /*! + * @brief This function returns a constant reference to member string_value + * @return Constant reference to member string_value + * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. + */ + eProsima_user_DllExport const std::string& string_value() const; + + /*! + * @brief This function returns a reference to member string_value + * @return Reference to member string_value + * @exception eprosima::fastcdr::BadParamException This exception is thrown if the requested union member is not the current selection. + */ + eProsima_user_DllExport std::string& string_value(); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const MyUnion& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + +private: + + int32_t m__d; + + uint8_t m_octet_value; + int32_t m_long_value; + std::string m_string_value; +}; +/*! + * @brief This class represents the structure union_struct defined by the user in the IDL file. + * @ingroup union_struct + */ +class union_struct +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport union_struct(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~union_struct(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object union_struct that will be copied. + */ + eProsima_user_DllExport union_struct( + const union_struct& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object union_struct that will be copied. + */ + eProsima_user_DllExport union_struct( + union_struct&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object union_struct that will be copied. + */ + eProsima_user_DllExport union_struct& operator =( + const union_struct& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object union_struct that will be copied. + */ + eProsima_user_DllExport union_struct& operator =( + union_struct&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x union_struct object to compare. + */ + eProsima_user_DllExport bool operator ==( + const union_struct& x) const; + + /*! + * @brief Comparison operator. + * @param x union_struct object to compare. + */ + eProsima_user_DllExport bool operator !=( + const union_struct& x) const; + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index); + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const; + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index(); + + /*! + * @brief This function copies the value in member union_value + * @param _union_value New value to be copied in member union_value + */ + eProsima_user_DllExport void union_value( + const MyUnion& _union_value); + + /*! + * @brief This function moves the value in member union_value + * @param _union_value New value to be moved in member union_value + */ + eProsima_user_DllExport void union_value( + MyUnion&& _union_value); + + /*! + * @brief This function returns a constant reference to member union_value + * @return Constant reference to member union_value + */ + eProsima_user_DllExport const MyUnion& union_value() const; + + /*! + * @brief This function returns a reference to member union_value + * @return Reference to member union_value + */ + eProsima_user_DllExport MyUnion& union_value(); + + /*! + * @brief This function returns the maximum serialized size of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function returns the serialized size of a data depending on the buffer alignment. + * @param data Data which is calculated its serialized size. + * @param current_alignment Buffer alignment. + * @return Serialized size. + */ + eProsima_user_DllExport static size_t getCdrSerializedSize( + const union_struct& data, + size_t current_alignment = 0); + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + /*! + * @brief This function returns the maximum serialized size of the Key of an object + * depending on the buffer alignment. + * @param current_alignment Buffer alignment. + * @return Maximum serialized size. + */ + eProsima_user_DllExport static size_t getKeyMaxCdrSerializedSize( + size_t current_alignment = 0); + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + +private: + + uint32_t m_index; + MyUnion m_union_value; + +}; + +#endif // _FAST_DDS_GENERATED_UNION_STRUCT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.cxx new file mode 100644 index 00000000..c1812023 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.cxx @@ -0,0 +1,170 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file union_structPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "union_structPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + + +union_structPubSubType::union_structPubSubType() +{ + setName("union_struct"); + auto type_size = union_struct::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = union_struct::isKeyDefined(); + size_t keyLength = union_struct::getKeyMaxCdrSerializedSize() > 16 ? + union_struct::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +union_structPubSubType::~union_structPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool union_structPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + union_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool union_structPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + union_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function union_structPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* union_structPubSubType::createData() +{ + return reinterpret_cast(new union_struct()); +} + +void union_structPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool union_structPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + union_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + union_struct::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || union_struct::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h new file mode 100644 index 00000000..c1812023 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h @@ -0,0 +1,170 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file union_structPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastcdrgen. + */ + + +#include +#include + +#include "union_structPubSubTypes.h" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; + + +union_structPubSubType::union_structPubSubType() +{ + setName("union_struct"); + auto type_size = union_struct::getMaxCdrSerializedSize(); + type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ + m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ + m_isGetKeyDefined = union_struct::isKeyDefined(); + size_t keyLength = union_struct::getKeyMaxCdrSerializedSize() > 16 ? + union_struct::getKeyMaxCdrSerializedSize() : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +union_structPubSubType::~union_structPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool union_structPubSubType::serialize( + void* data, + SerializedPayload_t* payload) +{ + union_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + p_type->serialize(ser); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + payload->length = static_cast(ser.getSerializedDataLength()); + return true; +} + +bool union_structPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + union_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + + // Object that deserializes the data. + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + p_type->deserialize(deser); + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function union_structPubSubType::getSerializedSizeProvider( + void* data) +{ + return [data]() -> uint32_t + { + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + }; +} + +void* union_structPubSubType::createData() +{ + return reinterpret_cast(new union_struct()); +} + +void union_structPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool union_structPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + union_struct* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + union_struct::getKeyMaxCdrSerializedSize()); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + p_type->serializeKey(ser); + if (force_md5 || union_struct::getKeyMaxCdrSerializedSize() > 16) + { + m_md5.init(); + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + m_md5.finalize(); + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_md5.digest[i]; + } + } + else + { + for (uint8_t i = 0; i < 16; ++i) + { + handle->value[i] = m_keyBuffer[i]; + } + } + return true; +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.cxx new file mode 100644 index 00000000..8796c646 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.cxx @@ -0,0 +1,512 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file union_structTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "union_struct.h" +#include "union_structTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerunion_structTypes() +{ + static std::once_flag once_flag; + std::call_once(once_flag, []() + { + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("MyUnion", GetMyUnionIdentifier(true), + GetMyUnionObject(true)); + factory->add_type_object("MyUnion", GetMyUnionIdentifier(false), + GetMyUnionObject(false)); + + factory->add_type_object("union_struct", Getunion_structIdentifier(true), + Getunion_structObject(true)); + factory->add_type_object("union_struct", Getunion_structIdentifier(false), + Getunion_structObject(false)); + + }); +} + +const TypeIdentifier* GetMyUnionIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetMyUnionObject(complete); + return TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); +} + +const TypeObject* GetMyUnionObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteMyUnionObject(); + } + // else + return GetMinimalMyUnionObject(); +} + +const TypeObject* GetMinimalMyUnionObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_UNION); + + type_object->minimal().union_type().union_flags().IS_FINAL(false); + type_object->minimal().union_type().union_flags().IS_APPENDABLE(false); + type_object->minimal().union_type().union_flags().IS_MUTABLE(false); + type_object->minimal().union_type().union_flags().IS_NESTED(false); + type_object->minimal().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported + + type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + type_object->minimal().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply + type_object->minimal().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply + type_object->minimal().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + type_object->minimal().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported + type_object->minimal().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply + + type_object->minimal().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + + MemberId memberId = 0; + MinimalUnionMember mst_octet_value; + mst_octet_value.common().member_id(memberId++); + mst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + mst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + mst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply + mst_octet_value.common().member_flags().IS_DEFAULT(false); + mst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); + + mst_octet_value.common().label_seq().emplace_back(1); + MD5 octet_value_hash("octet_value"); + for(int i = 0; i < 4; ++i) + { + mst_octet_value.detail().name_hash()[i] = octet_value_hash.digest[i]; + } + type_object->minimal().union_type().member_seq().emplace_back(mst_octet_value); + + MinimalUnionMember mst_long_value; + mst_long_value.common().member_id(memberId++); + mst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + mst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + mst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply + mst_long_value.common().member_flags().IS_DEFAULT(false); + mst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + + mst_long_value.common().label_seq().emplace_back(2); + MD5 long_value_hash("long_value"); + for(int i = 0; i < 4; ++i) + { + mst_long_value.detail().name_hash()[i] = long_value_hash.digest[i]; + } + type_object->minimal().union_type().member_seq().emplace_back(mst_long_value); + + MinimalUnionMember mst_string_value; + mst_string_value.common().member_id(memberId++); + mst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + mst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + mst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply + mst_string_value.common().member_flags().IS_DEFAULT(false); + mst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); + + + mst_string_value.common().label_seq().emplace_back(3); + MD5 string_value_hash("string_value"); + for(int i = 0; i < 4; ++i) + { + mst_string_value.detail().name_hash()[i] = string_value_hash.digest[i]; + } + type_object->minimal().union_type().member_seq().emplace_back(mst_string_value); + + + // Header + //type_object->minimal().union_type().header().detail()... // Empty + + TypeIdentifier* identifier = new TypeIdentifier(); + identifier->_d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalUnionType::getCdrSerializedSize(type_object->minimal().union_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier->equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); + delete type_object; + delete identifier; + return TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); +} + +const TypeObject* GetCompleteMyUnionObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_UNION); + + type_object->complete().union_type().union_flags().IS_FINAL(false); + type_object->complete().union_type().union_flags().IS_APPENDABLE(false); + type_object->complete().union_type().union_flags().IS_MUTABLE(false); + type_object->complete().union_type().union_flags().IS_NESTED(false); + type_object->complete().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported + + type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + type_object->complete().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply + type_object->complete().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply + type_object->complete().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + type_object->complete().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported + type_object->complete().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply + + type_object->complete().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + + + MemberId memberId = 0; + CompleteUnionMember cst_octet_value; + cst_octet_value.common().member_id(memberId++); + cst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + cst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + cst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply + cst_octet_value.common().member_flags().IS_DEFAULT(false); + cst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); + cst_octet_value.common().label_seq().emplace_back(1); + + cst_octet_value.detail().name("octet_value"); + + type_object->complete().union_type().member_seq().emplace_back(cst_octet_value); + + CompleteUnionMember cst_long_value; + cst_long_value.common().member_id(memberId++); + cst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + cst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + cst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply + cst_long_value.common().member_flags().IS_DEFAULT(false); + cst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + cst_long_value.common().label_seq().emplace_back(2); + + cst_long_value.detail().name("long_value"); + + type_object->complete().union_type().member_seq().emplace_back(cst_long_value); + + CompleteUnionMember cst_string_value; + cst_string_value.common().member_id(memberId++); + cst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + cst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + cst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply + cst_string_value.common().member_flags().IS_DEFAULT(false); + cst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); + + cst_string_value.common().label_seq().emplace_back(3); + + cst_string_value.detail().name("string_value"); + + type_object->complete().union_type().member_seq().emplace_back(cst_string_value); + + + // Header + type_object->complete().union_type().header().detail().type_name("MyUnion"); + + + TypeIdentifier* identifier = new TypeIdentifier(); + identifier->_d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteUnionType::getCdrSerializedSize(type_object->complete().union_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier->equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); + delete type_object; + delete identifier; + return TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); +} + +const TypeIdentifier* Getunion_structIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getunion_structObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); +} + +const TypeObject* Getunion_structObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteunion_structObject(); + } + //else + return GetMinimalunion_structObject(); +} + +const TypeObject* GetMinimalunion_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_index; + mst_index.common().member_id(memberId++); + mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_index.common().member_flags().IS_OPTIONAL(false); + mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_index.common().member_flags().IS_KEY(false); + mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); + + MD5 index_hash("index"); + for(int i = 0; i < 4; ++i) + { + mst_index.detail().name_hash()[i] = index_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_index); + + MinimalStructMember mst_union_value; + mst_union_value.common().member_id(memberId++); + mst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_union_value.common().member_flags().IS_OPTIONAL(false); + mst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_union_value.common().member_flags().IS_KEY(false); + mst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_union_value.common().member_type_id(*GetMyUnionIdentifier(false)); + MD5 union_value_hash("union_value"); + for(int i = 0; i < 4; ++i) + { + mst_union_value.detail().name_hash()[i] = union_value_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_union_value); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("union_struct", false); +} + +const TypeObject* GetCompleteunion_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_index; + cst_index.common().member_id(memberId++); + cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_index.common().member_flags().IS_OPTIONAL(false); + cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_index.common().member_flags().IS_KEY(false); + cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); + + cst_index.detail().name("index"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_index); + + CompleteStructMember cst_union_value; + cst_union_value.common().member_id(memberId++); + cst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_union_value.common().member_flags().IS_OPTIONAL(false); + cst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_union_value.common().member_flags().IS_KEY(false); + cst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_union_value.common().member_type_id(*GetMyUnionIdentifier(true)); + cst_union_value.detail().name("union_value"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_union_value); + + + // Header + type_object->complete().struct_type().header().detail().type_name("union_struct"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("union_struct", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h new file mode 100644 index 00000000..8796c646 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h @@ -0,0 +1,512 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file union_structTypeObject.cpp + * This source file contains the definition of the described types in the IDL file. + * + * This file was generated by the tool gen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { char dummy; } +#endif + +#include "union_struct.h" +#include "union_structTypeObject.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace eprosima::fastrtps::rtps; + +void registerunion_structTypes() +{ + static std::once_flag once_flag; + std::call_once(once_flag, []() + { + TypeObjectFactory *factory = TypeObjectFactory::get_instance(); + factory->add_type_object("MyUnion", GetMyUnionIdentifier(true), + GetMyUnionObject(true)); + factory->add_type_object("MyUnion", GetMyUnionIdentifier(false), + GetMyUnionObject(false)); + + factory->add_type_object("union_struct", Getunion_structIdentifier(true), + Getunion_structObject(true)); + factory->add_type_object("union_struct", Getunion_structIdentifier(false), + Getunion_structObject(false)); + + }); +} + +const TypeIdentifier* GetMyUnionIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + GetMyUnionObject(complete); + return TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); +} + +const TypeObject* GetMyUnionObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteMyUnionObject(); + } + // else + return GetMinimalMyUnionObject(); +} + +const TypeObject* GetMinimalMyUnionObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_UNION); + + type_object->minimal().union_type().union_flags().IS_FINAL(false); + type_object->minimal().union_type().union_flags().IS_APPENDABLE(false); + type_object->minimal().union_type().union_flags().IS_MUTABLE(false); + type_object->minimal().union_type().union_flags().IS_NESTED(false); + type_object->minimal().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported + + type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + type_object->minimal().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply + type_object->minimal().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply + type_object->minimal().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + type_object->minimal().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported + type_object->minimal().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply + + type_object->minimal().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + + MemberId memberId = 0; + MinimalUnionMember mst_octet_value; + mst_octet_value.common().member_id(memberId++); + mst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + mst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + mst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply + mst_octet_value.common().member_flags().IS_DEFAULT(false); + mst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); + + mst_octet_value.common().label_seq().emplace_back(1); + MD5 octet_value_hash("octet_value"); + for(int i = 0; i < 4; ++i) + { + mst_octet_value.detail().name_hash()[i] = octet_value_hash.digest[i]; + } + type_object->minimal().union_type().member_seq().emplace_back(mst_octet_value); + + MinimalUnionMember mst_long_value; + mst_long_value.common().member_id(memberId++); + mst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + mst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + mst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply + mst_long_value.common().member_flags().IS_DEFAULT(false); + mst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + + mst_long_value.common().label_seq().emplace_back(2); + MD5 long_value_hash("long_value"); + for(int i = 0; i < 4; ++i) + { + mst_long_value.detail().name_hash()[i] = long_value_hash.digest[i]; + } + type_object->minimal().union_type().member_seq().emplace_back(mst_long_value); + + MinimalUnionMember mst_string_value; + mst_string_value.common().member_id(memberId++); + mst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + mst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + mst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply + mst_string_value.common().member_flags().IS_DEFAULT(false); + mst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); + + + mst_string_value.common().label_seq().emplace_back(3); + MD5 string_value_hash("string_value"); + for(int i = 0; i < 4; ++i) + { + mst_string_value.detail().name_hash()[i] = string_value_hash.digest[i]; + } + type_object->minimal().union_type().member_seq().emplace_back(mst_string_value); + + + // Header + //type_object->minimal().union_type().header().detail()... // Empty + + TypeIdentifier* identifier = new TypeIdentifier(); + identifier->_d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalUnionType::getCdrSerializedSize(type_object->minimal().union_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier->equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); + delete type_object; + delete identifier; + return TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); +} + +const TypeObject* GetCompleteMyUnionObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_UNION); + + type_object->complete().union_type().union_flags().IS_FINAL(false); + type_object->complete().union_type().union_flags().IS_APPENDABLE(false); + type_object->complete().union_type().union_flags().IS_MUTABLE(false); + type_object->complete().union_type().union_flags().IS_NESTED(false); + type_object->complete().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported + + type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + type_object->complete().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply + type_object->complete().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply + type_object->complete().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + type_object->complete().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported + type_object->complete().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply + + type_object->complete().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + + + MemberId memberId = 0; + CompleteUnionMember cst_octet_value; + cst_octet_value.common().member_id(memberId++); + cst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + cst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + cst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply + cst_octet_value.common().member_flags().IS_DEFAULT(false); + cst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); + cst_octet_value.common().label_seq().emplace_back(1); + + cst_octet_value.detail().name("octet_value"); + + type_object->complete().union_type().member_seq().emplace_back(cst_octet_value); + + CompleteUnionMember cst_long_value; + cst_long_value.common().member_id(memberId++); + cst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + cst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + cst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply + cst_long_value.common().member_flags().IS_DEFAULT(false); + cst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); + cst_long_value.common().label_seq().emplace_back(2); + + cst_long_value.detail().name("long_value"); + + type_object->complete().union_type().member_seq().emplace_back(cst_long_value); + + CompleteUnionMember cst_string_value; + cst_string_value.common().member_id(memberId++); + cst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply + cst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply + cst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply + cst_string_value.common().member_flags().IS_DEFAULT(false); + cst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); + + cst_string_value.common().label_seq().emplace_back(3); + + cst_string_value.detail().name("string_value"); + + type_object->complete().union_type().member_seq().emplace_back(cst_string_value); + + + // Header + type_object->complete().union_type().header().detail().type_name("MyUnion"); + + + TypeIdentifier* identifier = new TypeIdentifier(); + identifier->_d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteUnionType::getCdrSerializedSize(type_object->complete().union_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier->equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); + delete type_object; + delete identifier; + return TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); +} + +const TypeIdentifier* Getunion_structIdentifier(bool complete) +{ + const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); + if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) + { + return c_identifier; + } + + Getunion_structObject(complete); // Generated inside + return TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); +} + +const TypeObject* Getunion_structObject(bool complete) +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", complete); + if (c_type_object != nullptr) + { + return c_type_object; + } + else if (complete) + { + return GetCompleteunion_structObject(); + } + //else + return GetMinimalunion_structObject(); +} + +const TypeObject* GetMinimalunion_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", false); + if (c_type_object != nullptr) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_MINIMAL); + type_object->minimal()._d(TK_STRUCTURE); + + type_object->minimal().struct_type().struct_flags().IS_FINAL(false); + type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); + type_object->minimal().struct_type().struct_flags().IS_NESTED(false); + type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + MinimalStructMember mst_index; + mst_index.common().member_id(memberId++); + mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_index.common().member_flags().IS_OPTIONAL(false); + mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_index.common().member_flags().IS_KEY(false); + mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); + + MD5 index_hash("index"); + for(int i = 0; i < 4; ++i) + { + mst_index.detail().name_hash()[i] = index_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_index); + + MinimalStructMember mst_union_value; + mst_union_value.common().member_id(memberId++); + mst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + mst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + mst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + mst_union_value.common().member_flags().IS_OPTIONAL(false); + mst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); + mst_union_value.common().member_flags().IS_KEY(false); + mst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply + mst_union_value.common().member_type_id(*GetMyUnionIdentifier(false)); + MD5 union_value_hash("union_value"); + for(int i = 0; i < 4; ++i) + { + mst_union_value.detail().name_hash()[i] = union_value_hash.digest[i]; + } + type_object->minimal().struct_type().member_seq().emplace_back(mst_union_value); + + + // Header + // TODO Inheritance + //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); + //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; + + TypeIdentifier identifier; + identifier._d(EK_MINIMAL); + + SerializedPayload_t payload(static_cast( + MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("union_struct", false); +} + +const TypeObject* GetCompleteunion_structObject() +{ + const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", true); + if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) + { + return c_type_object; + } + + TypeObject *type_object = new TypeObject(); + type_object->_d(EK_COMPLETE); + type_object->complete()._d(TK_STRUCTURE); + + type_object->complete().struct_type().struct_flags().IS_FINAL(false); + type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); + type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); + type_object->complete().struct_type().struct_flags().IS_NESTED(false); + type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported + + MemberId memberId = 0; + CompleteStructMember cst_index; + cst_index.common().member_id(memberId++); + cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_index.common().member_flags().IS_OPTIONAL(false); + cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_index.common().member_flags().IS_KEY(false); + cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); + + cst_index.detail().name("index"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_index); + + CompleteStructMember cst_union_value; + cst_union_value.common().member_id(memberId++); + cst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported + cst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported + cst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported + cst_union_value.common().member_flags().IS_OPTIONAL(false); + cst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); + cst_union_value.common().member_flags().IS_KEY(false); + cst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply + cst_union_value.common().member_type_id(*GetMyUnionIdentifier(true)); + cst_union_value.detail().name("union_value"); + + type_object->complete().struct_type().member_seq().emplace_back(cst_union_value); + + + // Header + type_object->complete().struct_type().header().detail().type_name("union_struct"); + // TODO inheritance + + + TypeIdentifier identifier; + identifier._d(EK_COMPLETE); + + SerializedPayload_t payload(static_cast( + CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); + eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) + eprosima::fastcdr::Cdr ser( + fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, + eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. + payload.encapsulation = CDR_LE; + + type_object->serialize(ser); + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + MD5 objectHash; + objectHash.update((char*)payload.data, payload.length); + objectHash.finalize(); + for(int i = 0; i < 14; ++i) + { + identifier.equivalence_hash()[i] = objectHash.digest[i]; + } + + TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); + delete type_object; + return TypeObjectFactory::get_instance()->get_type_object("union_struct", true); +} diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/all_types.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/all_types.hpp new file mode 100644 index 00000000..65fa0566 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/all_types.hpp @@ -0,0 +1,97 @@ +// Copyright 2022 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @file all_types.hpp + */ + +/* + * USEFUL COMMAND + * + * for TYPE in hello_world numeric_array char_sequence basic_struct basic_array_struct float_bounded_sequence arrays_and_sequences complex_nested_arrays; do ${FASTDDSGEN_WS}/scripts/fastddsgen -replace -d ${WS}/src/recorder/ddsrecorder/test/unittest/dynamic_types/types/type_objects/ -typeobject -cs ${WS}/src/recorder/ddsrecorder/test/unittest/dynamic_types/types/idls/${TYPE}.idl; done + */ + +#pragma once + +#include +#include +#include + +#include +#include +#include + +#include "type_objects/hello_worldTypeObject.h" +#include "type_objects/numeric_arrayTypeObject.h" +#include "type_objects/char_sequenceTypeObject.h" +#include "type_objects/basic_structTypeObject.h" +#include "type_objects/basic_array_structTypeObject.h" +#include "type_objects/float_bounded_sequenceTypeObject.h" +#include "type_objects/arrays_and_sequencesTypeObject.h" +#include "type_objects/complex_nested_arraysTypeObject.h" +#include "type_objects/enum_structTypeObject.h" +#include "type_objects/union_structTypeObject.h" +#include "type_objects/map_structTypeObject.h" + +namespace test { + +ENUMERATION_BUILDER( + SupportedType, + hello_world, + numeric_array, + char_sequence, + basic_struct, + basic_array_struct, + float_bounded_sequence, + arrays_and_sequences, + complex_nested_arrays, + enum_struct, + union_struct, // NOTE: default case currently not supported in dynamic types + map_struct + ); + +eprosima::fastrtps::types::DynamicType_ptr get_dynamic_type( + SupportedType type) +{ + registerhello_worldTypes(); + registernumeric_arrayTypes(); + registerchar_sequenceTypes(); + registerbasic_structTypes(); + registerbasic_array_structTypes(); + registerfloat_bounded_sequenceTypes(); + registerarrays_and_sequencesTypes(); + registercomplex_nested_arraysTypes(); + registerenum_structTypes(); + registerunion_structTypes(); + registermap_structTypes(); + + auto type_name = to_string(type); + + auto type_obj_factory = eprosima::fastrtps::types::TypeObjectFactory::get_instance(); + auto type_id = type_obj_factory->get_type_identifier(type_name, true); + if (type_id == nullptr) + { + throw eprosima::utils::InconsistencyException("Not Type Id"); + } + + auto type_obj = type_obj_factory->get_type_object(type_id); + if (type_obj == nullptr) + { + throw eprosima::utils::InconsistencyException("Not Type Object"); + } + + return type_obj_factory->build_dynamic_type(type_name, type_id, type_obj); +} + +} /* namespace test */ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/arrays_and_sequences.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/arrays_and_sequences.idl new file mode 100644 index 00000000..5d9f9819 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/arrays_and_sequences.idl @@ -0,0 +1,12 @@ +struct AnInternalObject +{ + float x; + boolean positive; +}; + +struct arrays_and_sequences +{ + sequence unlimited_vector; + sequence limited_vector; + AnInternalObject limited_array[10]; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_array_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_array_struct.idl new file mode 100644 index 00000000..b81e5956 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_array_struct.idl @@ -0,0 +1,11 @@ +struct TheOtherObjectInArray +{ + long some_num; + boolean positive; +}; + +struct basic_array_struct +{ + unsigned long index; + TheOtherObjectInArray sub_structs[5]; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_struct.idl new file mode 100644 index 00000000..da2ea1bb --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/basic_struct.idl @@ -0,0 +1,9 @@ +struct TheOtherObject +{ + long some_num; +}; + +struct basic_struct +{ + TheOtherObject sub_struct; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/char_sequence.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/char_sequence.idl new file mode 100644 index 00000000..0abf7dd8 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/char_sequence.idl @@ -0,0 +1,4 @@ +struct char_sequence +{ + sequence chars; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/complex_nested_arrays.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/complex_nested_arrays.idl new file mode 100644 index 00000000..b4eca21b --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/complex_nested_arrays.idl @@ -0,0 +1,23 @@ +struct ThirdLevelElement +{ + double x; + double y; +}; + +struct SecondLevelElement +{ + ThirdLevelElement an_element_alone; + sequence a_limited_other_value; +}; + +struct FirstLevelElement +{ + string useless_name; + sequence sub; + ThirdLevelElement an_element_alone; +}; + +struct complex_nested_arrays +{ + FirstLevelElement array_of_elements[3]; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/enum_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/enum_struct.idl new file mode 100644 index 00000000..c40eae6e --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/enum_struct.idl @@ -0,0 +1,12 @@ +enum ColorEnum +{ + RED, + GREEN, + BLUE +}; + +struct enum_struct +{ + unsigned long index; + ColorEnum enum_value; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/float_bounded_sequence.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/float_bounded_sequence.idl new file mode 100644 index 00000000..b297df86 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/float_bounded_sequence.idl @@ -0,0 +1,4 @@ +struct float_bounded_sequence +{ + sequence numbers; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/hello_world.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/hello_world.idl new file mode 100644 index 00000000..d82036d8 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/hello_world.idl @@ -0,0 +1,5 @@ +struct hello_world +{ + unsigned long index; + string message; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/map_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/map_struct.idl new file mode 100644 index 00000000..d4d19acb --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/map_struct.idl @@ -0,0 +1,4 @@ +struct map_struct +{ + map my_map; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/numeric_array.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/numeric_array.idl new file mode 100644 index 00000000..814abd59 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/numeric_array.idl @@ -0,0 +1,4 @@ +struct numeric_array +{ + long points[3]; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/union_struct.idl b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/union_struct.idl new file mode 100644 index 00000000..3967f961 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/idls/union_struct.idl @@ -0,0 +1,15 @@ +union MyUnion switch (long) +{ + case 1: + octet octet_value; + case 2: + long long_value; + case 3: + string string_value; +}; + +struct union_struct +{ + unsigned long index; + MyUnion union_value; +}; diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/arrays_and_sequences.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/arrays_and_sequences.msg new file mode 100644 index 00000000..1942bc58 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/arrays_and_sequences.msg @@ -0,0 +1,7 @@ +AnInternalObject[] unlimited_vector +AnInternalObject[<=10] limited_vector +AnInternalObject[10] limited_array +================================================================================ +MSG: fastdds/AnInternalObject +float32 x +bool positive diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_array_struct.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_array_struct.msg new file mode 100644 index 00000000..a012398a --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_array_struct.msg @@ -0,0 +1,6 @@ +uint32 index +TheOtherObjectInArray[5] sub_structs +================================================================================ +MSG: fastdds/TheOtherObjectInArray +int32 some_num +bool positive diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_struct.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_struct.msg new file mode 100644 index 00000000..eb9814cb --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/basic_struct.msg @@ -0,0 +1,4 @@ +TheOtherObject sub_struct +================================================================================ +MSG: fastdds/TheOtherObject +int32 some_num diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/char_sequence.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/char_sequence.msg new file mode 100644 index 00000000..bf4b2456 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/char_sequence.msg @@ -0,0 +1 @@ +int8[] chars diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/complex_nested_arrays.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/complex_nested_arrays.msg new file mode 100644 index 00000000..5eebc2f4 --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/complex_nested_arrays.msg @@ -0,0 +1,14 @@ +FirstLevelElement[3] array_of_elements +================================================================================ +MSG: fastdds/ThirdLevelElement +float64 x +float64 y +================================================================================ +MSG: fastdds/SecondLevelElement +ThirdLevelElement an_element_alone +ThirdLevelElement[<=1] a_limited_other_value +================================================================================ +MSG: fastdds/FirstLevelElement +string useless_name +SecondLevelElement[] sub +ThirdLevelElement an_element_alone diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/float_bounded_sequence.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/float_bounded_sequence.msg new file mode 100644 index 00000000..77503c2e --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/float_bounded_sequence.msg @@ -0,0 +1 @@ +float32[<=13] numbers diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/hello_world.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/hello_world.msg new file mode 100644 index 00000000..63e3fbcb --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/hello_world.msg @@ -0,0 +1,2 @@ +uint32 index +string message diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/numeric_array.msg b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/numeric_array.msg new file mode 100644 index 00000000..d391c85d --- /dev/null +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/msgs/numeric_array.msg @@ -0,0 +1 @@ +int32[3] points diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequences.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequences.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequences.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequences.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequences.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequences.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequences.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequences.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesPubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesPubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesPubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesPubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesv1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesv1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesv1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesv1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/arrays_and_sequencesv1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/arrays_and_sequencesv1.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_struct.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_struct.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_struct.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_struct.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_struct.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_struct.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structPubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structPubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structPubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structPubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structv1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structv1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structv1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structv1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_array_structv1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_array_structv1.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_struct.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_struct.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_struct.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_struct.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_struct.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_struct.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structPubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structPubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structPubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structPubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structv1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structv1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structv1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structv1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/basic_structv1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/basic_structv1.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequence.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequence.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequence.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequence.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequence.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequence.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequence.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequence.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencePubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencePubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencePubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencePubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencePubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencePubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencePubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencePubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequenceTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequenceTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencev1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencev1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencev1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencev1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencev1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencev1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/char_sequencev1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/char_sequencev1.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arrays.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arrays.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arrays.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arrays.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arrays.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arrays.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arrays.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arrays.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysPubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysPubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysPubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysPubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysv1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysv1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysv1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysv1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/complex_nested_arraysv1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/complex_nested_arraysv1.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_struct.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_struct.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_struct.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_struct.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_struct.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_struct.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structPubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structPubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structPubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structPubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structv1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structv1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structv1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structv1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/enum_structv1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/enum_structv1.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequence.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequence.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequence.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequence.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequence.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequence.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequence.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequence.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencePubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencePubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencePubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencePubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencePubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencePubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencePubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencePubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequenceTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequenceTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencev1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencev1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencev1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencev1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencev1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencev1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/float_bounded_sequencev1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/float_bounded_sequencev1.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_world.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_world.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_world.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_world.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_world.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_world.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_world.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_world.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldPubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldPubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldPubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldPubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldv1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldv1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldv1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldv1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/hello_worldv1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/hello_worldv1.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_struct.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_struct.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_struct.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_struct.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_struct.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_struct.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structPubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structPubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structPubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structPubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structv1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structv1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structv1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structv1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/map_structv1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/map_structv1.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_array.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_array.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_array.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_array.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_array.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_array.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_array.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_array.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayPubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayPubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayPubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayPubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayv1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayv1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayv1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayv1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/numeric_arrayv1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/numeric_arrayv1.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_struct.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_struct.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_struct.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_struct.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_struct.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_struct.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_struct.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_struct.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structCdrAux.hpp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structCdrAux.hpp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structCdrAux.hpp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structCdrAux.hpp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structCdrAux.ipp b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structCdrAux.ipp similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structCdrAux.ipp rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structCdrAux.ipp diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structPubSubTypes.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structPubSubTypes.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structTypeObject.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structTypeObject.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structTypeObject.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structTypeObject.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structTypeObject.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structTypeObject.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structTypeObject.h diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structv1.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structv1.cxx similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structv1.cxx rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structv1.cxx diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structv1.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structv1.h similarity index 100% rename from ddspipe_core/test/unittest/types/dynamic_types/types/type_objects/union_structv1.h rename to ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structv1.h diff --git a/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp index ed0a3809..53055f21 100644 --- a/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp @@ -69,12 +69,19 @@ void CommonReader::init() // Create CommonReader // Listener must be set in creation as no callbacks should be missed // It is safe to do so here as object is already created and callbacks do not require anything set in this method - reader_ = dds_subscriber_->create_datareader( - dds_topic_, - reckon_reader_qos_(), - nullptr, - eprosima::fastdds::dds::StatusMask::all(), - payload_pool_); + #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + reader_ = dds_subscriber_->create_datareader( + dds_topic_, + reckon_reader_qos_(), + nullptr); + #else + reader_ = dds_subscriber_->create_datareader( + dds_topic_, + reckon_reader_qos_(), + nullptr, + eprosima::fastdds::dds::StatusMask::all(), + payload_pool_); + #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 if (!reader_) { diff --git a/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp b/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp index 04662d9e..661f60dd 100644 --- a/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp @@ -69,12 +69,19 @@ void CommonWriter::init() participant_id_ << " in topic " << topic_ << "."); } - writer_ = dds_publisher_->create_datawriter( - dds_topic_, - reckon_writer_qos_(), - nullptr, - eprosima::fastdds::dds::StatusMask::all(), - payload_pool_); + #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + writer_ = dds_publisher_->create_datawriter( + dds_topic_, + reckon_writer_qos_(), + nullptr); + #else + writer_ = dds_publisher_->create_datawriter( + dds_topic_, + reckon_writer_qos_(), + nullptr, + eprosima::fastdds::dds::StatusMask::all(), + payload_pool_); + #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 if (!writer_) { From 95ba5acd2afd6a677579ea8d19db4b7a8a893a6a Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 12 Jan 2024 10:44:14 +0100 Subject: [PATCH 2/7] FASTDDS_SUBDIRECTORY -> DDS_TYPES_VERSION Signed-off-by: Irene Bandera --- ddspipe_core/CMakeLists.txt | 6 +++--- .../test/unittest/types/dynamic_types/CMakeLists.txt | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ddspipe_core/CMakeLists.txt b/ddspipe_core/CMakeLists.txt index 8e5d51c8..c1d44470 100644 --- a/ddspipe_core/CMakeLists.txt +++ b/ddspipe_core/CMakeLists.txt @@ -73,14 +73,14 @@ compile_library( # Determine Fast DDS version if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(FASTDDS_SUBDIRECTORY "/v2/") + set(DDS_TYPES_VERSION "/v2/") else() - set(FASTDDS_SUBDIRECTORY "/v1/") + set(DDS_TYPES_VERSION "/v1/") endif() file(GLOB_RECURSE TEST_FILES "${PROJECT_SOURCE_DIR}/test/") foreach(TEST_FILE ${TEST_FILES}) - if(NOT TEST_FILE MATCHES ${FASTDDS_SUBDIRECTORY}) + if(NOT TEST_FILE MATCHES ${DDS_TYPES_VERSION}) compile_test_tool(${TEST_FILE}) endif() endforeach() diff --git a/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt b/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt index 18e87ad9..7417fe5f 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt +++ b/ddspipe_core/test/unittest/types/dynamic_types/CMakeLists.txt @@ -20,13 +20,13 @@ set(TEST_NAME dtypes_idl_tests) # Determine Fast DDS version if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(FASTDDS_SUBDIRECTORY "v1") + set(DDS_TYPES_VERSION "v1") else() - set(FASTDDS_SUBDIRECTORY "v2") + set(DDS_TYPES_VERSION "v2") endif() # Add to test sources every FastDDSGen file generated -file(GLOB DATATYPE_SOURCES_CXX "types/${FASTDDS_SUBDIRECTORY}/**/*.cxx") +file(GLOB DATATYPE_SOURCES_CXX "types/${DDS_TYPES_VERSION}/**/*.cxx") set(TEST_SOURCES dtypes_idl_tests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/types/dynamic_types/schema_idl.cpp @@ -49,7 +49,7 @@ file( RESULT_SOURCES_IDL RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - "types/${FASTDDS_SUBDIRECTORY}/idls/*.idl") + "types/${DDS_TYPES_VERSION}/idls/*.idl") set(TEST_NEEDED_SOURCES ${RESULT_SOURCES_IDL} @@ -70,7 +70,7 @@ add_unittest_executable( set(TEST_NAME dtypes_msg_tests) # Add to test sources every FastDDSGen file generated -file(GLOB DATATYPE_SOURCES_CXX "types/${FASTDDS_SUBDIRECTORY}/**/*.cxx") +file(GLOB DATATYPE_SOURCES_CXX "types/${DDS_TYPES_VERSION}/**/*.cxx") set(TEST_SOURCES dtypes_msg_tests.cpp ${PROJECT_SOURCE_DIR}/src/cpp/types/dynamic_types/schema_msg.cpp @@ -93,7 +93,7 @@ file( RESULT_SOURCES_MSG RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - "types/${FASTDDS_SUBDIRECTORY}/msgs/*.msg") + "types/${DDS_TYPES_VERSION}/msgs/*.msg") set(TEST_NEEDED_SOURCES ${RESULT_SOURCES_MSG} From a4b5e494224fa0262565fdee2d8d4aaba33fab92 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Wed, 17 Jan 2024 14:24:11 +0100 Subject: [PATCH 3/7] Apply changes Signed-off-by: Irene Bandera --- ddspipe_core/CMakeLists.txt | 2 +- ddspipe_core/project_settings.cmake | 2 +- ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp | 4 +++- ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ddspipe_core/CMakeLists.txt b/ddspipe_core/CMakeLists.txt index c1d44470..4f759260 100644 --- a/ddspipe_core/CMakeLists.txt +++ b/ddspipe_core/CMakeLists.txt @@ -81,7 +81,7 @@ endif() file(GLOB_RECURSE TEST_FILES "${PROJECT_SOURCE_DIR}/test/") foreach(TEST_FILE ${TEST_FILES}) if(NOT TEST_FILE MATCHES ${DDS_TYPES_VERSION}) - compile_test_tool(${TEST_FILE}) + compile_test_library(${TEST_FILE}) endif() endforeach() diff --git a/ddspipe_core/project_settings.cmake b/ddspipe_core/project_settings.cmake index 3cc5a672..6d1817ca 100644 --- a/ddspipe_core/project_settings.cmake +++ b/ddspipe_core/project_settings.cmake @@ -30,7 +30,7 @@ set(MODULE_FIND_PACKAGES cpp_utils ) -set(fastrtps_MINIMUM_VERSION "2.8") +set(fastrtps_MINIMUM_VERSION "2.10") set(MODULE_DEPENDENCIES $<$:iphlpapi$Shlwapi> diff --git a/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp index 53055f21..1033d1b2 100644 --- a/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp @@ -73,7 +73,9 @@ void CommonReader::init() reader_ = dds_subscriber_->create_datareader( dds_topic_, reckon_reader_qos_(), - nullptr); + payload_pool_, + nullptr, + eprosima::fastdds::dds::StatusMask::all()); #else reader_ = dds_subscriber_->create_datareader( dds_topic_, diff --git a/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp b/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp index 661f60dd..ea5c5118 100644 --- a/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp @@ -73,7 +73,9 @@ void CommonWriter::init() writer_ = dds_publisher_->create_datawriter( dds_topic_, reckon_writer_qos_(), - nullptr); + payload_pool_, + nullptr, + eprosima::fastdds::dds::StatusMask::all()); #else writer_ = dds_publisher_->create_datawriter( dds_topic_, From 5dcfd24e54881956dfdc83a98858442c33e2d328 Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Wed, 17 Jan 2024 16:34:15 +0100 Subject: [PATCH 4/7] Correct function names Signed-off-by: Irene Bandera --- .../src/cpp/reader/dds/CommonReader.cpp | 24 +++++++++---------- .../src/cpp/writer/dds/CommonWriter.cpp | 24 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp index 1033d1b2..aea4cce7 100644 --- a/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp @@ -70,19 +70,19 @@ void CommonReader::init() // Listener must be set in creation as no callbacks should be missed // It is safe to do so here as object is already created and callbacks do not require anything set in this method #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - reader_ = dds_subscriber_->create_datareader( - dds_topic_, - reckon_reader_qos_(), - payload_pool_, - nullptr, - eprosima::fastdds::dds::StatusMask::all()); + reader_ = dds_subscriber_->create_datareader_with_payload_pool( + dds_topic_, + reckon_reader_qos_(), + payload_pool_, + nullptr, + eprosima::fastdds::dds::StatusMask::all()); #else - reader_ = dds_subscriber_->create_datareader( - dds_topic_, - reckon_reader_qos_(), - nullptr, - eprosima::fastdds::dds::StatusMask::all(), - payload_pool_); + reader_ = dds_subscriber_->create_datareader( + dds_topic_, + reckon_reader_qos_(), + nullptr, + eprosima::fastdds::dds::StatusMask::all(), + payload_pool_); #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 if (!reader_) diff --git a/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp b/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp index ea5c5118..6640fe8e 100644 --- a/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp @@ -70,19 +70,19 @@ void CommonWriter::init() } #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - writer_ = dds_publisher_->create_datawriter( - dds_topic_, - reckon_writer_qos_(), - payload_pool_, - nullptr, - eprosima::fastdds::dds::StatusMask::all()); + writer_ = dds_publisher_->create_datawriter_with_payload_pool( + dds_topic_, + reckon_writer_qos_(), + payload_pool_, + nullptr, + eprosima::fastdds::dds::StatusMask::all()); #else - writer_ = dds_publisher_->create_datawriter( - dds_topic_, - reckon_writer_qos_(), - nullptr, - eprosima::fastdds::dds::StatusMask::all(), - payload_pool_); + writer_ = dds_publisher_->create_datawriter( + dds_topic_, + reckon_writer_qos_(), + nullptr, + eprosima::fastdds::dds::StatusMask::all(), + payload_pool_); #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 if (!writer_) From 4c0071ecb5fbcf5471ecc620b04bf84824aa78ae Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 19 Jan 2024 12:40:06 +0100 Subject: [PATCH 5/7] Update FASTRTPS version check in CommonReader and CommonWriter Signed-off-by: Irene Bandera --- ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp | 2 +- ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp b/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp index aea4cce7..390a4587 100644 --- a/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp +++ b/ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp @@ -69,7 +69,7 @@ void CommonReader::init() // Create CommonReader // Listener must be set in creation as no callbacks should be missed // It is safe to do so here as object is already created and callbacks do not require anything set in this method - #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 12 reader_ = dds_subscriber_->create_datareader_with_payload_pool( dds_topic_, reckon_reader_qos_(), diff --git a/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp b/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp index 6640fe8e..bfb4d46b 100644 --- a/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp +++ b/ddspipe_participants/src/cpp/writer/dds/CommonWriter.cpp @@ -69,7 +69,7 @@ void CommonWriter::init() participant_id_ << " in topic " << topic_ << "."); } - #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 12 writer_ = dds_publisher_->create_datawriter_with_payload_pool( dds_topic_, reckon_writer_qos_(), From 9253fc5017f79259ab68a8d0ddfdac0d8ea9c24b Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Fri, 19 Jan 2024 12:59:50 +0100 Subject: [PATCH 6/7] Uncrustify Signed-off-by: Irene Bandera --- .../test/unittest/types/dynamic_types/dtypes_idl_tests.cpp | 4 ++-- .../test/unittest/types/dynamic_types/dtypes_msg_tests.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp index 215c706c..401fe14e 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_idl_tests.cpp @@ -44,9 +44,9 @@ std::string file_name_by_type( SupportedType type) { #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - return std::string("types/v1/idls/") + to_string(type) + ".idl"; + return std::string("types/v1/idls/") + to_string(type) + ".idl"; #else - return std::string("types/v2/idls/") + to_string(type) + ".idl"; + return std::string("types/v2/idls/") + to_string(type) + ".idl"; #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 } diff --git a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp index fd41cf44..79f31941 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp +++ b/ddspipe_core/test/unittest/types/dynamic_types/dtypes_msg_tests.cpp @@ -39,9 +39,9 @@ std::string file_name_by_type( SupportedType type) { #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - return std::string("types/v1/msgs/") + to_string(type) + ".msg"; + return std::string("types/v1/msgs/") + to_string(type) + ".msg"; #else - return std::string("types/v2/msgs/") + to_string(type) + ".msg"; + return std::string("types/v2/msgs/") + to_string(type) + ".msg"; #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 } From dfcb11c59ca8d8130da6c49f382e768308d916bc Mon Sep 17 00:00:00 2001 From: Irene Bandera Date: Mon, 22 Jan 2024 09:33:43 +0100 Subject: [PATCH 7/7] Compile test libraries in ddspipe_core Signed-off-by: Irene Bandera --- ddspipe_core/CMakeLists.txt | 15 +- .../arrays_and_sequencesTypeObject.h | 521 ++--------------- .../v1/type_objects/union_structPubSubTypes.h | 181 ++---- .../v1/type_objects/union_structTypeObject.h | 522 ++---------------- .../type_objects/union_structPubSubTypes.cxx | 1 - .../v2/type_objects/union_structPubSubTypes.h | 1 - 6 files changed, 151 insertions(+), 1090 deletions(-) diff --git a/ddspipe_core/CMakeLists.txt b/ddspipe_core/CMakeLists.txt index 4f759260..3b819f42 100644 --- a/ddspipe_core/CMakeLists.txt +++ b/ddspipe_core/CMakeLists.txt @@ -70,20 +70,7 @@ compile_library( # Test ############################################################################### # Compile tests if CMake options requires it - -# Determine Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(DDS_TYPES_VERSION "/v2/") -else() - set(DDS_TYPES_VERSION "/v1/") -endif() - -file(GLOB_RECURSE TEST_FILES "${PROJECT_SOURCE_DIR}/test/") -foreach(TEST_FILE ${TEST_FILES}) - if(NOT TEST_FILE MATCHES ${DDS_TYPES_VERSION}) - compile_test_library(${TEST_FILE}) - endif() -endforeach() +compile_test_library("${PROJECT_SOURCE_DIR}/test/") ############################################################################### # Packaging diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h index b6e19eaf..4ad8329f 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/arrays_and_sequencesTypeObject.h @@ -13,475 +13,60 @@ // limitations under the License. /*! - * @file arrays_and_sequencesTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. + * @file arrays_and_sequencesTypeObject.h + * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool gen. */ -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "arrays_and_sequences.h" -#include "arrays_and_sequencesTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerarrays_and_sequencesTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(true), - GetAnInternalObjectObject(true)); - factory->add_type_object("AnInternalObject", GetAnInternalObjectIdentifier(false), - GetAnInternalObjectObject(false)); - - factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(true), - Getarrays_and_sequencesObject(true)); - factory->add_type_object("arrays_and_sequences", Getarrays_and_sequencesIdentifier(false), - Getarrays_and_sequencesObject(false)); - -} - -const TypeIdentifier* GetAnInternalObjectIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetAnInternalObjectObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("AnInternalObject", complete); -} - -const TypeObject* GetAnInternalObjectObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteAnInternalObjectObject(); - } - //else - return GetMinimalAnInternalObjectObject(); -} - -const TypeObject* GetMinimalAnInternalObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_x; - mst_x.common().member_id(memberId++); - mst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_x.common().member_flags().IS_OPTIONAL(false); - mst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_x.common().member_flags().IS_KEY(false); - mst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); - - MD5 x_hash("x"); - for(int i = 0; i < 4; ++i) - { - mst_x.detail().name_hash()[i] = x_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_x); - - MinimalStructMember mst_positive; - mst_positive.common().member_id(memberId++); - mst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_positive.common().member_flags().IS_OPTIONAL(false); - mst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_positive.common().member_flags().IS_KEY(false); - mst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - MD5 positive_hash("positive"); - for(int i = 0; i < 4; ++i) - { - mst_positive.detail().name_hash()[i] = positive_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_positive); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", false); -} - -const TypeObject* GetCompleteAnInternalObjectObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_x; - cst_x.common().member_id(memberId++); - cst_x.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_x.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_x.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_x.common().member_flags().IS_OPTIONAL(false); - cst_x.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_x.common().member_flags().IS_KEY(false); - cst_x.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_x.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("float", false)); - - cst_x.detail().name("x"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_x); - - CompleteStructMember cst_positive; - cst_positive.common().member_id(memberId++); - cst_positive.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_positive.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_positive.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_positive.common().member_flags().IS_OPTIONAL(false); - cst_positive.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_positive.common().member_flags().IS_KEY(false); - cst_positive.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_positive.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - cst_positive.detail().name("positive"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_positive); - - - // Header - type_object->complete().struct_type().header().detail().type_name("AnInternalObject"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("AnInternalObject", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("AnInternalObject", true); -} - -const TypeIdentifier* Getarrays_and_sequencesIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getarrays_and_sequencesObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("arrays_and_sequences", complete); -} - -const TypeObject* Getarrays_and_sequencesObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletearrays_and_sequencesObject(); - } - //else - return GetMinimalarrays_and_sequencesObject(); -} - -const TypeObject* GetMinimalarrays_and_sequencesObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_unlimited_vector; - mst_unlimited_vector.common().member_id(memberId++); - mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); - mst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_unlimited_vector.common().member_flags().IS_KEY(false); - mst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, false)); - - - MD5 unlimited_vector_hash("unlimited_vector"); - for(int i = 0; i < 4; ++i) - { - mst_unlimited_vector.detail().name_hash()[i] = unlimited_vector_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_unlimited_vector); - - MinimalStructMember mst_limited_vector; - mst_limited_vector.common().member_id(memberId++); - mst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_limited_vector.common().member_flags().IS_OPTIONAL(false); - mst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_limited_vector.common().member_flags().IS_KEY(false); - mst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, false)); - - - MD5 limited_vector_hash("limited_vector"); - for(int i = 0; i < 4; ++i) - { - mst_limited_vector.detail().name_hash()[i] = limited_vector_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_vector); - - MinimalStructMember mst_limited_array; - mst_limited_array.common().member_id(memberId++); - mst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_limited_array.common().member_flags().IS_OPTIONAL(false); - mst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_limited_array.common().member_flags().IS_KEY(false); - mst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, false)); - - - MD5 limited_array_hash("limited_array"); - for(int i = 0; i < 4; ++i) - { - mst_limited_array.detail().name_hash()[i] = limited_array_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_limited_array); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", false); -} - -const TypeObject* GetCompletearrays_and_sequencesObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_unlimited_vector; - cst_unlimited_vector.common().member_id(memberId++); - cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_unlimited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_unlimited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_unlimited_vector.common().member_flags().IS_OPTIONAL(false); - cst_unlimited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_unlimited_vector.common().member_flags().IS_KEY(false); - cst_unlimited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_unlimited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 0, true)); - - - cst_unlimited_vector.detail().name("unlimited_vector"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_unlimited_vector); - - CompleteStructMember cst_limited_vector; - cst_limited_vector.common().member_id(memberId++); - cst_limited_vector.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_limited_vector.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_limited_vector.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_limited_vector.common().member_flags().IS_OPTIONAL(false); - cst_limited_vector.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_limited_vector.common().member_flags().IS_KEY(false); - cst_limited_vector.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_limited_vector.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("AnInternalObject", 10, true)); - - - cst_limited_vector.detail().name("limited_vector"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_limited_vector); - - CompleteStructMember cst_limited_array; - cst_limited_array.common().member_id(memberId++); - cst_limited_array.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_limited_array.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_limited_array.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_limited_array.common().member_flags().IS_OPTIONAL(false); - cst_limited_array.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_limited_array.common().member_flags().IS_KEY(false); - cst_limited_array.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_limited_array.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("AnInternalObject", {10}, true)); - - - cst_limited_array.detail().name("limited_array"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_limited_array); - - - // Header - type_object->complete().struct_type().header().detail().type_name("arrays_and_sequences"); - // TODO inheritance - - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("arrays_and_sequences", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("arrays_and_sequences", true); -} +#ifndef _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ + + +#include +#include + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define eProsima_user_DllExport +#endif // if defined(_WIN32) + +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(arrays_and_sequences_SOURCE) +#define arrays_and_sequences_DllAPI __declspec( dllexport ) +#else +#define arrays_and_sequences_DllAPI __declspec( dllimport ) +#endif // arrays_and_sequences_SOURCE +#else +#define arrays_and_sequences_DllAPI +#endif // if defined(EPROSIMA_USER_DLL_EXPORT) +#else +#define arrays_and_sequences_DllAPI +#endif // _WIN32 + +using namespace eprosima::fastrtps::types; + +eProsima_user_DllExport void registerarrays_and_sequencesTypes(); + +eProsima_user_DllExport const TypeIdentifier* GetAnInternalObjectIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetAnInternalObjectObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalAnInternalObjectObject(); +eProsima_user_DllExport const TypeObject* GetCompleteAnInternalObjectObject(); + +eProsima_user_DllExport const TypeIdentifier* Getarrays_and_sequencesIdentifier( + bool complete = false); +eProsima_user_DllExport const TypeObject* Getarrays_and_sequencesObject( + bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalarrays_and_sequencesObject(); +eProsima_user_DllExport const TypeObject* GetCompletearrays_and_sequencesObject(); + + +#endif // _FAST_DDS_GENERATED_ARRAYS_AND_SEQUENCES_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h index c1812023..4e92f498 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structPubSubTypes.h @@ -13,158 +13,93 @@ // limitations under the License. /*! - * @file union_structPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. + * @file union_structPubSubTypes.h + * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastcdrgen. */ -#include -#include +#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ -#include "union_structPubSubTypes.h" +#include +#include -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +#include "union_struct.h" -union_structPubSubType::union_structPubSubType() -{ - setName("union_struct"); - auto type_size = union_struct::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = union_struct::isKeyDefined(); - size_t keyLength = union_struct::getKeyMaxCdrSerializedSize() > 16 ? - union_struct::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -union_structPubSubType::~union_structPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} +#if !defined(GEN_API_VER) || (GEN_API_VER != 1) +#error \ + Generated union_struct is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER -bool union_structPubSubType::serialize( - void* data, - SerializedPayload_t* payload) + + +/*! + * @brief This class represents the TopicDataType of the type union_struct defined by the user in the IDL file. + * @ingroup union_struct + */ +class union_structPubSubType : public eprosima::fastdds::dds::TopicDataType { - union_struct* p_type = static_cast(data); +public: - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + typedef union_struct type; - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - p_type->serialize(ser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } + eProsima_user_DllExport union_structPubSubType(); - // Get the serialized length - payload->length = static_cast(ser.getSerializedDataLength()); - return true; -} + eProsima_user_DllExport virtual ~union_structPubSubType() override; -bool union_structPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - union_struct* p_type = static_cast(data); + eProsima_user_DllExport virtual bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override; - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->length); + eProsima_user_DllExport virtual bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; - // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); + eProsima_user_DllExport virtual std::function getSerializedSizeProvider( + void* data) override; - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + eProsima_user_DllExport virtual bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; - // Deserialize the object. - p_type->deserialize(deser); - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) + eProsima_user_DllExport virtual void* createData() override; + + eProsima_user_DllExport virtual void deleteData( + void* data) override; + +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED + eProsima_user_DllExport inline bool is_bounded() const override { return false; } - return true; -} +#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED -std::function union_structPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* union_structPubSubType::createData() -{ - return reinterpret_cast(new union_struct()); -} +#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN + eProsima_user_DllExport inline bool is_plain() const override + { + return false; + } -void union_structPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} +#endif // TOPIC_DATA_TYPE_API_HAS_IS_PLAIN -bool union_structPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) +#ifdef TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + eProsima_user_DllExport inline bool construct_sample( + void* memory) const override { + (void)memory; return false; } - union_struct* p_type = static_cast(data); +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - union_struct::getKeyMaxCdrSerializedSize()); + MD5 m_md5; + unsigned char* m_keyBuffer; - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || union_struct::getKeyMaxCdrSerializedSize() > 16) - { - m_md5.init(); - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - m_md5.finalize(); - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_md5.digest[i]; - } - } - else - { - for (uint8_t i = 0; i < 16; ++i) - { - handle->value[i] = m_keyBuffer[i]; - } - } - return true; -} +}; + +#endif // _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h index 8796c646..f341bb35 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v1/type_objects/union_structTypeObject.h @@ -13,500 +13,56 @@ // limitations under the License. /*! - * @file union_structTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. + * @file union_structTypeObject.h + * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool gen. */ -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { char dummy; } -#endif - -#include "union_struct.h" -#include "union_structTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerunion_structTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("MyUnion", GetMyUnionIdentifier(true), - GetMyUnionObject(true)); - factory->add_type_object("MyUnion", GetMyUnionIdentifier(false), - GetMyUnionObject(false)); - - factory->add_type_object("union_struct", Getunion_structIdentifier(true), - Getunion_structObject(true)); - factory->add_type_object("union_struct", Getunion_structIdentifier(false), - Getunion_structObject(false)); - - }); -} - -const TypeIdentifier* GetMyUnionIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMyUnionObject(complete); - return TypeObjectFactory::get_instance()->get_type_identifier("MyUnion", complete); -} - -const TypeObject* GetMyUnionObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMyUnionObject(); - } - // else - return GetMinimalMyUnionObject(); -} - -const TypeObject* GetMinimalMyUnionObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_UNION); - - type_object->minimal().union_type().union_flags().IS_FINAL(false); - type_object->minimal().union_type().union_flags().IS_APPENDABLE(false); - type_object->minimal().union_type().union_flags().IS_MUTABLE(false); - type_object->minimal().union_type().union_flags().IS_NESTED(false); - type_object->minimal().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported - - type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - type_object->minimal().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported - type_object->minimal().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply - - type_object->minimal().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - MemberId memberId = 0; - MinimalUnionMember mst_octet_value; - mst_octet_value.common().member_id(memberId++); - mst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_octet_value.common().member_flags().IS_DEFAULT(false); - mst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); - - mst_octet_value.common().label_seq().emplace_back(1); - MD5 octet_value_hash("octet_value"); - for(int i = 0; i < 4; ++i) - { - mst_octet_value.detail().name_hash()[i] = octet_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_octet_value); - - MinimalUnionMember mst_long_value; - mst_long_value.common().member_id(memberId++); - mst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_long_value.common().member_flags().IS_DEFAULT(false); - mst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - mst_long_value.common().label_seq().emplace_back(2); - MD5 long_value_hash("long_value"); - for(int i = 0; i < 4; ++i) - { - mst_long_value.detail().name_hash()[i] = long_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_long_value); - - MinimalUnionMember mst_string_value; - mst_string_value.common().member_id(memberId++); - mst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - mst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - mst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply - mst_string_value.common().member_flags().IS_DEFAULT(false); - mst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - mst_string_value.common().label_seq().emplace_back(3); - MD5 string_value_hash("string_value"); - for(int i = 0; i < 4; ++i) - { - mst_string_value.detail().name_hash()[i] = string_value_hash.digest[i]; - } - type_object->minimal().union_type().member_seq().emplace_back(mst_string_value); - - - // Header - //type_object->minimal().union_type().header().detail()... // Empty - - TypeIdentifier* identifier = new TypeIdentifier(); - identifier->_d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalUnionType::getCdrSerializedSize(type_object->minimal().union_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier->equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); - delete type_object; - delete identifier; - return TypeObjectFactory::get_instance()->get_type_object("MyUnion", false); -} - -const TypeObject* GetCompleteMyUnionObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_UNION); - - type_object->complete().union_type().union_flags().IS_FINAL(false); - type_object->complete().union_type().union_flags().IS_APPENDABLE(false); - type_object->complete().union_type().union_flags().IS_MUTABLE(false); - type_object->complete().union_type().union_flags().IS_NESTED(false); - type_object->complete().union_type().union_flags().IS_AUTOID_HASH(false); // Unsupported - - type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().IS_EXTERNAL(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_OPTIONAL(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - type_object->complete().union_type().discriminator().common().member_flags().IS_KEY(false); // Unsupported - type_object->complete().union_type().discriminator().common().member_flags().IS_DEFAULT(false); // Doesn't apply - - type_object->complete().union_type().discriminator().common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - MemberId memberId = 0; - CompleteUnionMember cst_octet_value; - cst_octet_value.common().member_id(memberId++); - cst_octet_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_octet_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_octet_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_octet_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_octet_value.common().member_flags().IS_DEFAULT(false); - cst_octet_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint8_t", false)); - cst_octet_value.common().label_seq().emplace_back(1); - - cst_octet_value.detail().name("octet_value"); - - type_object->complete().union_type().member_seq().emplace_back(cst_octet_value); - - CompleteUnionMember cst_long_value; - cst_long_value.common().member_id(memberId++); - cst_long_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_long_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_long_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_long_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_long_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_long_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_long_value.common().member_flags().IS_DEFAULT(false); - cst_long_value.common().type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - cst_long_value.common().label_seq().emplace_back(2); +#ifndef _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ +#define _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ - cst_long_value.detail().name("long_value"); - type_object->complete().union_type().member_seq().emplace_back(cst_long_value); +#include +#include - CompleteUnionMember cst_string_value; - cst_string_value.common().member_id(memberId++); - cst_string_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_string_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_string_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_string_value.common().member_flags().IS_OPTIONAL(false); // Doesn't apply - cst_string_value.common().member_flags().IS_MUST_UNDERSTAND(false); // Doesn't apply - cst_string_value.common().member_flags().IS_KEY(false); // Doesn't apply - cst_string_value.common().member_flags().IS_DEFAULT(false); - cst_string_value.common().type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_string_value.common().label_seq().emplace_back(3); - - cst_string_value.detail().name("string_value"); - - type_object->complete().union_type().member_seq().emplace_back(cst_string_value); - - - // Header - type_object->complete().union_type().header().detail().type_name("MyUnion"); - - - TypeIdentifier* identifier = new TypeIdentifier(); - identifier->_d(EK_COMPLETE); - - SerializedPayload_t payload(static_cast( - CompleteUnionType::getCdrSerializedSize(type_object->complete().union_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier->equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("MyUnion", identifier, type_object); - delete type_object; - delete identifier; - return TypeObjectFactory::get_instance()->get_type_object("MyUnion", true); -} - -const TypeIdentifier* Getunion_structIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - Getunion_structObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("union_struct", complete); -} - -const TypeObject* Getunion_structObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteunion_structObject(); - } - //else - return GetMinimalunion_structObject(); -} - -const TypeObject* GetMinimalunion_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", false); - if (c_type_object != nullptr) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_MINIMAL); - type_object->minimal()._d(TK_STRUCTURE); - - type_object->minimal().struct_type().struct_flags().IS_FINAL(false); - type_object->minimal().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->minimal().struct_type().struct_flags().IS_MUTABLE(false); - type_object->minimal().struct_type().struct_flags().IS_NESTED(false); - type_object->minimal().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - MinimalStructMember mst_index; - mst_index.common().member_id(memberId++); - mst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_index.common().member_flags().IS_OPTIONAL(false); - mst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_index.common().member_flags().IS_KEY(false); - mst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - MD5 index_hash("index"); - for(int i = 0; i < 4; ++i) - { - mst_index.detail().name_hash()[i] = index_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_index); - - MinimalStructMember mst_union_value; - mst_union_value.common().member_id(memberId++); - mst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_union_value.common().member_flags().IS_OPTIONAL(false); - mst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_union_value.common().member_flags().IS_KEY(false); - mst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_union_value.common().member_type_id(*GetMyUnionIdentifier(false)); - MD5 union_value_hash("union_value"); - for(int i = 0; i < 4; ++i) - { - mst_union_value.detail().name_hash()[i] = union_value_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_union_value); - - - // Header - // TODO Inheritance - //type_object->minimal().struct_type().header().base_type()._d(EK_MINIMAL); - //type_object->minimal().struct_type().header().base_type().equivalence_hash()[0..13]; - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - SerializedPayload_t payload(static_cast( - MinimalStructType::getCdrSerializedSize(type_object->minimal().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; - - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - - TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("union_struct", false); -} - -const TypeObject* GetCompleteunion_structObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("union_struct", true); - if (c_type_object != nullptr && c_type_object->_d() == EK_COMPLETE) - { - return c_type_object; - } - - TypeObject *type_object = new TypeObject(); - type_object->_d(EK_COMPLETE); - type_object->complete()._d(TK_STRUCTURE); - - type_object->complete().struct_type().struct_flags().IS_FINAL(false); - type_object->complete().struct_type().struct_flags().IS_APPENDABLE(false); - type_object->complete().struct_type().struct_flags().IS_MUTABLE(false); - type_object->complete().struct_type().struct_flags().IS_NESTED(false); - type_object->complete().struct_type().struct_flags().IS_AUTOID_HASH(false); // Unsupported - - MemberId memberId = 0; - CompleteStructMember cst_index; - cst_index.common().member_id(memberId++); - cst_index.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_index.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_index.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_index.common().member_flags().IS_OPTIONAL(false); - cst_index.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_index.common().member_flags().IS_KEY(false); - cst_index.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_index.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - cst_index.detail().name("index"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_index); - - CompleteStructMember cst_union_value; - cst_union_value.common().member_id(memberId++); - cst_union_value.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_union_value.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_union_value.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_union_value.common().member_flags().IS_OPTIONAL(false); - cst_union_value.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_union_value.common().member_flags().IS_KEY(false); - cst_union_value.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_union_value.common().member_type_id(*GetMyUnionIdentifier(true)); - cst_union_value.detail().name("union_value"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_union_value); +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#define eProsima_user_DllExport __declspec( dllexport ) +#else +#define eProsima_user_DllExport +#endif +#else +#define eProsima_user_DllExport +#endif +#if defined(_WIN32) +#if defined(EPROSIMA_USER_DLL_EXPORT) +#if defined(union_struct_SOURCE) +#define union_struct_DllAPI __declspec( dllexport ) +#else +#define union_struct_DllAPI __declspec( dllimport ) +#endif // union_struct_SOURCE +#else +#define union_struct_DllAPI +#endif +#else +#define union_struct_DllAPI +#endif // _WIN32 - // Header - type_object->complete().struct_type().header().detail().type_name("union_struct"); - // TODO inheritance +using namespace eprosima::fastrtps::types; +eProsima_user_DllExport void registerunion_structTypes(); - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); +eProsima_user_DllExport const TypeIdentifier* GetMyUnionIdentifier(bool complete = false); +eProsima_user_DllExport const TypeObject* GetMyUnionObject(bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalMyUnionObject(); +eProsima_user_DllExport const TypeObject* GetCompleteMyUnionObject(); - SerializedPayload_t payload(static_cast( - CompleteStructType::getCdrSerializedSize(type_object->complete().struct_type()) + 4)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - // Fixed endian (Page 221, EquivalenceHash definition of Extensible and Dynamic Topic Types for DDS document) - eprosima::fastcdr::Cdr ser( - fastbuffer, eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS, - eprosima::fastcdr::Cdr::DDS_CDR); // Object that serializes the data. - payload.encapsulation = CDR_LE; +eProsima_user_DllExport const TypeIdentifier* Getunion_structIdentifier(bool complete = false); +eProsima_user_DllExport const TypeObject* Getunion_structObject(bool complete = false); +eProsima_user_DllExport const TypeObject* GetMinimalunion_structObject(); +eProsima_user_DllExport const TypeObject* GetCompleteunion_structObject(); - type_object->serialize(ser); - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length - MD5 objectHash; - objectHash.update((char*)payload.data, payload.length); - objectHash.finalize(); - for(int i = 0; i < 14; ++i) - { - identifier.equivalence_hash()[i] = objectHash.digest[i]; - } - TypeObjectFactory::get_instance()->add_type_object("union_struct", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("union_struct", true); -} +#endif // _FAST_DDS_GENERATED_UNION_STRUCT_TYPE_OBJECT_H_ diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx index 6920b659..35732fdd 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.cxx @@ -222,4 +222,3 @@ bool union_structPubSubType::getKey( } return true; } - diff --git a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h index c688a939..ca9f95d0 100644 --- a/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h +++ b/ddspipe_core/test/unittest/types/dynamic_types/types/v2/type_objects/union_structPubSubTypes.h @@ -133,4 +133,3 @@ class union_structPubSubType : public eprosima::fastdds::dds::TopicDataType }; #endif // _FAST_DDS_GENERATED_UNION_STRUCT_PUBSUBTYPES_H_ -