From 3c543f7abddd77c2b76d4d7141ad47c2cc372334 Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Tue, 18 Jun 2024 09:14:01 +0200 Subject: [PATCH 01/52] [20509] Update repository for Fast DDS 3.0.0 compatibility Signed-off-by: Lucia Echevarria --- controller/controller_tool/CMakeLists.txt | 11 +- .../DdsRecorderCommand/CMakeLists.txt | 9 +- .../DdsRecorderCommand.hpp} | 129 +- .../DdsRecorderCommand/DdsRecorderCommand.idl | 0 .../DdsRecorderCommandCdrAux.hpp | 4 +- .../DdsRecorderCommandCdrAux.ipp | 26 +- .../DdsRecorderCommandPubSubTypes.cxx | 28 +- .../DdsRecorderCommandPubSubTypes.h | 11 +- .../DdsRecorderCommandTypeObjectSupport.cxx | 146 ++ .../DdsRecorderCommandTypeObjectSupport.hpp | 56 + .../{v2 => }/DdsRecorderStatus/CMakeLists.txt | 9 +- .../DdsRecorderStatus/DdsRecorderStatus.hpp | 156 +- .../DdsRecorderStatus/DdsRecorderStatus.idl | 0 .../DdsRecorderStatusCdrAux.hpp | 4 +- .../DdsRecorderStatusCdrAux.ipp | 36 +- .../DdsRecorderStatusPubSubTypes.cxx | 29 +- .../DdsRecorderStatusPubSubTypes.h | 11 +- .../DdsRecorderStatusTypeObjectSupport.cxx | 184 +++ .../DdsRecorderStatusTypeObjectSupport.hpp | 56 + .../v1/DdsRecorderCommand/CMakeLists.txt | 112 -- .../DdsRecorderCommand/DdsRecorderCommand.cxx | 234 --- .../DdsRecorderCommand/DdsRecorderCommand.h | 241 --- .../DdsRecorderCommand/DdsRecorderCommand.i | 99 -- .../DdsRecorderCommandPubSubTypes.cxx | 169 --- .../DdsRecorderCommandPubSubTypes.h | 101 -- .../DdsRecorderCommandPubSubTypes.i | 30 - .../v1/DdsRecorderStatus/CMakeLists.txt | 112 -- .../DdsRecorderStatus/DdsRecorderStatus.cxx | 282 ---- .../v1/DdsRecorderStatus/DdsRecorderStatus.h | 267 ---- .../v1/DdsRecorderStatus/DdsRecorderStatus.i | 107 -- .../DdsRecorderStatusPubSubTypes.cxx | 169 --- .../DdsRecorderStatusPubSubTypes.h | 101 -- .../DdsRecorderStatusPubSubTypes.i | 30 - .../DdsRecorderCommand/DdsRecorderCommand.cxx | 176 --- .../DdsRecorderCommand/DdsRecorderCommand.i | 121 -- .../DdsRecorderCommandPubSubTypes.i | 30 - .../DdsRecorderCommandv1.cxx | 299 ---- .../DdsRecorderCommand/DdsRecorderCommandv1.h | 249 ---- .../DdsRecorderStatus/DdsRecorderStatus.cxx | 219 --- .../v2/DdsRecorderStatus/DdsRecorderStatus.i | 131 -- .../DdsRecorderStatusPubSubTypes.i | 30 - .../DdsRecorderStatus/DdsRecorderStatusv1.cxx | 361 ----- .../DdsRecorderStatus/DdsRecorderStatusv1.h | 277 ---- controller/controller_tool/package.xml | 2 +- .../controller_tool/project_settings.cmake | 2 +- ddsrecorder/CMakeLists.txt | 9 +- ddsrecorder/project_settings.cmake | 4 +- .../cpp/command_receiver/CommandReceiver.cpp | 21 +- .../cpp/command_receiver/CommandReceiver.hpp | 58 +- .../DdsRecorderCommand.hpp} | 129 +- .../DdsRecorderCommand/DdsRecorderCommand.idl | 0 .../DdsRecorderCommandCdrAux.hpp | 4 +- .../DdsRecorderCommandCdrAux.ipp | 26 +- .../DdsRecorderCommandPubSubTypes.cxx | 31 +- .../DdsRecorderCommandPubSubTypes.h | 11 +- .../DdsRecorderCommandTypeObjectSupport.cxx | 146 ++ .../DdsRecorderCommandTypeObjectSupport.hpp | 56 + .../DdsRecorderStatus/DdsRecorderStatus.hpp | 156 +- .../DdsRecorderStatus/DdsRecorderStatus.idl | 0 .../DdsRecorderStatusCdrAux.hpp | 4 +- .../DdsRecorderStatusCdrAux.ipp | 36 +- .../DdsRecorderStatusPubSubTypes.cxx | 31 +- .../DdsRecorderStatusPubSubTypes.h | 11 +- .../DdsRecorderStatusTypeObjectSupport.cxx | 184 +++ .../DdsRecorderStatusTypeObjectSupport.hpp | 56 + .../DdsRecorderCommand/DdsRecorderCommand.cxx | 234 --- .../DdsRecorderCommand/DdsRecorderCommand.h | 241 --- .../DdsRecorderCommand/DdsRecorderCommand.idl | 5 - .../DdsRecorderCommandPubSubTypes.cxx | 169 --- .../DdsRecorderCommandPubSubTypes.h | 101 -- .../DdsRecorderCommandTypeObject.cxx | 255 ---- .../DdsRecorderCommandTypeObject.h | 65 - .../DdsRecorderStatus/DdsRecorderStatus.cxx | 285 ---- .../v1/DdsRecorderStatus/DdsRecorderStatus.h | 267 ---- .../DdsRecorderStatus/DdsRecorderStatus.idl | 6 - .../DdsRecorderStatusPubSubTypes.cxx | 169 --- .../DdsRecorderStatusPubSubTypes.h | 101 -- .../DdsRecorderStatusTypeObject.cxx | 285 ---- .../DdsRecorderStatusTypeObject.h | 65 - .../DdsRecorderCommand/DdsRecorderCommand.cxx | 180 --- .../DdsRecorderCommand/DdsRecorderCommand.idl | 5 - .../DdsRecorderCommandTypeObject.cxx | 265 ---- .../DdsRecorderCommandTypeObject.h | 67 - .../DdsRecorderCommandv1.cxx | 303 ---- .../DdsRecorderCommand/DdsRecorderCommandv1.h | 249 ---- .../DdsRecorderStatus/DdsRecorderStatus.cxx | 223 --- .../DdsRecorderStatus/DdsRecorderStatus.idl | 6 - .../DdsRecorderStatusTypeObject.cxx | 297 ---- .../DdsRecorderStatusTypeObject.h | 67 - .../DdsRecorderStatus/DdsRecorderStatusv1.cxx | 365 ----- .../DdsRecorderStatus/DdsRecorderStatusv1.h | 277 ---- ddsrecorder/test/blackbox/mcap/CMakeLists.txt | 9 - .../blackbox/mcap/McapFileCreationTest.cpp | 4 +- .../blackbox/resource_limits/CMakeLists.txt | 16 - .../types/hello_world/HelloWorld.hpp | 124 +- .../types}/hello_world/HelloWorldCdrAux.hpp | 4 +- .../types}/hello_world/HelloWorldCdrAux.ipp | 26 +- .../{v2 => }/HelloWorldPubSubTypes.cxx | 29 +- .../{v2 => }/HelloWorldPubSubTypes.h | 11 +- .../HelloWorldTypeObjectSupport.cxx | 138 ++ .../HelloWorldTypeObjectSupport.hpp | 56 + .../types/hello_world/v1/HelloWorld.cxx | 239 --- .../types/hello_world/v1/HelloWorld.h | 234 --- .../hello_world/v1/HelloWorldPubSubTypes.cxx | 170 --- .../hello_world/v1/HelloWorldPubSubTypes.h | 101 -- .../hello_world/v1/HelloWorldTypeObject.cxx | 252 ---- .../hello_world/v1/HelloWorldTypeObject.h | 65 - .../types/hello_world/v2/HelloWorld.cxx | 170 --- .../hello_world/v2/HelloWorldTypeObject.cxx | 265 ---- .../hello_world/v2/HelloWorldTypeObject.h | 67 - .../types/hello_world/v2/HelloWorldv1.cxx | 293 ---- .../types/hello_world/v2/HelloWorldv1.h | 242 --- ddsrecorder_participants/CMakeLists.txt | 9 - .../{v2 => }/DynamicTypesCollection.hpp | 250 +++- .../DynamicTypesCollection.idl | 0 .../DynamicTypesCollectionPubSubTypes.h | 233 +++ ...ynamicTypesCollectionTypeObjectSupport.hpp | 78 + .../v1/DynamicTypesCollection.hpp | 414 ------ .../v1/DynamicTypesCollectionPubSubTypes.hpp | 174 --- .../v2/DynamicTypesCollectionPubSubTypes.hpp | 229 --- .../v2/DynamicTypesCollectionv1.hpp | 430 ------ ...rderLogEntry.h => DdsRecorderLogEntry.hpp} | 30 +- .../{v1 => }/DdsRecorderLogEntryPubSubTypes.h | 9 +- .../DdsRecorderLogEntryTypeObjectSupport.hpp | 43 + .../types/logging/v2/DdsRecorderLogEntry.h | 83 -- .../v2/DdsRecorderLogEntryPubSubTypes.h | 45 - .../types/logging/v2/DdsRecorderLogEntryv1.h | 80 - ...atus.h => DdsRecorderMonitoringStatus.hpp} | 201 ++- .../DdsRecorderMonitoringStatusCdrAux.hpp | 7 +- .../DdsRecorderMonitoringStatusCdrAux.ipp | 59 +- .../DdsRecorderMonitoringStatusPubSubTypes.h | 21 +- ...orderMonitoringStatusTypeObjectSupport.hpp | 69 + .../v1/DdsRecorderMonitoringStatus.h | 376 ----- .../DdsRecorderMonitoringStatusPubSubTypes.h | 222 --- .../DdsRecorderMonitoringStatusTypeObject.h | 77 - .../v2/DdsRecorderMonitoringStatusCdrAux.hpp | 57 - .../v2/DdsRecorderMonitoringStatusCdrAux.ipp | 217 --- .../DdsRecorderMonitoringStatusTypeObject.h | 77 - .../v2/DdsRecorderMonitoringStatusv1.h | 381 ----- .../recorder/mcap/McapHandler.hpp | 22 +- .../DdsRecorderStatusMonitorProducer.hpp | 17 +- ddsrecorder_participants/package.xml | 2 +- .../project_settings.cmake | 6 +- .../{v2 => }/DynamicTypesCollectionCdrAux.hpp | 14 +- .../{v2 => }/DynamicTypesCollectionCdrAux.ipp | 49 +- .../DynamicTypesCollectionPubSubTypes.cxx | 431 ++++++ ...ynamicTypesCollectionTypeObjectSupport.cxx | 282 ++++ .../v1/DynamicTypesCollection.cpp | 422 ------ .../v1/DynamicTypesCollectionPubSubTypes.cpp | 319 ---- .../v2/DynamicTypesCollection.cpp | 318 ---- .../v2/DynamicTypesCollectionPubSubTypes.cpp | 421 ------ .../v2/DynamicTypesCollectionv1.cpp | 523 ------- .../DdsRecorderLogEntryTypeObjectSupport.cxx | 40 + .../types/logging/v1/DdsRecorderLogEntry.cxx | 91 -- .../types/logging/v2/DdsRecorderLogEntry.cxx | 42 - .../logging/v2/DdsRecorderLogEntryv1.cxx | 98 -- ...DdsRecorderMonitoringStatusPubSubTypes.cxx | 61 +- ...orderMonitoringStatusTypeObjectSupport.cxx | 209 +++ .../v1/DdsRecorderMonitoringStatus.cxx | 440 ------ .../DdsRecorderMonitoringStatusTypeObject.cxx | 477 ------ .../v2/DdsRecorderMonitoringStatus.cxx | 254 ---- ...DdsRecorderMonitoringStatusPubSubTypes.cxx | 415 ------ .../DdsRecorderMonitoringStatusTypeObject.cxx | 477 ------ .../v2/DdsRecorderMonitoringStatusv1.cxx | 444 ------ .../logging/DdsRecorderLogConsumer.cpp | 7 +- .../src/cpp/recorder/mcap/McapHandler.cpp | 260 ++-- .../monitoring/DdsRecorderMonitor.cpp | 11 +- .../ddsrecorder_status/dds/CMakeLists.txt | 9 +- .../dds/DdsMonitorDdsRecorderStatusTest.cpp | 19 +- .../ddsrecorder_status/logging/CMakeLists.txt | 9 +- ddsrecorder_yaml/project_settings.cmake | 4 +- ddsrecorder_yaml/test/CMakeLists.txt | 2 +- ddsreplayer/project_settings.cmake | 4 +- ddsreplayer/src/cpp/tool/DdsReplayer.cpp | 228 +-- ddsreplayer/src/cpp/tool/DdsReplayer.hpp | 16 +- ddsreplayer/test/blackbox/mcap/CMakeLists.txt | 19 +- .../mcap/dds/HelloWorldDynTypesSubscriber.cpp | 140 +- .../mcap/dds/HelloWorldDynTypesSubscriber.h | 34 +- .../mcap/dds/HelloWorldSubscriber.cpp | 7 +- .../blackbox/mcap/dds/HelloWorldSubscriber.h | 6 +- .../mcap/dds/types/hello_world/HelloWorld.hpp | 124 +- .../types/{v1 => }/hello_world/HelloWorld.idl | 0 .../types/hello_world}/HelloWorldCdrAux.hpp | 4 +- .../types/hello_world}/HelloWorldCdrAux.ipp | 26 +- .../hello_world/HelloWorldPubSubTypes.cxx | 29 +- .../hello_world/HelloWorldPubSubTypes.h | 11 +- .../HelloWorldTypeObjectSupport.cxx | 138 ++ .../HelloWorldTypeObjectSupport.hpp | 56 + .../HelloWorld.hpp} | 174 +-- .../HelloWorld.idl | 2 +- .../hello_world_basic/HelloWorldCdrAux.hpp | 46 + .../HelloWorldCdrAux.ipp | 26 +- .../HelloWorldPubSubTypes.cxx | 29 +- .../hello_world_basic/HelloWorldPubSubTypes.h | 133 ++ .../HelloWorldTypeObjectSupport.cxx | 164 +++ .../HelloWorldTypeObjectSupport.hpp | 56 + .../dds/types/v1/hello_world/HelloWorld.cxx | 236 --- .../dds/types/v1/hello_world/HelloWorld.h | 234 --- .../v1/hello_world/HelloWorldPubSubTypes.cxx | 169 --- .../v1/hello_world/HelloWorldPubSubTypes.h | 101 -- .../dds/types/v2/hello_world/HelloWorld.cxx | 166 --- .../dds/types/v2/hello_world/HelloWorldv1.cxx | 289 ---- .../resources/helloworld_withtype_file.mcap | Bin 2302 -> 2809 bytes .../installation/sources/linux.rst | 2 +- .../installation/sources/windows.rst | 2 +- docs/rst/recording/usage/usage.rst | 4 +- docs/rst/replaying/usage/usage.rst | 4 +- docs/rst/tutorials/dynamic_types.rst | 4 +- .../dds/TypeLookupService/CMakeLists.txt | 6 +- .../TypeLookupServicePublisher.cpp | 30 +- .../TypeLookupServicePublisher.h | 8 +- .../TypeLookupServiceSubscriber.cpp | 17 +- .../TypeLookupServiceSubscriber.h | 6 +- .../Complete.h => complete/Complete.hpp} | 579 ++++++-- .../types/{v2 => }/complete/Complete.idl | 0 .../{v2 => }/complete/CompleteCdrAux.hpp | 14 +- .../{v2 => }/complete/CompleteCdrAux.ipp | 158 +- .../{v2 => }/complete/CompletePubSubTypes.cxx | 105 +- .../{v2 => }/complete/CompletePubSubTypes.h | 39 +- .../complete/CompleteTypeObjectSupport.cxx | 678 +++++++++ .../complete/CompleteTypeObjectSupport.hpp | 104 ++ .../HelloWorld.hpp} | 124 +- .../types/{v2 => }/hello_world/HelloWorld.idl | 0 .../types}/hello_world/HelloWorldCdrAux.hpp | 4 +- .../types/hello_world/HelloWorldCdrAux.ipp | 126 ++ .../hello_world/HelloWorldPubSubTypes.cxx | 229 +++ .../hello_world/HelloWorldPubSubTypes.h | 11 +- .../HelloWorldTypeObjectSupport.cxx | 138 ++ .../HelloWorldTypeObjectSupport.hpp | 56 + .../types/v2/complete/Complete.cxx | 806 ---------- .../types/v2/complete/CompleteTypeObject.cxx | 1271 ---------------- .../types/v2/complete/CompleteTypeObject.h | 103 -- .../types/v2/complete/Completev1.cxx | 1304 ----------------- .../types/v2/complete/Completev1.h | 1004 ------------- .../types/v2/hello_world/HelloWorld.cxx | 170 --- .../v2/hello_world/HelloWorldTypeObject.cxx | 265 ---- .../v2/hello_world/HelloWorldTypeObject.h | 67 - .../types/v2/hello_world/HelloWorldv1.cxx | 293 ---- .../types/v2/hello_world/HelloWorldv1.h | 242 --- 239 files changed, 6834 insertions(+), 26768 deletions(-) rename controller/controller_tool/ddstypes/{v2 => }/DdsRecorderCommand/CMakeLists.txt (96%) rename controller/controller_tool/ddstypes/{v2/DdsRecorderCommand/DdsRecorderCommand.h => DdsRecorderCommand/DdsRecorderCommand.hpp} (69%) rename controller/controller_tool/ddstypes/{v1 => }/DdsRecorderCommand/DdsRecorderCommand.idl (100%) rename {ddsrecorder/src/cpp/command_receiver/types/v2 => controller/controller_tool/ddstypes}/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp (97%) rename {ddsrecorder/src/cpp/command_receiver/types/v2 => controller/controller_tool/ddstypes}/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp (84%) rename {ddsrecorder/src/cpp/command_receiver/types/v2 => controller/controller_tool/ddstypes}/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx (91%) rename {ddsrecorder/src/cpp/command_receiver/types/v2 => controller/controller_tool/ddstypes}/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h (92%) create mode 100644 controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.cxx create mode 100644 controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp rename controller/controller_tool/ddstypes/{v2 => }/DdsRecorderStatus/CMakeLists.txt (96%) rename ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.h => controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.hpp (66%) rename controller/controller_tool/ddstypes/{v1 => }/DdsRecorderStatus/DdsRecorderStatus.idl (100%) rename controller/controller_tool/ddstypes/{v2 => }/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp (97%) rename {ddsrecorder/src/cpp/command_receiver/types/v2 => controller/controller_tool/ddstypes}/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp (79%) rename {ddsrecorder/src/cpp/command_receiver/types/v2 => controller/controller_tool/ddstypes}/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx (90%) rename controller/controller_tool/ddstypes/{v2 => }/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h (92%) create mode 100644 controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.cxx create mode 100644 controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderCommand/CMakeLists.txt delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.cxx delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.h delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.i delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderStatus/CMakeLists.txt delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.cxx delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.h delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.i delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h delete mode 100644 controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i delete mode 100644 controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.cxx delete mode 100644 controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.i delete mode 100644 controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i delete mode 100644 controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx delete mode 100644 controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.h delete mode 100644 controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.cxx delete mode 100644 controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.i delete mode 100644 controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i delete mode 100644 controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx delete mode 100644 controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.h rename ddsrecorder/src/cpp/command_receiver/types/{v2/DdsRecorderCommand/DdsRecorderCommand.h => DdsRecorderCommand/DdsRecorderCommand.hpp} (69%) rename {controller/controller_tool/ddstypes/v2 => ddsrecorder/src/cpp/command_receiver/types}/DdsRecorderCommand/DdsRecorderCommand.idl (100%) rename {controller/controller_tool/ddstypes/v2 => ddsrecorder/src/cpp/command_receiver/types}/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp (97%) rename {controller/controller_tool/ddstypes/v2 => ddsrecorder/src/cpp/command_receiver/types}/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp (84%) rename {controller/controller_tool/ddstypes/v2 => ddsrecorder/src/cpp/command_receiver/types}/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx (90%) rename {controller/controller_tool/ddstypes/v2 => ddsrecorder/src/cpp/command_receiver/types}/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h (92%) create mode 100644 ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.cxx create mode 100644 ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp rename controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.h => ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.hpp (66%) rename {controller/controller_tool/ddstypes/v2 => ddsrecorder/src/cpp/command_receiver/types}/DdsRecorderStatus/DdsRecorderStatus.idl (100%) rename ddsrecorder/src/cpp/command_receiver/types/{v2 => }/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp (97%) rename {controller/controller_tool/ddstypes/v2 => ddsrecorder/src/cpp/command_receiver/types}/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp (79%) rename {controller/controller_tool/ddstypes/v2 => ddsrecorder/src/cpp/command_receiver/types}/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx (90%) rename ddsrecorder/src/cpp/command_receiver/types/{v2 => }/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h (92%) create mode 100644 ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.cxx create mode 100644 ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.h delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.idl delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.h delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.h delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.idl delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.h delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.idl delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.h delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.h delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.idl delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.h delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx delete mode 100644 ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.h rename ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.h => ddsrecorder/test/resources/types/hello_world/HelloWorld.hpp (69%) rename {resources/dds/TypeLookupService/types/v2 => ddsrecorder/test/resources/types}/hello_world/HelloWorldCdrAux.hpp (98%) rename {resources/dds/TypeLookupService/types/v2 => ddsrecorder/test/resources/types}/hello_world/HelloWorldCdrAux.ipp (84%) rename ddsrecorder/test/resources/types/hello_world/{v2 => }/HelloWorldPubSubTypes.cxx (91%) rename ddsrecorder/test/resources/types/hello_world/{v2 => }/HelloWorldPubSubTypes.h (92%) create mode 100644 ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.cxx create mode 100644 ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.hpp delete mode 100644 ddsrecorder/test/resources/types/hello_world/v1/HelloWorld.cxx delete mode 100644 ddsrecorder/test/resources/types/hello_world/v1/HelloWorld.h delete mode 100644 ddsrecorder/test/resources/types/hello_world/v1/HelloWorldPubSubTypes.cxx delete mode 100644 ddsrecorder/test/resources/types/hello_world/v1/HelloWorldPubSubTypes.h delete mode 100644 ddsrecorder/test/resources/types/hello_world/v1/HelloWorldTypeObject.cxx delete mode 100644 ddsrecorder/test/resources/types/hello_world/v1/HelloWorldTypeObject.h delete mode 100644 ddsrecorder/test/resources/types/hello_world/v2/HelloWorld.cxx delete mode 100644 ddsrecorder/test/resources/types/hello_world/v2/HelloWorldTypeObject.cxx delete mode 100644 ddsrecorder/test/resources/types/hello_world/v2/HelloWorldTypeObject.h delete mode 100644 ddsrecorder/test/resources/types/hello_world/v2/HelloWorldv1.cxx delete mode 100644 ddsrecorder/test/resources/types/hello_world/v2/HelloWorldv1.h rename ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/{v2 => }/DynamicTypesCollection.hpp (59%) rename ddsrecorder_participants/{src/cpp/common/types/dynamic_types_collection/v2 => include/ddsrecorder_participants/common/types/dynamic_types_collection}/DynamicTypesCollection.idl (100%) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.hpp delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v1/DynamicTypesCollection.hpp delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v1/DynamicTypesCollectionPubSubTypes.hpp delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollectionPubSubTypes.hpp delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollectionv1.hpp rename ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/{v1/DdsRecorderLogEntry.h => DdsRecorderLogEntry.hpp} (77%) rename ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/{v1 => }/DdsRecorderLogEntryPubSubTypes.h (92%) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.hpp delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntry.h delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntryPubSubTypes.h delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntryv1.h rename ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/{v2/DdsRecorderMonitoringStatus.h => DdsRecorderMonitoringStatus.hpp} (64%) rename ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/{v1 => }/DdsRecorderMonitoringStatusCdrAux.hpp (93%) rename ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/{v1 => }/DdsRecorderMonitoringStatusCdrAux.ipp (78%) rename ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/{v2 => }/DdsRecorderMonitoringStatusPubSubTypes.h (91%) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.hpp delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatus.h delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusPubSubTypes.h delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusTypeObject.h delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusCdrAux.hpp delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusCdrAux.ipp delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusTypeObject.h delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusv1.h rename ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/{v2 => }/DynamicTypesCollectionCdrAux.hpp (95%) rename ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/{v2 => }/DynamicTypesCollectionCdrAux.ipp (83%) create mode 100644 ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx create mode 100644 ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.cxx delete mode 100644 ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v1/DynamicTypesCollection.cpp delete mode 100644 ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v1/DynamicTypesCollectionPubSubTypes.cpp delete mode 100644 ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollection.cpp delete mode 100644 ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionPubSubTypes.cpp delete mode 100644 ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionv1.cpp create mode 100644 ddsrecorder_participants/src/cpp/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.cxx delete mode 100644 ddsrecorder_participants/src/cpp/common/types/logging/v1/DdsRecorderLogEntry.cxx delete mode 100644 ddsrecorder_participants/src/cpp/common/types/logging/v2/DdsRecorderLogEntry.cxx delete mode 100644 ddsrecorder_participants/src/cpp/common/types/logging/v2/DdsRecorderLogEntryv1.cxx rename ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/{v1 => }/DdsRecorderMonitoringStatusPubSubTypes.cxx (88%) create mode 100644 ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.cxx delete mode 100644 ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatus.cxx delete mode 100644 ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusTypeObject.cxx delete mode 100644 ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatus.cxx delete mode 100644 ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusPubSubTypes.cxx delete mode 100644 ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusTypeObject.cxx delete mode 100644 ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusv1.cxx rename ddsrecorder/test/resources/types/hello_world/v2/HelloWorld.h => ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.hpp (69%) rename ddsreplayer/test/blackbox/mcap/dds/types/{v1 => }/hello_world/HelloWorld.idl (100%) rename {ddsrecorder/test/resources/types/hello_world/v2 => ddsreplayer/test/blackbox/mcap/dds/types/hello_world}/HelloWorldCdrAux.hpp (98%) rename {ddsrecorder/test/resources/types/hello_world/v2 => ddsreplayer/test/blackbox/mcap/dds/types/hello_world}/HelloWorldCdrAux.ipp (84%) rename ddsreplayer/test/blackbox/mcap/dds/types/{v2 => }/hello_world/HelloWorldPubSubTypes.cxx (91%) rename ddsreplayer/test/blackbox/mcap/dds/types/{v2 => }/hello_world/HelloWorldPubSubTypes.h (92%) create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.cxx create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.hpp rename ddsreplayer/test/blackbox/mcap/dds/types/{v2/hello_world/HelloWorldv1.h => hello_world_basic/HelloWorld.hpp} (56%) rename ddsreplayer/test/blackbox/mcap/dds/types/{v2/hello_world => hello_world_basic}/HelloWorld.idl (70%) create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.hpp rename ddsreplayer/test/blackbox/mcap/dds/types/{v2/hello_world => hello_world_basic}/HelloWorldCdrAux.ipp (84%) rename {resources/dds/TypeLookupService/types/v2/hello_world => ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic}/HelloWorldPubSubTypes.cxx (91%) create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.cxx create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.hpp delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.cxx delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.h delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorldPubSubTypes.cxx delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorldPubSubTypes.h delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.cxx delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.cxx rename resources/dds/TypeLookupService/types/{v2/complete/Complete.h => complete/Complete.hpp} (62%) rename resources/dds/TypeLookupService/types/{v2 => }/complete/Complete.idl (100%) rename resources/dds/TypeLookupService/types/{v2 => }/complete/CompleteCdrAux.hpp (95%) rename resources/dds/TypeLookupService/types/{v2 => }/complete/CompleteCdrAux.ipp (74%) rename resources/dds/TypeLookupService/types/{v2 => }/complete/CompletePubSubTypes.cxx (92%) rename resources/dds/TypeLookupService/types/{v2 => }/complete/CompletePubSubTypes.h (91%) create mode 100644 resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.cxx create mode 100644 resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.hpp rename resources/dds/TypeLookupService/types/{v2/hello_world/HelloWorld.h => hello_world/HelloWorld.hpp} (69%) rename resources/dds/TypeLookupService/types/{v2 => }/hello_world/HelloWorld.idl (100%) rename {ddsreplayer/test/blackbox/mcap/dds/types/v2 => resources/dds/TypeLookupService/types}/hello_world/HelloWorldCdrAux.hpp (98%) create mode 100644 resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp create mode 100644 resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx rename resources/dds/TypeLookupService/types/{v2 => }/hello_world/HelloWorldPubSubTypes.h (92%) create mode 100644 resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.cxx create mode 100644 resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.hpp delete mode 100644 resources/dds/TypeLookupService/types/v2/complete/Complete.cxx delete mode 100644 resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.cxx delete mode 100644 resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.h delete mode 100644 resources/dds/TypeLookupService/types/v2/complete/Completev1.cxx delete mode 100644 resources/dds/TypeLookupService/types/v2/complete/Completev1.h delete mode 100644 resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.cxx delete mode 100644 resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.cxx delete mode 100644 resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.h delete mode 100644 resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.cxx delete mode 100644 resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.h diff --git a/controller/controller_tool/CMakeLists.txt b/controller/controller_tool/CMakeLists.txt index 31b5f3af4..c6754886f 100644 --- a/controller/controller_tool/CMakeLists.txt +++ b/controller/controller_tool/CMakeLists.txt @@ -53,16 +53,9 @@ if (BUILD_DDSRECORDER_CONTROLLER) # Build and install types ############################################################################### - # Determine Fast DDS version - if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(DDS_TYPES_VERSION "v1") - else() - set(DDS_TYPES_VERSION "v2") - endif() - # Add subdirectory based on Fast DDS version - add_subdirectory(ddstypes/${DDS_TYPES_VERSION}/DdsRecorderCommand) - add_subdirectory(ddstypes/${DDS_TYPES_VERSION}/DdsRecorderStatus) + add_subdirectory(ddstypes/DdsRecorderCommand) + add_subdirectory(ddstypes/DdsRecorderStatus) ############################################################################### # Install Tool diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/CMakeLists.txt b/controller/controller_tool/ddstypes/DdsRecorderCommand/CMakeLists.txt similarity index 96% rename from controller/controller_tool/ddstypes/v2/DdsRecorderCommand/CMakeLists.txt rename to controller/controller_tool/ddstypes/DdsRecorderCommand/CMakeLists.txt index e210a12e9..24c65178a 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/CMakeLists.txt +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/CMakeLists.txt @@ -23,15 +23,14 @@ message(STATUS "Configuring python wrapper for types in DdsRecorderCommand...") project(DdsRecorderCommand) find_package(fastcdr REQUIRED) -find_package(fastrtps REQUIRED) +find_package(fastdds REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) #Create library for C++ types add_library(${PROJECT_NAME} SHARED - DdsRecorderCommand.cxx - DdsRecorderCommandv1.cxx DdsRecorderCommandPubSubTypes.cxx + DdsRecorderCommandTypeObjectSupport.cxx ) if(WIN32) target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT) @@ -43,7 +42,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr - fastrtps + fastdds ) ############################################################################### @@ -88,7 +87,7 @@ endif() target_link_libraries(${${PROJECT_NAME}_MODULE} Python3::Module - fastrtps + fastdds ${PROJECT_NAME} ) diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.h b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.hpp similarity index 69% rename from controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.h rename to controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.hpp index 8d2a241c4..ca1be197a 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.h +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file DdsRecorderCommand.h + * @file DdsRecorderCommand.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "DdsRecorderCommandv1.h" +#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_HPP_ -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ - -#include -#include #include -#include #include -#include - +#include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +51,6 @@ #define DDSRECORDERCOMMAND_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure DdsRecorderCommand defined by the user in the IDL file. * @ingroup DdsRecorderCommand @@ -86,80 +62,127 @@ class DdsRecorderCommand /*! * @brief Default constructor. */ - eProsima_user_DllExport DdsRecorderCommand(); + eProsima_user_DllExport DdsRecorderCommand() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~DdsRecorderCommand(); + eProsima_user_DllExport ~DdsRecorderCommand() + { + } /*! * @brief Copy constructor. * @param x Reference to the object DdsRecorderCommand that will be copied. */ eProsima_user_DllExport DdsRecorderCommand( - const DdsRecorderCommand& x); + const DdsRecorderCommand& x) + { + m_command = x.m_command; + + m_args = x.m_args; + + } /*! * @brief Move constructor. * @param x Reference to the object DdsRecorderCommand that will be copied. */ eProsima_user_DllExport DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept; + DdsRecorderCommand&& x) noexcept + { + m_command = std::move(x.m_command); + m_args = std::move(x.m_args); + } /*! * @brief Copy assignment. * @param x Reference to the object DdsRecorderCommand that will be copied. */ eProsima_user_DllExport DdsRecorderCommand& operator =( - const DdsRecorderCommand& x); + const DdsRecorderCommand& x) + { + + m_command = x.m_command; + + m_args = x.m_args; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object DdsRecorderCommand that will be copied. */ eProsima_user_DllExport DdsRecorderCommand& operator =( - DdsRecorderCommand&& x) noexcept; + DdsRecorderCommand&& x) noexcept + { + + m_command = std::move(x.m_command); + m_args = std::move(x.m_args); + return *this; + } /*! * @brief Comparison operator. * @param x DdsRecorderCommand object to compare. */ eProsima_user_DllExport bool operator ==( - const DdsRecorderCommand& x) const; + const DdsRecorderCommand& x) const + { + return (m_command == x.m_command && + m_args == x.m_args); + } /*! * @brief Comparison operator. * @param x DdsRecorderCommand object to compare. */ eProsima_user_DllExport bool operator !=( - const DdsRecorderCommand& x) const; + const DdsRecorderCommand& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member command * @param _command New value to be copied in member command */ eProsima_user_DllExport void command( - const std::string& _command); + const std::string& _command) + { + m_command = _command; + } /*! * @brief This function moves the value in member command * @param _command New value to be moved in member command */ eProsima_user_DllExport void command( - std::string&& _command); + std::string&& _command) + { + m_command = std::move(_command); + } /*! * @brief This function returns a constant reference to member command * @return Constant reference to member command */ - eProsima_user_DllExport const std::string& command() const; + eProsima_user_DllExport const std::string& command() const + { + return m_command; + } /*! * @brief This function returns a reference to member command * @return Reference to member command */ - eProsima_user_DllExport std::string& command(); + eProsima_user_DllExport std::string& command() + { + return m_command; + } /*! @@ -167,26 +190,40 @@ class DdsRecorderCommand * @param _args New value to be copied in member args */ eProsima_user_DllExport void args( - const std::string& _args); + const std::string& _args) + { + m_args = _args; + } /*! * @brief This function moves the value in member args * @param _args New value to be moved in member args */ eProsima_user_DllExport void args( - std::string&& _args); + std::string&& _args) + { + m_args = std::move(_args); + } /*! * @brief This function returns a constant reference to member args * @return Constant reference to member args */ - eProsima_user_DllExport const std::string& args() const; + eProsima_user_DllExport const std::string& args() const + { + return m_args; + } /*! * @brief This function returns a reference to member args * @return Reference to member args */ - eProsima_user_DllExport std::string& args(); + eProsima_user_DllExport std::string& args() + { + return m_args; + } + + private: @@ -195,8 +232,6 @@ class DdsRecorderCommand }; -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ - +#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.idl b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.idl similarity index 100% rename from controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.idl rename to controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.idl diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp similarity index 97% rename from ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp rename to controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp index cafda9b13..77005bd95 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp @@ -22,7 +22,7 @@ #ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_HPP_ #define _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_HPP_ -#include "DdsRecorderCommand.h" +#include "DdsRecorderCommand.hpp" constexpr uint32_t DdsRecorderCommand_max_cdr_typesize {524UL}; constexpr uint32_t DdsRecorderCommand_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsRecorderCommand& data); diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp similarity index 84% rename from ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp rename to controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp index d60a0359e..f0f7c5c15 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,11 +50,11 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.command(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.command(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.args(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.args(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -78,7 +76,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.command() << eprosima::fastcdr::MemberId(1) << data.args() - ; +; scdr.end_serialize_type(current_state); } @@ -95,13 +93,13 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.command(); - break; + case 0: + dcdr >> data.command(); + break; - case 1: - dcdr >> data.args(); - break; + case 1: + dcdr >> data.args(); + break; default: ret_value = false; @@ -119,6 +117,8 @@ void serialize_key( static_cast(data); } + + } // namespace fastcdr } // namespace eprosima diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx similarity index 91% rename from ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx rename to controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx index bc0af9a72..d0ac3c025 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -19,27 +19,27 @@ * This file was generated by the tool fastddsgen. */ +#include "DdsRecorderCommandPubSubTypes.h" +#include #include -#include "DdsRecorderCommandPubSubTypes.h" #include "DdsRecorderCommandCdrAux.hpp" +#include "DdsRecorderCommandTypeObjectSupport.hpp" using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - DdsRecorderCommandPubSubType::DdsRecorderCommandPubSubType() { setName("DdsRecorderCommand"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - static_cast(DdsRecorderCommand::getMaxCdrSerializedSize()); + static_cast(DdsRecorderCommand::getMaxCdrSerializedSize()); #else - DdsRecorderCommand_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + DdsRecorderCommand_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -150,8 +150,8 @@ std::function DdsRecorderCommandPubSubType::getSerializedSizeProvide eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -189,8 +189,7 @@ bool DdsRecorderCommandPubSubType::getKey( DdsRecorderCommand_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -219,3 +218,12 @@ bool DdsRecorderCommandPubSubType::getKey( } return true; } + +void DdsRecorderCommandPubSubType::register_type_object_representation() +{ + register_DdsRecorderCommand_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "DdsRecorderCommandCdrAux.ipp" diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h similarity index 92% rename from ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h rename to controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h index f0a4d49e3..df428fcb8 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h @@ -27,9 +27,9 @@ #include #include #include -#include +#include -#include "DdsRecorderCommand.h" +#include "DdsRecorderCommand.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type DdsRecorderCommand defined by the user in the IDL file. * @ingroup DdsRecorderCommand @@ -90,6 +88,9 @@ class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -105,7 +106,7 @@ class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataTyp } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.cxx b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.cxx new file mode 100644 index 000000000..0b9d8bd2d --- /dev/null +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.cxx @@ -0,0 +1,146 @@ +// 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 DdsRecorderCommandTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "DdsRecorderCommandTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "DdsRecorderCommand.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_DdsRecorderCommand_type_identifier( + TypeIdentifierPair& type_ids_DdsRecorderCommand) +{ + + ReturnCode_t return_code_DdsRecorderCommand {eprosima::fastdds::dds::RETCODE_OK}; + return_code_DdsRecorderCommand = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsRecorderCommand", type_ids_DdsRecorderCommand); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsRecorderCommand) + { + StructTypeFlag struct_flags_DdsRecorderCommand = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_DdsRecorderCommand = "DdsRecorderCommand"; + eprosima::fastcdr::optional type_ann_builtin_DdsRecorderCommand; + eprosima::fastcdr::optional ann_custom_DdsRecorderCommand; + CompleteTypeDetail detail_DdsRecorderCommand = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsRecorderCommand, ann_custom_DdsRecorderCommand, type_name_DdsRecorderCommand.to_string()); + CompleteStructHeader header_DdsRecorderCommand; + header_DdsRecorderCommand = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DdsRecorderCommand); + CompleteStructMemberSeq member_seq_DdsRecorderCommand; + { + TypeIdentifierPair type_ids_command; + ReturnCode_t return_code_command {eprosima::fastdds::dds::RETCODE_OK}; + return_code_command = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_command); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_command) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_command)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_command = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_command = 0x00000000; + bool common_command_ec {false}; + CommonStructMember common_command {TypeObjectUtils::build_common_struct_member(member_id_command, member_flags_command, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_command, common_command_ec))}; + if (!common_command_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure command member TypeIdentifier inconsistent."); + return; + } + MemberName name_command = "command"; + eprosima::fastcdr::optional member_ann_builtin_command; + ann_custom_DdsRecorderCommand.reset(); + CompleteMemberDetail detail_command = TypeObjectUtils::build_complete_member_detail(name_command, member_ann_builtin_command, ann_custom_DdsRecorderCommand); + CompleteStructMember member_command = TypeObjectUtils::build_complete_struct_member(common_command, detail_command); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderCommand, member_command); + } + { + TypeIdentifierPair type_ids_args; + ReturnCode_t return_code_args {eprosima::fastdds::dds::RETCODE_OK}; + return_code_args = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_args); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_args) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_args)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_args = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_args = 0x00000001; + bool common_args_ec {false}; + CommonStructMember common_args {TypeObjectUtils::build_common_struct_member(member_id_args, member_flags_args, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_args, common_args_ec))}; + if (!common_args_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure args member TypeIdentifier inconsistent."); + return; + } + MemberName name_args = "args"; + eprosima::fastcdr::optional member_ann_builtin_args; + ann_custom_DdsRecorderCommand.reset(); + CompleteMemberDetail detail_args = TypeObjectUtils::build_complete_member_detail(name_args, member_ann_builtin_args, ann_custom_DdsRecorderCommand); + CompleteStructMember member_args = TypeObjectUtils::build_complete_struct_member(common_args, detail_args); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderCommand, member_args); + } + CompleteStructType struct_type_DdsRecorderCommand = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsRecorderCommand, header_DdsRecorderCommand, member_seq_DdsRecorderCommand); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsRecorderCommand, type_name_DdsRecorderCommand.to_string(), type_ids_DdsRecorderCommand)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "DdsRecorderCommand already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp new file mode 100644 index 000000000..76fc6f9b1 --- /dev/null +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 DdsRecorderCommandTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register DdsRecorderCommand related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_DdsRecorderCommand_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/CMakeLists.txt b/controller/controller_tool/ddstypes/DdsRecorderStatus/CMakeLists.txt similarity index 96% rename from controller/controller_tool/ddstypes/v2/DdsRecorderStatus/CMakeLists.txt rename to controller/controller_tool/ddstypes/DdsRecorderStatus/CMakeLists.txt index 13b7aa19f..a388d9d42 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/CMakeLists.txt +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/CMakeLists.txt @@ -23,15 +23,14 @@ message(STATUS "Configuring python wrapper for types in DdsRecorderStatus...") project(DdsRecorderStatus) find_package(fastcdr REQUIRED) -find_package(fastrtps REQUIRED) +find_package(fastdds REQUIRED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) #Create library for C++ types add_library(${PROJECT_NAME} SHARED - DdsRecorderStatus.cxx - DdsRecorderStatusv1.cxx DdsRecorderStatusPubSubTypes.cxx + DdsRecorderStatusTypeObjectSupport.cxx ) if(WIN32) target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT) @@ -43,7 +42,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr - fastrtps + fastdds ) ############################################################################### @@ -88,7 +87,7 @@ endif() target_link_libraries(${${PROJECT_NAME}_MODULE} Python3::Module - fastrtps + fastdds ${PROJECT_NAME} ) diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.h b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.hpp similarity index 66% rename from ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.h rename to controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.hpp index e5cc4053e..c4cfbe7a1 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.h +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file DdsRecorderStatus.h + * @file DdsRecorderStatus.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "DdsRecorderStatusv1.h" +#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_HPP_ -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ - -#include -#include #include -#include #include -#include - +#include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +51,6 @@ #define DDSRECORDERSTATUS_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure DdsRecorderStatus defined by the user in the IDL file. * @ingroup DdsRecorderStatus @@ -86,80 +62,134 @@ class DdsRecorderStatus /*! * @brief Default constructor. */ - eProsima_user_DllExport DdsRecorderStatus(); + eProsima_user_DllExport DdsRecorderStatus() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~DdsRecorderStatus(); + eProsima_user_DllExport ~DdsRecorderStatus() + { + } /*! * @brief Copy constructor. * @param x Reference to the object DdsRecorderStatus that will be copied. */ eProsima_user_DllExport DdsRecorderStatus( - const DdsRecorderStatus& x); + const DdsRecorderStatus& x) + { + m_previous = x.m_previous; + + m_current = x.m_current; + + m_info = x.m_info; + + } /*! * @brief Move constructor. * @param x Reference to the object DdsRecorderStatus that will be copied. */ eProsima_user_DllExport DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept; + DdsRecorderStatus&& x) noexcept + { + m_previous = std::move(x.m_previous); + m_current = std::move(x.m_current); + m_info = std::move(x.m_info); + } /*! * @brief Copy assignment. * @param x Reference to the object DdsRecorderStatus that will be copied. */ eProsima_user_DllExport DdsRecorderStatus& operator =( - const DdsRecorderStatus& x); + const DdsRecorderStatus& x) + { + + m_previous = x.m_previous; + + m_current = x.m_current; + + m_info = x.m_info; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object DdsRecorderStatus that will be copied. */ eProsima_user_DllExport DdsRecorderStatus& operator =( - DdsRecorderStatus&& x) noexcept; + DdsRecorderStatus&& x) noexcept + { + + m_previous = std::move(x.m_previous); + m_current = std::move(x.m_current); + m_info = std::move(x.m_info); + return *this; + } /*! * @brief Comparison operator. * @param x DdsRecorderStatus object to compare. */ eProsima_user_DllExport bool operator ==( - const DdsRecorderStatus& x) const; + const DdsRecorderStatus& x) const + { + return (m_previous == x.m_previous && + m_current == x.m_current && + m_info == x.m_info); + } /*! * @brief Comparison operator. * @param x DdsRecorderStatus object to compare. */ eProsima_user_DllExport bool operator !=( - const DdsRecorderStatus& x) const; + const DdsRecorderStatus& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member previous * @param _previous New value to be copied in member previous */ eProsima_user_DllExport void previous( - const std::string& _previous); + const std::string& _previous) + { + m_previous = _previous; + } /*! * @brief This function moves the value in member previous * @param _previous New value to be moved in member previous */ eProsima_user_DllExport void previous( - std::string&& _previous); + std::string&& _previous) + { + m_previous = std::move(_previous); + } /*! * @brief This function returns a constant reference to member previous * @return Constant reference to member previous */ - eProsima_user_DllExport const std::string& previous() const; + eProsima_user_DllExport const std::string& previous() const + { + return m_previous; + } /*! * @brief This function returns a reference to member previous * @return Reference to member previous */ - eProsima_user_DllExport std::string& previous(); + eProsima_user_DllExport std::string& previous() + { + return m_previous; + } /*! @@ -167,26 +197,38 @@ class DdsRecorderStatus * @param _current New value to be copied in member current */ eProsima_user_DllExport void current( - const std::string& _current); + const std::string& _current) + { + m_current = _current; + } /*! * @brief This function moves the value in member current * @param _current New value to be moved in member current */ eProsima_user_DllExport void current( - std::string&& _current); + std::string&& _current) + { + m_current = std::move(_current); + } /*! * @brief This function returns a constant reference to member current * @return Constant reference to member current */ - eProsima_user_DllExport const std::string& current() const; + eProsima_user_DllExport const std::string& current() const + { + return m_current; + } /*! * @brief This function returns a reference to member current * @return Reference to member current */ - eProsima_user_DllExport std::string& current(); + eProsima_user_DllExport std::string& current() + { + return m_current; + } /*! @@ -194,26 +236,40 @@ class DdsRecorderStatus * @param _info New value to be copied in member info */ eProsima_user_DllExport void info( - const std::string& _info); + const std::string& _info) + { + m_info = _info; + } /*! * @brief This function moves the value in member info * @param _info New value to be moved in member info */ eProsima_user_DllExport void info( - std::string&& _info); + std::string&& _info) + { + m_info = std::move(_info); + } /*! * @brief This function returns a constant reference to member info * @return Constant reference to member info */ - eProsima_user_DllExport const std::string& info() const; + eProsima_user_DllExport const std::string& info() const + { + return m_info; + } /*! * @brief This function returns a reference to member info * @return Reference to member info */ - eProsima_user_DllExport std::string& info(); + eProsima_user_DllExport std::string& info() + { + return m_info; + } + + private: @@ -223,8 +279,6 @@ class DdsRecorderStatus }; -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ - +#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.idl b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.idl similarity index 100% rename from controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.idl rename to controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.idl diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp similarity index 97% rename from controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp rename to controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp index cfbb11098..7ad935b53 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp @@ -22,7 +22,7 @@ #ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_HPP_ #define _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_HPP_ -#include "DdsRecorderStatus.h" +#include "DdsRecorderStatus.hpp" constexpr uint32_t DdsRecorderStatus_max_cdr_typesize {784UL}; constexpr uint32_t DdsRecorderStatus_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsRecorderStatus& data); diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp similarity index 79% rename from ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp rename to controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp index d1bb71e66..983ef7b9b 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,14 +50,14 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.previous(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.previous(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.current(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.current(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.info(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.info(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -82,7 +80,7 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(0) << data.previous() << eprosima::fastcdr::MemberId(1) << data.current() << eprosima::fastcdr::MemberId(2) << data.info() - ; +; scdr.end_serialize_type(current_state); } @@ -99,17 +97,17 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.previous(); - break; + case 0: + dcdr >> data.previous(); + break; - case 1: - dcdr >> data.current(); - break; + case 1: + dcdr >> data.current(); + break; - case 2: - dcdr >> data.info(); - break; + case 2: + dcdr >> data.info(); + break; default: ret_value = false; @@ -127,6 +125,8 @@ void serialize_key( static_cast(data); } + + } // namespace fastcdr } // namespace eprosima diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx similarity index 90% rename from ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx rename to controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx index 7efd35fc1..9a4dbdfe6 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -19,27 +19,27 @@ * This file was generated by the tool fastddsgen. */ +#include "DdsRecorderStatusPubSubTypes.h" +#include #include -#include "DdsRecorderStatusPubSubTypes.h" #include "DdsRecorderStatusCdrAux.hpp" +#include "DdsRecorderStatusTypeObjectSupport.hpp" using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - DdsRecorderStatusPubSubType::DdsRecorderStatusPubSubType() { setName("DdsRecorderStatus"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - DdsRecorderStatus::getMaxCdrSerializedSize(); + static_cast(DdsRecorderStatus::getMaxCdrSerializedSize()); #else - DdsRecorderStatus_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + DdsRecorderStatus_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -139,6 +139,7 @@ std::function DdsRecorderStatusPubSubType::getSerializedSizeProvider return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -149,8 +150,8 @@ std::function DdsRecorderStatusPubSubType::getSerializedSizeProvider eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -188,8 +189,7 @@ bool DdsRecorderStatusPubSubType::getKey( DdsRecorderStatus_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -218,3 +218,12 @@ bool DdsRecorderStatusPubSubType::getKey( } return true; } + +void DdsRecorderStatusPubSubType::register_type_object_representation() +{ + register_DdsRecorderStatus_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "DdsRecorderStatusCdrAux.ipp" diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h similarity index 92% rename from controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h rename to controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h index f3e3861cb..af1c8bd29 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h @@ -27,9 +27,9 @@ #include #include #include -#include +#include -#include "DdsRecorderStatus.h" +#include "DdsRecorderStatus.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type DdsRecorderStatus defined by the user in the IDL file. * @ingroup DdsRecorderStatus @@ -90,6 +88,9 @@ class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -105,7 +106,7 @@ class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.cxx b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.cxx new file mode 100644 index 000000000..ad8801123 --- /dev/null +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.cxx @@ -0,0 +1,184 @@ +// 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 DdsRecorderStatusTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "DdsRecorderStatusTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "DdsRecorderStatus.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_DdsRecorderStatus_type_identifier( + TypeIdentifierPair& type_ids_DdsRecorderStatus) +{ + + ReturnCode_t return_code_DdsRecorderStatus {eprosima::fastdds::dds::RETCODE_OK}; + return_code_DdsRecorderStatus = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsRecorderStatus", type_ids_DdsRecorderStatus); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsRecorderStatus) + { + StructTypeFlag struct_flags_DdsRecorderStatus = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_DdsRecorderStatus = "DdsRecorderStatus"; + eprosima::fastcdr::optional type_ann_builtin_DdsRecorderStatus; + eprosima::fastcdr::optional ann_custom_DdsRecorderStatus; + CompleteTypeDetail detail_DdsRecorderStatus = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsRecorderStatus, ann_custom_DdsRecorderStatus, type_name_DdsRecorderStatus.to_string()); + CompleteStructHeader header_DdsRecorderStatus; + header_DdsRecorderStatus = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DdsRecorderStatus); + CompleteStructMemberSeq member_seq_DdsRecorderStatus; + { + TypeIdentifierPair type_ids_previous; + ReturnCode_t return_code_previous {eprosima::fastdds::dds::RETCODE_OK}; + return_code_previous = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_previous); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_previous) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_previous)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_previous = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_previous = 0x00000000; + bool common_previous_ec {false}; + CommonStructMember common_previous {TypeObjectUtils::build_common_struct_member(member_id_previous, member_flags_previous, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_previous, common_previous_ec))}; + if (!common_previous_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure previous member TypeIdentifier inconsistent."); + return; + } + MemberName name_previous = "previous"; + eprosima::fastcdr::optional member_ann_builtin_previous; + ann_custom_DdsRecorderStatus.reset(); + CompleteMemberDetail detail_previous = TypeObjectUtils::build_complete_member_detail(name_previous, member_ann_builtin_previous, ann_custom_DdsRecorderStatus); + CompleteStructMember member_previous = TypeObjectUtils::build_complete_struct_member(common_previous, detail_previous); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderStatus, member_previous); + } + { + TypeIdentifierPair type_ids_current; + ReturnCode_t return_code_current {eprosima::fastdds::dds::RETCODE_OK}; + return_code_current = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_current); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_current) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_current)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_current = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_current = 0x00000001; + bool common_current_ec {false}; + CommonStructMember common_current {TypeObjectUtils::build_common_struct_member(member_id_current, member_flags_current, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_current, common_current_ec))}; + if (!common_current_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure current member TypeIdentifier inconsistent."); + return; + } + MemberName name_current = "current"; + eprosima::fastcdr::optional member_ann_builtin_current; + ann_custom_DdsRecorderStatus.reset(); + CompleteMemberDetail detail_current = TypeObjectUtils::build_complete_member_detail(name_current, member_ann_builtin_current, ann_custom_DdsRecorderStatus); + CompleteStructMember member_current = TypeObjectUtils::build_complete_struct_member(common_current, detail_current); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderStatus, member_current); + } + { + TypeIdentifierPair type_ids_info; + ReturnCode_t return_code_info {eprosima::fastdds::dds::RETCODE_OK}; + return_code_info = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_info); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_info) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_info)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_info = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_info = 0x00000002; + bool common_info_ec {false}; + CommonStructMember common_info {TypeObjectUtils::build_common_struct_member(member_id_info, member_flags_info, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_info, common_info_ec))}; + if (!common_info_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure info member TypeIdentifier inconsistent."); + return; + } + MemberName name_info = "info"; + eprosima::fastcdr::optional member_ann_builtin_info; + ann_custom_DdsRecorderStatus.reset(); + CompleteMemberDetail detail_info = TypeObjectUtils::build_complete_member_detail(name_info, member_ann_builtin_info, ann_custom_DdsRecorderStatus); + CompleteStructMember member_info = TypeObjectUtils::build_complete_struct_member(common_info, detail_info); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderStatus, member_info); + } + CompleteStructType struct_type_DdsRecorderStatus = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsRecorderStatus, header_DdsRecorderStatus, member_seq_DdsRecorderStatus); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsRecorderStatus, type_name_DdsRecorderStatus.to_string(), type_ids_DdsRecorderStatus)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "DdsRecorderStatus already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp new file mode 100644 index 000000000..1da3c0bd7 --- /dev/null +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 DdsRecorderStatusTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register DdsRecorderStatus related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_DdsRecorderStatus_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/CMakeLists.txt b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/CMakeLists.txt deleted file mode 100644 index 765948b4c..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/CMakeLists.txt +++ /dev/null @@ -1,112 +0,0 @@ - -cmake_minimum_required(VERSION 3.16.3) - -# SWIG: use standard target name. -if(POLICY CMP0078) - cmake_policy(SET CMP0078 NEW) -endif() - -# SWIG: use SWIG_MODULE_NAME property. -if(POLICY CMP0086) - cmake_policy(SET CMP0086 NEW) -endif() - -############################################################################### -# Library for types defined in DdsRecorderCommand IDL -############################################################################### - -message(STATUS "Configuring python wrapper for types in DdsRecorderCommand...") - -############################################################################### -# Type library on C++ - -project(DdsRecorderCommand) - -find_package(fastcdr REQUIRED) -find_package(fastrtps REQUIRED) - - -set(${PROJECT_NAME}_FILES - DdsRecorderCommand.cxx - DdsRecorderCommandPubSubTypes.cxx - ) - -include_directories() - -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -#Create library for C++ types -add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_FILES}) -if(WIN32) - target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT) -endif(WIN32) -target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr fastrtps) - -############################################################################### -# Python bindings for type - -find_package(SWIG REQUIRED) -include(${SWIG_USE_FILE}) -set(CMAKE_SWIG_FLAGS "") - -find_package(Python3 COMPONENTS Interpreter Development REQUIRED) -set(PYTHON_INCLUDE_PATH ${Python3_INCLUDE_DIRS}) -set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) -set(PYTHON_LIBRARIES ${Python3_LIBRARIES}) - -include_directories(${PYTHON_INCLUDE_PATH}) - -set(${PROJECT_NAME}_MODULE - DdsRecorderCommandWrapper - ) - -set(${PROJECT_NAME}_MODULE_FILES - ${PROJECT_NAME}.i - ) - -SET_SOURCE_FILES_PROPERTIES( - ${${PROJECT_NAME}_MODULE_FILES} - PROPERTIES CPLUSPLUS ON - USE_TARGET_INCLUDE_DIRECTORIES TRUE - ) - -include_directories( - ${PROJECT_SOURCE_DIR} - ) - -SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE} - TYPE SHARED - LANGUAGE python - SOURCES ${${PROJECT_NAME}_MODULE_FILES}) - -if(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8) - set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_COMPILE_DEFINITIONS SWIGWORDSIZE64) -endif() - -SWIG_LINK_LIBRARIES(${${PROJECT_NAME}_MODULE} - Python3::Module - fastrtps - ${PROJECT_NAME} - ) - -# Find the installation path -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" - OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - -get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE) -file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH}) -SET (PYTHON_MODULE_PATH - ${_REL_PYTHON_MODULE_PATH} - ) - -# Install -install(TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION bin/ - LIBRARY DESTINATION lib/ - ARCHIVE DESTINATION lib/ - ) -install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}) -get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES) -install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}) diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.cxx b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.cxx deleted file mode 100644 index 5a176add0..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.cxx +++ /dev/null @@ -1,234 +0,0 @@ -// 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 DdsRecorderCommand.cxx - * 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 "DdsRecorderCommand.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -#define DdsRecorderCommand_max_cdr_typesize 520ULL; -#define DdsRecorderCommand_max_key_cdr_typesize 0ULL; - -DdsRecorderCommand::DdsRecorderCommand() -{ - // string m_command - m_command =""; - // string m_args - m_args =""; - -} - -DdsRecorderCommand::~DdsRecorderCommand() -{ - - -} - -DdsRecorderCommand::DdsRecorderCommand( - const DdsRecorderCommand& x) -{ - m_command = x.m_command; - m_args = x.m_args; -} - -DdsRecorderCommand::DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept -{ - m_command = std::move(x.m_command); - m_args = std::move(x.m_args); -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - const DdsRecorderCommand& x) -{ - - m_command = x.m_command; - m_args = x.m_args; - - return *this; -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - DdsRecorderCommand&& x) noexcept -{ - - m_command = std::move(x.m_command); - m_args = std::move(x.m_args); - - return *this; -} - -bool DdsRecorderCommand::operator ==( - const DdsRecorderCommand& x) const -{ - - return (m_command == x.m_command && m_args == x.m_args); -} - -bool DdsRecorderCommand::operator !=( - const DdsRecorderCommand& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderCommand::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderCommand_max_cdr_typesize; -} - -size_t DdsRecorderCommand::getCdrSerializedSize( - const DdsRecorderCommand& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.command().size() + 1; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.args().size() + 1; - - - return current_alignment - initial_alignment; -} - -void DdsRecorderCommand::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_command.c_str(); - scdr << m_args.c_str(); - -} - -void DdsRecorderCommand::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_command; - dcdr >> m_args; -} - -/*! - * @brief This function copies the value in member command - * @param _command New value to be copied in member command - */ -void DdsRecorderCommand::command( - const std::string& _command) -{ - m_command = _command; -} - -/*! - * @brief This function moves the value in member command - * @param _command New value to be moved in member command - */ -void DdsRecorderCommand::command( - std::string&& _command) -{ - m_command = std::move(_command); -} - -/*! - * @brief This function returns a constant reference to member command - * @return Constant reference to member command - */ -const std::string& DdsRecorderCommand::command() const -{ - return m_command; -} - -/*! - * @brief This function returns a reference to member command - * @return Reference to member command - */ -std::string& DdsRecorderCommand::command() -{ - return m_command; -} -/*! - * @brief This function copies the value in member args - * @param _args New value to be copied in member args - */ -void DdsRecorderCommand::args( - const std::string& _args) -{ - m_args = _args; -} - -/*! - * @brief This function moves the value in member args - * @param _args New value to be moved in member args - */ -void DdsRecorderCommand::args( - std::string&& _args) -{ - m_args = std::move(_args); -} - -/*! - * @brief This function returns a constant reference to member args - * @return Constant reference to member args - */ -const std::string& DdsRecorderCommand::args() const -{ - return m_args; -} - -/*! - * @brief This function returns a reference to member args - * @return Reference to member args - */ -std::string& DdsRecorderCommand::args() -{ - return m_args; -} - - -size_t DdsRecorderCommand::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderCommand_max_key_cdr_typesize; -} - -bool DdsRecorderCommand::isKeyDefined() -{ - return false; -} - -void DdsRecorderCommand::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.h b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.h deleted file mode 100644 index 51dcd1769..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.h +++ /dev/null @@ -1,241 +0,0 @@ -// 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 DdsRecorderCommand.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_DDSRECORDERCOMMAND_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_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(DdsRecorderCommand_SOURCE) -#define DdsRecorderCommand_DllAPI __declspec( dllexport ) -#else -#define DdsRecorderCommand_DllAPI __declspec( dllimport ) -#endif // DdsRecorderCommand_SOURCE -#else -#define DdsRecorderCommand_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DdsRecorderCommand_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure DdsRecorderCommand defined by the user in the IDL file. - * @ingroup DDSRECORDERCOMMAND - */ -class DdsRecorderCommand -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderCommand(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderCommand(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand( - const DdsRecorderCommand& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand& operator =( - const DdsRecorderCommand& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand& operator =( - DdsRecorderCommand&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderCommand object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderCommand& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderCommand object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderCommand& x) const; - - /*! - * @brief This function copies the value in member command - * @param _command New value to be copied in member command - */ - eProsima_user_DllExport void command( - const std::string& _command); - - /*! - * @brief This function moves the value in member command - * @param _command New value to be moved in member command - */ - eProsima_user_DllExport void command( - std::string&& _command); - - /*! - * @brief This function returns a constant reference to member command - * @return Constant reference to member command - */ - eProsima_user_DllExport const std::string& command() const; - - /*! - * @brief This function returns a reference to member command - * @return Reference to member command - */ - eProsima_user_DllExport std::string& command(); - /*! - * @brief This function copies the value in member args - * @param _args New value to be copied in member args - */ - eProsima_user_DllExport void args( - const std::string& _args); - - /*! - * @brief This function moves the value in member args - * @param _args New value to be moved in member args - */ - eProsima_user_DllExport void args( - std::string&& _args); - - /*! - * @brief This function returns a constant reference to member args - * @return Constant reference to member args - */ - eProsima_user_DllExport const std::string& args() const; - - /*! - * @brief This function returns a reference to member args - * @return Reference to member args - */ - eProsima_user_DllExport std::string& args(); - - /*! - * @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 DdsRecorderCommand& 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_command; - std::string m_args; - -}; - -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.i b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.i deleted file mode 100644 index 6f612586e..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.i +++ /dev/null @@ -1,99 +0,0 @@ -// 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 DdsRecorderCommand.i - * This header file contains the SWIG interface of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -%module DdsRecorderCommand - -// SWIG helper modules -%include "stdint.i" -%include "std_string.i" -%include "std_vector.i" -%include "std_array.i" -%include "std_map.i" -%include "typemaps.i" - -// Assignemt operators are ignored, as there is no such thing in Python. -// Trying to export them issues a warning -%ignore *::operator=; - -// Macro declarations -// Any macro used on the Fast DDS header files will give an error if it is not redefined here -#define RTPS_DllAPI -#define eProsima_user_DllExport - - -%{ -#include "DdsRecorderCommand.h" - -#include -%} - -%import(module="fastdds") "fastdds/dds/core/LoanableCollection.hpp" -%import(module="fastdds") "fastdds/dds/core/LoanableTypedCollection.hpp" -%import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp" - -//////////////////////////////////////////////////////// -// Binding for class DdsRecorderCommand -//////////////////////////////////////////////////////// - -// Ignore overloaded methods that have no application on Python -// Otherwise they will issue a warning -%ignore DdsRecorderCommand::DdsRecorderCommand(DdsRecorderCommand&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Avoid a warning ignoring all but one -%ignore DdsRecorderCommand::command(std::string&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore DdsRecorderCommand::command(); -%rename("%s") DdsRecorderCommand::command() const; - -%ignore DdsRecorderCommand::args(std::string&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore DdsRecorderCommand::args(); -%rename("%s") DdsRecorderCommand::args() const; - - -%template(_DdsRecorderCommandSeq) eprosima::fastdds::dds::LoanableTypedCollection; -%template(DdsRecorderCommandSeq) eprosima::fastdds::dds::LoanableSequence; -%extend eprosima::fastdds::dds::LoanableSequence -{ - size_t __len__() const - { - return self->length(); - } - - const DdsRecorderCommand& __getitem__(size_t i) const - { - return (*self)[i]; - } -} - - -// Include the class interfaces -%include "DdsRecorderCommand.h" - -// Include the corresponding TopicDataType -%include "DdsRecorderCommandPubSubTypes.i" diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx deleted file mode 100644 index 720747c92..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ /dev/null @@ -1,169 +0,0 @@ -// 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 DdsRecorderCommandPubSubTypes.cxx - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "DdsRecorderCommandPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -DdsRecorderCommandPubSubType::DdsRecorderCommandPubSubType() -{ - setName("DdsRecorderCommand"); - auto type_size = DdsRecorderCommand::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = DdsRecorderCommand::isKeyDefined(); - size_t keyLength = DdsRecorderCommand::getKeyMaxCdrSerializedSize() > 16 ? - DdsRecorderCommand::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DdsRecorderCommandPubSubType::~DdsRecorderCommandPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DdsRecorderCommandPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - DdsRecorderCommand* 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 DdsRecorderCommandPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - DdsRecorderCommand* 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 DdsRecorderCommandPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* DdsRecorderCommandPubSubType::createData() -{ - return reinterpret_cast(new DdsRecorderCommand()); -} - -void DdsRecorderCommandPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DdsRecorderCommandPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DdsRecorderCommand* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DdsRecorderCommand::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || DdsRecorderCommand::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/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h deleted file mode 100644 index b10231ffc..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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 DdsRecorderCommandPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ - -#include -#include - -#include "DdsRecorderCommand.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated DdsRecorderCommand 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 DdsRecorderCommand defined by the user in the IDL file. - * @ingroup DDSRECORDERCOMMAND - */ -class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DdsRecorderCommand type; - - eProsima_user_DllExport DdsRecorderCommandPubSubType(); - - eProsima_user_DllExport virtual ~DdsRecorderCommandPubSubType() 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_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i deleted file mode 100644 index 463d59e4b..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i +++ /dev/null @@ -1,30 +0,0 @@ -// 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 DdsRecorderCommandPubSubTypes.i - * This header file contains the SWIG interface of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - -%import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; - -%{ -#include "DdsRecorderCommandPubSubTypes.h" -%} - -#define GEN_API_VER 1 - -%include "DdsRecorderCommandPubSubTypes.h" diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/CMakeLists.txt b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/CMakeLists.txt deleted file mode 100644 index ac4942397..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/CMakeLists.txt +++ /dev/null @@ -1,112 +0,0 @@ - -cmake_minimum_required(VERSION 3.16.3) - -# SWIG: use standard target name. -if(POLICY CMP0078) - cmake_policy(SET CMP0078 NEW) -endif() - -# SWIG: use SWIG_MODULE_NAME property. -if(POLICY CMP0086) - cmake_policy(SET CMP0086 NEW) -endif() - -############################################################################### -# Library for types defined in DdsRecorderStatus IDL -############################################################################### - -message(STATUS "Configuring python wrapper for types in DdsRecorderStatus...") - -############################################################################### -# Type library on C++ - -project(DdsRecorderStatus) - -find_package(fastcdr REQUIRED) -find_package(fastrtps REQUIRED) - - -set(${PROJECT_NAME}_FILES - DdsRecorderStatus.cxx - DdsRecorderStatusPubSubTypes.cxx - ) - -include_directories() - -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -#Create library for C++ types -add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_FILES}) -if(WIN32) - target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT) -endif(WIN32) -target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr fastrtps) - -############################################################################### -# Python bindings for type - -find_package(SWIG REQUIRED) -include(${SWIG_USE_FILE}) -set(CMAKE_SWIG_FLAGS "") - -find_package(Python3 COMPONENTS Interpreter Development REQUIRED) -set(PYTHON_INCLUDE_PATH ${Python3_INCLUDE_DIRS}) -set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) -set(PYTHON_LIBRARIES ${Python3_LIBRARIES}) - -include_directories(${PYTHON_INCLUDE_PATH}) - -set(${PROJECT_NAME}_MODULE - DdsRecorderStatusWrapper - ) - -set(${PROJECT_NAME}_MODULE_FILES - ${PROJECT_NAME}.i - ) - -SET_SOURCE_FILES_PROPERTIES( - ${${PROJECT_NAME}_MODULE_FILES} - PROPERTIES CPLUSPLUS ON - USE_TARGET_INCLUDE_DIRECTORIES TRUE - ) - -include_directories( - ${PROJECT_SOURCE_DIR} - ) - -SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE} - TYPE SHARED - LANGUAGE python - SOURCES ${${PROJECT_NAME}_MODULE_FILES}) - -if(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8) - set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_COMPILE_DEFINITIONS SWIGWORDSIZE64) -endif() - -SWIG_LINK_LIBRARIES(${${PROJECT_NAME}_MODULE} - Python3::Module - fastrtps - ${PROJECT_NAME} - ) - -# Find the installation path -execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" - OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - -get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE) -file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH}) -SET (PYTHON_MODULE_PATH - ${_REL_PYTHON_MODULE_PATH} - ) - -# Install -install(TARGETS ${PROJECT_NAME} - RUNTIME DESTINATION bin/ - LIBRARY DESTINATION lib/ - ARCHIVE DESTINATION lib/ - ) -install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH}) -get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES) -install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}) diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.cxx b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.cxx deleted file mode 100644 index 17f5f32aa..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.cxx +++ /dev/null @@ -1,282 +0,0 @@ -// 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 DdsRecorderStatus.cxx - * 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 "DdsRecorderStatus.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -#define DdsRecorderStatus_max_cdr_typesize 780ULL; -#define DdsRecorderStatus_max_key_cdr_typesize 0ULL; - -DdsRecorderStatus::DdsRecorderStatus() -{ - // string m_previous - m_previous =""; - // string m_current - m_current =""; - // string m_info - m_info =""; - -} - -DdsRecorderStatus::~DdsRecorderStatus() -{ - - - -} - -DdsRecorderStatus::DdsRecorderStatus( - const DdsRecorderStatus& x) -{ - m_previous = x.m_previous; - m_current = x.m_current; - m_info = x.m_info; -} - -DdsRecorderStatus::DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept -{ - m_previous = std::move(x.m_previous); - m_current = std::move(x.m_current); - m_info = std::move(x.m_info); -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - const DdsRecorderStatus& x) -{ - - m_previous = x.m_previous; - m_current = x.m_current; - m_info = x.m_info; - - return *this; -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - DdsRecorderStatus&& x) noexcept -{ - - m_previous = std::move(x.m_previous); - m_current = std::move(x.m_current); - m_info = std::move(x.m_info); - - return *this; -} - -bool DdsRecorderStatus::operator ==( - const DdsRecorderStatus& x) const -{ - - return (m_previous == x.m_previous && m_current == x.m_current && m_info == x.m_info); -} - -bool DdsRecorderStatus::operator !=( - const DdsRecorderStatus& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderStatus_max_cdr_typesize; -} - -size_t DdsRecorderStatus::getCdrSerializedSize( - const DdsRecorderStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.previous().size() + 1; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.current().size() + 1; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.info().size() + 1; - - - return current_alignment - initial_alignment; -} - -void DdsRecorderStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_previous.c_str(); - scdr << m_current.c_str(); - scdr << m_info.c_str(); - -} - -void DdsRecorderStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_previous; - dcdr >> m_current; - dcdr >> m_info; -} - -/*! - * @brief This function copies the value in member previous - * @param _previous New value to be copied in member previous - */ -void DdsRecorderStatus::previous( - const std::string& _previous) -{ - m_previous = _previous; -} - -/*! - * @brief This function moves the value in member previous - * @param _previous New value to be moved in member previous - */ -void DdsRecorderStatus::previous( - std::string&& _previous) -{ - m_previous = std::move(_previous); -} - -/*! - * @brief This function returns a constant reference to member previous - * @return Constant reference to member previous - */ -const std::string& DdsRecorderStatus::previous() const -{ - return m_previous; -} - -/*! - * @brief This function returns a reference to member previous - * @return Reference to member previous - */ -std::string& DdsRecorderStatus::previous() -{ - return m_previous; -} -/*! - * @brief This function copies the value in member current - * @param _current New value to be copied in member current - */ -void DdsRecorderStatus::current( - const std::string& _current) -{ - m_current = _current; -} - -/*! - * @brief This function moves the value in member current - * @param _current New value to be moved in member current - */ -void DdsRecorderStatus::current( - std::string&& _current) -{ - m_current = std::move(_current); -} - -/*! - * @brief This function returns a constant reference to member current - * @return Constant reference to member current - */ -const std::string& DdsRecorderStatus::current() const -{ - return m_current; -} - -/*! - * @brief This function returns a reference to member current - * @return Reference to member current - */ -std::string& DdsRecorderStatus::current() -{ - return m_current; -} -/*! - * @brief This function copies the value in member info - * @param _info New value to be copied in member info - */ -void DdsRecorderStatus::info( - const std::string& _info) -{ - m_info = _info; -} - -/*! - * @brief This function moves the value in member info - * @param _info New value to be moved in member info - */ -void DdsRecorderStatus::info( - std::string&& _info) -{ - m_info = std::move(_info); -} - -/*! - * @brief This function returns a constant reference to member info - * @return Constant reference to member info - */ -const std::string& DdsRecorderStatus::info() const -{ - return m_info; -} - -/*! - * @brief This function returns a reference to member info - * @return Reference to member info - */ -std::string& DdsRecorderStatus::info() -{ - return m_info; -} - - -size_t DdsRecorderStatus::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderStatus_max_key_cdr_typesize; -} - -bool DdsRecorderStatus::isKeyDefined() -{ - return false; -} - -void DdsRecorderStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.h b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.h deleted file mode 100644 index ef7f75e20..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.h +++ /dev/null @@ -1,267 +0,0 @@ -// 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 DdsRecorderStatus.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_DDSRECORDERSTATUS_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_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(DdsRecorderStatus_SOURCE) -#define DdsRecorderStatus_DllAPI __declspec( dllexport ) -#else -#define DdsRecorderStatus_DllAPI __declspec( dllimport ) -#endif // DdsRecorderStatus_SOURCE -#else -#define DdsRecorderStatus_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DdsRecorderStatus_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure DdsRecorderStatus defined by the user in the IDL file. - * @ingroup DDSRECORDERSTATUS - */ -class DdsRecorderStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus( - const DdsRecorderStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus& operator =( - const DdsRecorderStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus& operator =( - DdsRecorderStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderStatus& x) const; - - /*! - * @brief This function copies the value in member previous - * @param _previous New value to be copied in member previous - */ - eProsima_user_DllExport void previous( - const std::string& _previous); - - /*! - * @brief This function moves the value in member previous - * @param _previous New value to be moved in member previous - */ - eProsima_user_DllExport void previous( - std::string&& _previous); - - /*! - * @brief This function returns a constant reference to member previous - * @return Constant reference to member previous - */ - eProsima_user_DllExport const std::string& previous() const; - - /*! - * @brief This function returns a reference to member previous - * @return Reference to member previous - */ - eProsima_user_DllExport std::string& previous(); - /*! - * @brief This function copies the value in member current - * @param _current New value to be copied in member current - */ - eProsima_user_DllExport void current( - const std::string& _current); - - /*! - * @brief This function moves the value in member current - * @param _current New value to be moved in member current - */ - eProsima_user_DllExport void current( - std::string&& _current); - - /*! - * @brief This function returns a constant reference to member current - * @return Constant reference to member current - */ - eProsima_user_DllExport const std::string& current() const; - - /*! - * @brief This function returns a reference to member current - * @return Reference to member current - */ - eProsima_user_DllExport std::string& current(); - /*! - * @brief This function copies the value in member info - * @param _info New value to be copied in member info - */ - eProsima_user_DllExport void info( - const std::string& _info); - - /*! - * @brief This function moves the value in member info - * @param _info New value to be moved in member info - */ - eProsima_user_DllExport void info( - std::string&& _info); - - /*! - * @brief This function returns a constant reference to member info - * @return Constant reference to member info - */ - eProsima_user_DllExport const std::string& info() const; - - /*! - * @brief This function returns a reference to member info - * @return Reference to member info - */ - eProsima_user_DllExport std::string& info(); - - /*! - * @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 DdsRecorderStatus& 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_previous; - std::string m_current; - std::string m_info; - -}; - -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.i b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.i deleted file mode 100644 index b00372401..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.i +++ /dev/null @@ -1,107 +0,0 @@ -// 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 DdsRecorderStatus.i - * This header file contains the SWIG interface of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -%module DdsRecorderStatus - -// SWIG helper modules -%include "stdint.i" -%include "std_string.i" -%include "std_vector.i" -%include "std_array.i" -%include "std_map.i" -%include "typemaps.i" - -// Assignemt operators are ignored, as there is no such thing in Python. -// Trying to export them issues a warning -%ignore *::operator=; - -// Macro declarations -// Any macro used on the Fast DDS header files will give an error if it is not redefined here -#define RTPS_DllAPI -#define eProsima_user_DllExport - - -%{ -#include "DdsRecorderStatus.h" - -#include -%} - -%import(module="fastdds") "fastdds/dds/core/LoanableCollection.hpp" -%import(module="fastdds") "fastdds/dds/core/LoanableTypedCollection.hpp" -%import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp" - -//////////////////////////////////////////////////////// -// Binding for class DdsRecorderStatus -//////////////////////////////////////////////////////// - -// Ignore overloaded methods that have no application on Python -// Otherwise they will issue a warning -%ignore DdsRecorderStatus::DdsRecorderStatus(DdsRecorderStatus&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Avoid a warning ignoring all but one -%ignore DdsRecorderStatus::previous(std::string&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore DdsRecorderStatus::previous(); -%rename("%s") DdsRecorderStatus::previous() const; - -%ignore DdsRecorderStatus::current(std::string&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore DdsRecorderStatus::current(); -%rename("%s") DdsRecorderStatus::current() const; - -%ignore DdsRecorderStatus::info(std::string&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore DdsRecorderStatus::info(); -%rename("%s") DdsRecorderStatus::info() const; - - -%template(_DdsRecorderStatusSeq) eprosima::fastdds::dds::LoanableTypedCollection; -%template(DdsRecorderStatusSeq) eprosima::fastdds::dds::LoanableSequence; -%extend eprosima::fastdds::dds::LoanableSequence -{ - size_t __len__() const - { - return self->length(); - } - - const DdsRecorderStatus& __getitem__(size_t i) const - { - return (*self)[i]; - } -} - - -// Include the class interfaces -%include "DdsRecorderStatus.h" - -// Include the corresponding TopicDataType -%include "DdsRecorderStatusPubSubTypes.i" diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx deleted file mode 100644 index ce6ce75ae..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ /dev/null @@ -1,169 +0,0 @@ -// 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 DdsRecorderStatusPubSubTypes.cxx - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "DdsRecorderStatusPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -DdsRecorderStatusPubSubType::DdsRecorderStatusPubSubType() -{ - setName("DdsRecorderStatus"); - auto type_size = DdsRecorderStatus::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = DdsRecorderStatus::isKeyDefined(); - size_t keyLength = DdsRecorderStatus::getKeyMaxCdrSerializedSize() > 16 ? - DdsRecorderStatus::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DdsRecorderStatusPubSubType::~DdsRecorderStatusPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DdsRecorderStatusPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - DdsRecorderStatus* 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 DdsRecorderStatusPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - DdsRecorderStatus* 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 DdsRecorderStatusPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* DdsRecorderStatusPubSubType::createData() -{ - return reinterpret_cast(new DdsRecorderStatus()); -} - -void DdsRecorderStatusPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DdsRecorderStatusPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DdsRecorderStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DdsRecorderStatus::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || DdsRecorderStatus::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/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h deleted file mode 100644 index a6a6d3ae3..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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 DdsRecorderStatusPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_PUBSUBTYPES_H_ - -#include -#include - -#include "DdsRecorderStatus.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated DdsRecorderStatus 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 DdsRecorderStatus defined by the user in the IDL file. - * @ingroup DDSRECORDERSTATUS - */ -class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DdsRecorderStatus type; - - eProsima_user_DllExport DdsRecorderStatusPubSubType(); - - eProsima_user_DllExport virtual ~DdsRecorderStatusPubSubType() 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_DDSRECORDERSTATUS_PUBSUBTYPES_H_ diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i deleted file mode 100644 index 9577a3232..000000000 --- a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i +++ /dev/null @@ -1,30 +0,0 @@ -// 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 DdsRecorderStatusPubSubTypes.i - * This header file contains the SWIG interface of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - -%import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; - -%{ -#include "DdsRecorderStatusPubSubTypes.h" -%} - -#define GEN_API_VER 1 - -%include "DdsRecorderStatusPubSubTypes.h" diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.cxx b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.cxx deleted file mode 100644 index 4b67e14f1..000000000 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.cxx +++ /dev/null @@ -1,176 +0,0 @@ -// 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 DdsRecorderCommand.cxx - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "DdsRecorderCommand.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -DdsRecorderCommand::DdsRecorderCommand() -{ -} - -DdsRecorderCommand::~DdsRecorderCommand() -{ -} - -DdsRecorderCommand::DdsRecorderCommand( - const DdsRecorderCommand& x) -{ - m_command = x.m_command; - m_args = x.m_args; -} - -DdsRecorderCommand::DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept -{ - m_command = std::move(x.m_command); - m_args = std::move(x.m_args); -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - const DdsRecorderCommand& x) -{ - - m_command = x.m_command; - m_args = x.m_args; - return *this; -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - DdsRecorderCommand&& x) noexcept -{ - - m_command = std::move(x.m_command); - m_args = std::move(x.m_args); - return *this; -} - -bool DdsRecorderCommand::operator ==( - const DdsRecorderCommand& x) const -{ - return (m_command == x.m_command && - m_args == x.m_args); -} - -bool DdsRecorderCommand::operator !=( - const DdsRecorderCommand& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member command - * @param _command New value to be copied in member command - */ -void DdsRecorderCommand::command( - const std::string& _command) -{ - m_command = _command; -} - -/*! - * @brief This function moves the value in member command - * @param _command New value to be moved in member command - */ -void DdsRecorderCommand::command( - std::string&& _command) -{ - m_command = std::move(_command); -} - -/*! - * @brief This function returns a constant reference to member command - * @return Constant reference to member command - */ -const std::string& DdsRecorderCommand::command() const -{ - return m_command; -} - -/*! - * @brief This function returns a reference to member command - * @return Reference to member command - */ -std::string& DdsRecorderCommand::command() -{ - return m_command; -} - -/*! - * @brief This function copies the value in member args - * @param _args New value to be copied in member args - */ -void DdsRecorderCommand::args( - const std::string& _args) -{ - m_args = _args; -} - -/*! - * @brief This function moves the value in member args - * @param _args New value to be moved in member args - */ -void DdsRecorderCommand::args( - std::string&& _args) -{ - m_args = std::move(_args); -} - -/*! - * @brief This function returns a constant reference to member args - * @return Constant reference to member args - */ -const std::string& DdsRecorderCommand::args() const -{ - return m_args; -} - -/*! - * @brief This function returns a reference to member args - * @return Reference to member args - */ -std::string& DdsRecorderCommand::args() -{ - return m_args; -} - -// Include auxiliary functions like for serializing/deserializing. -#include "DdsRecorderCommandCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.i b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.i deleted file mode 100644 index 8ec3c1d57..000000000 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.i +++ /dev/null @@ -1,121 +0,0 @@ -// 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 DdsRecorderCommand.i - * This header file contains the SWIG interface of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -%module DdsRecorderCommand - -// SWIG helper modules -%include "stdint.i" -%include "std_array.i" -%include "std_map.i" -%include "std_string.i" -%include "std_vector.i" -%include "typemaps.i" - -// Assignemt operators are ignored, as there is no such thing in Python. -// Trying to export them issues a warning -%ignore *::operator=; - -// Macro declarations -// Any macro used on the Fast DDS header files will give an error if it is not redefined here -#define RTPS_DllAPI -#define eProsima_user_DllExport - - -%{ -#include "DdsRecorderCommand.h" - -#include -%} - -%include -#if FASTCDR_VERSION_MAJOR > 1 -%import(module="fastdds") "fastcdr/xcdr/optional.hpp" -#endif -%import(module="fastdds") "fastdds/dds/core/LoanableCollection.hpp" -%import(module="fastdds") "fastdds/dds/core/LoanableTypedCollection.hpp" -%import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp" - -%define %traits_penumn(Type...) - %fragment(SWIG_Traits_frag(Type),"header", - fragment="StdTraits") { -namespace swig { - template <> struct traits< Type > { - typedef value_category category; - static const char* type_name() { return #Type; } - }; -} -} -%enddef - - - -//////////////////////////////////////////////////////// -// Binding for class DdsRecorderCommand -//////////////////////////////////////////////////////// - -// Ignore overloaded methods that have no application on Python -// Otherwise they will issue a warning -%ignore DdsRecorderCommand::DdsRecorderCommand(DdsRecorderCommand&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Avoid a warning ignoring all but one -%ignore DdsRecorderCommand::command(std::string&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore DdsRecorderCommand::command(); -%rename("%s") DdsRecorderCommand::command() const; - - - -%ignore DdsRecorderCommand::args(std::string&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore DdsRecorderCommand::args(); -%rename("%s") DdsRecorderCommand::args() const; - - - -%template(_DdsRecorderCommandSeq) eprosima::fastdds::dds::LoanableTypedCollection; -%template(DdsRecorderCommandSeq) eprosima::fastdds::dds::LoanableSequence; -%extend eprosima::fastdds::dds::LoanableSequence -{ - size_t __len__() const - { - return self->length(); - } - - const DdsRecorderCommand& __getitem__(size_t i) const - { - return (*self)[i]; - } -} - - -// Include the class interfaces -%include "DdsRecorderCommand.h" -%include "DdsRecorderCommandv1.h" - -// Include the corresponding TopicDataType -%include "DdsRecorderCommandPubSubTypes.i" diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i deleted file mode 100644 index 934b8986f..000000000 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i +++ /dev/null @@ -1,30 +0,0 @@ -// 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 DdsRecorderCommandPubSubTypes.i - * This header file contains the SWIG interface of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -%import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; - -%{ -#include "DdsRecorderCommandPubSubTypes.h" -%} - -#define GEN_API_VER 2 - -%include "DdsRecorderCommandPubSubTypes.h" diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx deleted file mode 100644 index 41e51e300..000000000 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx +++ /dev/null @@ -1,299 +0,0 @@ -// 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 DdsRecorderCommandv1.cxx - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "DdsRecorderCommand.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define DdsRecorderCommand_max_cdr_typesize 524ULL; - - - - -DdsRecorderCommand::DdsRecorderCommand() -{ - // /type_d() m_command - - // /type_d() m_args - - -} - -DdsRecorderCommand::~DdsRecorderCommand() -{ -} - -DdsRecorderCommand::DdsRecorderCommand( - const DdsRecorderCommand& x) -{ - m_command = x.m_command; - - - m_args = x.m_args; - -} - -DdsRecorderCommand::DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept -{ - m_command = std::move(x.m_command); - - - m_args = std::move(x.m_args); - -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - const DdsRecorderCommand& x) -{ - m_command = x.m_command; - - - m_args = x.m_args; - - return *this; -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - DdsRecorderCommand&& x) noexcept -{ - m_command = std::move(x.m_command); - - - m_args = std::move(x.m_args); - - return *this; -} - -bool DdsRecorderCommand::operator ==( - const DdsRecorderCommand& x) const -{ - return (m_command == x.m_command && - m_args == x.m_args); -} - -bool DdsRecorderCommand::operator !=( - const DdsRecorderCommand& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderCommand::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderCommand_max_cdr_typesize; -} - -size_t DdsRecorderCommand::getCdrSerializedSize( - const DdsRecorderCommand& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.command().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.args().size() + 1; - - - return current_alignment - initial_alignment; -} - -void DdsRecorderCommand::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_command.c_str(); - - scdr << m_args.c_str(); - -} - -void DdsRecorderCommand::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_command; - - - - dcdr >> m_args; - - -} - -bool DdsRecorderCommand::isKeyDefined() -{ - return false; -} - -void DdsRecorderCommand::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member command - * @param _command New value to be copied in member command - */ -void DdsRecorderCommand::command( - const std::string& _command) -{ - m_command = _command; -} - -/*! - * @brief This function moves the value in member command - * @param _command New value to be moved in member command - */ -void DdsRecorderCommand::command( - std::string&& _command) -{ - m_command = std::move(_command); -} - -/*! - * @brief This function returns a constant reference to member command - * @return Constant reference to member command - */ -const std::string& DdsRecorderCommand::command() const -{ - return m_command; -} - -/*! - * @brief This function returns a reference to member command - * @return Reference to member command - */ -std::string& DdsRecorderCommand::command() -{ - return m_command; -} - -/*! - * @brief This function copies the value in member args - * @param _args New value to be copied in member args - */ -void DdsRecorderCommand::args( - const std::string& _args) -{ - m_args = _args; -} - -/*! - * @brief This function moves the value in member args - * @param _args New value to be moved in member args - */ -void DdsRecorderCommand::args( - std::string&& _args) -{ - m_args = std::move(_args); -} - -/*! - * @brief This function returns a constant reference to member args - * @return Constant reference to member args - */ -const std::string& DdsRecorderCommand::args() const -{ - return m_args; -} - -/*! - * @brief This function returns a reference to member args - * @return Reference to member args - */ -std::string& DdsRecorderCommand::args() -{ - return m_args; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.h b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.h deleted file mode 100644 index 1da59383c..000000000 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.h +++ /dev/null @@ -1,249 +0,0 @@ -// 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 DdsRecorderCommandv1.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_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(DDSRECORDERCOMMAND_SOURCE) -#define DDSRECORDERCOMMAND_DllAPI __declspec( dllexport ) -#else -#define DDSRECORDERCOMMAND_DllAPI __declspec( dllimport ) -#endif // DDSRECORDERCOMMAND_SOURCE -#else -#define DDSRECORDERCOMMAND_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DDSRECORDERCOMMAND_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure DdsRecorderCommand defined by the user in the IDL file. - * @ingroup DdsRecorderCommand - */ -class DdsRecorderCommand -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderCommand(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderCommand(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand( - const DdsRecorderCommand& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand& operator =( - const DdsRecorderCommand& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand& operator =( - DdsRecorderCommand&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderCommand object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderCommand& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderCommand object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderCommand& x) const; - - /*! - * @brief This function copies the value in member command - * @param _command New value to be copied in member command - */ - eProsima_user_DllExport void command( - const std::string& _command); - - /*! - * @brief This function moves the value in member command - * @param _command New value to be moved in member command - */ - eProsima_user_DllExport void command( - std::string&& _command); - - /*! - * @brief This function returns a constant reference to member command - * @return Constant reference to member command - */ - eProsima_user_DllExport const std::string& command() const; - - /*! - * @brief This function returns a reference to member command - * @return Reference to member command - */ - eProsima_user_DllExport std::string& command(); - - - /*! - * @brief This function copies the value in member args - * @param _args New value to be copied in member args - */ - eProsima_user_DllExport void args( - const std::string& _args); - - /*! - * @brief This function moves the value in member args - * @param _args New value to be moved in member args - */ - eProsima_user_DllExport void args( - std::string&& _args); - - /*! - * @brief This function returns a constant reference to member args - * @return Constant reference to member args - */ - eProsima_user_DllExport const std::string& args() const; - - /*! - * @brief This function returns a reference to member args - * @return Reference to member args - */ - eProsima_user_DllExport std::string& args(); - - - /*! - * @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 DdsRecorderCommand& 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 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_command; - std::string m_args; - -}; - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.cxx b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.cxx deleted file mode 100644 index 6e32de2b6..000000000 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.cxx +++ /dev/null @@ -1,219 +0,0 @@ -// 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 DdsRecorderStatus.cxx - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "DdsRecorderStatus.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -DdsRecorderStatus::DdsRecorderStatus() -{ -} - -DdsRecorderStatus::~DdsRecorderStatus() -{ -} - -DdsRecorderStatus::DdsRecorderStatus( - const DdsRecorderStatus& x) -{ - m_previous = x.m_previous; - m_current = x.m_current; - m_info = x.m_info; -} - -DdsRecorderStatus::DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept -{ - m_previous = std::move(x.m_previous); - m_current = std::move(x.m_current); - m_info = std::move(x.m_info); -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - const DdsRecorderStatus& x) -{ - - m_previous = x.m_previous; - m_current = x.m_current; - m_info = x.m_info; - return *this; -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - DdsRecorderStatus&& x) noexcept -{ - - m_previous = std::move(x.m_previous); - m_current = std::move(x.m_current); - m_info = std::move(x.m_info); - return *this; -} - -bool DdsRecorderStatus::operator ==( - const DdsRecorderStatus& x) const -{ - return (m_previous == x.m_previous && - m_current == x.m_current && - m_info == x.m_info); -} - -bool DdsRecorderStatus::operator !=( - const DdsRecorderStatus& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member previous - * @param _previous New value to be copied in member previous - */ -void DdsRecorderStatus::previous( - const std::string& _previous) -{ - m_previous = _previous; -} - -/*! - * @brief This function moves the value in member previous - * @param _previous New value to be moved in member previous - */ -void DdsRecorderStatus::previous( - std::string&& _previous) -{ - m_previous = std::move(_previous); -} - -/*! - * @brief This function returns a constant reference to member previous - * @return Constant reference to member previous - */ -const std::string& DdsRecorderStatus::previous() const -{ - return m_previous; -} - -/*! - * @brief This function returns a reference to member previous - * @return Reference to member previous - */ -std::string& DdsRecorderStatus::previous() -{ - return m_previous; -} - -/*! - * @brief This function copies the value in member current - * @param _current New value to be copied in member current - */ -void DdsRecorderStatus::current( - const std::string& _current) -{ - m_current = _current; -} - -/*! - * @brief This function moves the value in member current - * @param _current New value to be moved in member current - */ -void DdsRecorderStatus::current( - std::string&& _current) -{ - m_current = std::move(_current); -} - -/*! - * @brief This function returns a constant reference to member current - * @return Constant reference to member current - */ -const std::string& DdsRecorderStatus::current() const -{ - return m_current; -} - -/*! - * @brief This function returns a reference to member current - * @return Reference to member current - */ -std::string& DdsRecorderStatus::current() -{ - return m_current; -} - -/*! - * @brief This function copies the value in member info - * @param _info New value to be copied in member info - */ -void DdsRecorderStatus::info( - const std::string& _info) -{ - m_info = _info; -} - -/*! - * @brief This function moves the value in member info - * @param _info New value to be moved in member info - */ -void DdsRecorderStatus::info( - std::string&& _info) -{ - m_info = std::move(_info); -} - -/*! - * @brief This function returns a constant reference to member info - * @return Constant reference to member info - */ -const std::string& DdsRecorderStatus::info() const -{ - return m_info; -} - -/*! - * @brief This function returns a reference to member info - * @return Reference to member info - */ -std::string& DdsRecorderStatus::info() -{ - return m_info; -} - -// Include auxiliary functions like for serializing/deserializing. -#include "DdsRecorderStatusCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.i b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.i deleted file mode 100644 index 8e2e666d3..000000000 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.i +++ /dev/null @@ -1,131 +0,0 @@ -// 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 DdsRecorderStatus.i - * This header file contains the SWIG interface of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -%module DdsRecorderStatus - -// SWIG helper modules -%include "stdint.i" -%include "std_array.i" -%include "std_map.i" -%include "std_string.i" -%include "std_vector.i" -%include "typemaps.i" - -// Assignemt operators are ignored, as there is no such thing in Python. -// Trying to export them issues a warning -%ignore *::operator=; - -// Macro declarations -// Any macro used on the Fast DDS header files will give an error if it is not redefined here -#define RTPS_DllAPI -#define eProsima_user_DllExport - - -%{ -#include "DdsRecorderStatus.h" - -#include -%} - -%include -#if FASTCDR_VERSION_MAJOR > 1 -%import(module="fastdds") "fastcdr/xcdr/optional.hpp" -#endif -%import(module="fastdds") "fastdds/dds/core/LoanableCollection.hpp" -%import(module="fastdds") "fastdds/dds/core/LoanableTypedCollection.hpp" -%import(module="fastdds") "fastdds/dds/core/LoanableSequence.hpp" - -%define %traits_penumn(Type...) - %fragment(SWIG_Traits_frag(Type),"header", - fragment="StdTraits") { -namespace swig { - template <> struct traits< Type > { - typedef value_category category; - static const char* type_name() { return #Type; } - }; -} -} -%enddef - - - -//////////////////////////////////////////////////////// -// Binding for class DdsRecorderStatus -//////////////////////////////////////////////////////// - -// Ignore overloaded methods that have no application on Python -// Otherwise they will issue a warning -%ignore DdsRecorderStatus::DdsRecorderStatus(DdsRecorderStatus&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Avoid a warning ignoring all but one -%ignore DdsRecorderStatus::previous(std::string&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore DdsRecorderStatus::previous(); -%rename("%s") DdsRecorderStatus::previous() const; - - - -%ignore DdsRecorderStatus::current(std::string&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore DdsRecorderStatus::current(); -%rename("%s") DdsRecorderStatus::current() const; - - - -%ignore DdsRecorderStatus::info(std::string&&); - -// Overloaded getter methods shadow each other and are equivalent in python -// Const accesors produced constant enums instead of arrays/dictionaries when used -// We ignore them to prevent this -%ignore DdsRecorderStatus::info(); -%rename("%s") DdsRecorderStatus::info() const; - - - -%template(_DdsRecorderStatusSeq) eprosima::fastdds::dds::LoanableTypedCollection; -%template(DdsRecorderStatusSeq) eprosima::fastdds::dds::LoanableSequence; -%extend eprosima::fastdds::dds::LoanableSequence -{ - size_t __len__() const - { - return self->length(); - } - - const DdsRecorderStatus& __getitem__(size_t i) const - { - return (*self)[i]; - } -} - - -// Include the class interfaces -%include "DdsRecorderStatus.h" -%include "DdsRecorderStatusv1.h" - -// Include the corresponding TopicDataType -%include "DdsRecorderStatusPubSubTypes.i" diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i deleted file mode 100644 index 037f53b02..000000000 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i +++ /dev/null @@ -1,30 +0,0 @@ -// 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 DdsRecorderStatusPubSubTypes.i - * This header file contains the SWIG interface of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -%import(module="fastdds") "fastdds/dds/topic/TopicDataType.hpp"; - -%{ -#include "DdsRecorderStatusPubSubTypes.h" -%} - -#define GEN_API_VER 2 - -%include "DdsRecorderStatusPubSubTypes.h" diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx deleted file mode 100644 index 8e94280a8..000000000 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx +++ /dev/null @@ -1,361 +0,0 @@ -// 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 DdsRecorderStatusv1.cxx - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "DdsRecorderStatus.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define DdsRecorderStatus_max_cdr_typesize 784ULL; - - - - -DdsRecorderStatus::DdsRecorderStatus() -{ - // /type_d() m_previous - - // /type_d() m_current - - // /type_d() m_info - - -} - -DdsRecorderStatus::~DdsRecorderStatus() -{ -} - -DdsRecorderStatus::DdsRecorderStatus( - const DdsRecorderStatus& x) -{ - m_previous = x.m_previous; - - - m_current = x.m_current; - - - m_info = x.m_info; - -} - -DdsRecorderStatus::DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept -{ - m_previous = std::move(x.m_previous); - - - m_current = std::move(x.m_current); - - - m_info = std::move(x.m_info); - -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - const DdsRecorderStatus& x) -{ - m_previous = x.m_previous; - - - m_current = x.m_current; - - - m_info = x.m_info; - - return *this; -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - DdsRecorderStatus&& x) noexcept -{ - m_previous = std::move(x.m_previous); - - - m_current = std::move(x.m_current); - - - m_info = std::move(x.m_info); - - return *this; -} - -bool DdsRecorderStatus::operator ==( - const DdsRecorderStatus& x) const -{ - return (m_previous == x.m_previous && - m_current == x.m_current && - m_info == x.m_info); -} - -bool DdsRecorderStatus::operator !=( - const DdsRecorderStatus& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderStatus_max_cdr_typesize; -} - -size_t DdsRecorderStatus::getCdrSerializedSize( - const DdsRecorderStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.previous().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.current().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.info().size() + 1; - - - return current_alignment - initial_alignment; -} - -void DdsRecorderStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_previous.c_str(); - - scdr << m_current.c_str(); - - scdr << m_info.c_str(); - -} - -void DdsRecorderStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_previous; - - - - dcdr >> m_current; - - - - dcdr >> m_info; - - -} - -bool DdsRecorderStatus::isKeyDefined() -{ - return false; -} - -void DdsRecorderStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member previous - * @param _previous New value to be copied in member previous - */ -void DdsRecorderStatus::previous( - const std::string& _previous) -{ - m_previous = _previous; -} - -/*! - * @brief This function moves the value in member previous - * @param _previous New value to be moved in member previous - */ -void DdsRecorderStatus::previous( - std::string&& _previous) -{ - m_previous = std::move(_previous); -} - -/*! - * @brief This function returns a constant reference to member previous - * @return Constant reference to member previous - */ -const std::string& DdsRecorderStatus::previous() const -{ - return m_previous; -} - -/*! - * @brief This function returns a reference to member previous - * @return Reference to member previous - */ -std::string& DdsRecorderStatus::previous() -{ - return m_previous; -} - -/*! - * @brief This function copies the value in member current - * @param _current New value to be copied in member current - */ -void DdsRecorderStatus::current( - const std::string& _current) -{ - m_current = _current; -} - -/*! - * @brief This function moves the value in member current - * @param _current New value to be moved in member current - */ -void DdsRecorderStatus::current( - std::string&& _current) -{ - m_current = std::move(_current); -} - -/*! - * @brief This function returns a constant reference to member current - * @return Constant reference to member current - */ -const std::string& DdsRecorderStatus::current() const -{ - return m_current; -} - -/*! - * @brief This function returns a reference to member current - * @return Reference to member current - */ -std::string& DdsRecorderStatus::current() -{ - return m_current; -} - -/*! - * @brief This function copies the value in member info - * @param _info New value to be copied in member info - */ -void DdsRecorderStatus::info( - const std::string& _info) -{ - m_info = _info; -} - -/*! - * @brief This function moves the value in member info - * @param _info New value to be moved in member info - */ -void DdsRecorderStatus::info( - std::string&& _info) -{ - m_info = std::move(_info); -} - -/*! - * @brief This function returns a constant reference to member info - * @return Constant reference to member info - */ -const std::string& DdsRecorderStatus::info() const -{ - return m_info; -} - -/*! - * @brief This function returns a reference to member info - * @return Reference to member info - */ -std::string& DdsRecorderStatus::info() -{ - return m_info; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.h b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.h deleted file mode 100644 index 6b6d9b6c5..000000000 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.h +++ /dev/null @@ -1,277 +0,0 @@ -// 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 DdsRecorderStatusv1.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_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(DDSRECORDERSTATUS_SOURCE) -#define DDSRECORDERSTATUS_DllAPI __declspec( dllexport ) -#else -#define DDSRECORDERSTATUS_DllAPI __declspec( dllimport ) -#endif // DDSRECORDERSTATUS_SOURCE -#else -#define DDSRECORDERSTATUS_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DDSRECORDERSTATUS_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure DdsRecorderStatus defined by the user in the IDL file. - * @ingroup DdsRecorderStatus - */ -class DdsRecorderStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus( - const DdsRecorderStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus& operator =( - const DdsRecorderStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus& operator =( - DdsRecorderStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderStatus& x) const; - - /*! - * @brief This function copies the value in member previous - * @param _previous New value to be copied in member previous - */ - eProsima_user_DllExport void previous( - const std::string& _previous); - - /*! - * @brief This function moves the value in member previous - * @param _previous New value to be moved in member previous - */ - eProsima_user_DllExport void previous( - std::string&& _previous); - - /*! - * @brief This function returns a constant reference to member previous - * @return Constant reference to member previous - */ - eProsima_user_DllExport const std::string& previous() const; - - /*! - * @brief This function returns a reference to member previous - * @return Reference to member previous - */ - eProsima_user_DllExport std::string& previous(); - - - /*! - * @brief This function copies the value in member current - * @param _current New value to be copied in member current - */ - eProsima_user_DllExport void current( - const std::string& _current); - - /*! - * @brief This function moves the value in member current - * @param _current New value to be moved in member current - */ - eProsima_user_DllExport void current( - std::string&& _current); - - /*! - * @brief This function returns a constant reference to member current - * @return Constant reference to member current - */ - eProsima_user_DllExport const std::string& current() const; - - /*! - * @brief This function returns a reference to member current - * @return Reference to member current - */ - eProsima_user_DllExport std::string& current(); - - - /*! - * @brief This function copies the value in member info - * @param _info New value to be copied in member info - */ - eProsima_user_DllExport void info( - const std::string& _info); - - /*! - * @brief This function moves the value in member info - * @param _info New value to be moved in member info - */ - eProsima_user_DllExport void info( - std::string&& _info); - - /*! - * @brief This function returns a constant reference to member info - * @return Constant reference to member info - */ - eProsima_user_DllExport const std::string& info() const; - - /*! - * @brief This function returns a reference to member info - * @return Reference to member info - */ - eProsima_user_DllExport std::string& info(); - - - /*! - * @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 DdsRecorderStatus& 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 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_previous; - std::string m_current; - std::string m_info; - -}; - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/controller/controller_tool/package.xml b/controller/controller_tool/package.xml index 69fb2bb3d..6be599f0d 100644 --- a/controller/controller_tool/package.xml +++ b/controller/controller_tool/package.xml @@ -12,7 +12,7 @@ cmake_utils cpp_utils fastcdr - fastrtps + fastdds fastdds_python diff --git a/controller/controller_tool/project_settings.cmake b/controller/controller_tool/project_settings.cmake index e66b933ee..37072833e 100644 --- a/controller/controller_tool/project_settings.cmake +++ b/controller/controller_tool/project_settings.cmake @@ -25,7 +25,7 @@ set(MODULE_SUMMARY ) set(MODULE_FIND_PACKAGES - fastrtps + fastdds fastcdr fastdds_python ) diff --git a/ddsrecorder/CMakeLists.txt b/ddsrecorder/CMakeLists.txt index 2945d4e23..9acf3588a 100644 --- a/ddsrecorder/CMakeLists.txt +++ b/ddsrecorder/CMakeLists.txt @@ -60,20 +60,13 @@ project( # - Configure log depending on LOG_INFO flag and CMake type configure_project_cpp() -# Determine Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(DDS_TYPES_VERSION "v1") -else() - set(DDS_TYPES_VERSION "v2") -endif() - file( GLOB_RECURSE SOURCES_FILES "${PROJECT_SOURCE_DIR}/src/cpp/tool/*.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/user_interface/*.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/main.cpp" "${PROJECT_SOURCE_DIR}/src/cpp/command_receiver/Command*.cpp" - "${PROJECT_SOURCE_DIR}/src/cpp/*/*/${DDS_TYPES_VERSION}/*/*.cxx" + "${PROJECT_SOURCE_DIR}/src/cpp/*/*/*/*.cxx" ) compile_tool( diff --git a/ddsrecorder/project_settings.cmake b/ddsrecorder/project_settings.cmake index fb082a454..01517ec50 100644 --- a/ddsrecorder/project_settings.cmake +++ b/ddsrecorder/project_settings.cmake @@ -25,7 +25,7 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants @@ -43,7 +43,7 @@ endif() set(MODULE_DEPENDENCIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp index 489a5bf41..277fd4dc9 100644 --- a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp +++ b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp @@ -23,9 +23,8 @@ #include #include #include -#include #include -#include +#include #include @@ -60,8 +59,8 @@ CommandReceiver::CommandReceiver( , event_handler_(event_handler) , participant_configuration_(participant_configuration) { - registerDdsRecorderCommandTypes(); - registerDdsRecorderStatusTypes(); + command_type_->register_type_object_representation(); + status_type_->register_type_object_representation(); } bool CommandReceiver::init() @@ -153,18 +152,6 @@ bool CommandReceiver::init() participant_configuration_->app_metadata, "true"); - // Enable type information sending - pqos.wire_protocol().builtin.typelookup_config.use_server = true; - - // Set Intraprocess OFF - // WORKAROUND: This is a temporal solution to fix a potential deadlock in the communication - // between a recorder and its corresponding command receiver (both being in the same - // DDS domain). More precisely, the deadlock affects the current implementation of - // TypeLookupService module with intraprocess communication. - auto settings = fastrtps::xmlparser::XMLProfileManager::library_settings(); - settings.intraprocess_delivery = fastrtps::INTRAPROCESS_OFF; - fastrtps::xmlparser::XMLProfileManager::library_settings(settings); - participant_ = DomainParticipantFactory::get_instance()->create_participant(domain_, pqos); if (participant_ == nullptr) @@ -357,7 +344,7 @@ void CommandReceiver::on_data_available( SampleInfo info; DdsRecorderCommand controller_command; while ((reader->take_next_sample(&controller_command, - &info)) == (ReturnCode_t::RETCODE_OK && info.instance_state == ALIVE_INSTANCE_STATE)) + &info)) == (RETCODE_OK && info.instance_state == ALIVE_INSTANCE_STATE)) { logInfo( DDSRECORDER_COMMAND_RECEIVER, diff --git a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp index a8f37d5d0..599b9b03e 100644 --- a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp +++ b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp @@ -21,11 +21,7 @@ #include #include - -#include -#include - -#include +#include #include #include @@ -35,17 +31,15 @@ #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include "types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h" - #include "types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.h" - #include "types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h" - #include "types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.h" -#else - #include "types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h" - #include "types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.h" - #include "types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h" - #include "types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.h" -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 +#include +#include + +#include + +#include "types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h" +#include "types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp" +#include "types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h" +#include "types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp" namespace eprosima { namespace ddsrecorder { @@ -71,8 +65,8 @@ class CommandReceiver : public eprosima::fastdds::dds::DataReaderListener uint32_t domain, const std::string& command_topic_name, const std::string& status_topic_name, - std::shared_ptr event_handler, - std::shared_ptr participant_configuration); + std::shared_ptr event_handler, + std::shared_ptr participant_configuration); virtual ~CommandReceiver(); @@ -86,11 +80,11 @@ class CommandReceiver : public eprosima::fastdds::dds::DataReaderListener std::string info = ""); void on_data_available( - eprosima::fastdds::dds::DataReader* reader) override; + fastdds::dds::DataReader* reader) override; void on_subscription_matched( - eprosima::fastdds::dds::DataReader* reader, - const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) override; + fastdds::dds::DataReader* reader, + const fastdds::dds::SubscriptionMatchedStatus& info) override; private: @@ -102,25 +96,25 @@ class CommandReceiver : public eprosima::fastdds::dds::DataReaderListener // DDS related attributes uint32_t domain_; - eprosima::fastdds::dds::DomainParticipant* participant_; + fastdds::dds::DomainParticipant* participant_; // Command attributes std::string command_topic_name_; - eprosima::fastdds::dds::Subscriber* command_subscriber_; - eprosima::fastdds::dds::Topic* command_topic_; - eprosima::fastdds::dds::DataReader* command_reader_; - eprosima::fastdds::dds::TypeSupport command_type_; + fastdds::dds::Subscriber* command_subscriber_; + fastdds::dds::Topic* command_topic_; + fastdds::dds::DataReader* command_reader_; + fastdds::dds::TypeSupport command_type_; // Status attributes std::string status_topic_name_; - eprosima::fastdds::dds::Publisher* status_publisher_; - eprosima::fastdds::dds::Topic* status_topic_; - eprosima::fastdds::dds::DataWriter* status_writer_; - eprosima::fastdds::dds::TypeSupport status_type_; + fastdds::dds::Publisher* status_publisher_; + fastdds::dds::Topic* status_topic_; + fastdds::dds::DataWriter* status_writer_; + fastdds::dds::TypeSupport status_type_; - std::shared_ptr event_handler_; + std::shared_ptr event_handler_; - std::shared_ptr participant_configuration_; + std::shared_ptr participant_configuration_; }; } /* namespace receiver */ diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.hpp similarity index 69% rename from ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.h rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.hpp index 8d2a241c4..ca1be197a 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file DdsRecorderCommand.h + * @file DdsRecorderCommand.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "DdsRecorderCommandv1.h" +#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_HPP_ -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ - -#include -#include #include -#include #include -#include - +#include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +51,6 @@ #define DDSRECORDERCOMMAND_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure DdsRecorderCommand defined by the user in the IDL file. * @ingroup DdsRecorderCommand @@ -86,80 +62,127 @@ class DdsRecorderCommand /*! * @brief Default constructor. */ - eProsima_user_DllExport DdsRecorderCommand(); + eProsima_user_DllExport DdsRecorderCommand() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~DdsRecorderCommand(); + eProsima_user_DllExport ~DdsRecorderCommand() + { + } /*! * @brief Copy constructor. * @param x Reference to the object DdsRecorderCommand that will be copied. */ eProsima_user_DllExport DdsRecorderCommand( - const DdsRecorderCommand& x); + const DdsRecorderCommand& x) + { + m_command = x.m_command; + + m_args = x.m_args; + + } /*! * @brief Move constructor. * @param x Reference to the object DdsRecorderCommand that will be copied. */ eProsima_user_DllExport DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept; + DdsRecorderCommand&& x) noexcept + { + m_command = std::move(x.m_command); + m_args = std::move(x.m_args); + } /*! * @brief Copy assignment. * @param x Reference to the object DdsRecorderCommand that will be copied. */ eProsima_user_DllExport DdsRecorderCommand& operator =( - const DdsRecorderCommand& x); + const DdsRecorderCommand& x) + { + + m_command = x.m_command; + + m_args = x.m_args; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object DdsRecorderCommand that will be copied. */ eProsima_user_DllExport DdsRecorderCommand& operator =( - DdsRecorderCommand&& x) noexcept; + DdsRecorderCommand&& x) noexcept + { + + m_command = std::move(x.m_command); + m_args = std::move(x.m_args); + return *this; + } /*! * @brief Comparison operator. * @param x DdsRecorderCommand object to compare. */ eProsima_user_DllExport bool operator ==( - const DdsRecorderCommand& x) const; + const DdsRecorderCommand& x) const + { + return (m_command == x.m_command && + m_args == x.m_args); + } /*! * @brief Comparison operator. * @param x DdsRecorderCommand object to compare. */ eProsima_user_DllExport bool operator !=( - const DdsRecorderCommand& x) const; + const DdsRecorderCommand& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member command * @param _command New value to be copied in member command */ eProsima_user_DllExport void command( - const std::string& _command); + const std::string& _command) + { + m_command = _command; + } /*! * @brief This function moves the value in member command * @param _command New value to be moved in member command */ eProsima_user_DllExport void command( - std::string&& _command); + std::string&& _command) + { + m_command = std::move(_command); + } /*! * @brief This function returns a constant reference to member command * @return Constant reference to member command */ - eProsima_user_DllExport const std::string& command() const; + eProsima_user_DllExport const std::string& command() const + { + return m_command; + } /*! * @brief This function returns a reference to member command * @return Reference to member command */ - eProsima_user_DllExport std::string& command(); + eProsima_user_DllExport std::string& command() + { + return m_command; + } /*! @@ -167,26 +190,40 @@ class DdsRecorderCommand * @param _args New value to be copied in member args */ eProsima_user_DllExport void args( - const std::string& _args); + const std::string& _args) + { + m_args = _args; + } /*! * @brief This function moves the value in member args * @param _args New value to be moved in member args */ eProsima_user_DllExport void args( - std::string&& _args); + std::string&& _args) + { + m_args = std::move(_args); + } /*! * @brief This function returns a constant reference to member args * @return Constant reference to member args */ - eProsima_user_DllExport const std::string& args() const; + eProsima_user_DllExport const std::string& args() const + { + return m_args; + } /*! * @brief This function returns a reference to member args * @return Reference to member args */ - eProsima_user_DllExport std::string& args(); + eProsima_user_DllExport std::string& args() + { + return m_args; + } + + private: @@ -195,8 +232,6 @@ class DdsRecorderCommand }; -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ - +#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.idl b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.idl similarity index 100% rename from controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.idl rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.idl diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp similarity index 97% rename from controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp index cafda9b13..77005bd95 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp @@ -22,7 +22,7 @@ #ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_HPP_ #define _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_HPP_ -#include "DdsRecorderCommand.h" +#include "DdsRecorderCommand.hpp" constexpr uint32_t DdsRecorderCommand_max_cdr_typesize {524UL}; constexpr uint32_t DdsRecorderCommand_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsRecorderCommand& data); diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp similarity index 84% rename from controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp index d60a0359e..f0f7c5c15 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,11 +50,11 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.command(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.command(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.args(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.args(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -78,7 +76,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.command() << eprosima::fastcdr::MemberId(1) << data.args() - ; +; scdr.end_serialize_type(current_state); } @@ -95,13 +93,13 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.command(); - break; + case 0: + dcdr >> data.command(); + break; - case 1: - dcdr >> data.args(); - break; + case 1: + dcdr >> data.args(); + break; default: ret_value = false; @@ -119,6 +117,8 @@ void serialize_key( static_cast(data); } + + } // namespace fastcdr } // namespace eprosima diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx similarity index 90% rename from controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx index fa2c15f39..d0ac3c025 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -13,33 +13,33 @@ // limitations under the License. /*! - * @file DdsRecorderCommandPubSubTypes.cxx + * @file DdsRecorderCommandPubSubTypes.cpp * This header file contains the implementation of the serialization functions. * * This file was generated by the tool fastddsgen. */ +#include "DdsRecorderCommandPubSubTypes.h" +#include #include -#include "DdsRecorderCommandPubSubTypes.h" #include "DdsRecorderCommandCdrAux.hpp" +#include "DdsRecorderCommandTypeObjectSupport.hpp" using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - DdsRecorderCommandPubSubType::DdsRecorderCommandPubSubType() { setName("DdsRecorderCommand"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - DdsRecorderCommand::getMaxCdrSerializedSize(); + static_cast(DdsRecorderCommand::getMaxCdrSerializedSize()); #else - DdsRecorderCommand_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + DdsRecorderCommand_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -139,6 +139,7 @@ std::function DdsRecorderCommandPubSubType::getSerializedSizeProvide return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -149,8 +150,8 @@ std::function DdsRecorderCommandPubSubType::getSerializedSizeProvide eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -188,8 +189,7 @@ bool DdsRecorderCommandPubSubType::getKey( DdsRecorderCommand_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -218,3 +218,12 @@ bool DdsRecorderCommandPubSubType::getKey( } return true; } + +void DdsRecorderCommandPubSubType::register_type_object_representation() +{ + register_DdsRecorderCommand_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "DdsRecorderCommandCdrAux.ipp" diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h similarity index 92% rename from controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h index f0a4d49e3..df428fcb8 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h @@ -27,9 +27,9 @@ #include #include #include -#include +#include -#include "DdsRecorderCommand.h" +#include "DdsRecorderCommand.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type DdsRecorderCommand defined by the user in the IDL file. * @ingroup DdsRecorderCommand @@ -90,6 +88,9 @@ class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -105,7 +106,7 @@ class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataTyp } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.cxx new file mode 100644 index 000000000..0b9d8bd2d --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.cxx @@ -0,0 +1,146 @@ +// 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 DdsRecorderCommandTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "DdsRecorderCommandTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "DdsRecorderCommand.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_DdsRecorderCommand_type_identifier( + TypeIdentifierPair& type_ids_DdsRecorderCommand) +{ + + ReturnCode_t return_code_DdsRecorderCommand {eprosima::fastdds::dds::RETCODE_OK}; + return_code_DdsRecorderCommand = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsRecorderCommand", type_ids_DdsRecorderCommand); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsRecorderCommand) + { + StructTypeFlag struct_flags_DdsRecorderCommand = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_DdsRecorderCommand = "DdsRecorderCommand"; + eprosima::fastcdr::optional type_ann_builtin_DdsRecorderCommand; + eprosima::fastcdr::optional ann_custom_DdsRecorderCommand; + CompleteTypeDetail detail_DdsRecorderCommand = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsRecorderCommand, ann_custom_DdsRecorderCommand, type_name_DdsRecorderCommand.to_string()); + CompleteStructHeader header_DdsRecorderCommand; + header_DdsRecorderCommand = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DdsRecorderCommand); + CompleteStructMemberSeq member_seq_DdsRecorderCommand; + { + TypeIdentifierPair type_ids_command; + ReturnCode_t return_code_command {eprosima::fastdds::dds::RETCODE_OK}; + return_code_command = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_command); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_command) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_command)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_command = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_command = 0x00000000; + bool common_command_ec {false}; + CommonStructMember common_command {TypeObjectUtils::build_common_struct_member(member_id_command, member_flags_command, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_command, common_command_ec))}; + if (!common_command_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure command member TypeIdentifier inconsistent."); + return; + } + MemberName name_command = "command"; + eprosima::fastcdr::optional member_ann_builtin_command; + ann_custom_DdsRecorderCommand.reset(); + CompleteMemberDetail detail_command = TypeObjectUtils::build_complete_member_detail(name_command, member_ann_builtin_command, ann_custom_DdsRecorderCommand); + CompleteStructMember member_command = TypeObjectUtils::build_complete_struct_member(common_command, detail_command); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderCommand, member_command); + } + { + TypeIdentifierPair type_ids_args; + ReturnCode_t return_code_args {eprosima::fastdds::dds::RETCODE_OK}; + return_code_args = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_args); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_args) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_args)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_args = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_args = 0x00000001; + bool common_args_ec {false}; + CommonStructMember common_args {TypeObjectUtils::build_common_struct_member(member_id_args, member_flags_args, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_args, common_args_ec))}; + if (!common_args_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure args member TypeIdentifier inconsistent."); + return; + } + MemberName name_args = "args"; + eprosima::fastcdr::optional member_ann_builtin_args; + ann_custom_DdsRecorderCommand.reset(); + CompleteMemberDetail detail_args = TypeObjectUtils::build_complete_member_detail(name_args, member_ann_builtin_args, ann_custom_DdsRecorderCommand); + CompleteStructMember member_args = TypeObjectUtils::build_complete_struct_member(common_args, detail_args); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderCommand, member_args); + } + CompleteStructType struct_type_DdsRecorderCommand = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsRecorderCommand, header_DdsRecorderCommand, member_seq_DdsRecorderCommand); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsRecorderCommand, type_name_DdsRecorderCommand.to_string(), type_ids_DdsRecorderCommand)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "DdsRecorderCommand already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp new file mode 100644 index 000000000..76fc6f9b1 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 DdsRecorderCommandTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register DdsRecorderCommand related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_DdsRecorderCommand_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.hpp similarity index 66% rename from controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.h rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.hpp index e5cc4053e..c4cfbe7a1 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file DdsRecorderStatus.h + * @file DdsRecorderStatus.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "DdsRecorderStatusv1.h" +#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_HPP_ -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ - -#include -#include #include -#include #include -#include - +#include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +51,6 @@ #define DDSRECORDERSTATUS_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure DdsRecorderStatus defined by the user in the IDL file. * @ingroup DdsRecorderStatus @@ -86,80 +62,134 @@ class DdsRecorderStatus /*! * @brief Default constructor. */ - eProsima_user_DllExport DdsRecorderStatus(); + eProsima_user_DllExport DdsRecorderStatus() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~DdsRecorderStatus(); + eProsima_user_DllExport ~DdsRecorderStatus() + { + } /*! * @brief Copy constructor. * @param x Reference to the object DdsRecorderStatus that will be copied. */ eProsima_user_DllExport DdsRecorderStatus( - const DdsRecorderStatus& x); + const DdsRecorderStatus& x) + { + m_previous = x.m_previous; + + m_current = x.m_current; + + m_info = x.m_info; + + } /*! * @brief Move constructor. * @param x Reference to the object DdsRecorderStatus that will be copied. */ eProsima_user_DllExport DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept; + DdsRecorderStatus&& x) noexcept + { + m_previous = std::move(x.m_previous); + m_current = std::move(x.m_current); + m_info = std::move(x.m_info); + } /*! * @brief Copy assignment. * @param x Reference to the object DdsRecorderStatus that will be copied. */ eProsima_user_DllExport DdsRecorderStatus& operator =( - const DdsRecorderStatus& x); + const DdsRecorderStatus& x) + { + + m_previous = x.m_previous; + + m_current = x.m_current; + + m_info = x.m_info; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object DdsRecorderStatus that will be copied. */ eProsima_user_DllExport DdsRecorderStatus& operator =( - DdsRecorderStatus&& x) noexcept; + DdsRecorderStatus&& x) noexcept + { + + m_previous = std::move(x.m_previous); + m_current = std::move(x.m_current); + m_info = std::move(x.m_info); + return *this; + } /*! * @brief Comparison operator. * @param x DdsRecorderStatus object to compare. */ eProsima_user_DllExport bool operator ==( - const DdsRecorderStatus& x) const; + const DdsRecorderStatus& x) const + { + return (m_previous == x.m_previous && + m_current == x.m_current && + m_info == x.m_info); + } /*! * @brief Comparison operator. * @param x DdsRecorderStatus object to compare. */ eProsima_user_DllExport bool operator !=( - const DdsRecorderStatus& x) const; + const DdsRecorderStatus& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member previous * @param _previous New value to be copied in member previous */ eProsima_user_DllExport void previous( - const std::string& _previous); + const std::string& _previous) + { + m_previous = _previous; + } /*! * @brief This function moves the value in member previous * @param _previous New value to be moved in member previous */ eProsima_user_DllExport void previous( - std::string&& _previous); + std::string&& _previous) + { + m_previous = std::move(_previous); + } /*! * @brief This function returns a constant reference to member previous * @return Constant reference to member previous */ - eProsima_user_DllExport const std::string& previous() const; + eProsima_user_DllExport const std::string& previous() const + { + return m_previous; + } /*! * @brief This function returns a reference to member previous * @return Reference to member previous */ - eProsima_user_DllExport std::string& previous(); + eProsima_user_DllExport std::string& previous() + { + return m_previous; + } /*! @@ -167,26 +197,38 @@ class DdsRecorderStatus * @param _current New value to be copied in member current */ eProsima_user_DllExport void current( - const std::string& _current); + const std::string& _current) + { + m_current = _current; + } /*! * @brief This function moves the value in member current * @param _current New value to be moved in member current */ eProsima_user_DllExport void current( - std::string&& _current); + std::string&& _current) + { + m_current = std::move(_current); + } /*! * @brief This function returns a constant reference to member current * @return Constant reference to member current */ - eProsima_user_DllExport const std::string& current() const; + eProsima_user_DllExport const std::string& current() const + { + return m_current; + } /*! * @brief This function returns a reference to member current * @return Reference to member current */ - eProsima_user_DllExport std::string& current(); + eProsima_user_DllExport std::string& current() + { + return m_current; + } /*! @@ -194,26 +236,40 @@ class DdsRecorderStatus * @param _info New value to be copied in member info */ eProsima_user_DllExport void info( - const std::string& _info); + const std::string& _info) + { + m_info = _info; + } /*! * @brief This function moves the value in member info * @param _info New value to be moved in member info */ eProsima_user_DllExport void info( - std::string&& _info); + std::string&& _info) + { + m_info = std::move(_info); + } /*! * @brief This function returns a constant reference to member info * @return Constant reference to member info */ - eProsima_user_DllExport const std::string& info() const; + eProsima_user_DllExport const std::string& info() const + { + return m_info; + } /*! * @brief This function returns a reference to member info * @return Reference to member info */ - eProsima_user_DllExport std::string& info(); + eProsima_user_DllExport std::string& info() + { + return m_info; + } + + private: @@ -223,8 +279,6 @@ class DdsRecorderStatus }; -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ - +#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.idl b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.idl similarity index 100% rename from controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.idl rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.idl diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp similarity index 97% rename from ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp index cfbb11098..7ad935b53 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp @@ -22,7 +22,7 @@ #ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_HPP_ #define _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_HPP_ -#include "DdsRecorderStatus.h" +#include "DdsRecorderStatus.hpp" constexpr uint32_t DdsRecorderStatus_max_cdr_typesize {784UL}; constexpr uint32_t DdsRecorderStatus_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsRecorderStatus& data); diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp similarity index 79% rename from controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp index d1bb71e66..983ef7b9b 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,14 +50,14 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.previous(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.previous(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.current(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.current(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.info(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.info(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -82,7 +80,7 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(0) << data.previous() << eprosima::fastcdr::MemberId(1) << data.current() << eprosima::fastcdr::MemberId(2) << data.info() - ; +; scdr.end_serialize_type(current_state); } @@ -99,17 +97,17 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.previous(); - break; + case 0: + dcdr >> data.previous(); + break; - case 1: - dcdr >> data.current(); - break; + case 1: + dcdr >> data.current(); + break; - case 2: - dcdr >> data.info(); - break; + case 2: + dcdr >> data.info(); + break; default: ret_value = false; @@ -127,6 +125,8 @@ void serialize_key( static_cast(data); } + + } // namespace fastcdr } // namespace eprosima diff --git a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx similarity index 90% rename from controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx index 5d7506b0b..9a4dbdfe6 100644 --- a/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -13,33 +13,33 @@ // limitations under the License. /*! - * @file DdsRecorderStatusPubSubTypes.cxx + * @file DdsRecorderStatusPubSubTypes.cpp * This header file contains the implementation of the serialization functions. * * This file was generated by the tool fastddsgen. */ +#include "DdsRecorderStatusPubSubTypes.h" +#include #include -#include "DdsRecorderStatusPubSubTypes.h" #include "DdsRecorderStatusCdrAux.hpp" +#include "DdsRecorderStatusTypeObjectSupport.hpp" using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - DdsRecorderStatusPubSubType::DdsRecorderStatusPubSubType() { setName("DdsRecorderStatus"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - DdsRecorderStatus::getMaxCdrSerializedSize(); + static_cast(DdsRecorderStatus::getMaxCdrSerializedSize()); #else - DdsRecorderStatus_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + DdsRecorderStatus_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -139,6 +139,7 @@ std::function DdsRecorderStatusPubSubType::getSerializedSizeProvider return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -149,8 +150,8 @@ std::function DdsRecorderStatusPubSubType::getSerializedSizeProvider eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -188,8 +189,7 @@ bool DdsRecorderStatusPubSubType::getKey( DdsRecorderStatus_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -218,3 +218,12 @@ bool DdsRecorderStatusPubSubType::getKey( } return true; } + +void DdsRecorderStatusPubSubType::register_type_object_representation() +{ + register_DdsRecorderStatus_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "DdsRecorderStatusCdrAux.ipp" diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h similarity index 92% rename from ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h index f3e3861cb..af1c8bd29 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h @@ -27,9 +27,9 @@ #include #include #include -#include +#include -#include "DdsRecorderStatus.h" +#include "DdsRecorderStatus.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type DdsRecorderStatus defined by the user in the IDL file. * @ingroup DdsRecorderStatus @@ -90,6 +88,9 @@ class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -105,7 +106,7 @@ class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.cxx new file mode 100644 index 000000000..ad8801123 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.cxx @@ -0,0 +1,184 @@ +// 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 DdsRecorderStatusTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "DdsRecorderStatusTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "DdsRecorderStatus.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_DdsRecorderStatus_type_identifier( + TypeIdentifierPair& type_ids_DdsRecorderStatus) +{ + + ReturnCode_t return_code_DdsRecorderStatus {eprosima::fastdds::dds::RETCODE_OK}; + return_code_DdsRecorderStatus = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsRecorderStatus", type_ids_DdsRecorderStatus); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsRecorderStatus) + { + StructTypeFlag struct_flags_DdsRecorderStatus = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_DdsRecorderStatus = "DdsRecorderStatus"; + eprosima::fastcdr::optional type_ann_builtin_DdsRecorderStatus; + eprosima::fastcdr::optional ann_custom_DdsRecorderStatus; + CompleteTypeDetail detail_DdsRecorderStatus = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsRecorderStatus, ann_custom_DdsRecorderStatus, type_name_DdsRecorderStatus.to_string()); + CompleteStructHeader header_DdsRecorderStatus; + header_DdsRecorderStatus = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DdsRecorderStatus); + CompleteStructMemberSeq member_seq_DdsRecorderStatus; + { + TypeIdentifierPair type_ids_previous; + ReturnCode_t return_code_previous {eprosima::fastdds::dds::RETCODE_OK}; + return_code_previous = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_previous); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_previous) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_previous)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_previous = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_previous = 0x00000000; + bool common_previous_ec {false}; + CommonStructMember common_previous {TypeObjectUtils::build_common_struct_member(member_id_previous, member_flags_previous, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_previous, common_previous_ec))}; + if (!common_previous_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure previous member TypeIdentifier inconsistent."); + return; + } + MemberName name_previous = "previous"; + eprosima::fastcdr::optional member_ann_builtin_previous; + ann_custom_DdsRecorderStatus.reset(); + CompleteMemberDetail detail_previous = TypeObjectUtils::build_complete_member_detail(name_previous, member_ann_builtin_previous, ann_custom_DdsRecorderStatus); + CompleteStructMember member_previous = TypeObjectUtils::build_complete_struct_member(common_previous, detail_previous); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderStatus, member_previous); + } + { + TypeIdentifierPair type_ids_current; + ReturnCode_t return_code_current {eprosima::fastdds::dds::RETCODE_OK}; + return_code_current = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_current); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_current) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_current)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_current = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_current = 0x00000001; + bool common_current_ec {false}; + CommonStructMember common_current {TypeObjectUtils::build_common_struct_member(member_id_current, member_flags_current, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_current, common_current_ec))}; + if (!common_current_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure current member TypeIdentifier inconsistent."); + return; + } + MemberName name_current = "current"; + eprosima::fastcdr::optional member_ann_builtin_current; + ann_custom_DdsRecorderStatus.reset(); + CompleteMemberDetail detail_current = TypeObjectUtils::build_complete_member_detail(name_current, member_ann_builtin_current, ann_custom_DdsRecorderStatus); + CompleteStructMember member_current = TypeObjectUtils::build_complete_struct_member(common_current, detail_current); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderStatus, member_current); + } + { + TypeIdentifierPair type_ids_info; + ReturnCode_t return_code_info {eprosima::fastdds::dds::RETCODE_OK}; + return_code_info = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_info); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_info) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_info)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_info = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_info = 0x00000002; + bool common_info_ec {false}; + CommonStructMember common_info {TypeObjectUtils::build_common_struct_member(member_id_info, member_flags_info, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_info, common_info_ec))}; + if (!common_info_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure info member TypeIdentifier inconsistent."); + return; + } + MemberName name_info = "info"; + eprosima::fastcdr::optional member_ann_builtin_info; + ann_custom_DdsRecorderStatus.reset(); + CompleteMemberDetail detail_info = TypeObjectUtils::build_complete_member_detail(name_info, member_ann_builtin_info, ann_custom_DdsRecorderStatus); + CompleteStructMember member_info = TypeObjectUtils::build_complete_struct_member(common_info, detail_info); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderStatus, member_info); + } + CompleteStructType struct_type_DdsRecorderStatus = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsRecorderStatus, header_DdsRecorderStatus, member_seq_DdsRecorderStatus); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsRecorderStatus, type_name_DdsRecorderStatus.to_string(), type_ids_DdsRecorderStatus)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "DdsRecorderStatus already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp new file mode 100644 index 000000000..1da3c0bd7 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 DdsRecorderStatusTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register DdsRecorderStatus related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_DdsRecorderStatus_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.cxx b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.cxx deleted file mode 100644 index 7b0cc0ecf..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.cxx +++ /dev/null @@ -1,234 +0,0 @@ -// 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 DdsRecorderCommand.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 "DdsRecorderCommand.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -#define DdsRecorderCommand_max_cdr_typesize 520ULL; -#define DdsRecorderCommand_max_key_cdr_typesize 0ULL; - -DdsRecorderCommand::DdsRecorderCommand() -{ - // string m_command - m_command =""; - // string m_args - m_args =""; - -} - -DdsRecorderCommand::~DdsRecorderCommand() -{ - - -} - -DdsRecorderCommand::DdsRecorderCommand( - const DdsRecorderCommand& x) -{ - m_command = x.m_command; - m_args = x.m_args; -} - -DdsRecorderCommand::DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept -{ - m_command = std::move(x.m_command); - m_args = std::move(x.m_args); -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - const DdsRecorderCommand& x) -{ - - m_command = x.m_command; - m_args = x.m_args; - - return *this; -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - DdsRecorderCommand&& x) noexcept -{ - - m_command = std::move(x.m_command); - m_args = std::move(x.m_args); - - return *this; -} - -bool DdsRecorderCommand::operator ==( - const DdsRecorderCommand& x) const -{ - - return (m_command == x.m_command && m_args == x.m_args); -} - -bool DdsRecorderCommand::operator !=( - const DdsRecorderCommand& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderCommand::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderCommand_max_cdr_typesize; -} - -size_t DdsRecorderCommand::getCdrSerializedSize( - const DdsRecorderCommand& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.command().size() + 1; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.args().size() + 1; - - - return current_alignment - initial_alignment; -} - -void DdsRecorderCommand::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_command.c_str(); - scdr << m_args.c_str(); - -} - -void DdsRecorderCommand::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_command; - dcdr >> m_args; -} - -/*! - * @brief This function copies the value in member command - * @param _command New value to be copied in member command - */ -void DdsRecorderCommand::command( - const std::string& _command) -{ - m_command = _command; -} - -/*! - * @brief This function moves the value in member command - * @param _command New value to be moved in member command - */ -void DdsRecorderCommand::command( - std::string&& _command) -{ - m_command = std::move(_command); -} - -/*! - * @brief This function returns a constant reference to member command - * @return Constant reference to member command - */ -const std::string& DdsRecorderCommand::command() const -{ - return m_command; -} - -/*! - * @brief This function returns a reference to member command - * @return Reference to member command - */ -std::string& DdsRecorderCommand::command() -{ - return m_command; -} -/*! - * @brief This function copies the value in member args - * @param _args New value to be copied in member args - */ -void DdsRecorderCommand::args( - const std::string& _args) -{ - m_args = _args; -} - -/*! - * @brief This function moves the value in member args - * @param _args New value to be moved in member args - */ -void DdsRecorderCommand::args( - std::string&& _args) -{ - m_args = std::move(_args); -} - -/*! - * @brief This function returns a constant reference to member args - * @return Constant reference to member args - */ -const std::string& DdsRecorderCommand::args() const -{ - return m_args; -} - -/*! - * @brief This function returns a reference to member args - * @return Reference to member args - */ -std::string& DdsRecorderCommand::args() -{ - return m_args; -} - - -size_t DdsRecorderCommand::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderCommand_max_key_cdr_typesize; -} - -bool DdsRecorderCommand::isKeyDefined() -{ - return false; -} - -void DdsRecorderCommand::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.h b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.h deleted file mode 100644 index 51dcd1769..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.h +++ /dev/null @@ -1,241 +0,0 @@ -// 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 DdsRecorderCommand.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_DDSRECORDERCOMMAND_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_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(DdsRecorderCommand_SOURCE) -#define DdsRecorderCommand_DllAPI __declspec( dllexport ) -#else -#define DdsRecorderCommand_DllAPI __declspec( dllimport ) -#endif // DdsRecorderCommand_SOURCE -#else -#define DdsRecorderCommand_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DdsRecorderCommand_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure DdsRecorderCommand defined by the user in the IDL file. - * @ingroup DDSRECORDERCOMMAND - */ -class DdsRecorderCommand -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderCommand(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderCommand(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand( - const DdsRecorderCommand& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand& operator =( - const DdsRecorderCommand& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand& operator =( - DdsRecorderCommand&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderCommand object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderCommand& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderCommand object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderCommand& x) const; - - /*! - * @brief This function copies the value in member command - * @param _command New value to be copied in member command - */ - eProsima_user_DllExport void command( - const std::string& _command); - - /*! - * @brief This function moves the value in member command - * @param _command New value to be moved in member command - */ - eProsima_user_DllExport void command( - std::string&& _command); - - /*! - * @brief This function returns a constant reference to member command - * @return Constant reference to member command - */ - eProsima_user_DllExport const std::string& command() const; - - /*! - * @brief This function returns a reference to member command - * @return Reference to member command - */ - eProsima_user_DllExport std::string& command(); - /*! - * @brief This function copies the value in member args - * @param _args New value to be copied in member args - */ - eProsima_user_DllExport void args( - const std::string& _args); - - /*! - * @brief This function moves the value in member args - * @param _args New value to be moved in member args - */ - eProsima_user_DllExport void args( - std::string&& _args); - - /*! - * @brief This function returns a constant reference to member args - * @return Constant reference to member args - */ - eProsima_user_DllExport const std::string& args() const; - - /*! - * @brief This function returns a reference to member args - * @return Reference to member args - */ - eProsima_user_DllExport std::string& args(); - - /*! - * @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 DdsRecorderCommand& 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_command; - std::string m_args; - -}; - -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.idl b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.idl deleted file mode 100644 index 001fd4b2e..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.idl +++ /dev/null @@ -1,5 +0,0 @@ -struct DdsRecorderCommand -{ - string command; - string args; -}; diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx deleted file mode 100644 index 2f92b59be..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ /dev/null @@ -1,169 +0,0 @@ -// 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 DdsRecorderCommandPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "DdsRecorderCommandPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -DdsRecorderCommandPubSubType::DdsRecorderCommandPubSubType() -{ - setName("DdsRecorderCommand"); - auto type_size = DdsRecorderCommand::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = DdsRecorderCommand::isKeyDefined(); - size_t keyLength = DdsRecorderCommand::getKeyMaxCdrSerializedSize() > 16 ? - DdsRecorderCommand::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DdsRecorderCommandPubSubType::~DdsRecorderCommandPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DdsRecorderCommandPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - DdsRecorderCommand* 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 DdsRecorderCommandPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - DdsRecorderCommand* 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 DdsRecorderCommandPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* DdsRecorderCommandPubSubType::createData() -{ - return reinterpret_cast(new DdsRecorderCommand()); -} - -void DdsRecorderCommandPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DdsRecorderCommandPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DdsRecorderCommand* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DdsRecorderCommand::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || DdsRecorderCommand::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/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h deleted file mode 100644 index b10231ffc..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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 DdsRecorderCommandPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ - -#include -#include - -#include "DdsRecorderCommand.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated DdsRecorderCommand 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 DdsRecorderCommand defined by the user in the IDL file. - * @ingroup DDSRECORDERCOMMAND - */ -class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DdsRecorderCommand type; - - eProsima_user_DllExport DdsRecorderCommandPubSubType(); - - eProsima_user_DllExport virtual ~DdsRecorderCommandPubSubType() 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_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx deleted file mode 100644 index 9bea321d5..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx +++ /dev/null @@ -1,255 +0,0 @@ -// 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 DdsRecorderCommandTypeObject.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 "DdsRecorderCommand.h" -#include "DdsRecorderCommandTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerDdsRecorderCommandTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("DdsRecorderCommand", GetDdsRecorderCommandIdentifier(true), - GetDdsRecorderCommandObject(true)); - factory->add_type_object("DdsRecorderCommand", GetDdsRecorderCommandIdentifier(false), - GetDdsRecorderCommandObject(false)); - - }); -} - -const TypeIdentifier* GetDdsRecorderCommandIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderCommand", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsRecorderCommandObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderCommand", complete); -} - -const TypeObject* GetDdsRecorderCommandObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsRecorderCommandObject(); - } - //else - return GetMinimalDdsRecorderCommandObject(); -} - -const TypeObject* GetMinimalDdsRecorderCommandObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", 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_command; - mst_command.common().member_id(memberId++); - mst_command.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_command.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_command.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_command.common().member_flags().IS_OPTIONAL(false); - mst_command.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_command.common().member_flags().IS_KEY(false); - mst_command.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_command.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - MD5 command_hash("command"); - for(int i = 0; i < 4; ++i) - { - mst_command.detail().name_hash()[i] = command_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_command); - - MinimalStructMember mst_args; - mst_args.common().member_id(memberId++); - mst_args.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_args.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_args.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_args.common().member_flags().IS_OPTIONAL(false); - mst_args.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_args.common().member_flags().IS_KEY(false); - mst_args.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_args.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - MD5 args_hash("args"); - for(int i = 0; i < 4; ++i) - { - mst_args.detail().name_hash()[i] = args_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_args); - - - // 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("DdsRecorderCommand", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", false); -} - -const TypeObject* GetCompleteDdsRecorderCommandObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", 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_command; - cst_command.common().member_id(memberId++); - cst_command.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_command.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_command.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_command.common().member_flags().IS_OPTIONAL(false); - cst_command.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_command.common().member_flags().IS_KEY(false); - cst_command.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_command.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - cst_command.detail().name("command"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_command); - - CompleteStructMember cst_args; - cst_args.common().member_id(memberId++); - cst_args.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_args.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_args.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_args.common().member_flags().IS_OPTIONAL(false); - cst_args.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_args.common().member_flags().IS_KEY(false); - cst_args.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_args.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - cst_args.detail().name("args"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_args); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsRecorderCommand"); - // 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("DdsRecorderCommand", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", true); -} diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.h b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.h deleted file mode 100644 index 7158aaa66..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 DdsRecorderCommandTypeObject.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_DDSRECORDERCOMMAND_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_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(DdsRecorderCommand_SOURCE) -#define DdsRecorderCommand_DllAPI __declspec( dllexport ) -#else -#define DdsRecorderCommand_DllAPI __declspec( dllimport ) -#endif // DdsRecorderCommand_SOURCE -#else -#define DdsRecorderCommand_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define DdsRecorderCommand_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerDdsRecorderCommandTypes(); - -eProsima_user_DllExport const TypeIdentifier* GetDdsRecorderCommandIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsRecorderCommandObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsRecorderCommandObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsRecorderCommandObject(); - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_H_ diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.cxx b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.cxx deleted file mode 100644 index a8bf3c9f4..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.cxx +++ /dev/null @@ -1,285 +0,0 @@ -// 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 DdsRecorderStatus.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 "DdsRecorderStatus.h" -#include "DdsRecorderStatusTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -#define DdsRecorderStatus_max_cdr_typesize 780ULL; -#define DdsRecorderStatus_max_key_cdr_typesize 0ULL; - -DdsRecorderStatus::DdsRecorderStatus() -{ - // string m_previous - m_previous =""; - // string m_current - m_current =""; - // string m_info - m_info =""; - - // Just to register all known types - registerDdsRecorderStatusTypes(); -} - -DdsRecorderStatus::~DdsRecorderStatus() -{ - - - -} - -DdsRecorderStatus::DdsRecorderStatus( - const DdsRecorderStatus& x) -{ - m_previous = x.m_previous; - m_current = x.m_current; - m_info = x.m_info; -} - -DdsRecorderStatus::DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept -{ - m_previous = std::move(x.m_previous); - m_current = std::move(x.m_current); - m_info = std::move(x.m_info); -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - const DdsRecorderStatus& x) -{ - - m_previous = x.m_previous; - m_current = x.m_current; - m_info = x.m_info; - - return *this; -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - DdsRecorderStatus&& x) noexcept -{ - - m_previous = std::move(x.m_previous); - m_current = std::move(x.m_current); - m_info = std::move(x.m_info); - - return *this; -} - -bool DdsRecorderStatus::operator ==( - const DdsRecorderStatus& x) const -{ - - return (m_previous == x.m_previous && m_current == x.m_current && m_info == x.m_info); -} - -bool DdsRecorderStatus::operator !=( - const DdsRecorderStatus& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderStatus_max_cdr_typesize; -} - -size_t DdsRecorderStatus::getCdrSerializedSize( - const DdsRecorderStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.previous().size() + 1; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.current().size() + 1; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.info().size() + 1; - - - return current_alignment - initial_alignment; -} - -void DdsRecorderStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_previous.c_str(); - scdr << m_current.c_str(); - scdr << m_info.c_str(); - -} - -void DdsRecorderStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - - dcdr >> m_previous; - dcdr >> m_current; - dcdr >> m_info; -} - -/*! - * @brief This function copies the value in member previous - * @param _previous New value to be copied in member previous - */ -void DdsRecorderStatus::previous( - const std::string& _previous) -{ - m_previous = _previous; -} - -/*! - * @brief This function moves the value in member previous - * @param _previous New value to be moved in member previous - */ -void DdsRecorderStatus::previous( - std::string&& _previous) -{ - m_previous = std::move(_previous); -} - -/*! - * @brief This function returns a constant reference to member previous - * @return Constant reference to member previous - */ -const std::string& DdsRecorderStatus::previous() const -{ - return m_previous; -} - -/*! - * @brief This function returns a reference to member previous - * @return Reference to member previous - */ -std::string& DdsRecorderStatus::previous() -{ - return m_previous; -} -/*! - * @brief This function copies the value in member current - * @param _current New value to be copied in member current - */ -void DdsRecorderStatus::current( - const std::string& _current) -{ - m_current = _current; -} - -/*! - * @brief This function moves the value in member current - * @param _current New value to be moved in member current - */ -void DdsRecorderStatus::current( - std::string&& _current) -{ - m_current = std::move(_current); -} - -/*! - * @brief This function returns a constant reference to member current - * @return Constant reference to member current - */ -const std::string& DdsRecorderStatus::current() const -{ - return m_current; -} - -/*! - * @brief This function returns a reference to member current - * @return Reference to member current - */ -std::string& DdsRecorderStatus::current() -{ - return m_current; -} -/*! - * @brief This function copies the value in member info - * @param _info New value to be copied in member info - */ -void DdsRecorderStatus::info( - const std::string& _info) -{ - m_info = _info; -} - -/*! - * @brief This function moves the value in member info - * @param _info New value to be moved in member info - */ -void DdsRecorderStatus::info( - std::string&& _info) -{ - m_info = std::move(_info); -} - -/*! - * @brief This function returns a constant reference to member info - * @return Constant reference to member info - */ -const std::string& DdsRecorderStatus::info() const -{ - return m_info; -} - -/*! - * @brief This function returns a reference to member info - * @return Reference to member info - */ -std::string& DdsRecorderStatus::info() -{ - return m_info; -} - - -size_t DdsRecorderStatus::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderStatus_max_key_cdr_typesize; -} - -bool DdsRecorderStatus::isKeyDefined() -{ - return false; -} - -void DdsRecorderStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.h b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.h deleted file mode 100644 index ef7f75e20..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.h +++ /dev/null @@ -1,267 +0,0 @@ -// 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 DdsRecorderStatus.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_DDSRECORDERSTATUS_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_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(DdsRecorderStatus_SOURCE) -#define DdsRecorderStatus_DllAPI __declspec( dllexport ) -#else -#define DdsRecorderStatus_DllAPI __declspec( dllimport ) -#endif // DdsRecorderStatus_SOURCE -#else -#define DdsRecorderStatus_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DdsRecorderStatus_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure DdsRecorderStatus defined by the user in the IDL file. - * @ingroup DDSRECORDERSTATUS - */ -class DdsRecorderStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus( - const DdsRecorderStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus& operator =( - const DdsRecorderStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus& operator =( - DdsRecorderStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderStatus& x) const; - - /*! - * @brief This function copies the value in member previous - * @param _previous New value to be copied in member previous - */ - eProsima_user_DllExport void previous( - const std::string& _previous); - - /*! - * @brief This function moves the value in member previous - * @param _previous New value to be moved in member previous - */ - eProsima_user_DllExport void previous( - std::string&& _previous); - - /*! - * @brief This function returns a constant reference to member previous - * @return Constant reference to member previous - */ - eProsima_user_DllExport const std::string& previous() const; - - /*! - * @brief This function returns a reference to member previous - * @return Reference to member previous - */ - eProsima_user_DllExport std::string& previous(); - /*! - * @brief This function copies the value in member current - * @param _current New value to be copied in member current - */ - eProsima_user_DllExport void current( - const std::string& _current); - - /*! - * @brief This function moves the value in member current - * @param _current New value to be moved in member current - */ - eProsima_user_DllExport void current( - std::string&& _current); - - /*! - * @brief This function returns a constant reference to member current - * @return Constant reference to member current - */ - eProsima_user_DllExport const std::string& current() const; - - /*! - * @brief This function returns a reference to member current - * @return Reference to member current - */ - eProsima_user_DllExport std::string& current(); - /*! - * @brief This function copies the value in member info - * @param _info New value to be copied in member info - */ - eProsima_user_DllExport void info( - const std::string& _info); - - /*! - * @brief This function moves the value in member info - * @param _info New value to be moved in member info - */ - eProsima_user_DllExport void info( - std::string&& _info); - - /*! - * @brief This function returns a constant reference to member info - * @return Constant reference to member info - */ - eProsima_user_DllExport const std::string& info() const; - - /*! - * @brief This function returns a reference to member info - * @return Reference to member info - */ - eProsima_user_DllExport std::string& info(); - - /*! - * @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 DdsRecorderStatus& 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_previous; - std::string m_current; - std::string m_info; - -}; - -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.idl b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.idl deleted file mode 100644 index cee55f14f..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.idl +++ /dev/null @@ -1,6 +0,0 @@ -struct DdsRecorderStatus -{ - string previous; - string current; - string info; -}; diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx deleted file mode 100644 index b89abb8f5..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ /dev/null @@ -1,169 +0,0 @@ -// 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 DdsRecorderStatusPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "DdsRecorderStatusPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -DdsRecorderStatusPubSubType::DdsRecorderStatusPubSubType() -{ - setName("DdsRecorderStatus"); - auto type_size = DdsRecorderStatus::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = DdsRecorderStatus::isKeyDefined(); - size_t keyLength = DdsRecorderStatus::getKeyMaxCdrSerializedSize() > 16 ? - DdsRecorderStatus::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DdsRecorderStatusPubSubType::~DdsRecorderStatusPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DdsRecorderStatusPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - DdsRecorderStatus* 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 DdsRecorderStatusPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - DdsRecorderStatus* 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 DdsRecorderStatusPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* DdsRecorderStatusPubSubType::createData() -{ - return reinterpret_cast(new DdsRecorderStatus()); -} - -void DdsRecorderStatusPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DdsRecorderStatusPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DdsRecorderStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DdsRecorderStatus::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || DdsRecorderStatus::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/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h deleted file mode 100644 index a6a6d3ae3..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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 DdsRecorderStatusPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_PUBSUBTYPES_H_ - -#include -#include - -#include "DdsRecorderStatus.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated DdsRecorderStatus 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 DdsRecorderStatus defined by the user in the IDL file. - * @ingroup DDSRECORDERSTATUS - */ -class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DdsRecorderStatus type; - - eProsima_user_DllExport DdsRecorderStatusPubSubType(); - - eProsima_user_DllExport virtual ~DdsRecorderStatusPubSubType() 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_DDSRECORDERSTATUS_PUBSUBTYPES_H_ diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx deleted file mode 100644 index 65fd9310c..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx +++ /dev/null @@ -1,285 +0,0 @@ -// 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 DdsRecorderStatusTypeObject.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 "DdsRecorderStatus.h" -#include "DdsRecorderStatusTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerDdsRecorderStatusTypes() -{ - TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("DdsRecorderStatus", GetDdsRecorderStatusIdentifier(true), - GetDdsRecorderStatusObject(true)); - factory->add_type_object("DdsRecorderStatus", GetDdsRecorderStatusIdentifier(false), - GetDdsRecorderStatusObject(false)); - -} - -const TypeIdentifier* GetDdsRecorderStatusIdentifier(bool complete) -{ - const TypeIdentifier * c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderStatus", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsRecorderStatusObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderStatus", complete); -} - -const TypeObject* GetDdsRecorderStatusObject(bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderStatus", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsRecorderStatusObject(); - } - //else - return GetMinimalDdsRecorderStatusObject(); -} - -const TypeObject* GetMinimalDdsRecorderStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderStatus", 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_previous; - mst_previous.common().member_id(memberId++); - mst_previous.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_previous.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_previous.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_previous.common().member_flags().IS_OPTIONAL(false); - mst_previous.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_previous.common().member_flags().IS_KEY(false); - mst_previous.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_previous.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - MD5 previous_hash("previous"); - for(int i = 0; i < 4; ++i) - { - mst_previous.detail().name_hash()[i] = previous_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_previous); - - MinimalStructMember mst_current; - mst_current.common().member_id(memberId++); - mst_current.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_current.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_current.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_current.common().member_flags().IS_OPTIONAL(false); - mst_current.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_current.common().member_flags().IS_KEY(false); - mst_current.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_current.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - MD5 current_hash("current"); - for(int i = 0; i < 4; ++i) - { - mst_current.detail().name_hash()[i] = current_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_current); - - MinimalStructMember mst_info; - mst_info.common().member_id(memberId++); - mst_info.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_info.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_info.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_info.common().member_flags().IS_OPTIONAL(false); - mst_info.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_info.common().member_flags().IS_KEY(false); - mst_info.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_info.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - MD5 info_hash("info"); - for(int i = 0; i < 4; ++i) - { - mst_info.detail().name_hash()[i] = info_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_info); - - - // 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("DdsRecorderStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderStatus", false); -} - -const TypeObject* GetCompleteDdsRecorderStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderStatus", 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_previous; - cst_previous.common().member_id(memberId++); - cst_previous.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_previous.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_previous.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_previous.common().member_flags().IS_OPTIONAL(false); - cst_previous.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_previous.common().member_flags().IS_KEY(false); - cst_previous.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_previous.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - cst_previous.detail().name("previous"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_previous); - - CompleteStructMember cst_current; - cst_current.common().member_id(memberId++); - cst_current.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_current.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_current.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_current.common().member_flags().IS_OPTIONAL(false); - cst_current.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_current.common().member_flags().IS_KEY(false); - cst_current.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_current.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - cst_current.detail().name("current"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_current); - - CompleteStructMember cst_info; - cst_info.common().member_id(memberId++); - cst_info.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_info.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_info.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_info.common().member_flags().IS_OPTIONAL(false); - cst_info.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_info.common().member_flags().IS_KEY(false); - cst_info.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_info.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - - cst_info.detail().name("info"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_info); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsRecorderStatus"); - // 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("DdsRecorderStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderStatus", true); -} diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.h b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.h deleted file mode 100644 index 759aad885..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 DdsRecorderStatusTypeObject.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_DDSRECORDERSTATUS_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_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(DdsRecorderStatus_SOURCE) -#define DdsRecorderStatus_DllAPI __declspec( dllexport ) -#else -#define DdsRecorderStatus_DllAPI __declspec( dllimport ) -#endif // DdsRecorderStatus_SOURCE -#else -#define DdsRecorderStatus_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define DdsRecorderStatus_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerDdsRecorderStatusTypes(); - -eProsima_user_DllExport const TypeIdentifier* GetDdsRecorderStatusIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsRecorderStatusObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsRecorderStatusObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsRecorderStatusObject(); - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_H_ diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.cxx deleted file mode 100644 index bd0bbd18f..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.cxx +++ /dev/null @@ -1,180 +0,0 @@ -// 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 DdsRecorderCommand.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "DdsRecorderCommand.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "DdsRecorderCommandTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -DdsRecorderCommand::DdsRecorderCommand() -{ - // Just to register all known types - registerDdsRecorderCommandTypes(); -} - -DdsRecorderCommand::~DdsRecorderCommand() -{ -} - -DdsRecorderCommand::DdsRecorderCommand( - const DdsRecorderCommand& x) -{ - m_command = x.m_command; - m_args = x.m_args; -} - -DdsRecorderCommand::DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept -{ - m_command = std::move(x.m_command); - m_args = std::move(x.m_args); -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - const DdsRecorderCommand& x) -{ - - m_command = x.m_command; - m_args = x.m_args; - return *this; -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - DdsRecorderCommand&& x) noexcept -{ - - m_command = std::move(x.m_command); - m_args = std::move(x.m_args); - return *this; -} - -bool DdsRecorderCommand::operator ==( - const DdsRecorderCommand& x) const -{ - return (m_command == x.m_command && - m_args == x.m_args); -} - -bool DdsRecorderCommand::operator !=( - const DdsRecorderCommand& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member command - * @param _command New value to be copied in member command - */ -void DdsRecorderCommand::command( - const std::string& _command) -{ - m_command = _command; -} - -/*! - * @brief This function moves the value in member command - * @param _command New value to be moved in member command - */ -void DdsRecorderCommand::command( - std::string&& _command) -{ - m_command = std::move(_command); -} - -/*! - * @brief This function returns a constant reference to member command - * @return Constant reference to member command - */ -const std::string& DdsRecorderCommand::command() const -{ - return m_command; -} - -/*! - * @brief This function returns a reference to member command - * @return Reference to member command - */ -std::string& DdsRecorderCommand::command() -{ - return m_command; -} - -/*! - * @brief This function copies the value in member args - * @param _args New value to be copied in member args - */ -void DdsRecorderCommand::args( - const std::string& _args) -{ - m_args = _args; -} - -/*! - * @brief This function moves the value in member args - * @param _args New value to be moved in member args - */ -void DdsRecorderCommand::args( - std::string&& _args) -{ - m_args = std::move(_args); -} - -/*! - * @brief This function returns a constant reference to member args - * @return Constant reference to member args - */ -const std::string& DdsRecorderCommand::args() const -{ - return m_args; -} - -/*! - * @brief This function returns a reference to member args - * @return Reference to member args - */ -std::string& DdsRecorderCommand::args() -{ - return m_args; -} - -// Include auxiliary functions like for serializing/deserializing. -#include "DdsRecorderCommandCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.idl b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.idl deleted file mode 100644 index 001fd4b2e..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.idl +++ /dev/null @@ -1,5 +0,0 @@ -struct DdsRecorderCommand -{ - string command; - string args; -}; diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx deleted file mode 100644 index f9da567d7..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx +++ /dev/null @@ -1,265 +0,0 @@ -// 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 DdsRecorderCommandTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include "DdsRecorderCommand.h" -#include "DdsRecorderCommandTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerDdsRecorderCommandTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("DdsRecorderCommand", GetDdsRecorderCommandIdentifier(true), - GetDdsRecorderCommandObject(true)); - factory->add_type_object("DdsRecorderCommand", GetDdsRecorderCommandIdentifier(false), - GetDdsRecorderCommandObject(false)); - - }); -} - -const TypeIdentifier* GetDdsRecorderCommandIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderCommand", - complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsRecorderCommandObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderCommand", complete); -} - -const TypeObject* GetDdsRecorderCommandObject( - bool complete) -{ - const TypeObject* c_type_object = - TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsRecorderCommandObject(); - } - //else - return GetMinimalDdsRecorderCommandObject(); -} - -const TypeObject* GetMinimalDdsRecorderCommandObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", 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_command; - mst_command.common().member_id(memberId++); - mst_command.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_command.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_command.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_command.common().member_flags().IS_OPTIONAL(false); - mst_command.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_command.common().member_flags().IS_KEY(false); - mst_command.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_command.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 command_hash("command"); - for (int i = 0; i < 4; ++i) - { - mst_command.detail().name_hash()[i] = command_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_command); - - MinimalStructMember mst_args; - mst_args.common().member_id(memberId++); - mst_args.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_args.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_args.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_args.common().member_flags().IS_OPTIONAL(false); - mst_args.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_args.common().member_flags().IS_KEY(false); - mst_args.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_args.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 args_hash("args"); - for (int i = 0; i < 4; ++i) - { - mst_args.detail().name_hash()[i] = args_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_args); - - - // 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderCommand", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", false); -} - -const TypeObject* GetCompleteDdsRecorderCommandObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", 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_command; - cst_command.common().member_id(memberId++); - cst_command.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_command.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_command.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_command.common().member_flags().IS_OPTIONAL(false); - cst_command.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_command.common().member_flags().IS_KEY(false); - cst_command.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_command.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_command.detail().name("command"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_command); - - CompleteStructMember cst_args; - cst_args.common().member_id(memberId++); - cst_args.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_args.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_args.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_args.common().member_flags().IS_OPTIONAL(false); - cst_args.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_args.common().member_flags().IS_KEY(false); - cst_args.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_args.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_args.detail().name("args"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_args); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsRecorderCommand"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderCommand", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderCommand", true); -} diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.h deleted file mode 100644 index ff6b23261..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.h +++ /dev/null @@ -1,67 +0,0 @@ -// 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 DdsRecorderCommandTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_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(DdsRecorderCommand_SOURCE) -#define DdsRecorderCommand_DllAPI __declspec( dllexport ) -#else -#define DdsRecorderCommand_DllAPI __declspec( dllimport ) -#endif // DdsRecorderCommand_SOURCE -#else -#define DdsRecorderCommand_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define DdsRecorderCommand_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerDdsRecorderCommandTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetDdsRecorderCommandIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsRecorderCommandObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsRecorderCommandObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsRecorderCommandObject(); - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx deleted file mode 100644 index 53e96a98a..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx +++ /dev/null @@ -1,303 +0,0 @@ -// 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 DdsRecorderCommand.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "DdsRecorderCommand.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "DdsRecorderCommandTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define DdsRecorderCommand_max_cdr_typesize 524ULL; - - - - -DdsRecorderCommand::DdsRecorderCommand() -{ - // /type_d() m_command - - // /type_d() m_args - - - // Just to register all known types - registerDdsRecorderCommandTypes(); -} - -DdsRecorderCommand::~DdsRecorderCommand() -{ -} - -DdsRecorderCommand::DdsRecorderCommand( - const DdsRecorderCommand& x) -{ - m_command = x.m_command; - - - m_args = x.m_args; - -} - -DdsRecorderCommand::DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept -{ - m_command = std::move(x.m_command); - - - m_args = std::move(x.m_args); - -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - const DdsRecorderCommand& x) -{ - m_command = x.m_command; - - - m_args = x.m_args; - - return *this; -} - -DdsRecorderCommand& DdsRecorderCommand::operator =( - DdsRecorderCommand&& x) noexcept -{ - m_command = std::move(x.m_command); - - - m_args = std::move(x.m_args); - - return *this; -} - -bool DdsRecorderCommand::operator ==( - const DdsRecorderCommand& x) const -{ - return (m_command == x.m_command && - m_args == x.m_args); -} - -bool DdsRecorderCommand::operator !=( - const DdsRecorderCommand& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderCommand::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderCommand_max_cdr_typesize; -} - -size_t DdsRecorderCommand::getCdrSerializedSize( - const DdsRecorderCommand& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.command().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.args().size() + 1; - - - return current_alignment - initial_alignment; -} - -void DdsRecorderCommand::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_command.c_str(); - - scdr << m_args.c_str(); - -} - -void DdsRecorderCommand::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_command; - - - - dcdr >> m_args; - - -} - -bool DdsRecorderCommand::isKeyDefined() -{ - return false; -} - -void DdsRecorderCommand::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member command - * @param _command New value to be copied in member command - */ -void DdsRecorderCommand::command( - const std::string& _command) -{ - m_command = _command; -} - -/*! - * @brief This function moves the value in member command - * @param _command New value to be moved in member command - */ -void DdsRecorderCommand::command( - std::string&& _command) -{ - m_command = std::move(_command); -} - -/*! - * @brief This function returns a constant reference to member command - * @return Constant reference to member command - */ -const std::string& DdsRecorderCommand::command() const -{ - return m_command; -} - -/*! - * @brief This function returns a reference to member command - * @return Reference to member command - */ -std::string& DdsRecorderCommand::command() -{ - return m_command; -} - -/*! - * @brief This function copies the value in member args - * @param _args New value to be copied in member args - */ -void DdsRecorderCommand::args( - const std::string& _args) -{ - m_args = _args; -} - -/*! - * @brief This function moves the value in member args - * @param _args New value to be moved in member args - */ -void DdsRecorderCommand::args( - std::string&& _args) -{ - m_args = std::move(_args); -} - -/*! - * @brief This function returns a constant reference to member args - * @return Constant reference to member args - */ -const std::string& DdsRecorderCommand::args() const -{ - return m_args; -} - -/*! - * @brief This function returns a reference to member args - * @return Reference to member args - */ -std::string& DdsRecorderCommand::args() -{ - return m_args; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.h deleted file mode 100644 index ae03d6c94..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.h +++ /dev/null @@ -1,249 +0,0 @@ -// 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 DdsRecorderCommand.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_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(DDSRECORDERCOMMAND_SOURCE) -#define DDSRECORDERCOMMAND_DllAPI __declspec( dllexport ) -#else -#define DDSRECORDERCOMMAND_DllAPI __declspec( dllimport ) -#endif // DDSRECORDERCOMMAND_SOURCE -#else -#define DDSRECORDERCOMMAND_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DDSRECORDERCOMMAND_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure DdsRecorderCommand defined by the user in the IDL file. - * @ingroup DdsRecorderCommand - */ -class DdsRecorderCommand -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderCommand(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderCommand(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand( - const DdsRecorderCommand& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand( - DdsRecorderCommand&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand& operator =( - const DdsRecorderCommand& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderCommand that will be copied. - */ - eProsima_user_DllExport DdsRecorderCommand& operator =( - DdsRecorderCommand&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderCommand object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderCommand& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderCommand object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderCommand& x) const; - - /*! - * @brief This function copies the value in member command - * @param _command New value to be copied in member command - */ - eProsima_user_DllExport void command( - const std::string& _command); - - /*! - * @brief This function moves the value in member command - * @param _command New value to be moved in member command - */ - eProsima_user_DllExport void command( - std::string&& _command); - - /*! - * @brief This function returns a constant reference to member command - * @return Constant reference to member command - */ - eProsima_user_DllExport const std::string& command() const; - - /*! - * @brief This function returns a reference to member command - * @return Reference to member command - */ - eProsima_user_DllExport std::string& command(); - - - /*! - * @brief This function copies the value in member args - * @param _args New value to be copied in member args - */ - eProsima_user_DllExport void args( - const std::string& _args); - - /*! - * @brief This function moves the value in member args - * @param _args New value to be moved in member args - */ - eProsima_user_DllExport void args( - std::string&& _args); - - /*! - * @brief This function returns a constant reference to member args - * @return Constant reference to member args - */ - eProsima_user_DllExport const std::string& args() const; - - /*! - * @brief This function returns a reference to member args - * @return Reference to member args - */ - eProsima_user_DllExport std::string& args(); - - - /*! - * @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 DdsRecorderCommand& 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 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_command; - std::string m_args; - -}; - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.cxx deleted file mode 100644 index a364eefe7..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.cxx +++ /dev/null @@ -1,223 +0,0 @@ -// 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 DdsRecorderStatus.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "DdsRecorderStatus.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "DdsRecorderStatusTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -DdsRecorderStatus::DdsRecorderStatus() -{ - // Just to register all known types - registerDdsRecorderStatusTypes(); -} - -DdsRecorderStatus::~DdsRecorderStatus() -{ -} - -DdsRecorderStatus::DdsRecorderStatus( - const DdsRecorderStatus& x) -{ - m_previous = x.m_previous; - m_current = x.m_current; - m_info = x.m_info; -} - -DdsRecorderStatus::DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept -{ - m_previous = std::move(x.m_previous); - m_current = std::move(x.m_current); - m_info = std::move(x.m_info); -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - const DdsRecorderStatus& x) -{ - - m_previous = x.m_previous; - m_current = x.m_current; - m_info = x.m_info; - return *this; -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - DdsRecorderStatus&& x) noexcept -{ - - m_previous = std::move(x.m_previous); - m_current = std::move(x.m_current); - m_info = std::move(x.m_info); - return *this; -} - -bool DdsRecorderStatus::operator ==( - const DdsRecorderStatus& x) const -{ - return (m_previous == x.m_previous && - m_current == x.m_current && - m_info == x.m_info); -} - -bool DdsRecorderStatus::operator !=( - const DdsRecorderStatus& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member previous - * @param _previous New value to be copied in member previous - */ -void DdsRecorderStatus::previous( - const std::string& _previous) -{ - m_previous = _previous; -} - -/*! - * @brief This function moves the value in member previous - * @param _previous New value to be moved in member previous - */ -void DdsRecorderStatus::previous( - std::string&& _previous) -{ - m_previous = std::move(_previous); -} - -/*! - * @brief This function returns a constant reference to member previous - * @return Constant reference to member previous - */ -const std::string& DdsRecorderStatus::previous() const -{ - return m_previous; -} - -/*! - * @brief This function returns a reference to member previous - * @return Reference to member previous - */ -std::string& DdsRecorderStatus::previous() -{ - return m_previous; -} - -/*! - * @brief This function copies the value in member current - * @param _current New value to be copied in member current - */ -void DdsRecorderStatus::current( - const std::string& _current) -{ - m_current = _current; -} - -/*! - * @brief This function moves the value in member current - * @param _current New value to be moved in member current - */ -void DdsRecorderStatus::current( - std::string&& _current) -{ - m_current = std::move(_current); -} - -/*! - * @brief This function returns a constant reference to member current - * @return Constant reference to member current - */ -const std::string& DdsRecorderStatus::current() const -{ - return m_current; -} - -/*! - * @brief This function returns a reference to member current - * @return Reference to member current - */ -std::string& DdsRecorderStatus::current() -{ - return m_current; -} - -/*! - * @brief This function copies the value in member info - * @param _info New value to be copied in member info - */ -void DdsRecorderStatus::info( - const std::string& _info) -{ - m_info = _info; -} - -/*! - * @brief This function moves the value in member info - * @param _info New value to be moved in member info - */ -void DdsRecorderStatus::info( - std::string&& _info) -{ - m_info = std::move(_info); -} - -/*! - * @brief This function returns a constant reference to member info - * @return Constant reference to member info - */ -const std::string& DdsRecorderStatus::info() const -{ - return m_info; -} - -/*! - * @brief This function returns a reference to member info - * @return Reference to member info - */ -std::string& DdsRecorderStatus::info() -{ - return m_info; -} - -// Include auxiliary functions like for serializing/deserializing. -#include "DdsRecorderStatusCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.idl b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.idl deleted file mode 100644 index cee55f14f..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.idl +++ /dev/null @@ -1,6 +0,0 @@ -struct DdsRecorderStatus -{ - string previous; - string current; - string info; -}; diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx deleted file mode 100644 index 0243774c6..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx +++ /dev/null @@ -1,297 +0,0 @@ -// 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 DdsRecorderStatusTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include "DdsRecorderStatus.h" -#include "DdsRecorderStatusTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerDdsRecorderStatusTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("DdsRecorderStatus", GetDdsRecorderStatusIdentifier(true), - GetDdsRecorderStatusObject(true)); - factory->add_type_object("DdsRecorderStatus", GetDdsRecorderStatusIdentifier(false), - GetDdsRecorderStatusObject(false)); - - }); -} - -const TypeIdentifier* GetDdsRecorderStatusIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderStatus", - complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsRecorderStatusObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderStatus", complete); -} - -const TypeObject* GetDdsRecorderStatusObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderStatus", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsRecorderStatusObject(); - } - //else - return GetMinimalDdsRecorderStatusObject(); -} - -const TypeObject* GetMinimalDdsRecorderStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderStatus", 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_previous; - mst_previous.common().member_id(memberId++); - mst_previous.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_previous.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_previous.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_previous.common().member_flags().IS_OPTIONAL(false); - mst_previous.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_previous.common().member_flags().IS_KEY(false); - mst_previous.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_previous.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 previous_hash("previous"); - for (int i = 0; i < 4; ++i) - { - mst_previous.detail().name_hash()[i] = previous_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_previous); - - MinimalStructMember mst_current; - mst_current.common().member_id(memberId++); - mst_current.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_current.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_current.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_current.common().member_flags().IS_OPTIONAL(false); - mst_current.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_current.common().member_flags().IS_KEY(false); - mst_current.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_current.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 current_hash("current"); - for (int i = 0; i < 4; ++i) - { - mst_current.detail().name_hash()[i] = current_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_current); - - MinimalStructMember mst_info; - mst_info.common().member_id(memberId++); - mst_info.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_info.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_info.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_info.common().member_flags().IS_OPTIONAL(false); - mst_info.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_info.common().member_flags().IS_KEY(false); - mst_info.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_info.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 info_hash("info"); - for (int i = 0; i < 4; ++i) - { - mst_info.detail().name_hash()[i] = info_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_info); - - - // 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderStatus", false); -} - -const TypeObject* GetCompleteDdsRecorderStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderStatus", 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_previous; - cst_previous.common().member_id(memberId++); - cst_previous.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_previous.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_previous.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_previous.common().member_flags().IS_OPTIONAL(false); - cst_previous.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_previous.common().member_flags().IS_KEY(false); - cst_previous.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_previous.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_previous.detail().name("previous"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_previous); - - CompleteStructMember cst_current; - cst_current.common().member_id(memberId++); - cst_current.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_current.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_current.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_current.common().member_flags().IS_OPTIONAL(false); - cst_current.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_current.common().member_flags().IS_KEY(false); - cst_current.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_current.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_current.detail().name("current"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_current); - - CompleteStructMember cst_info; - cst_info.common().member_id(memberId++); - cst_info.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_info.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_info.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_info.common().member_flags().IS_OPTIONAL(false); - cst_info.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_info.common().member_flags().IS_KEY(false); - cst_info.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_info.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_info.detail().name("info"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_info); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsRecorderStatus"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderStatus", true); -} diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.h deleted file mode 100644 index a871b5a99..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.h +++ /dev/null @@ -1,67 +0,0 @@ -// 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 DdsRecorderStatusTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_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(DdsRecorderStatus_SOURCE) -#define DdsRecorderStatus_DllAPI __declspec( dllexport ) -#else -#define DdsRecorderStatus_DllAPI __declspec( dllimport ) -#endif // DdsRecorderStatus_SOURCE -#else -#define DdsRecorderStatus_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define DdsRecorderStatus_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerDdsRecorderStatusTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetDdsRecorderStatusIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsRecorderStatusObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsRecorderStatusObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsRecorderStatusObject(); - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx deleted file mode 100644 index c1d6e705e..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx +++ /dev/null @@ -1,365 +0,0 @@ -// 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 DdsRecorderStatus.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "DdsRecorderStatus.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "DdsRecorderStatusTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define DdsRecorderStatus_max_cdr_typesize 784ULL; - - - - -DdsRecorderStatus::DdsRecorderStatus() -{ - // /type_d() m_previous - - // /type_d() m_current - - // /type_d() m_info - - - // Just to register all known types - registerDdsRecorderStatusTypes(); -} - -DdsRecorderStatus::~DdsRecorderStatus() -{ -} - -DdsRecorderStatus::DdsRecorderStatus( - const DdsRecorderStatus& x) -{ - m_previous = x.m_previous; - - - m_current = x.m_current; - - - m_info = x.m_info; - -} - -DdsRecorderStatus::DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept -{ - m_previous = std::move(x.m_previous); - - - m_current = std::move(x.m_current); - - - m_info = std::move(x.m_info); - -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - const DdsRecorderStatus& x) -{ - m_previous = x.m_previous; - - - m_current = x.m_current; - - - m_info = x.m_info; - - return *this; -} - -DdsRecorderStatus& DdsRecorderStatus::operator =( - DdsRecorderStatus&& x) noexcept -{ - m_previous = std::move(x.m_previous); - - - m_current = std::move(x.m_current); - - - m_info = std::move(x.m_info); - - return *this; -} - -bool DdsRecorderStatus::operator ==( - const DdsRecorderStatus& x) const -{ - return (m_previous == x.m_previous && - m_current == x.m_current && - m_info == x.m_info); -} - -bool DdsRecorderStatus::operator !=( - const DdsRecorderStatus& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderStatus_max_cdr_typesize; -} - -size_t DdsRecorderStatus::getCdrSerializedSize( - const DdsRecorderStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.previous().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.current().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.info().size() + 1; - - - return current_alignment - initial_alignment; -} - -void DdsRecorderStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_previous.c_str(); - - scdr << m_current.c_str(); - - scdr << m_info.c_str(); - -} - -void DdsRecorderStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_previous; - - - - dcdr >> m_current; - - - - dcdr >> m_info; - - -} - -bool DdsRecorderStatus::isKeyDefined() -{ - return false; -} - -void DdsRecorderStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member previous - * @param _previous New value to be copied in member previous - */ -void DdsRecorderStatus::previous( - const std::string& _previous) -{ - m_previous = _previous; -} - -/*! - * @brief This function moves the value in member previous - * @param _previous New value to be moved in member previous - */ -void DdsRecorderStatus::previous( - std::string&& _previous) -{ - m_previous = std::move(_previous); -} - -/*! - * @brief This function returns a constant reference to member previous - * @return Constant reference to member previous - */ -const std::string& DdsRecorderStatus::previous() const -{ - return m_previous; -} - -/*! - * @brief This function returns a reference to member previous - * @return Reference to member previous - */ -std::string& DdsRecorderStatus::previous() -{ - return m_previous; -} - -/*! - * @brief This function copies the value in member current - * @param _current New value to be copied in member current - */ -void DdsRecorderStatus::current( - const std::string& _current) -{ - m_current = _current; -} - -/*! - * @brief This function moves the value in member current - * @param _current New value to be moved in member current - */ -void DdsRecorderStatus::current( - std::string&& _current) -{ - m_current = std::move(_current); -} - -/*! - * @brief This function returns a constant reference to member current - * @return Constant reference to member current - */ -const std::string& DdsRecorderStatus::current() const -{ - return m_current; -} - -/*! - * @brief This function returns a reference to member current - * @return Reference to member current - */ -std::string& DdsRecorderStatus::current() -{ - return m_current; -} - -/*! - * @brief This function copies the value in member info - * @param _info New value to be copied in member info - */ -void DdsRecorderStatus::info( - const std::string& _info) -{ - m_info = _info; -} - -/*! - * @brief This function moves the value in member info - * @param _info New value to be moved in member info - */ -void DdsRecorderStatus::info( - std::string&& _info) -{ - m_info = std::move(_info); -} - -/*! - * @brief This function returns a constant reference to member info - * @return Constant reference to member info - */ -const std::string& DdsRecorderStatus::info() const -{ - return m_info; -} - -/*! - * @brief This function returns a reference to member info - * @return Reference to member info - */ -std::string& DdsRecorderStatus::info() -{ - return m_info; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.h deleted file mode 100644 index 11acbbe91..000000000 --- a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.h +++ /dev/null @@ -1,277 +0,0 @@ -// 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 DdsRecorderStatus.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_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(DDSRECORDERSTATUS_SOURCE) -#define DDSRECORDERSTATUS_DllAPI __declspec( dllexport ) -#else -#define DDSRECORDERSTATUS_DllAPI __declspec( dllimport ) -#endif // DDSRECORDERSTATUS_SOURCE -#else -#define DDSRECORDERSTATUS_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DDSRECORDERSTATUS_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure DdsRecorderStatus defined by the user in the IDL file. - * @ingroup DdsRecorderStatus - */ -class DdsRecorderStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus( - const DdsRecorderStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus( - DdsRecorderStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus& operator =( - const DdsRecorderStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderStatus& operator =( - DdsRecorderStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderStatus& x) const; - - /*! - * @brief This function copies the value in member previous - * @param _previous New value to be copied in member previous - */ - eProsima_user_DllExport void previous( - const std::string& _previous); - - /*! - * @brief This function moves the value in member previous - * @param _previous New value to be moved in member previous - */ - eProsima_user_DllExport void previous( - std::string&& _previous); - - /*! - * @brief This function returns a constant reference to member previous - * @return Constant reference to member previous - */ - eProsima_user_DllExport const std::string& previous() const; - - /*! - * @brief This function returns a reference to member previous - * @return Reference to member previous - */ - eProsima_user_DllExport std::string& previous(); - - - /*! - * @brief This function copies the value in member current - * @param _current New value to be copied in member current - */ - eProsima_user_DllExport void current( - const std::string& _current); - - /*! - * @brief This function moves the value in member current - * @param _current New value to be moved in member current - */ - eProsima_user_DllExport void current( - std::string&& _current); - - /*! - * @brief This function returns a constant reference to member current - * @return Constant reference to member current - */ - eProsima_user_DllExport const std::string& current() const; - - /*! - * @brief This function returns a reference to member current - * @return Reference to member current - */ - eProsima_user_DllExport std::string& current(); - - - /*! - * @brief This function copies the value in member info - * @param _info New value to be copied in member info - */ - eProsima_user_DllExport void info( - const std::string& _info); - - /*! - * @brief This function moves the value in member info - * @param _info New value to be moved in member info - */ - eProsima_user_DllExport void info( - std::string&& _info); - - /*! - * @brief This function returns a constant reference to member info - * @return Constant reference to member info - */ - eProsima_user_DllExport const std::string& info() const; - - /*! - * @brief This function returns a reference to member info - * @return Reference to member info - */ - eProsima_user_DllExport std::string& info(); - - - /*! - * @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 DdsRecorderStatus& 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 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_previous; - std::string m_current; - std::string m_info; - -}; - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt index deec55b26..1873b9598 100644 --- a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt @@ -31,15 +31,6 @@ file( list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER TEST_SOURCES EXCLUDE REGEX "v2/") - list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER TEST_SOURCES EXCLUDE REGEX "v1/") - list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - set(TEST_LIST mcap_data_msgs mcap_dds_topic diff --git a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp index a1cf385fe..627c1b9b6 100644 --- a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp @@ -140,7 +140,7 @@ void create_publisher( GetHelloWorldIdentifier(true), GetHelloWorldObject(true)); - TypeSupport type(new eprosima::fastrtps::types::DynamicPubSubType(test::dynamic_type_)); + TypeSupport type(new eprosima::fastdds::dds::DynamicPubSubType(test::dynamic_type_)); // Set type so introspection info is sent type->auto_fill_type_information(true); type->auto_fill_type_object(false); @@ -322,7 +322,7 @@ TEST(McapFileCreationTest, mcap_data_msgs) eprosima::fastrtps::types::DynamicData_ptr send_data; send_data = record(file_name); - eprosima::fastrtps::types::DynamicPubSubType pubsubType; + eprosima::fastdds::dds::DynamicPubSubType pubsubType; eprosima::fastrtps::rtps::SerializedPayload_t payload; payload.reserve( pubsubType.getSerializedSizeProvider( diff --git a/ddsrecorder/test/blackbox/resource_limits/CMakeLists.txt b/ddsrecorder/test/blackbox/resource_limits/CMakeLists.txt index bc19c6653..8e17a6054 100644 --- a/ddsrecorder/test/blackbox/resource_limits/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/resource_limits/CMakeLists.txt @@ -31,15 +31,6 @@ file( list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER TEST_SOURCES EXCLUDE REGEX "v2/") - list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER TEST_SOURCES EXCLUDE REGEX "v1/") - list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - set(TEST_LIST max_file_size max_size @@ -53,13 +44,6 @@ set(TEST_EXTRA_HEADERS ${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/ ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER TEST_EXTRA_HEADERS EXCLUDE REGEX "v2/") -else() - list(FILTER TEST_EXTRA_HEADERS EXCLUDE REGEX "v1/") -endif() - add_blackbox_executable( "${TEST_NAME}" "${TEST_SOURCES}" diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.h b/ddsrecorder/test/resources/types/hello_world/HelloWorld.hpp similarity index 69% rename from ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.h rename to ddsrecorder/test/resources/types/hello_world/HelloWorld.hpp index 5cd0ddba5..971fea8d9 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.h +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorld.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file HelloWorld.h + * @file HelloWorld.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "HelloWorldv1.h" +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_H_ - -#include -#include #include -#include #include -#include - +#include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +51,6 @@ #define HELLOWORLD_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -86,73 +62,117 @@ class HelloWorld /*! * @brief Default constructor. */ - eProsima_user_DllExport HelloWorld(); + eProsima_user_DllExport HelloWorld() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~HelloWorld(); + eProsima_user_DllExport ~HelloWorld() + { + } /*! * @brief Copy constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - const HelloWorld& x); + const HelloWorld& x) + { + m_index = x.m_index; + + m_message = x.m_message; + + } /*! * @brief Move constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + m_index = x.m_index; + m_message = std::move(x.m_message); + } /*! * @brief Copy assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); + const HelloWorld& x) + { + + m_index = x.m_index; + + m_message = x.m_message; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + + m_index = x.m_index; + m_message = std::move(x.m_message); + return *this; + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return (m_index == x.m_index && + m_message == x.m_message); + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member index * @param _index New value for member index */ eProsima_user_DllExport void index( - uint32_t _index); + uint32_t _index) + { + m_index = _index; + } /*! * @brief This function returns the value of member index * @return Value of member index */ - eProsima_user_DllExport uint32_t index() const; + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } /*! * @brief This function returns a reference to member index * @return Reference to member index */ - eProsima_user_DllExport uint32_t& index(); + eProsima_user_DllExport uint32_t& index() + { + return m_index; + } /*! @@ -160,26 +180,40 @@ class HelloWorld * @param _message New value to be copied in member message */ eProsima_user_DllExport void message( - const std::string& _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 */ eProsima_user_DllExport void message( - std::string&& _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 */ - eProsima_user_DllExport const std::string& message() const; + eProsima_user_DllExport const std::string& message() const + { + return m_message; + } /*! * @brief This function returns a reference to member message * @return Reference to member message */ - eProsima_user_DllExport std::string& message(); + eProsima_user_DllExport std::string& message() + { + return m_message; + } + + private: @@ -188,8 +222,6 @@ class HelloWorld }; -#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ - +#endif // _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldCdrAux.hpp b/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.hpp similarity index 98% rename from resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldCdrAux.hpp rename to ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.hpp index 9f346d306..6feb8a9da 100644 --- a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldCdrAux.hpp +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.hpp @@ -22,7 +22,7 @@ #ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ #define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#include "HelloWorld.h" +#include "HelloWorld.hpp" constexpr uint32_t HelloWorld_max_cdr_typesize {268UL}; constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data); diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldCdrAux.ipp b/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.ipp similarity index 84% rename from resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldCdrAux.ipp rename to ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.ipp index ec08b909a..97df3fe9d 100644 --- a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldCdrAux.ipp +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,11 +50,11 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.index(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.index(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.message(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.message(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -78,7 +76,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.index() << eprosima::fastcdr::MemberId(1) << data.message() - ; +; scdr.end_serialize_type(current_state); } @@ -95,13 +93,13 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.index(); - break; + case 0: + dcdr >> data.index(); + break; - case 1: - dcdr >> data.message(); - break; + case 1: + dcdr >> data.message(); + break; default: ret_value = false; @@ -119,6 +117,8 @@ void serialize_key( static_cast(data); } + + } // namespace fastcdr } // namespace eprosima diff --git a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldPubSubTypes.cxx b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx similarity index 91% rename from ddsrecorder/test/resources/types/hello_world/v2/HelloWorldPubSubTypes.cxx rename to ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx index ef09d8f97..aa161b2e1 100644 --- a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldPubSubTypes.cxx +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx @@ -19,27 +19,27 @@ * This file was generated by the tool fastddsgen. */ +#include "HelloWorldPubSubTypes.h" +#include #include -#include "HelloWorldPubSubTypes.h" #include "HelloWorldCdrAux.hpp" +#include "HelloWorldTypeObjectSupport.hpp" using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - HelloWorldPubSubType::HelloWorldPubSubType() { setName("HelloWorld"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - HelloWorld::getMaxCdrSerializedSize(); + static_cast(HelloWorld::getMaxCdrSerializedSize()); #else - HelloWorld_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + HelloWorld_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -139,6 +139,7 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -149,8 +150,8 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -188,8 +189,7 @@ bool HelloWorldPubSubType::getKey( HelloWorld_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -218,3 +218,12 @@ bool HelloWorldPubSubType::getKey( } return true; } + +void HelloWorldPubSubType::register_type_object_representation() +{ + register_HelloWorld_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "HelloWorldCdrAux.ipp" diff --git a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldPubSubTypes.h b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.h similarity index 92% rename from ddsrecorder/test/resources/types/hello_world/v2/HelloWorldPubSubTypes.h rename to ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.h index f8186b177..7c83d2b30 100644 --- a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldPubSubTypes.h +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.h @@ -27,9 +27,9 @@ #include #include #include -#include +#include -#include "HelloWorld.h" +#include "HelloWorld.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -90,6 +88,9 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -105,7 +106,7 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.cxx b/ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.cxx new file mode 100644 index 000000000..58928b6f0 --- /dev/null +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.cxx @@ -0,0 +1,138 @@ +// 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 HelloWorldTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "HelloWorldTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "HelloWorld.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_HelloWorld_type_identifier( + TypeIdentifierPair& type_ids_HelloWorld) +{ + + ReturnCode_t return_code_HelloWorld {eprosima::fastdds::dds::RETCODE_OK}; + return_code_HelloWorld = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "HelloWorld", type_ids_HelloWorld); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloWorld) + { + StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_HelloWorld = "HelloWorld"; + eprosima::fastcdr::optional type_ann_builtin_HelloWorld; + eprosima::fastcdr::optional ann_custom_HelloWorld; + CompleteTypeDetail detail_HelloWorld = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloWorld, ann_custom_HelloWorld, type_name_HelloWorld.to_string()); + CompleteStructHeader header_HelloWorld; + header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld); + CompleteStructMemberSeq member_seq_HelloWorld; + { + TypeIdentifierPair type_ids_index; + ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; + return_code_index = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_index); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_index = 0x00000000; + bool common_index_ec {false}; + CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; + if (!common_index_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); + return; + } + MemberName name_index = "index"; + eprosima::fastcdr::optional member_ann_builtin_index; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_HelloWorld); + CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index); + } + { + TypeIdentifierPair type_ids_message; + ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_message)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_message = 0x00000001; + bool common_message_ec {false}; + CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; + if (!common_message_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); + return; + } + MemberName name_message = "message"; + eprosima::fastcdr::optional member_ann_builtin_message; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_HelloWorld); + CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_message); + } + CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_ids_HelloWorld)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "HelloWorld already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.hpp b/ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.hpp new file mode 100644 index 000000000..2eba797b0 --- /dev/null +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 HelloWorldTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register HelloWorld related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_HelloWorld_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorld.cxx b/ddsrecorder/test/resources/types/hello_world/v1/HelloWorld.cxx deleted file mode 100644 index 3f4c9beb1..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorld.cxx +++ /dev/null @@ -1,239 +0,0 @@ -// 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 HelloWorld.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 "HelloWorld.h" -#include "HelloWorldTypeObject.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -HelloWorld::HelloWorld() -{ - // m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@74a10858 - m_index = 0; - // m_message com.eprosima.idl.parser.typecode.StringTypeCode@23fe1d71 - m_message = ""; - - // Just to register all known types - registerHelloWorldTypes(); -} - -HelloWorld::~HelloWorld() -{ - - -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - m_message = x.m_message; -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - m_message = std::move(x.m_message); -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - - m_index = x.m_index; - m_message = x.m_message; - - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - - m_index = x.m_index; - m_message = std::move(x.m_message); - - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - - return (m_index == x.m_index && m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -size_t HelloWorld::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 HelloWorld::getCdrSerializedSize( - const HelloWorld& 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 HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_index; - scdr << m_message.c_str(); - -} - -void HelloWorld::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 HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::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 HelloWorld::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& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& HelloWorld::message() -{ - return m_message; -} - -size_t HelloWorld::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - - - return current_align; -} - -bool HelloWorld::isKeyDefined() -{ - return false; -} - -void HelloWorld::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} diff --git a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorld.h b/ddsrecorder/test/resources/types/hello_world/v1/HelloWorld.h deleted file mode 100644 index cb7885b35..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorld.h +++ /dev/null @@ -1,234 +0,0 @@ -// 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 HelloWorld.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_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_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(HelloWorld_SOURCE) -#define HelloWorld_DllAPI __declspec( dllexport ) -#else -#define HelloWorld_DllAPI __declspec( dllimport ) -#endif // HelloWorld_SOURCE -#else -#define HelloWorld_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HelloWorld_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure HelloWorld defined by the user in the IDL file. - * @ingroup HELLOWORLD - */ -class HelloWorld -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport HelloWorld(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~HelloWorld(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - const HelloWorld& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator !=( - const HelloWorld& 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 HelloWorld& 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_HELLOWORLD_H_ diff --git a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldPubSubTypes.cxx b/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldPubSubTypes.cxx deleted file mode 100644 index 237fb7584..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldPubSubTypes.cxx +++ /dev/null @@ -1,170 +0,0 @@ -// 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 HelloWorldPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "HelloWorldPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -HelloWorldPubSubType::HelloWorldPubSubType() -{ - setName("HelloWorld"); - auto type_size = HelloWorld::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = HelloWorld::isKeyDefined(); - size_t keyLength = HelloWorld::getKeyMaxCdrSerializedSize() > 16 ? - HelloWorld::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -HelloWorldPubSubType::~HelloWorldPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool HelloWorldPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - HelloWorld* 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 HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - HelloWorld* 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 HelloWorldPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* HelloWorldPubSubType::createData() -{ - return reinterpret_cast(new HelloWorld()); -} - -void HelloWorldPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool HelloWorldPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - HelloWorld::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || HelloWorld::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/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldPubSubTypes.h b/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldPubSubTypes.h deleted file mode 100644 index 3ec5efa14..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldPubSubTypes.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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 HelloWorldPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ - -#include -#include - -#include "HelloWorld.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated HelloWorld 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 HelloWorld defined by the user in the IDL file. - * @ingroup HELLOWORLD - */ -class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef HelloWorld type; - - eProsima_user_DllExport HelloWorldPubSubType(); - - eProsima_user_DllExport virtual ~HelloWorldPubSubType() 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_HELLOWORLD_PUBSUBTYPES_H_ diff --git a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldTypeObject.cxx b/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldTypeObject.cxx deleted file mode 100644 index adf767259..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldTypeObject.cxx +++ /dev/null @@ -1,252 +0,0 @@ -// 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 HelloWorldTypeObject.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 // ifdef _WIN32 - -#include "HelloWorld.h" -#include "HelloWorldTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerHelloWorldTypes() -{ - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("HelloWorld", GetHelloWorldIdentifier(true), - GetHelloWorldObject(true)); - factory->add_type_object("HelloWorld", GetHelloWorldIdentifier(false), - GetHelloWorldObject(false)); - -} - -const TypeIdentifier* GetHelloWorldIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("HelloWorld", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetHelloWorldObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("HelloWorld", complete); -} - -const TypeObject* GetHelloWorldObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("HelloWorld", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteHelloWorldObject(); - } - //else - return GetMinimalHelloWorldObject(); -} - -const TypeObject* GetMinimalHelloWorldObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("HelloWorld", 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("HelloWorld", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("HelloWorld", false); -} - -const TypeObject* GetCompleteHelloWorldObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("HelloWorld", 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("HelloWorld"); - // 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("HelloWorld", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("HelloWorld", true); -} diff --git a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldTypeObject.h b/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldTypeObject.h deleted file mode 100644 index 37639c165..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v1/HelloWorldTypeObject.h +++ /dev/null @@ -1,65 +0,0 @@ -// 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 HelloWorldTypeObject.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_HELLOWORLD_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_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(HelloWorld_SOURCE) -#define HelloWorld_DllAPI __declspec( dllexport ) -#else -#define HelloWorld_DllAPI __declspec( dllimport ) -#endif // HelloWorld_SOURCE -#else -#define HelloWorld_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define HelloWorld_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerHelloWorldTypes(); - -eProsima_user_DllExport const TypeIdentifier* GetHelloWorldIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetHelloWorldObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalHelloWorldObject(); -eProsima_user_DllExport const TypeObject* GetCompleteHelloWorldObject(); - - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_H_ diff --git a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorld.cxx b/ddsrecorder/test/resources/types/hello_world/v2/HelloWorld.cxx deleted file mode 100644 index ed390c241..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorld.cxx +++ /dev/null @@ -1,170 +0,0 @@ -// 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 HelloWorld.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "HelloWorldTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -HelloWorld::HelloWorld() -{ - // Just to register all known types - registerHelloWorldTypes(); -} - -HelloWorld::~HelloWorld() -{ -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - m_message = x.m_message; -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - m_message = std::move(x.m_message); -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - - m_index = x.m_index; - m_message = x.m_message; - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - - m_index = x.m_index; - m_message = std::move(x.m_message); - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::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 HelloWorld::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& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& HelloWorld::message() -{ - return m_message; -} - -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldTypeObject.cxx b/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldTypeObject.cxx deleted file mode 100644 index ff56e98c4..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldTypeObject.cxx +++ /dev/null @@ -1,265 +0,0 @@ -// 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 HelloWorldTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include "HelloWorld.h" -#include "HelloWorldTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerHelloWorldTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("HelloWorld", GetHelloWorldIdentifier(true), - GetHelloWorldObject(true)); - factory->add_type_object("HelloWorld", GetHelloWorldIdentifier(false), - GetHelloWorldObject(false)); - - }); -} - -const TypeIdentifier* GetHelloWorldIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("HelloWorld", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetHelloWorldObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("HelloWorld", complete); -} - -const TypeObject* GetHelloWorldObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("HelloWorld", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteHelloWorldObject(); - } - //else - return GetMinimalHelloWorldObject(); -} - -const TypeObject* GetMinimalHelloWorldObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("HelloWorld", 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("HelloWorld", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("HelloWorld", false); -} - -const TypeObject* GetCompleteHelloWorldObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("HelloWorld", 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("HelloWorld"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("HelloWorld", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("HelloWorld", true); -} diff --git a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldTypeObject.h b/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldTypeObject.h deleted file mode 100644 index 480d05f15..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldTypeObject.h +++ /dev/null @@ -1,67 +0,0 @@ -// 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 HelloWorldTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_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(HelloWorld_SOURCE) -#define HelloWorld_DllAPI __declspec( dllexport ) -#else -#define HelloWorld_DllAPI __declspec( dllimport ) -#endif // HelloWorld_SOURCE -#else -#define HelloWorld_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define HelloWorld_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerHelloWorldTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetHelloWorldIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetHelloWorldObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalHelloWorldObject(); -eProsima_user_DllExport const TypeObject* GetCompleteHelloWorldObject(); - - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldv1.cxx b/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldv1.cxx deleted file mode 100644 index 745d9517d..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldv1.cxx +++ /dev/null @@ -1,293 +0,0 @@ -// 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 HelloWorld.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "HelloWorldTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define HelloWorld_max_cdr_typesize 268ULL; - - - - -HelloWorld::HelloWorld() -{ - // unsigned long m_index - m_index = 0; - // /type_d() m_message - - - // Just to register all known types - registerHelloWorldTypes(); -} - -HelloWorld::~HelloWorld() -{ -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -size_t HelloWorld::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return HelloWorld_max_cdr_typesize; -} - -size_t HelloWorld::getCdrSerializedSize( - const HelloWorld& 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 HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_index; - - scdr << m_message.c_str(); - -} - -void HelloWorld::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_index; - - - - dcdr >> m_message; - - -} - -bool HelloWorld::isKeyDefined() -{ - return false; -} - -void HelloWorld::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::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 HelloWorld::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& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& HelloWorld::message() -{ - return m_message; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldv1.h b/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldv1.h deleted file mode 100644 index aae554340..000000000 --- a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldv1.h +++ /dev/null @@ -1,242 +0,0 @@ -// 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 HelloWorld.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_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(HELLOWORLD_SOURCE) -#define HELLOWORLD_DllAPI __declspec( dllexport ) -#else -#define HELLOWORLD_DllAPI __declspec( dllimport ) -#endif // HELLOWORLD_SOURCE -#else -#define HELLOWORLD_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HELLOWORLD_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorld -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport HelloWorld(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~HelloWorld(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - const HelloWorld& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator !=( - const HelloWorld& 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 HelloWorld& 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 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_HELLOWORLD_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder_participants/CMakeLists.txt b/ddsrecorder_participants/CMakeLists.txt index 881cd149c..e63995ff0 100644 --- a/ddsrecorder_participants/CMakeLists.txt +++ b/ddsrecorder_participants/CMakeLists.txt @@ -70,15 +70,6 @@ file( "${PROJECT_SOURCE_DIR}/include/*.h*" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER SOURCES_FILES EXCLUDE REGEX "v2/") - list(FILTER HEADERS_FILES EXCLUDE REGEX "v2/") -else() - list(FILTER SOURCES_FILES EXCLUDE REGEX "v1/") - list(FILTER HEADERS_FILES EXCLUDE REGEX "v1/") -endif() - # Compile C++ library compile_library( "${PROJECT_SOURCE_DIR}/src/cpp" # Source directory diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollection.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollection.hpp similarity index 59% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollection.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollection.hpp index 21ded9b4a..7889fd1fd 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollection.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollection.hpp @@ -13,32 +13,21 @@ // limitations under the License. /*! - * @file DynamicTypesCollection.h + * @file DynamicTypesCollection.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "DynamicTypesCollectionv1.hpp" +#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_HPP_ +#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_HPP_ -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ -#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ - -#include -#include #include -#include #include +#include #include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,23 +53,12 @@ #define DYNAMICTYPESCOLLECTION_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - namespace eprosima { namespace ddsrecorder { namespace participants { - - /*! * @brief This class represents the structure DynamicType defined by the user in the IDL file. * @ingroup DynamicTypesCollection @@ -92,80 +70,134 @@ class DynamicType /*! * @brief Default constructor. */ - eProsima_user_DllExport DynamicType(); + eProsima_user_DllExport DynamicType() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~DynamicType(); + eProsima_user_DllExport ~DynamicType() + { + } /*! * @brief Copy constructor. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. + * @param x Reference to the object DynamicType that will be copied. */ eProsima_user_DllExport DynamicType( - const DynamicType& x); + const DynamicType& x) + { + m_type_name = x.m_type_name; + + m_type_information = x.m_type_information; + + m_type_object = x.m_type_object; + + } /*! * @brief Move constructor. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. + * @param x Reference to the object DynamicType that will be copied. */ eProsima_user_DllExport DynamicType( - DynamicType&& x) noexcept; + DynamicType&& x) noexcept + { + m_type_name = std::move(x.m_type_name); + m_type_information = std::move(x.m_type_information); + m_type_object = std::move(x.m_type_object); + } /*! * @brief Copy assignment. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. + * @param x Reference to the object DynamicType that will be copied. */ eProsima_user_DllExport DynamicType& operator =( - const DynamicType& x); + const DynamicType& x) + { + + m_type_name = x.m_type_name; + + m_type_information = x.m_type_information; + + m_type_object = x.m_type_object; + + return *this; + } /*! * @brief Move assignment. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. + * @param x Reference to the object DynamicType that will be copied. */ eProsima_user_DllExport DynamicType& operator =( - DynamicType&& x) noexcept; + DynamicType&& x) noexcept + { + + m_type_name = std::move(x.m_type_name); + m_type_information = std::move(x.m_type_information); + m_type_object = std::move(x.m_type_object); + return *this; + } /*! * @brief Comparison operator. - * @param x eprosima::ddsrecorder::participants::DynamicType object to compare. + * @param x DynamicType object to compare. */ eProsima_user_DllExport bool operator ==( - const DynamicType& x) const; + const DynamicType& x) const + { + return (m_type_name == x.m_type_name && + m_type_information == x.m_type_information && + m_type_object == x.m_type_object); + } /*! * @brief Comparison operator. - * @param x eprosima::ddsrecorder::participants::DynamicType object to compare. + * @param x DynamicType object to compare. */ eProsima_user_DllExport bool operator !=( - const DynamicType& x) const; + const DynamicType& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member type_name * @param _type_name New value to be copied in member type_name */ eProsima_user_DllExport void type_name( - const std::string& _type_name); + const std::string& _type_name) + { + m_type_name = _type_name; + } /*! * @brief This function moves the value in member type_name * @param _type_name New value to be moved in member type_name */ eProsima_user_DllExport void type_name( - std::string&& _type_name); + std::string&& _type_name) + { + m_type_name = std::move(_type_name); + } /*! * @brief This function returns a constant reference to member type_name * @return Constant reference to member type_name */ - eProsima_user_DllExport const std::string& type_name() const; + eProsima_user_DllExport const std::string& type_name() const + { + return m_type_name; + } /*! * @brief This function returns a reference to member type_name * @return Reference to member type_name */ - eProsima_user_DllExport std::string& type_name(); + eProsima_user_DllExport std::string& type_name() + { + return m_type_name; + } /*! @@ -173,26 +205,38 @@ class DynamicType * @param _type_information New value to be copied in member type_information */ eProsima_user_DllExport void type_information( - const std::string& _type_information); + const std::string& _type_information) + { + m_type_information = _type_information; + } /*! * @brief This function moves the value in member type_information * @param _type_information New value to be moved in member type_information */ eProsima_user_DllExport void type_information( - std::string&& _type_information); + std::string&& _type_information) + { + m_type_information = std::move(_type_information); + } /*! * @brief This function returns a constant reference to member type_information * @return Constant reference to member type_information */ - eProsima_user_DllExport const std::string& type_information() const; + eProsima_user_DllExport const std::string& type_information() const + { + return m_type_information; + } /*! * @brief This function returns a reference to member type_information * @return Reference to member type_information */ - eProsima_user_DllExport std::string& type_information(); + eProsima_user_DllExport std::string& type_information() + { + return m_type_information; + } /*! @@ -200,26 +244,40 @@ class DynamicType * @param _type_object New value to be copied in member type_object */ eProsima_user_DllExport void type_object( - const std::string& _type_object); + const std::string& _type_object) + { + m_type_object = _type_object; + } /*! * @brief This function moves the value in member type_object * @param _type_object New value to be moved in member type_object */ eProsima_user_DllExport void type_object( - std::string&& _type_object); + std::string&& _type_object) + { + m_type_object = std::move(_type_object); + } /*! * @brief This function returns a constant reference to member type_object * @return Constant reference to member type_object */ - eProsima_user_DllExport const std::string& type_object() const; + eProsima_user_DllExport const std::string& type_object() const + { + return m_type_object; + } /*! * @brief This function returns a reference to member type_object * @return Reference to member type_object */ - eProsima_user_DllExport std::string& type_object(); + eProsima_user_DllExport std::string& type_object() + { + return m_type_object; + } + + private: @@ -228,10 +286,6 @@ class DynamicType std::string m_type_object; }; - - - - /*! * @brief This class represents the structure DynamicTypesCollection defined by the user in the IDL file. * @ingroup DynamicTypesCollection @@ -243,84 +297,126 @@ class DynamicTypesCollection /*! * @brief Default constructor. */ - eProsima_user_DllExport DynamicTypesCollection(); + eProsima_user_DllExport DynamicTypesCollection() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~DynamicTypesCollection(); + eProsima_user_DllExport ~DynamicTypesCollection() + { + } /*! * @brief Copy constructor. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. + * @param x Reference to the object DynamicTypesCollection that will be copied. */ eProsima_user_DllExport DynamicTypesCollection( - const DynamicTypesCollection& x); + const DynamicTypesCollection& x) + { + m_dynamic_types = x.m_dynamic_types; + + } /*! * @brief Move constructor. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. + * @param x Reference to the object DynamicTypesCollection that will be copied. */ eProsima_user_DllExport DynamicTypesCollection( - DynamicTypesCollection&& x) noexcept; + DynamicTypesCollection&& x) noexcept + { + m_dynamic_types = std::move(x.m_dynamic_types); + } /*! * @brief Copy assignment. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. + * @param x Reference to the object DynamicTypesCollection that will be copied. */ eProsima_user_DllExport DynamicTypesCollection& operator =( - const DynamicTypesCollection& x); + const DynamicTypesCollection& x) + { + + m_dynamic_types = x.m_dynamic_types; + + return *this; + } /*! * @brief Move assignment. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. + * @param x Reference to the object DynamicTypesCollection that will be copied. */ eProsima_user_DllExport DynamicTypesCollection& operator =( - DynamicTypesCollection&& x) noexcept; + DynamicTypesCollection&& x) noexcept + { + + m_dynamic_types = std::move(x.m_dynamic_types); + return *this; + } /*! * @brief Comparison operator. - * @param x eprosima::ddsrecorder::participants::DynamicTypesCollection object to compare. + * @param x DynamicTypesCollection object to compare. */ eProsima_user_DllExport bool operator ==( - const DynamicTypesCollection& x) const; + const DynamicTypesCollection& x) const + { + return (m_dynamic_types == x.m_dynamic_types); + } /*! * @brief Comparison operator. - * @param x eprosima::ddsrecorder::participants::DynamicTypesCollection object to compare. + * @param x DynamicTypesCollection object to compare. */ eProsima_user_DllExport bool operator !=( - const DynamicTypesCollection& x) const; + const DynamicTypesCollection& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member dynamic_types * @param _dynamic_types New value to be copied in member dynamic_types */ eProsima_user_DllExport void dynamic_types( - const std::vector& _dynamic_types); + const std::vector& _dynamic_types) + { + m_dynamic_types = _dynamic_types; + } /*! * @brief This function moves the value in member dynamic_types * @param _dynamic_types New value to be moved in member dynamic_types */ eProsima_user_DllExport void dynamic_types( - std::vector&& _dynamic_types); + std::vector&& _dynamic_types) + { + m_dynamic_types = std::move(_dynamic_types); + } /*! * @brief This function returns a constant reference to member dynamic_types * @return Constant reference to member dynamic_types */ - eProsima_user_DllExport const std::vector& dynamic_types() const; + eProsima_user_DllExport const std::vector& dynamic_types() const + { + return m_dynamic_types; + } /*! * @brief This function returns a reference to member dynamic_types * @return Reference to member dynamic_types */ - eProsima_user_DllExport std::vector& dynamic_types(); + eProsima_user_DllExport std::vector& dynamic_types() + { + return m_dynamic_types; + } + + private: - std::vector m_dynamic_types; + std::vector m_dynamic_types; }; @@ -330,8 +426,6 @@ class DynamicTypesCollection } // namespace eprosima -#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ - +#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollection.idl b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollection.idl similarity index 100% rename from ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollection.idl rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollection.idl diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h new file mode 100644 index 000000000..c09fa6e58 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h @@ -0,0 +1,233 @@ +// 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 DynamicTypesCollectionPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + + +#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ + +#include +#include +#include +#include +#include + +#include "DynamicTypesCollection.hpp" + + +#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#error \ + Generated DynamicTypesCollection is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. +#endif // GEN_API_VER + +namespace eprosima +{ + namespace ddsrecorder + { + namespace participants + { + + /*! + * @brief This class represents the TopicDataType of the type DynamicType defined by the user in the IDL file. + * @ingroup DynamicTypesCollection + */ + class DynamicTypePubSubType : public eprosima::fastdds::dds::TopicDataType + { + public: + + typedef DynamicType type; + + eProsima_user_DllExport DynamicTypePubSubType(); + + eProsima_user_DllExport ~DynamicTypePubSubType() override; + + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport void* createData() override; + + eProsima_user_DllExport void deleteData( + void* data) override; + + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() 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; + } + + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + 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 + { + static_cast(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 DynamicTypesCollection defined by the user in the IDL file. + * @ingroup DynamicTypesCollection + */ + class DynamicTypesCollectionPubSubType : public eprosima::fastdds::dds::TopicDataType + { + public: + + typedef DynamicTypesCollection type; + + eProsima_user_DllExport DynamicTypesCollectionPubSubType(); + + eProsima_user_DllExport ~DynamicTypesCollectionPubSubType() override; + + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport void* createData() override; + + eProsima_user_DllExport void deleteData( + void* data) override; + + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() 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; + } + + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + 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 + { + static_cast(memory); + return false; + } + + #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; + + }; + } // namespace participants + } // namespace ddsrecorder +} // namespace eprosima + +#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ + diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.hpp new file mode 100644 index 000000000..ac7c82e12 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.hpp @@ -0,0 +1,78 @@ +// 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 DynamicTypesCollectionTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +namespace eprosima { +namespace ddsrecorder { +namespace participants { +/** + * @brief Register DynamicType related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_DynamicType_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + +/** + * @brief Register DynamicTypesCollection related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_DynamicTypesCollection_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + +} // namespace participants + +} // namespace ddsrecorder + +} // namespace eprosima + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v1/DynamicTypesCollection.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v1/DynamicTypesCollection.hpp deleted file mode 100644 index 457ce1788..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v1/DynamicTypesCollection.hpp +++ /dev/null @@ -1,414 +0,0 @@ -// 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 DynamicTypesCollection.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool gen. - */ - -#pragma once - -#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(DYNAMICTYPESCOLLECTION_SOURCE) -#define DYNAMICTYPESCOLLECTION_DllAPI __declspec( dllexport ) -#else -#define DYNAMICTYPESCOLLECTION_DllAPI __declspec( dllimport ) -#endif // DYNAMICTYPESCOLLECTION_SOURCE -#else -#define DYNAMICTYPESCOLLECTION_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DYNAMICTYPESCOLLECTION_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - -/*! - * @brief This class represents the structure DynamicType defined by the user in the IDL file. - * @ingroup DynamicTypesCollection - */ -class DynamicType -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DynamicType(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DynamicType(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DynamicType that will be copied. - */ - eProsima_user_DllExport DynamicType( - const DynamicType& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DynamicType that will be copied. - */ - eProsima_user_DllExport DynamicType( - DynamicType&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DynamicType that will be copied. - */ - eProsima_user_DllExport DynamicType& operator =( - const DynamicType& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DynamicType that will be copied. - */ - eProsima_user_DllExport DynamicType& operator =( - DynamicType&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DynamicType object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DynamicType& x) const; - - /*! - * @brief Comparison operator. - * @param x DynamicType object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DynamicType& x) const; - - /*! - * @brief This function copies the value in member type_name - * @param _type_name New value to be copied in member type_name - */ - eProsima_user_DllExport void type_name( - const std::string& _type_name); - - /*! - * @brief This function moves the value in member type_name - * @param _type_name New value to be moved in member type_name - */ - eProsima_user_DllExport void type_name( - std::string&& _type_name); - - /*! - * @brief This function returns a constant reference to member type_name - * @return Constant reference to member type_name - */ - eProsima_user_DllExport const std::string& type_name() const; - - /*! - * @brief This function returns a reference to member type_name - * @return Reference to member type_name - */ - eProsima_user_DllExport std::string& type_name(); - /*! - * @brief This function copies the value in member type_information - * @param _type_information New value to be copied in member type_information - */ - eProsima_user_DllExport void type_information( - const std::string& _type_information); - - /*! - * @brief This function moves the value in member type_information - * @param _type_information New value to be moved in member type_information - */ - eProsima_user_DllExport void type_information( - std::string&& _type_information); - - /*! - * @brief This function returns a constant reference to member type_information - * @return Constant reference to member type_information - */ - eProsima_user_DllExport const std::string& type_information() const; - - /*! - * @brief This function returns a reference to member type_information - * @return Reference to member type_information - */ - eProsima_user_DllExport std::string& type_information(); - /*! - * @brief This function copies the value in member type_object - * @param _type_object New value to be copied in member type_object - */ - eProsima_user_DllExport void type_object( - const std::string& _type_object); - - /*! - * @brief This function moves the value in member type_object - * @param _type_object New value to be moved in member type_object - */ - eProsima_user_DllExport void type_object( - std::string&& _type_object); - - /*! - * @brief This function returns a constant reference to member type_object - * @return Constant reference to member type_object - */ - eProsima_user_DllExport const std::string& type_object() const; - - /*! - * @brief This function returns a reference to member type_object - * @return Reference to member type_object - */ - eProsima_user_DllExport std::string& type_object(); - - /*! - * @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 DynamicType& 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_type_name; - std::string m_type_information; - std::string m_type_object; - -}; -/*! - * @brief This class represents the structure DynamicTypesCollection defined by the user in the IDL file. - * @ingroup DynamicTypesCollection - */ -class DynamicTypesCollection -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DynamicTypesCollection(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DynamicTypesCollection(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DynamicTypesCollection that will be copied. - */ - eProsima_user_DllExport DynamicTypesCollection( - const DynamicTypesCollection& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DynamicTypesCollection that will be copied. - */ - eProsima_user_DllExport DynamicTypesCollection( - DynamicTypesCollection&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DynamicTypesCollection that will be copied. - */ - eProsima_user_DllExport DynamicTypesCollection& operator =( - const DynamicTypesCollection& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DynamicTypesCollection that will be copied. - */ - eProsima_user_DllExport DynamicTypesCollection& operator =( - DynamicTypesCollection&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DynamicTypesCollection object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DynamicTypesCollection& x) const; - - /*! - * @brief Comparison operator. - * @param x DynamicTypesCollection object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DynamicTypesCollection& x) const; - - /*! - * @brief This function copies the value in member dynamic_types - * @param _dynamic_types New value to be copied in member dynamic_types - */ - eProsima_user_DllExport void dynamic_types( - const std::vector& _dynamic_types); - - /*! - * @brief This function moves the value in member dynamic_types - * @param _dynamic_types New value to be moved in member dynamic_types - */ - eProsima_user_DllExport void dynamic_types( - std::vector&& _dynamic_types); - - /*! - * @brief This function returns a constant reference to member dynamic_types - * @return Constant reference to member dynamic_types - */ - eProsima_user_DllExport const std::vector& dynamic_types() const; - - /*! - * @brief This function returns a reference to member dynamic_types - * @return Reference to member dynamic_types - */ - eProsima_user_DllExport std::vector& dynamic_types(); - - /*! - * @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 DynamicTypesCollection& 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_dynamic_types; - -}; - -} /* namespace participants */ -} /* namespace ddsrecorder */ -} /* namespace eprosima */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v1/DynamicTypesCollectionPubSubTypes.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v1/DynamicTypesCollectionPubSubTypes.hpp deleted file mode 100644 index 393296d12..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v1/DynamicTypesCollectionPubSubTypes.hpp +++ /dev/null @@ -1,174 +0,0 @@ -// 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 DynamicTypesCollectionPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#pragma once - -#include -#include - -#include - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated DynamicTypesCollection 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 DynamicType defined by the user in the IDL file. - * @ingroup DynamicTypesCollection - */ -class DynamicTypePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DynamicType type; - - eProsima_user_DllExport DynamicTypePubSubType(); - - eProsima_user_DllExport virtual ~DynamicTypePubSubType() 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 DynamicTypesCollection defined by the user in the IDL file. - * @ingroup DynamicTypesCollection - */ -class DynamicTypesCollectionPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DynamicTypesCollection type; - - eProsima_user_DllExport DynamicTypesCollectionPubSubType(); - - eProsima_user_DllExport virtual ~DynamicTypesCollectionPubSubType() 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; -}; - -} /* namespace participants */ -} /* namespace ddsrecorder */ -} /* namespace eprosima */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollectionPubSubTypes.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollectionPubSubTypes.hpp deleted file mode 100644 index 470e635a5..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollectionPubSubTypes.hpp +++ /dev/null @@ -1,229 +0,0 @@ -// 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 DynamicTypesCollectionPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated DynamicTypesCollection is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - - - -/*! - * @brief This class represents the TopicDataType of the type DynamicType defined by the user in the IDL file. - * @ingroup DynamicTypesCollection - */ -class DynamicTypePubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DynamicType type; - - eProsima_user_DllExport DynamicTypePubSubType(); - - eProsima_user_DllExport ~DynamicTypePubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - 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 - { - static_cast(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 DynamicTypesCollection defined by the user in the IDL file. - * @ingroup DynamicTypesCollection - */ -class DynamicTypesCollectionPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DynamicTypesCollection type; - - eProsima_user_DllExport DynamicTypesCollectionPubSubType(); - - eProsima_user_DllExport ~DynamicTypesCollectionPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - 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 - { - static_cast(memory); - return false; - } - - #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; -} // namespace participants -} // namespace ddsrecorder -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollectionv1.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollectionv1.hpp deleted file mode 100644 index 5db93545e..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/v2/DynamicTypesCollectionv1.hpp +++ /dev/null @@ -1,430 +0,0 @@ -// 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 DynamicTypesCollection.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ -#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_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(DYNAMICTYPESCOLLECTION_SOURCE) -#define DYNAMICTYPESCOLLECTION_DllAPI __declspec( dllexport ) -#else -#define DYNAMICTYPESCOLLECTION_DllAPI __declspec( dllimport ) -#endif // DYNAMICTYPESCOLLECTION_SOURCE -#else -#define DYNAMICTYPESCOLLECTION_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DYNAMICTYPESCOLLECTION_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - - -/*! - * @brief This class represents the structure DynamicType defined by the user in the IDL file. - * @ingroup DynamicTypesCollection - */ -class DynamicType -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DynamicType(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DynamicType(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. - */ - eProsima_user_DllExport DynamicType( - const DynamicType& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. - */ - eProsima_user_DllExport DynamicType( - DynamicType&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. - */ - eProsima_user_DllExport DynamicType& operator =( - const DynamicType& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicType that will be copied. - */ - eProsima_user_DllExport DynamicType& operator =( - DynamicType&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x eprosima::ddsrecorder::participants::DynamicType object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DynamicType& x) const; - - /*! - * @brief Comparison operator. - * @param x eprosima::ddsrecorder::participants::DynamicType object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DynamicType& x) const; - - /*! - * @brief This function copies the value in member type_name - * @param _type_name New value to be copied in member type_name - */ - eProsima_user_DllExport void type_name( - const std::string& _type_name); - - /*! - * @brief This function moves the value in member type_name - * @param _type_name New value to be moved in member type_name - */ - eProsima_user_DllExport void type_name( - std::string&& _type_name); - - /*! - * @brief This function returns a constant reference to member type_name - * @return Constant reference to member type_name - */ - eProsima_user_DllExport const std::string& type_name() const; - - /*! - * @brief This function returns a reference to member type_name - * @return Reference to member type_name - */ - eProsima_user_DllExport std::string& type_name(); - - - /*! - * @brief This function copies the value in member type_information - * @param _type_information New value to be copied in member type_information - */ - eProsima_user_DllExport void type_information( - const std::string& _type_information); - - /*! - * @brief This function moves the value in member type_information - * @param _type_information New value to be moved in member type_information - */ - eProsima_user_DllExport void type_information( - std::string&& _type_information); - - /*! - * @brief This function returns a constant reference to member type_information - * @return Constant reference to member type_information - */ - eProsima_user_DllExport const std::string& type_information() const; - - /*! - * @brief This function returns a reference to member type_information - * @return Reference to member type_information - */ - eProsima_user_DllExport std::string& type_information(); - - - /*! - * @brief This function copies the value in member type_object - * @param _type_object New value to be copied in member type_object - */ - eProsima_user_DllExport void type_object( - const std::string& _type_object); - - /*! - * @brief This function moves the value in member type_object - * @param _type_object New value to be moved in member type_object - */ - eProsima_user_DllExport void type_object( - std::string&& _type_object); - - /*! - * @brief This function returns a constant reference to member type_object - * @return Constant reference to member type_object - */ - eProsima_user_DllExport const std::string& type_object() const; - - /*! - * @brief This function returns a reference to member type_object - * @return Reference to member type_object - */ - eProsima_user_DllExport std::string& type_object(); - - - /*! - * @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 eprosima::ddsrecorder::participants::DynamicType& 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 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_type_name; - std::string m_type_information; - std::string m_type_object; - -}; - - - - - -/*! - * @brief This class represents the structure DynamicTypesCollection defined by the user in the IDL file. - * @ingroup DynamicTypesCollection - */ -class DynamicTypesCollection -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DynamicTypesCollection(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DynamicTypesCollection(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. - */ - eProsima_user_DllExport DynamicTypesCollection( - const DynamicTypesCollection& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. - */ - eProsima_user_DllExport DynamicTypesCollection( - DynamicTypesCollection&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. - */ - eProsima_user_DllExport DynamicTypesCollection& operator =( - const DynamicTypesCollection& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object eprosima::ddsrecorder::participants::DynamicTypesCollection that will be copied. - */ - eProsima_user_DllExport DynamicTypesCollection& operator =( - DynamicTypesCollection&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x eprosima::ddsrecorder::participants::DynamicTypesCollection object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DynamicTypesCollection& x) const; - - /*! - * @brief Comparison operator. - * @param x eprosima::ddsrecorder::participants::DynamicTypesCollection object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DynamicTypesCollection& x) const; - - /*! - * @brief This function copies the value in member dynamic_types - * @param _dynamic_types New value to be copied in member dynamic_types - */ - eProsima_user_DllExport void dynamic_types( - const std::vector& _dynamic_types); - - /*! - * @brief This function moves the value in member dynamic_types - * @param _dynamic_types New value to be moved in member dynamic_types - */ - eProsima_user_DllExport void dynamic_types( - std::vector&& _dynamic_types); - - /*! - * @brief This function returns a constant reference to member dynamic_types - * @return Constant reference to member dynamic_types - */ - eProsima_user_DllExport const std::vector& dynamic_types() const; - - /*! - * @brief This function returns a reference to member dynamic_types - * @return Reference to member dynamic_types - */ - eProsima_user_DllExport std::vector& dynamic_types(); - - - /*! - * @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 eprosima::ddsrecorder::participants::DynamicTypesCollection& 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 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_dynamic_types; - -}; - -} // namespace participants -} // namespace ddsrecorder -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v1/DdsRecorderLogEntry.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntry.hpp similarity index 77% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v1/DdsRecorderLogEntry.h rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntry.hpp index caa255562..8114c38c2 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v1/DdsRecorderLogEntry.h +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntry.hpp @@ -13,24 +13,17 @@ // limitations under the License. /*! - * @file DdsRecorderLogEntry.h + * @file DdsRecorderLogEntry.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_H_ +#ifndef _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_HPP_ - -#include - -#include -#include -#include -#include -#include -#include +#include +#include #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -56,20 +49,9 @@ #define DDSRECORDERLOGENTRY_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - const int32_t FAIL_MCAP_CREATION = 0x12000001; - const int32_t FAIL_MCAP_WRITE = 0x12000002; - -#endif // _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_H_ - +#endif // _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_HPP_ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v1/DdsRecorderLogEntryPubSubTypes.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryPubSubTypes.h similarity index 92% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v1/DdsRecorderLogEntryPubSubTypes.h rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryPubSubTypes.h index fd4522fe8..5e46fa646 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v1/DdsRecorderLogEntryPubSubTypes.h +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryPubSubTypes.h @@ -27,9 +27,9 @@ #include #include #include -#include +#include -#include +#include "DdsRecorderLogEntry.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,5 @@ #endif // GEN_API_VER - - - - #endif // _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_PUBSUBTYPES_H_ + diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.hpp new file mode 100644 index 000000000..4f7dc76f3 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.hpp @@ -0,0 +1,43 @@ +// 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 DdsRecorderLogEntryTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntry.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntry.h deleted file mode 100644 index 7ec9a05b5..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntry.h +++ /dev/null @@ -1,83 +0,0 @@ -// 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 DdsRecorderLogEntry.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include -#include "DdsRecorderLogEntryv1.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_H_ - -#include -#include -#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(DDSRECORDERLOGENTRY_SOURCE) -#define DDSRECORDERLOGENTRY_DllAPI __declspec( dllexport ) -#else -#define DDSRECORDERLOGENTRY_DllAPI __declspec( dllimport ) -#endif // DDSRECORDERLOGENTRY_SOURCE -#else -#define DDSRECORDERLOGENTRY_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DDSRECORDERLOGENTRY_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - -const int32_t FAIL_MCAP_CREATION = 0x12000001; -const int32_t FAIL_MCAP_WRITE = 0x12000002; - -#endif // _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_H_ - - - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntryPubSubTypes.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntryPubSubTypes.h deleted file mode 100644 index 7c8b97ac9..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntryPubSubTypes.h +++ /dev/null @@ -1,45 +0,0 @@ -// 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 DdsRecorderLogEntryPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated DdsRecorderLogEntry is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. -#endif // GEN_API_VER - - - - - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_PUBSUBTYPES_H_ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntryv1.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntryv1.h deleted file mode 100644 index f20459249..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/v2/DdsRecorderLogEntryv1.h +++ /dev/null @@ -1,80 +0,0 @@ -// 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 DdsRecorderLogEntry.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_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(DDSRECORDERLOGENTRY_SOURCE) -#define DDSRECORDERLOGENTRY_DllAPI __declspec( dllexport ) -#else -#define DDSRECORDERLOGENTRY_DllAPI __declspec( dllimport ) -#endif // DDSRECORDERLOGENTRY_SOURCE -#else -#define DDSRECORDERLOGENTRY_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DDSRECORDERLOGENTRY_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - -const int32_t FAIL_MCAP_CREATION = 0x12000001; - -const int32_t FAIL_MCAP_WRITE = 0x12000002; - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatus.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatus.hpp similarity index 64% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatus.h rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatus.hpp index 1849d5410..35da36d3a 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatus.h +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatus.hpp @@ -13,33 +13,18 @@ // limitations under the License. /*! - * @file DdsRecorderMonitoringStatus.h + * @file DdsRecorderMonitoringStatus.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "DdsRecorderMonitoringStatusv1.h" +#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_HPP_ -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_H_ - -#include -#include #include -#include -#include -#include - -#include -#include -#include - -#include "ddspipe_core/types/monitoring/status/v2/MonitoringStatus.h" - +#include +#include "ddspipe_core/types/monitoring/status/MonitoringStatus.hpp" #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -65,17 +50,6 @@ #define DDSRECORDERMONITORINGSTATUS_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure DdsRecorderMonitoringErrorStatus defined by the user in the IDL file. * @ingroup DdsRecorderMonitoringStatus @@ -87,73 +61,117 @@ class DdsRecorderMonitoringErrorStatus /*! * @brief Default constructor. */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus(); + eProsima_user_DllExport DdsRecorderMonitoringErrorStatus() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~DdsRecorderMonitoringErrorStatus(); + eProsima_user_DllExport ~DdsRecorderMonitoringErrorStatus() + { + } /*! * @brief Copy constructor. * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. */ eProsima_user_DllExport DdsRecorderMonitoringErrorStatus( - const DdsRecorderMonitoringErrorStatus& x); + const DdsRecorderMonitoringErrorStatus& x) + { + m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; + + m_disk_full = x.m_disk_full; + + } /*! * @brief Move constructor. * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. */ eProsima_user_DllExport DdsRecorderMonitoringErrorStatus( - DdsRecorderMonitoringErrorStatus&& x) noexcept; + DdsRecorderMonitoringErrorStatus&& x) noexcept + { + m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; + m_disk_full = x.m_disk_full; + } /*! * @brief Copy assignment. * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. */ eProsima_user_DllExport DdsRecorderMonitoringErrorStatus& operator =( - const DdsRecorderMonitoringErrorStatus& x); + const DdsRecorderMonitoringErrorStatus& x) + { + + m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; + + m_disk_full = x.m_disk_full; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. */ eProsima_user_DllExport DdsRecorderMonitoringErrorStatus& operator =( - DdsRecorderMonitoringErrorStatus&& x) noexcept; + DdsRecorderMonitoringErrorStatus&& x) noexcept + { + + m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; + m_disk_full = x.m_disk_full; + return *this; + } /*! * @brief Comparison operator. * @param x DdsRecorderMonitoringErrorStatus object to compare. */ eProsima_user_DllExport bool operator ==( - const DdsRecorderMonitoringErrorStatus& x) const; + const DdsRecorderMonitoringErrorStatus& x) const + { + return (m_mcap_file_creation_failure == x.m_mcap_file_creation_failure && + m_disk_full == x.m_disk_full); + } /*! * @brief Comparison operator. * @param x DdsRecorderMonitoringErrorStatus object to compare. */ eProsima_user_DllExport bool operator !=( - const DdsRecorderMonitoringErrorStatus& x) const; + const DdsRecorderMonitoringErrorStatus& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member mcap_file_creation_failure * @param _mcap_file_creation_failure New value for member mcap_file_creation_failure */ eProsima_user_DllExport void mcap_file_creation_failure( - bool _mcap_file_creation_failure); + bool _mcap_file_creation_failure) + { + m_mcap_file_creation_failure = _mcap_file_creation_failure; + } /*! * @brief This function returns the value of member mcap_file_creation_failure * @return Value of member mcap_file_creation_failure */ - eProsima_user_DllExport bool mcap_file_creation_failure() const; + eProsima_user_DllExport bool mcap_file_creation_failure() const + { + return m_mcap_file_creation_failure; + } /*! * @brief This function returns a reference to member mcap_file_creation_failure * @return Reference to member mcap_file_creation_failure */ - eProsima_user_DllExport bool& mcap_file_creation_failure(); + eProsima_user_DllExport bool& mcap_file_creation_failure() + { + return m_mcap_file_creation_failure; + } /*! @@ -161,19 +179,30 @@ class DdsRecorderMonitoringErrorStatus * @param _disk_full New value for member disk_full */ eProsima_user_DllExport void disk_full( - bool _disk_full); + bool _disk_full) + { + m_disk_full = _disk_full; + } /*! * @brief This function returns the value of member disk_full * @return Value of member disk_full */ - eProsima_user_DllExport bool disk_full() const; + eProsima_user_DllExport bool disk_full() const + { + return m_disk_full; + } /*! * @brief This function returns a reference to member disk_full * @return Reference to member disk_full */ - eProsima_user_DllExport bool& disk_full(); + eProsima_user_DllExport bool& disk_full() + { + return m_disk_full; + } + + private: @@ -181,8 +210,6 @@ class DdsRecorderMonitoringErrorStatus bool m_disk_full{false}; }; - - /*! * @brief This class represents the structure DdsRecorderMonitoringStatus defined by the user in the IDL file. * @ingroup DdsRecorderMonitoringStatus @@ -194,80 +221,132 @@ class DdsRecorderMonitoringStatus : public MonitoringStatus /*! * @brief Default constructor. */ - eProsima_user_DllExport DdsRecorderMonitoringStatus(); + eProsima_user_DllExport DdsRecorderMonitoringStatus() + : MonitoringStatus() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~DdsRecorderMonitoringStatus(); + eProsima_user_DllExport ~DdsRecorderMonitoringStatus() + { + } /*! * @brief Copy constructor. * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. */ eProsima_user_DllExport DdsRecorderMonitoringStatus( - const DdsRecorderMonitoringStatus& x); + const DdsRecorderMonitoringStatus& x) + : MonitoringStatus(x) + { + m_ddsrecorder_error_status = x.m_ddsrecorder_error_status; + + } /*! * @brief Move constructor. * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. */ eProsima_user_DllExport DdsRecorderMonitoringStatus( - DdsRecorderMonitoringStatus&& x) noexcept; + DdsRecorderMonitoringStatus&& x) noexcept + : MonitoringStatus(std::move(x)) + + { + m_ddsrecorder_error_status = std::move(x.m_ddsrecorder_error_status); + } /*! * @brief Copy assignment. * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. */ eProsima_user_DllExport DdsRecorderMonitoringStatus& operator =( - const DdsRecorderMonitoringStatus& x); + const DdsRecorderMonitoringStatus& x) + { + MonitoringStatus::operator =(x); + + m_ddsrecorder_error_status = x.m_ddsrecorder_error_status; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. */ eProsima_user_DllExport DdsRecorderMonitoringStatus& operator =( - DdsRecorderMonitoringStatus&& x) noexcept; + DdsRecorderMonitoringStatus&& x) noexcept + { + MonitoringStatus::operator =(std::move(x)); + + m_ddsrecorder_error_status = std::move(x.m_ddsrecorder_error_status); + return *this; + } /*! * @brief Comparison operator. * @param x DdsRecorderMonitoringStatus object to compare. */ eProsima_user_DllExport bool operator ==( - const DdsRecorderMonitoringStatus& x) const; + const DdsRecorderMonitoringStatus& x) const + { + if (MonitoringStatus::operator !=(x)) + { + return false; + } + return (m_ddsrecorder_error_status == x.m_ddsrecorder_error_status); + } /*! * @brief Comparison operator. * @param x DdsRecorderMonitoringStatus object to compare. */ eProsima_user_DllExport bool operator !=( - const DdsRecorderMonitoringStatus& x) const; + const DdsRecorderMonitoringStatus& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member ddsrecorder_error_status * @param _ddsrecorder_error_status New value to be copied in member ddsrecorder_error_status */ eProsima_user_DllExport void ddsrecorder_error_status( - const DdsRecorderMonitoringErrorStatus& _ddsrecorder_error_status); + const DdsRecorderMonitoringErrorStatus& _ddsrecorder_error_status) + { + m_ddsrecorder_error_status = _ddsrecorder_error_status; + } /*! * @brief This function moves the value in member ddsrecorder_error_status * @param _ddsrecorder_error_status New value to be moved in member ddsrecorder_error_status */ eProsima_user_DllExport void ddsrecorder_error_status( - DdsRecorderMonitoringErrorStatus&& _ddsrecorder_error_status); + DdsRecorderMonitoringErrorStatus&& _ddsrecorder_error_status) + { + m_ddsrecorder_error_status = std::move(_ddsrecorder_error_status); + } /*! * @brief This function returns a constant reference to member ddsrecorder_error_status * @return Constant reference to member ddsrecorder_error_status */ - eProsima_user_DllExport const DdsRecorderMonitoringErrorStatus& ddsrecorder_error_status() const; + eProsima_user_DllExport const DdsRecorderMonitoringErrorStatus& ddsrecorder_error_status() const + { + return m_ddsrecorder_error_status; + } /*! * @brief This function returns a reference to member ddsrecorder_error_status * @return Reference to member ddsrecorder_error_status */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus& ddsrecorder_error_status(); + eProsima_user_DllExport DdsRecorderMonitoringErrorStatus& ddsrecorder_error_status() + { + return m_ddsrecorder_error_status; + } + + private: @@ -275,8 +354,6 @@ class DdsRecorderMonitoringStatus : public MonitoringStatus }; -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_H_ - +#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusCdrAux.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.hpp similarity index 93% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusCdrAux.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.hpp index 41ae33aee..0e5f11341 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusCdrAux.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.hpp @@ -22,7 +22,7 @@ #ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_HPP_ #define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_HPP_ -#include +#include "DdsRecorderMonitoringStatus.hpp" constexpr uint32_t DdsRecorderMonitoringErrorStatus_max_cdr_typesize {6UL}; constexpr uint32_t DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize {0UL}; @@ -38,14 +38,10 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsRecorderMonitoringErrorStatus& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const DdsRecorderMonitoringStatus& data); @@ -55,3 +51,4 @@ eProsima_user_DllExport void serialize_key( } // namespace eprosima #endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_HPP_ + diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusCdrAux.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.ipp similarity index 78% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusCdrAux.ipp rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.ipp index e08897352..c425b4547 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusCdrAux.ipp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,11 +50,11 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.mcap_file_creation_failure(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.mcap_file_creation_failure(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.disk_full(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.disk_full(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -78,7 +76,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.mcap_file_creation_failure() << eprosima::fastcdr::MemberId(1) << data.disk_full() - ; +; scdr.end_serialize_type(current_state); } @@ -95,13 +93,13 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.mcap_file_creation_failure(); - break; + case 0: + dcdr >> data.mcap_file_creation_failure(); + break; - case 1: - dcdr >> data.disk_full(); - break; + case 1: + dcdr >> data.disk_full(); + break; default: ret_value = false; @@ -119,6 +117,7 @@ void serialize_key( static_cast(data); } + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -135,14 +134,14 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.error_status(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.error_status(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.has_errors(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.has_errors(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.ddsrecorder_error_status(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.ddsrecorder_error_status(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -165,7 +164,7 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(0) << data.error_status() << eprosima::fastcdr::MemberId(1) << data.has_errors() << eprosima::fastcdr::MemberId(2) << data.ddsrecorder_error_status() - ; +; scdr.end_serialize_type(current_state); } @@ -182,17 +181,17 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.error_status(); - break; + case 0: + dcdr >> data.error_status(); + break; - case 1: - dcdr >> data.has_errors(); - break; + case 1: + dcdr >> data.has_errors(); + break; - case 2: - dcdr >> data.ddsrecorder_error_status(); - break; + case 2: + dcdr >> data.ddsrecorder_error_status(); + break; default: ret_value = false; @@ -210,6 +209,8 @@ void serialize_key( static_cast(data); } + + } // namespace fastcdr } // namespace eprosima diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusPubSubTypes.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.h similarity index 91% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusPubSubTypes.h rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.h index aaf8bcdde..80f85a4f9 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusPubSubTypes.h +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.h @@ -27,11 +27,11 @@ #include #include #include -#include +#include -#include +#include "DdsRecorderMonitoringStatus.hpp" -#include "ddspipe_core/types/monitoring/status/v2/MonitoringStatusPubSubTypes.h" +#include "ddspipe_core/types/monitoring/status/MonitoringStatusPubSubTypes.h" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) #error \ @@ -39,8 +39,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type DdsRecorderMonitoringErrorStatus defined by the user in the IDL file. * @ingroup DdsRecorderMonitoringStatus @@ -91,6 +89,9 @@ class DdsRecorderMonitoringErrorStatusPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -106,7 +107,7 @@ class DdsRecorderMonitoringErrorStatusPubSubType : public eprosima::fastdds::dds } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -129,8 +130,6 @@ class DdsRecorderMonitoringErrorStatusPubSubType : public eprosima::fastdds::dds }; - - /*! * @brief This class represents the TopicDataType of the type DdsRecorderMonitoringStatus defined by the user in the IDL file. * @ingroup DdsRecorderMonitoringStatus @@ -181,6 +180,9 @@ class DdsRecorderMonitoringStatusPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -196,7 +198,7 @@ class DdsRecorderMonitoringStatusPubSubType : public eprosima::fastdds::dds::Top } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -220,3 +222,4 @@ class DdsRecorderMonitoringStatusPubSubType : public eprosima::fastdds::dds::Top }; #endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_PUBSUBTYPES_H_ + diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.hpp new file mode 100644 index 000000000..6e74f8589 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.hpp @@ -0,0 +1,69 @@ +// 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 DdsRecorderMonitoringStatusTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP_ + +#include + +#include "ddspipe_core/types/monitoring/status/MonitoringStatusTypeObjectSupport.hpp" + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register DdsRecorderMonitoringErrorStatus related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_DdsRecorderMonitoringErrorStatus_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register DdsRecorderMonitoringStatus related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_DdsRecorderMonitoringStatus_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatus.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatus.h deleted file mode 100644 index 4e09289d6..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatus.h +++ /dev/null @@ -1,376 +0,0 @@ -// 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 DdsRecorderMonitoringStatus.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_H_ - -#include "ddspipe_core/types/monitoring/status/v1/MonitoringStatus.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(DDSRECORDERMONITORINGSTATUS_SOURCE) -#define DDSRECORDERMONITORINGSTATUS_DllAPI __declspec( dllexport ) -#else -#define DDSRECORDERMONITORINGSTATUS_DllAPI __declspec( dllimport ) -#endif // DDSRECORDERMONITORINGSTATUS_SOURCE -#else -#define DDSRECORDERMONITORINGSTATUS_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DDSRECORDERMONITORINGSTATUS_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure DdsRecorderMonitoringErrorStatus defined by the user in the IDL file. - * @ingroup DdsRecorderMonitoringStatus - */ -class DdsRecorderMonitoringErrorStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderMonitoringErrorStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus( - const DdsRecorderMonitoringErrorStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus( - DdsRecorderMonitoringErrorStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus& operator =( - const DdsRecorderMonitoringErrorStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus& operator =( - DdsRecorderMonitoringErrorStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderMonitoringErrorStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderMonitoringErrorStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderMonitoringErrorStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderMonitoringErrorStatus& x) const; - - /*! - * @brief This function sets a value in member mcap_file_creation_failure - * @param _mcap_file_creation_failure New value for member mcap_file_creation_failure - */ - eProsima_user_DllExport void mcap_file_creation_failure( - bool _mcap_file_creation_failure); - - /*! - * @brief This function returns the value of member mcap_file_creation_failure - * @return Value of member mcap_file_creation_failure - */ - eProsima_user_DllExport bool mcap_file_creation_failure() const; - - /*! - * @brief This function returns a reference to member mcap_file_creation_failure - * @return Reference to member mcap_file_creation_failure - */ - eProsima_user_DllExport bool& mcap_file_creation_failure(); - - - /*! - * @brief This function sets a value in member disk_full - * @param _disk_full New value for member disk_full - */ - eProsima_user_DllExport void disk_full( - bool _disk_full); - - /*! - * @brief This function returns the value of member disk_full - * @return Value of member disk_full - */ - eProsima_user_DllExport bool disk_full() const; - - /*! - * @brief This function returns a reference to member disk_full - * @return Reference to member disk_full - */ - eProsima_user_DllExport bool& disk_full(); - - - /*! - * @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 DdsRecorderMonitoringErrorStatus& 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 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: - - bool m_mcap_file_creation_failure; - bool m_disk_full; - -}; - - - -/*! - * @brief This class represents the structure DdsRecorderMonitoringStatus defined by the user in the IDL file. - * @ingroup DdsRecorderMonitoringStatus - */ -class DdsRecorderMonitoringStatus : public MonitoringStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderMonitoringStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderMonitoringStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringStatus( - const DdsRecorderMonitoringStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringStatus( - DdsRecorderMonitoringStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringStatus& operator =( - const DdsRecorderMonitoringStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringStatus& operator =( - DdsRecorderMonitoringStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderMonitoringStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderMonitoringStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderMonitoringStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderMonitoringStatus& x) const; - - /*! - * @brief This function copies the value in member ddsrecorder_error_status - * @param _ddsrecorder_error_status New value to be copied in member ddsrecorder_error_status - */ - eProsima_user_DllExport void ddsrecorder_error_status( - const DdsRecorderMonitoringErrorStatus& _ddsrecorder_error_status); - - /*! - * @brief This function moves the value in member ddsrecorder_error_status - * @param _ddsrecorder_error_status New value to be moved in member ddsrecorder_error_status - */ - eProsima_user_DllExport void ddsrecorder_error_status( - DdsRecorderMonitoringErrorStatus&& _ddsrecorder_error_status); - - /*! - * @brief This function returns a constant reference to member ddsrecorder_error_status - * @return Constant reference to member ddsrecorder_error_status - */ - eProsima_user_DllExport const DdsRecorderMonitoringErrorStatus& ddsrecorder_error_status() const; - - /*! - * @brief This function returns a reference to member ddsrecorder_error_status - * @return Reference to member ddsrecorder_error_status - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus& ddsrecorder_error_status(); - - - /*! - * @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 DdsRecorderMonitoringStatus& 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 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: - - DdsRecorderMonitoringErrorStatus m_ddsrecorder_error_status; - -}; - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_H_ - - - diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusPubSubTypes.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusPubSubTypes.h deleted file mode 100644 index 5400ff0fe..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusPubSubTypes.h +++ /dev/null @@ -1,222 +0,0 @@ -// 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 DdsRecorderMonitoringStatusPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include - -#include "ddspipe_core/types/monitoring/status/v1/MonitoringStatusPubSubTypes.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated DdsRecorderMonitoringStatus 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 DdsRecorderMonitoringErrorStatus defined by the user in the IDL file. - * @ingroup DdsRecorderMonitoringStatus - */ -class DdsRecorderMonitoringErrorStatusPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DdsRecorderMonitoringErrorStatus type; - - eProsima_user_DllExport DdsRecorderMonitoringErrorStatusPubSubType(); - - eProsima_user_DllExport ~DdsRecorderMonitoringErrorStatusPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - 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 - { - static_cast(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 DdsRecorderMonitoringStatus defined by the user in the IDL file. - * @ingroup DdsRecorderMonitoringStatus - */ -class DdsRecorderMonitoringStatusPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef DdsRecorderMonitoringStatus type; - - eProsima_user_DllExport DdsRecorderMonitoringStatusPubSubType(); - - eProsima_user_DllExport ~DdsRecorderMonitoringStatusPubSubType() override; - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - 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 - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_PUBSUBTYPES_H_ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusTypeObject.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusTypeObject.h deleted file mode 100644 index 8dc29cc92..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusTypeObject.h +++ /dev/null @@ -1,77 +0,0 @@ -// 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 DdsRecorderMonitoringStatusTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_H_ - -#include "ddspipe_core/types/monitoring/status/v1/MonitoringStatusTypeObject.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(DdsRecorderMonitoringStatus_SOURCE) -#define DdsRecorderMonitoringStatus_DllAPI __declspec( dllexport ) -#else -#define DdsRecorderMonitoringStatus_DllAPI __declspec( dllimport ) -#endif // DdsRecorderMonitoringStatus_SOURCE -#else -#define DdsRecorderMonitoringStatus_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define DdsRecorderMonitoringStatus_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerDdsRecorderMonitoringStatusTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetDdsRecorderMonitoringErrorStatusIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsRecorderMonitoringErrorStatusObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsRecorderMonitoringErrorStatusObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsRecorderMonitoringErrorStatusObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetDdsRecorderMonitoringStatusIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsRecorderMonitoringStatusObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsRecorderMonitoringStatusObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsRecorderMonitoringStatusObject(); - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusCdrAux.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusCdrAux.hpp deleted file mode 100644 index 58b44021a..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusCdrAux.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// 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 DdsRecorderMonitoringStatusCdrAux.hpp - * This source file contains some definitions of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_HPP_ - -#include - -constexpr uint32_t DdsRecorderMonitoringErrorStatus_max_cdr_typesize {6UL}; -constexpr uint32_t DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize {0UL}; - -constexpr uint32_t DdsRecorderMonitoringStatus_max_cdr_typesize {18UL}; -constexpr uint32_t DdsRecorderMonitoringStatus_max_key_cdr_typesize {0UL}; - - - -namespace eprosima { -namespace fastcdr { - -class Cdr; -class CdrSizeCalculator; - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const DdsRecorderMonitoringErrorStatus& data); - - - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const DdsRecorderMonitoringStatus& data); - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_HPP_ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusCdrAux.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusCdrAux.ipp deleted file mode 100644 index e08897352..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusCdrAux.ipp +++ /dev/null @@ -1,217 +0,0 @@ -// 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 DdsRecorderMonitoringStatusCdrAux.ipp - * This source file contains some declarations of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_IPP_ - -#include "DdsRecorderMonitoringStatusCdrAux.hpp" - -#include -#include - - -#include -using namespace eprosima::fastcdr::exception; - -namespace eprosima { -namespace fastcdr { - - - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const DdsRecorderMonitoringErrorStatus& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.mcap_file_creation_failure(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.disk_full(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const DdsRecorderMonitoringErrorStatus& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.mcap_file_creation_failure() - << eprosima::fastcdr::MemberId(1) << data.disk_full() - ; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - DdsRecorderMonitoringErrorStatus& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.mcap_file_creation_failure(); - break; - - case 1: - dcdr >> data.disk_full(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const DdsRecorderMonitoringErrorStatus& data) -{ - static_cast(scdr); - static_cast(data); -} - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const DdsRecorderMonitoringStatus& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.error_status(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.has_errors(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.ddsrecorder_error_status(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const DdsRecorderMonitoringStatus& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.error_status() - << eprosima::fastcdr::MemberId(1) << data.has_errors() - << eprosima::fastcdr::MemberId(2) << data.ddsrecorder_error_status() - ; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - DdsRecorderMonitoringStatus& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.error_status(); - break; - - case 1: - dcdr >> data.has_errors(); - break; - - case 2: - dcdr >> data.ddsrecorder_error_status(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const DdsRecorderMonitoringStatus& data) -{ - static_cast(scdr); - static_cast(data); -} - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_IPP_ - diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusTypeObject.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusTypeObject.h deleted file mode 100644 index f0f4105b1..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusTypeObject.h +++ /dev/null @@ -1,77 +0,0 @@ -// 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 DdsRecorderMonitoringStatusTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_H_ - -#include "ddspipe_core/types/monitoring/status/v2/MonitoringStatusTypeObject.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(DdsRecorderMonitoringStatus_SOURCE) -#define DdsRecorderMonitoringStatus_DllAPI __declspec( dllexport ) -#else -#define DdsRecorderMonitoringStatus_DllAPI __declspec( dllimport ) -#endif // DdsRecorderMonitoringStatus_SOURCE -#else -#define DdsRecorderMonitoringStatus_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define DdsRecorderMonitoringStatus_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerDdsRecorderMonitoringStatusTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetDdsRecorderMonitoringErrorStatusIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsRecorderMonitoringErrorStatusObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsRecorderMonitoringErrorStatusObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsRecorderMonitoringErrorStatusObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetDdsRecorderMonitoringStatusIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetDdsRecorderMonitoringStatusObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalDdsRecorderMonitoringStatusObject(); -eProsima_user_DllExport const TypeObject* GetCompleteDdsRecorderMonitoringStatusObject(); - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusv1.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusv1.h deleted file mode 100644 index e4b4936b1..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusv1.h +++ /dev/null @@ -1,381 +0,0 @@ -// 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 DdsRecorderMonitoringStatus.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_H_ - -#include "ddspipe_core/types/monitoring/status/v2/MonitoringStatus.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(DDSRECORDERMONITORINGSTATUS_SOURCE) -#define DDSRECORDERMONITORINGSTATUS_DllAPI __declspec( dllexport ) -#else -#define DDSRECORDERMONITORINGSTATUS_DllAPI __declspec( dllimport ) -#endif // DDSRECORDERMONITORINGSTATUS_SOURCE -#else -#define DDSRECORDERMONITORINGSTATUS_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define DDSRECORDERMONITORINGSTATUS_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure DdsRecorderMonitoringErrorStatus defined by the user in the IDL file. - * @ingroup DdsRecorderMonitoringStatus - */ -class DdsRecorderMonitoringErrorStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderMonitoringErrorStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus( - const DdsRecorderMonitoringErrorStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus( - DdsRecorderMonitoringErrorStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus& operator =( - const DdsRecorderMonitoringErrorStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderMonitoringErrorStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus& operator =( - DdsRecorderMonitoringErrorStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderMonitoringErrorStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderMonitoringErrorStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderMonitoringErrorStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderMonitoringErrorStatus& x) const; - - /*! - * @brief This function sets a value in member mcap_file_creation_failure - * @param _mcap_file_creation_failure New value for member mcap_file_creation_failure - */ - eProsima_user_DllExport void mcap_file_creation_failure( - bool _mcap_file_creation_failure); - - /*! - * @brief This function returns the value of member mcap_file_creation_failure - * @return Value of member mcap_file_creation_failure - */ - eProsima_user_DllExport bool mcap_file_creation_failure() const; - - /*! - * @brief This function returns a reference to member mcap_file_creation_failure - * @return Reference to member mcap_file_creation_failure - */ - eProsima_user_DllExport bool& mcap_file_creation_failure(); - - - /*! - * @brief This function sets a value in member disk_full - * @param _disk_full New value for member disk_full - */ - eProsima_user_DllExport void disk_full( - bool _disk_full); - - /*! - * @brief This function returns the value of member disk_full - * @return Value of member disk_full - */ - eProsima_user_DllExport bool disk_full() const; - - /*! - * @brief This function returns a reference to member disk_full - * @return Reference to member disk_full - */ - eProsima_user_DllExport bool& disk_full(); - - - /*! - * @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 DdsRecorderMonitoringErrorStatus& 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 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: - - bool m_mcap_file_creation_failure; - bool m_disk_full; - -}; - - - -/*! - * @brief This class represents the structure DdsRecorderMonitoringStatus defined by the user in the IDL file. - * @ingroup DdsRecorderMonitoringStatus - */ -class DdsRecorderMonitoringStatus : public MonitoringStatus -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport DdsRecorderMonitoringStatus(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~DdsRecorderMonitoringStatus(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringStatus( - const DdsRecorderMonitoringStatus& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringStatus( - DdsRecorderMonitoringStatus&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringStatus& operator =( - const DdsRecorderMonitoringStatus& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object DdsRecorderMonitoringStatus that will be copied. - */ - eProsima_user_DllExport DdsRecorderMonitoringStatus& operator =( - DdsRecorderMonitoringStatus&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderMonitoringStatus object to compare. - */ - eProsima_user_DllExport bool operator ==( - const DdsRecorderMonitoringStatus& x) const; - - /*! - * @brief Comparison operator. - * @param x DdsRecorderMonitoringStatus object to compare. - */ - eProsima_user_DllExport bool operator !=( - const DdsRecorderMonitoringStatus& x) const; - - /*! - * @brief This function copies the value in member ddsrecorder_error_status - * @param _ddsrecorder_error_status New value to be copied in member ddsrecorder_error_status - */ - eProsima_user_DllExport void ddsrecorder_error_status( - const DdsRecorderMonitoringErrorStatus& _ddsrecorder_error_status); - - /*! - * @brief This function moves the value in member ddsrecorder_error_status - * @param _ddsrecorder_error_status New value to be moved in member ddsrecorder_error_status - */ - eProsima_user_DllExport void ddsrecorder_error_status( - DdsRecorderMonitoringErrorStatus&& _ddsrecorder_error_status); - - /*! - * @brief This function returns a constant reference to member ddsrecorder_error_status - * @return Constant reference to member ddsrecorder_error_status - */ - eProsima_user_DllExport const DdsRecorderMonitoringErrorStatus& ddsrecorder_error_status() const; - - /*! - * @brief This function returns a reference to member ddsrecorder_error_status - * @return Reference to member ddsrecorder_error_status - */ - eProsima_user_DllExport DdsRecorderMonitoringErrorStatus& ddsrecorder_error_status(); - - - /*! - * @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 DdsRecorderMonitoringStatus& 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 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: - - DdsRecorderMonitoringErrorStatus m_ddsrecorder_error_status; - -}; - - -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index 965f2f57b..3aa797cd4 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -31,7 +31,8 @@ #include #include -#include +#include +#include #include #include @@ -46,11 +47,7 @@ #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include -#else - #include -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 +#include namespace eprosima { namespace ddsrecorder { @@ -121,7 +118,9 @@ class McapHandler : public ddspipe::participants::ISchemaHandler */ DDSRECORDER_PARTICIPANTS_DllAPI void add_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) override; + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_id) override; /** * @brief Add a data sample, to be written through a mcap \c Channel associated to the given \c topic. @@ -394,6 +393,7 @@ class McapHandler : public ddspipe::participants::ISchemaHandler */ void store_dynamic_type_( const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_id, DynamicTypesCollection& dynamic_types) const; /** @@ -405,8 +405,8 @@ class McapHandler : public ddspipe::participants::ISchemaHandler * @param [in,out] dynamic_types Collection where to store serialized dynamic type. */ void store_dynamic_type_( - const eprosima::fastrtps::types::TypeIdentifier* type_identifier, - const eprosima::fastrtps::types::TypeObject* type_object, + const fastdds::dds::xtypes::TypeIdentifier& type_identifier, + const fastdds::dds::xtypes::TypeObject& type_object, const std::string& type_name, DynamicTypesCollection& dynamic_types) const; @@ -435,7 +435,7 @@ class McapHandler : public ddspipe::participants::ISchemaHandler * @return Serialized TypeIdentifier string */ static std::string serialize_type_identifier_( - const eprosima::fastrtps::types::TypeIdentifier* type_identifier); + const fastdds::dds::xtypes::TypeIdentifier& type_identifier); /** * @brief Serialize a \c TypeObject into a string. @@ -444,7 +444,7 @@ class McapHandler : public ddspipe::participants::ISchemaHandler * @return Serialized TypeObject string */ static std::string serialize_type_object_( - const eprosima::fastrtps::types::TypeObject* type_object); + const fastdds::dds::xtypes::TypeObject& type_object); //! Handler configuration McapHandlerConfiguration configuration_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/monitoring/producers/DdsRecorderStatusMonitorProducer.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/monitoring/producers/DdsRecorderStatusMonitorProducer.hpp index 1c7290406..685bf32b6 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/monitoring/producers/DdsRecorderStatusMonitorProducer.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/monitoring/producers/DdsRecorderStatusMonitorProducer.hpp @@ -22,20 +22,9 @@ #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include \ - - #include \ - -#else - #include - #include \ - - #include \ - -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - +#include +#include +#include namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder_participants/package.xml b/ddsrecorder_participants/package.xml index e51febfe5..7e1533919 100644 --- a/ddsrecorder_participants/package.xml +++ b/ddsrecorder_participants/package.xml @@ -21,7 +21,7 @@ cpp_utils ddspipe_core ddspipe_participants - fastrtps + fastdds doxygen diff --git a/ddsrecorder_participants/project_settings.cmake b/ddsrecorder_participants/project_settings.cmake index d2f651ed7..619eb30df 100644 --- a/ddsrecorder_participants/project_settings.cmake +++ b/ddsrecorder_participants/project_settings.cmake @@ -25,7 +25,7 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants) @@ -40,13 +40,13 @@ endif() set(MODULE_THIRDPARTY_HEADERONLY mcap) -set(fastrtps_MINIMUM_VERSION "2.8") +set(fastdds_MINIMUM_VERSION "3.0.0") set(MODULE_DEPENDENCIES yaml-cpp $<$:iphlpapi$Shlwapi> fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionCdrAux.hpp b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.hpp similarity index 95% rename from ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionCdrAux.hpp rename to ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.hpp index ef360c9b2..fc59637d3 100644 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionCdrAux.hpp +++ b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.hpp @@ -22,9 +22,9 @@ #ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_HPP_ #define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_HPP_ -#include +#include -constexpr uint32_t eprosima_ddsrecorder_participants_DynamicTypesCollection_max_cdr_typesize {78412UL}; +constexpr uint32_t eprosima_ddsrecorder_participants_DynamicTypesCollection_max_cdr_typesize {12UL}; constexpr uint32_t eprosima_ddsrecorder_participants_DynamicTypesCollection_max_key_cdr_typesize {0UL}; constexpr uint32_t eprosima_ddsrecorder_participants_DynamicType_max_cdr_typesize {784UL}; @@ -37,25 +37,17 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const eprosima::ddsrecorder::participants::DynamicType& data); - - - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const eprosima::ddsrecorder::participants::DynamicTypesCollection& data); - - - } // namespace fastcdr } // namespace eprosima #endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_HPP_ + diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionCdrAux.ipp b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.ipp similarity index 83% rename from ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionCdrAux.ipp rename to ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.ipp index 05a6970c4..57368df88 100644 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionCdrAux.ipp +++ b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -54,14 +52,14 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.type_name(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.type_name(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.type_information(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.type_information(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.type_object(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.type_object(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -86,7 +84,7 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(0) << data.type_name() << eprosima::fastcdr::MemberId(1) << data.type_information() << eprosima::fastcdr::MemberId(2) << data.type_object() - ; +; scdr.end_serialize_type(current_state); } @@ -105,17 +103,17 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.type_name(); - break; + case 0: + dcdr >> data.type_name(); + break; - case 1: - dcdr >> data.type_information(); - break; + case 1: + dcdr >> data.type_information(); + break; - case 2: - dcdr >> data.type_object(); - break; + case 2: + dcdr >> data.type_object(); + break; default: ret_value = false; @@ -135,6 +133,7 @@ void serialize_key( static_cast(data); } + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -153,8 +152,8 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.dynamic_types(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.dynamic_types(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -177,7 +176,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.dynamic_types() - ; +; scdr.end_serialize_type(current_state); } @@ -196,9 +195,9 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.dynamic_types(); - break; + case 0: + dcdr >> data.dynamic_types(); + break; default: ret_value = false; @@ -218,6 +217,8 @@ void serialize_key( static_cast(data); } + + } // namespace fastcdr } // namespace eprosima diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx new file mode 100644 index 000000000..503bb7a20 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx @@ -0,0 +1,431 @@ +// 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 DynamicTypesCollectionPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#include +#include + +#include "DynamicTypesCollectionCdrAux.hpp" +#include + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +namespace eprosima { + namespace ddsrecorder { + namespace participants { + DynamicTypePubSubType::DynamicTypePubSubType() + { + setName("eprosima::ddsrecorder::participants::DynamicType"); + uint32_t type_size = + #if FASTCDR_VERSION_MAJOR == 1 + static_cast(DynamicType::getMaxCdrSerializedSize()); + #else + eprosima_ddsrecorder_participants_DynamicType_max_cdr_typesize; + #endif + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + m_typeSize = type_size + 4; /*encapsulation*/ + m_isGetKeyDefined = false; + uint32_t keyLength = eprosima_ddsrecorder_participants_DynamicType_max_key_cdr_typesize > 16 ? eprosima_ddsrecorder_participants_DynamicType_max_key_cdr_typesize : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); + } + + DynamicTypePubSubType::~DynamicTypePubSubType() + { + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } + } + + bool DynamicTypePubSubType::serialize( + void* data, + SerializedPayload_t* payload, + DataRepresentationId_t data_representation) + { + DynamicType* 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, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + #if FASTCDR_VERSION_MAJOR > 1 + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + #endif // FASTCDR_VERSION_MAJOR > 1 + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + #if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast(ser.getSerializedDataLength()); + #else + payload->length = static_cast(ser.get_serialized_data_length()); + #endif // FASTCDR_VERSION_MAJOR == 1 + return true; + } + + bool DynamicTypePubSubType::deserialize( + SerializedPayload_t* payload, + void* data) + { + try + { + // Convert DATA to pointer of your type + DynamicType* 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 + #if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR + #endif // FASTCDR_VERSION_MAJOR == 1 + ); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; + } + + std::function DynamicTypePubSubType::getSerializedSizeProvider( + void* data, + DataRepresentationId_t data_representation) + { + return [data, data_representation]() -> uint32_t + { + #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + #else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } + #endif // FASTCDR_VERSION_MAJOR == 1 + }; + } + + void* DynamicTypePubSubType::createData() + { + return reinterpret_cast(new DynamicType()); + } + + void DynamicTypePubSubType::deleteData( + void* data) + { + delete(reinterpret_cast(data)); + } + + bool DynamicTypePubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) + { + if (!m_isGetKeyDefined) + { + return false; + } + + DynamicType* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima_ddsrecorder_participants_DynamicType_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + #if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); + #else + eprosima::fastcdr::serialize_key(ser, *p_type); + #endif // FASTCDR_VERSION_MAJOR == 1 + if (force_md5 || eprosima_ddsrecorder_participants_DynamicType_max_key_cdr_typesize > 16) + { + m_md5.init(); + #if FASTCDR_VERSION_MAJOR == 1 + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + #else + m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); + #endif // FASTCDR_VERSION_MAJOR == 1 + 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; + } + + void DynamicTypePubSubType::register_type_object_representation() + { + register_DynamicType_type_identifier(type_identifiers_); + } + + DynamicTypesCollectionPubSubType::DynamicTypesCollectionPubSubType() + { + setName("eprosima::ddsrecorder::participants::DynamicTypesCollection"); + uint32_t type_size = + #if FASTCDR_VERSION_MAJOR == 1 + static_cast(DynamicTypesCollection::getMaxCdrSerializedSize()); + #else + eprosima_ddsrecorder_participants_DynamicTypesCollection_max_cdr_typesize; + #endif + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + m_typeSize = type_size + 4; /*encapsulation*/ + m_isGetKeyDefined = false; + uint32_t keyLength = eprosima_ddsrecorder_participants_DynamicTypesCollection_max_key_cdr_typesize > 16 ? eprosima_ddsrecorder_participants_DynamicTypesCollection_max_key_cdr_typesize : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); + } + + DynamicTypesCollectionPubSubType::~DynamicTypesCollectionPubSubType() + { + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } + } + + bool DynamicTypesCollectionPubSubType::serialize( + void* data, + SerializedPayload_t* payload, + DataRepresentationId_t data_representation) + { + DynamicTypesCollection* 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, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + #if FASTCDR_VERSION_MAJOR > 1 + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + #endif // FASTCDR_VERSION_MAJOR > 1 + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length + #if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast(ser.getSerializedDataLength()); + #else + payload->length = static_cast(ser.get_serialized_data_length()); + #endif // FASTCDR_VERSION_MAJOR == 1 + return true; + } + + bool DynamicTypesCollectionPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) + { + try + { + // Convert DATA to pointer of your type + DynamicTypesCollection* 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 + #if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR + #endif // FASTCDR_VERSION_MAJOR == 1 + ); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; + } + + std::function DynamicTypesCollectionPubSubType::getSerializedSizeProvider( + void* data, + DataRepresentationId_t data_representation) + { + return [data, data_representation]() -> uint32_t + { + #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; + #else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } + #endif // FASTCDR_VERSION_MAJOR == 1 + }; + } + + void* DynamicTypesCollectionPubSubType::createData() + { + return reinterpret_cast(new DynamicTypesCollection()); + } + + void DynamicTypesCollectionPubSubType::deleteData( + void* data) + { + delete(reinterpret_cast(data)); + } + + bool DynamicTypesCollectionPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) + { + if (!m_isGetKeyDefined) + { + return false; + } + + DynamicTypesCollection* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + eprosima_ddsrecorder_participants_DynamicTypesCollection_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + #if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); + #else + eprosima::fastcdr::serialize_key(ser, *p_type); + #endif // FASTCDR_VERSION_MAJOR == 1 + if (force_md5 || eprosima_ddsrecorder_participants_DynamicTypesCollection_max_key_cdr_typesize > 16) + { + m_md5.init(); + #if FASTCDR_VERSION_MAJOR == 1 + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); + #else + m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); + #endif // FASTCDR_VERSION_MAJOR == 1 + 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; + } + + void DynamicTypesCollectionPubSubType::register_type_object_representation() + { + register_DynamicTypesCollection_type_identifier(type_identifiers_); + } + + } // namespace participants + + } // namespace ddsrecorder + +} // namespace eprosima + + +// Include auxiliary functions like for serializing/deserializing. +#include "DynamicTypesCollectionCdrAux.ipp" diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.cxx b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.cxx new file mode 100644 index 000000000..7c0608072 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.cxx @@ -0,0 +1,282 @@ +// 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 DynamicTypesCollectionTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +using namespace eprosima::fastdds::dds::xtypes; + +namespace eprosima { +namespace ddsrecorder { +namespace participants { +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_DynamicType_type_identifier( + TypeIdentifierPair& type_ids_DynamicType) +{ + + ReturnCode_t return_code_DynamicType {eprosima::fastdds::dds::RETCODE_OK}; + return_code_DynamicType = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "eprosima::ddsrecorder::participants::DynamicType", type_ids_DynamicType); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_DynamicType) + { + StructTypeFlag struct_flags_DynamicType = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_DynamicType = "eprosima::ddsrecorder::participants::DynamicType"; + eprosima::fastcdr::optional type_ann_builtin_DynamicType; + eprosima::fastcdr::optional ann_custom_DynamicType; + CompleteTypeDetail detail_DynamicType = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DynamicType, ann_custom_DynamicType, type_name_DynamicType.to_string()); + CompleteStructHeader header_DynamicType; + header_DynamicType = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DynamicType); + CompleteStructMemberSeq member_seq_DynamicType; + { + TypeIdentifierPair type_ids_type_name; + ReturnCode_t return_code_type_name {eprosima::fastdds::dds::RETCODE_OK}; + return_code_type_name = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_type_name); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_type_name) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_type_name)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_type_name = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_type_name = 0x00000000; + bool common_type_name_ec {false}; + CommonStructMember common_type_name {TypeObjectUtils::build_common_struct_member(member_id_type_name, member_flags_type_name, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_type_name, common_type_name_ec))}; + if (!common_type_name_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure type_name member TypeIdentifier inconsistent."); + return; + } + MemberName name_type_name = "type_name"; + eprosima::fastcdr::optional member_ann_builtin_type_name; + ann_custom_DynamicType.reset(); + CompleteMemberDetail detail_type_name = TypeObjectUtils::build_complete_member_detail(name_type_name, member_ann_builtin_type_name, ann_custom_DynamicType); + CompleteStructMember member_type_name = TypeObjectUtils::build_complete_struct_member(common_type_name, detail_type_name); + TypeObjectUtils::add_complete_struct_member(member_seq_DynamicType, member_type_name); + } + { + TypeIdentifierPair type_ids_type_information; + ReturnCode_t return_code_type_information {eprosima::fastdds::dds::RETCODE_OK}; + return_code_type_information = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_type_information); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_type_information) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_type_information)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_type_information = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_type_information = 0x00000001; + bool common_type_information_ec {false}; + CommonStructMember common_type_information {TypeObjectUtils::build_common_struct_member(member_id_type_information, member_flags_type_information, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_type_information, common_type_information_ec))}; + if (!common_type_information_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure type_information member TypeIdentifier inconsistent."); + return; + } + MemberName name_type_information = "type_information"; + eprosima::fastcdr::optional member_ann_builtin_type_information; + ann_custom_DynamicType.reset(); + CompleteMemberDetail detail_type_information = TypeObjectUtils::build_complete_member_detail(name_type_information, member_ann_builtin_type_information, ann_custom_DynamicType); + CompleteStructMember member_type_information = TypeObjectUtils::build_complete_struct_member(common_type_information, detail_type_information); + TypeObjectUtils::add_complete_struct_member(member_seq_DynamicType, member_type_information); + } + { + TypeIdentifierPair type_ids_type_object; + ReturnCode_t return_code_type_object {eprosima::fastdds::dds::RETCODE_OK}; + return_code_type_object = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_type_object); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_type_object) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_type_object)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_type_object = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_type_object = 0x00000002; + bool common_type_object_ec {false}; + CommonStructMember common_type_object {TypeObjectUtils::build_common_struct_member(member_id_type_object, member_flags_type_object, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_type_object, common_type_object_ec))}; + if (!common_type_object_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure type_object member TypeIdentifier inconsistent."); + return; + } + MemberName name_type_object = "type_object"; + eprosima::fastcdr::optional member_ann_builtin_type_object; + ann_custom_DynamicType.reset(); + CompleteMemberDetail detail_type_object = TypeObjectUtils::build_complete_member_detail(name_type_object, member_ann_builtin_type_object, ann_custom_DynamicType); + CompleteStructMember member_type_object = TypeObjectUtils::build_complete_struct_member(common_type_object, detail_type_object); + TypeObjectUtils::add_complete_struct_member(member_seq_DynamicType, member_type_object); + } + CompleteStructType struct_type_DynamicType = TypeObjectUtils::build_complete_struct_type(struct_flags_DynamicType, header_DynamicType, member_seq_DynamicType); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_DynamicType, type_name_DynamicType.to_string(), type_ids_DynamicType)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "eprosima::ddsrecorder::participants::DynamicType already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_DynamicTypesCollection_type_identifier( + TypeIdentifierPair& type_ids_DynamicTypesCollection) +{ + + ReturnCode_t return_code_DynamicTypesCollection {eprosima::fastdds::dds::RETCODE_OK}; + return_code_DynamicTypesCollection = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "eprosima::ddsrecorder::participants::DynamicTypesCollection", type_ids_DynamicTypesCollection); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_DynamicTypesCollection) + { + StructTypeFlag struct_flags_DynamicTypesCollection = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_DynamicTypesCollection = "eprosima::ddsrecorder::participants::DynamicTypesCollection"; + eprosima::fastcdr::optional type_ann_builtin_DynamicTypesCollection; + eprosima::fastcdr::optional ann_custom_DynamicTypesCollection; + CompleteTypeDetail detail_DynamicTypesCollection = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DynamicTypesCollection, ann_custom_DynamicTypesCollection, type_name_DynamicTypesCollection.to_string()); + CompleteStructHeader header_DynamicTypesCollection; + header_DynamicTypesCollection = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DynamicTypesCollection); + CompleteStructMemberSeq member_seq_DynamicTypesCollection; + { + TypeIdentifierPair type_ids_dynamic_types; + ReturnCode_t return_code_dynamic_types {eprosima::fastdds::dds::RETCODE_OK}; + return_code_dynamic_types = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded", type_ids_dynamic_types); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_dynamic_types) + { + return_code_dynamic_types = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "eprosima::ddsrecorder::participants::DynamicType", type_ids_dynamic_types); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_dynamic_types) + { + eprosima::ddsrecorder::participants::register_DynamicType_type_identifier(type_ids_dynamic_types); + } + bool element_identifier_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_dynamic_types, element_identifier_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded_ec))}; + if (!element_identifier_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded = EK_COMPLETE; + if (TK_NONE == type_ids_dynamic_types.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded = 0; + PlainCollectionHeader header_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded, element_flags_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded); + { + SBound bound = 0; + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded", type_ids_dynamic_types)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_eprosima_ddsrecorder_participants_DynamicType_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_dynamic_types = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_dynamic_types = 0x00000000; + bool common_dynamic_types_ec {false}; + CommonStructMember common_dynamic_types {TypeObjectUtils::build_common_struct_member(member_id_dynamic_types, member_flags_dynamic_types, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_dynamic_types, common_dynamic_types_ec))}; + if (!common_dynamic_types_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure dynamic_types member TypeIdentifier inconsistent."); + return; + } + MemberName name_dynamic_types = "dynamic_types"; + eprosima::fastcdr::optional member_ann_builtin_dynamic_types; + ann_custom_DynamicTypesCollection.reset(); + CompleteMemberDetail detail_dynamic_types = TypeObjectUtils::build_complete_member_detail(name_dynamic_types, member_ann_builtin_dynamic_types, ann_custom_DynamicTypesCollection); + CompleteStructMember member_dynamic_types = TypeObjectUtils::build_complete_struct_member(common_dynamic_types, detail_dynamic_types); + TypeObjectUtils::add_complete_struct_member(member_seq_DynamicTypesCollection, member_dynamic_types); + } + CompleteStructType struct_type_DynamicTypesCollection = TypeObjectUtils::build_complete_struct_type(struct_flags_DynamicTypesCollection, header_DynamicTypesCollection, member_seq_DynamicTypesCollection); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_DynamicTypesCollection, type_name_DynamicTypesCollection.to_string(), type_ids_DynamicTypesCollection)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "eprosima::ddsrecorder::participants::DynamicTypesCollection already registered in TypeObjectRegistry for a different type."); + } + } +} + +} // namespace participants + +} // namespace ddsrecorder + +} // namespace eprosima + diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v1/DynamicTypesCollection.cpp b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v1/DynamicTypesCollection.cpp deleted file mode 100644 index c2bc07953..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v1/DynamicTypesCollection.cpp +++ /dev/null @@ -1,422 +0,0 @@ -// Copyright 2023 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 DynamicTypesCollection.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 -#include - -#include - -#include - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - -using namespace eprosima::fastcdr::exception; - -#define DynamicTypesCollection_max_cdr_typesize 78004ULL; -#define DynamicType_max_cdr_typesize 780ULL; -#define DynamicTypesCollection_max_key_cdr_typesize 0ULL; -#define DynamicType_max_key_cdr_typesize 0ULL; - -DynamicType::DynamicType() -{ - // string m_type_name - m_type_name = ""; - - // string m_type_information - m_type_information = ""; - - // string m_type_object - m_type_object = ""; -} - -DynamicType::~DynamicType() -{ -} - -DynamicType::DynamicType( - const DynamicType& x) -{ - m_type_name = x.m_type_name; - m_type_information = x.m_type_information; - m_type_object = x.m_type_object; -} - -DynamicType::DynamicType( - DynamicType&& x) noexcept -{ - m_type_name = std::move(x.m_type_name); - m_type_information = std::move(x.m_type_information); - m_type_object = std::move(x.m_type_object); -} - -DynamicType& DynamicType::operator =( - const DynamicType& x) -{ - m_type_name = x.m_type_name; - m_type_information = x.m_type_information; - m_type_object = x.m_type_object; - - return *this; -} - -DynamicType& DynamicType::operator =( - DynamicType&& x) noexcept -{ - m_type_name = std::move(x.m_type_name); - m_type_information = std::move(x.m_type_information); - m_type_object = std::move(x.m_type_object); - - return *this; -} - -bool DynamicType::operator ==( - const DynamicType& x) const -{ - return (m_type_name == x.m_type_name && m_type_information == x.m_type_information && - m_type_object == x.m_type_object); -} - -bool DynamicType::operator !=( - const DynamicType& x) const -{ - return !(*this == x); -} - -size_t DynamicType::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DynamicType_max_cdr_typesize; -} - -size_t DynamicType::getCdrSerializedSize( - const DynamicType& data, - size_t current_alignment) -{ - static_cast(data); - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_name().size() + 1; - current_alignment += 4 + - eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_information().size() + 1; - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_object().size() + 1; - - return current_alignment - initial_alignment; -} - -void DynamicType::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_type_name.c_str(); scdr << m_type_information.c_str(); scdr << m_type_object.c_str(); -} - -void DynamicType::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_type_name; - dcdr >> m_type_information; - dcdr >> m_type_object; -} - -/*! - * @brief This function copies the value in member type_name - * @param _type_name New value to be copied in member type_name - */ -void DynamicType::type_name( - const std::string& _type_name) -{ - m_type_name = _type_name; -} - -/*! - * @brief This function moves the value in member type_name - * @param _type_name New value to be moved in member type_name - */ -void DynamicType::type_name( - std::string&& _type_name) -{ - m_type_name = std::move(_type_name); -} - -/*! - * @brief This function returns a constant reference to member type_name - * @return Constant reference to member type_name - */ -const std::string& DynamicType::type_name() const -{ - return m_type_name; -} - -/*! - * @brief This function returns a reference to member type_name - * @return Reference to member type_name - */ -std::string& DynamicType::type_name() -{ - return m_type_name; -} - -/*! - * @brief This function copies the value in member type_information - * @param _type_information New value to be copied in member type_information - */ -void DynamicType::type_information( - const std::string& _type_information) -{ - m_type_information = _type_information; -} - -/*! - * @brief This function moves the value in member type_information - * @param _type_information New value to be moved in member type_information - */ -void DynamicType::type_information( - std::string&& _type_information) -{ - m_type_information = std::move(_type_information); -} - -/*! - * @brief This function returns a constant reference to member type_information - * @return Constant reference to member type_information - */ -const std::string& DynamicType::type_information() const -{ - return m_type_information; -} - -/*! - * @brief This function returns a reference to member type_information - * @return Reference to member type_information - */ -std::string& DynamicType::type_information() -{ - return m_type_information; -} - -/*! - * @brief This function copies the value in member type_object - * @param _type_object New value to be copied in member type_object - */ -void DynamicType::type_object( - const std::string& _type_object) -{ - m_type_object = _type_object; -} - -/*! - * @brief This function moves the value in member type_object - * @param _type_object New value to be moved in member type_object - */ -void DynamicType::type_object( - std::string&& _type_object) -{ - m_type_object = std::move(_type_object); -} - -/*! - * @brief This function returns a constant reference to member type_object - * @return Constant reference to member type_object - */ -const std::string& DynamicType::type_object() const -{ - return m_type_object; -} - -/*! - * @brief This function returns a reference to member type_object - * @return Reference to member type_object - */ -std::string& DynamicType::type_object() -{ - return m_type_object; -} - -size_t DynamicType::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DynamicType_max_key_cdr_typesize; -} - -bool DynamicType::isKeyDefined() -{ - return false; -} - -void DynamicType::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - static_cast(scdr); -} - -DynamicTypesCollection::DynamicTypesCollection() -{ -} - -DynamicTypesCollection::~DynamicTypesCollection() -{ -} - -DynamicTypesCollection::DynamicTypesCollection( - const DynamicTypesCollection& x) -{ - m_dynamic_types = x.m_dynamic_types; -} - -DynamicTypesCollection::DynamicTypesCollection( - DynamicTypesCollection&& x) noexcept -{ - m_dynamic_types = std::move(x.m_dynamic_types); -} - -DynamicTypesCollection& DynamicTypesCollection::operator =( - const DynamicTypesCollection& x) -{ - m_dynamic_types = x.m_dynamic_types; - - return *this; -} - -DynamicTypesCollection& DynamicTypesCollection::operator =( - DynamicTypesCollection&& x) noexcept -{ - m_dynamic_types = std::move(x.m_dynamic_types); - - return *this; -} - -bool DynamicTypesCollection::operator ==( - const DynamicTypesCollection& x) const -{ - return (m_dynamic_types == x.m_dynamic_types); -} - -bool DynamicTypesCollection::operator !=( - const DynamicTypesCollection& x) const -{ - return !(*this == x); -} - -size_t DynamicTypesCollection::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DynamicTypesCollection_max_cdr_typesize; -} - -size_t DynamicTypesCollection::getCdrSerializedSize( - const DynamicTypesCollection& data, - size_t current_alignment) -{ - static_cast(data); - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - for (size_t a = 0; a < data.dynamic_types().size(); ++a) - { - current_alignment += DynamicType::getCdrSerializedSize(data.dynamic_types().at(a), current_alignment); - } - - return current_alignment - initial_alignment; -} - -void DynamicTypesCollection::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_dynamic_types; -} - -void DynamicTypesCollection::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_dynamic_types; -} - -/*! - * @brief This function copies the value in member dynamic_types - * @param _dynamic_types New value to be copied in member dynamic_types - */ -void DynamicTypesCollection::dynamic_types( - const std::vector& _dynamic_types) -{ - m_dynamic_types = _dynamic_types; -} - -/*! - * @brief This function moves the value in member dynamic_types - * @param _dynamic_types New value to be moved in member dynamic_types - */ -void DynamicTypesCollection::dynamic_types( - std::vector&& _dynamic_types) -{ - m_dynamic_types = std::move(_dynamic_types); -} - -/*! - * @brief This function returns a constant reference to member dynamic_types - * @return Constant reference to member dynamic_types - */ -const std::vector& DynamicTypesCollection::dynamic_types() const -{ - return m_dynamic_types; -} - -/*! - * @brief This function returns a reference to member dynamic_types - * @return Reference to member dynamic_types - */ -std::vector& DynamicTypesCollection::dynamic_types() -{ - return m_dynamic_types; -} - -size_t DynamicTypesCollection::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DynamicTypesCollection_max_key_cdr_typesize; -} - -bool DynamicTypesCollection::isKeyDefined() -{ - return false; -} - -void DynamicTypesCollection::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - static_cast(scdr); -} - -} /* namespace participants */ -} /* namespace ddsrecorder */ -} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v1/DynamicTypesCollectionPubSubTypes.cpp b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v1/DynamicTypesCollectionPubSubTypes.cpp deleted file mode 100644 index f33e1bb82..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v1/DynamicTypesCollectionPubSubTypes.cpp +++ /dev/null @@ -1,319 +0,0 @@ -// 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 DynamicTypesCollectionPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -DynamicTypePubSubType::DynamicTypePubSubType() -{ - setName("DynamicType"); - auto type_size = DynamicType::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = DynamicType::isKeyDefined(); - size_t keyLength = DynamicType::getKeyMaxCdrSerializedSize() > 16 ? - DynamicType::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DynamicTypePubSubType::~DynamicTypePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DynamicTypePubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - DynamicType* 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 DynamicTypePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - DynamicType* 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 DynamicTypePubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* DynamicTypePubSubType::createData() -{ - return reinterpret_cast(new DynamicType()); -} - -void DynamicTypePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DynamicTypePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DynamicType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DynamicType::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || DynamicType::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; -} - -DynamicTypesCollectionPubSubType::DynamicTypesCollectionPubSubType() -{ - setName("DynamicTypesCollection"); - auto type_size = DynamicTypesCollection::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = DynamicTypesCollection::isKeyDefined(); - size_t keyLength = DynamicTypesCollection::getKeyMaxCdrSerializedSize() > 16 ? - DynamicTypesCollection::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DynamicTypesCollectionPubSubType::~DynamicTypesCollectionPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DynamicTypesCollectionPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - DynamicTypesCollection* 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 DynamicTypesCollectionPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - DynamicTypesCollection* 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 DynamicTypesCollectionPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* DynamicTypesCollectionPubSubType::createData() -{ - return reinterpret_cast(new DynamicTypesCollection()); -} - -void DynamicTypesCollectionPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DynamicTypesCollectionPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DynamicTypesCollection* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DynamicTypesCollection::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || DynamicTypesCollection::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; -} - -} /* namespace participants */ -} /* namespace ddsrecorder */ -} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollection.cpp b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollection.cpp deleted file mode 100644 index df2fae582..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollection.cpp +++ /dev/null @@ -1,318 +0,0 @@ -// 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 DynamicTypesCollection.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - -namespace eprosima { - -namespace ddsrecorder { - -namespace participants { - - - -DynamicType::DynamicType() -{ -} - -DynamicType::~DynamicType() -{ -} - -DynamicType::DynamicType( - const DynamicType& x) -{ - m_type_name = x.m_type_name; - m_type_information = x.m_type_information; - m_type_object = x.m_type_object; -} - -DynamicType::DynamicType( - DynamicType&& x) noexcept -{ - m_type_name = std::move(x.m_type_name); - m_type_information = std::move(x.m_type_information); - m_type_object = std::move(x.m_type_object); -} - -DynamicType& DynamicType::operator =( - const DynamicType& x) -{ - - m_type_name = x.m_type_name; - m_type_information = x.m_type_information; - m_type_object = x.m_type_object; - return *this; -} - -DynamicType& DynamicType::operator =( - DynamicType&& x) noexcept -{ - - m_type_name = std::move(x.m_type_name); - m_type_information = std::move(x.m_type_information); - m_type_object = std::move(x.m_type_object); - return *this; -} - -bool DynamicType::operator ==( - const DynamicType& x) const -{ - return (m_type_name == x.m_type_name && - m_type_information == x.m_type_information && - m_type_object == x.m_type_object); -} - -bool DynamicType::operator !=( - const DynamicType& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member type_name - * @param _type_name New value to be copied in member type_name - */ -void DynamicType::type_name( - const std::string& _type_name) -{ - m_type_name = _type_name; -} - -/*! - * @brief This function moves the value in member type_name - * @param _type_name New value to be moved in member type_name - */ -void DynamicType::type_name( - std::string&& _type_name) -{ - m_type_name = std::move(_type_name); -} - -/*! - * @brief This function returns a constant reference to member type_name - * @return Constant reference to member type_name - */ -const std::string& DynamicType::type_name() const -{ - return m_type_name; -} - -/*! - * @brief This function returns a reference to member type_name - * @return Reference to member type_name - */ -std::string& DynamicType::type_name() -{ - return m_type_name; -} - -/*! - * @brief This function copies the value in member type_information - * @param _type_information New value to be copied in member type_information - */ -void DynamicType::type_information( - const std::string& _type_information) -{ - m_type_information = _type_information; -} - -/*! - * @brief This function moves the value in member type_information - * @param _type_information New value to be moved in member type_information - */ -void DynamicType::type_information( - std::string&& _type_information) -{ - m_type_information = std::move(_type_information); -} - -/*! - * @brief This function returns a constant reference to member type_information - * @return Constant reference to member type_information - */ -const std::string& DynamicType::type_information() const -{ - return m_type_information; -} - -/*! - * @brief This function returns a reference to member type_information - * @return Reference to member type_information - */ -std::string& DynamicType::type_information() -{ - return m_type_information; -} - -/*! - * @brief This function copies the value in member type_object - * @param _type_object New value to be copied in member type_object - */ -void DynamicType::type_object( - const std::string& _type_object) -{ - m_type_object = _type_object; -} - -/*! - * @brief This function moves the value in member type_object - * @param _type_object New value to be moved in member type_object - */ -void DynamicType::type_object( - std::string&& _type_object) -{ - m_type_object = std::move(_type_object); -} - -/*! - * @brief This function returns a constant reference to member type_object - * @return Constant reference to member type_object - */ -const std::string& DynamicType::type_object() const -{ - return m_type_object; -} - -/*! - * @brief This function returns a reference to member type_object - * @return Reference to member type_object - */ -std::string& DynamicType::type_object() -{ - return m_type_object; -} - -DynamicTypesCollection::DynamicTypesCollection() -{ -} - -DynamicTypesCollection::~DynamicTypesCollection() -{ -} - -DynamicTypesCollection::DynamicTypesCollection( - const DynamicTypesCollection& x) -{ - m_dynamic_types = x.m_dynamic_types; -} - -DynamicTypesCollection::DynamicTypesCollection( - DynamicTypesCollection&& x) noexcept -{ - m_dynamic_types = std::move(x.m_dynamic_types); -} - -DynamicTypesCollection& DynamicTypesCollection::operator =( - const DynamicTypesCollection& x) -{ - - m_dynamic_types = x.m_dynamic_types; - return *this; -} - -DynamicTypesCollection& DynamicTypesCollection::operator =( - DynamicTypesCollection&& x) noexcept -{ - - m_dynamic_types = std::move(x.m_dynamic_types); - return *this; -} - -bool DynamicTypesCollection::operator ==( - const DynamicTypesCollection& x) const -{ - return (m_dynamic_types == x.m_dynamic_types); -} - -bool DynamicTypesCollection::operator !=( - const DynamicTypesCollection& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member dynamic_types - * @param _dynamic_types New value to be copied in member dynamic_types - */ -void DynamicTypesCollection::dynamic_types( - const std::vector& _dynamic_types) -{ - m_dynamic_types = _dynamic_types; -} - -/*! - * @brief This function moves the value in member dynamic_types - * @param _dynamic_types New value to be moved in member dynamic_types - */ -void DynamicTypesCollection::dynamic_types( - std::vector&& _dynamic_types) -{ - m_dynamic_types = std::move(_dynamic_types); -} - -/*! - * @brief This function returns a constant reference to member dynamic_types - * @return Constant reference to member dynamic_types - */ -const std::vector& DynamicTypesCollection::dynamic_types() const -{ - return m_dynamic_types; -} - -/*! - * @brief This function returns a reference to member dynamic_types - * @return Reference to member dynamic_types - */ -std::vector& DynamicTypesCollection::dynamic_types() -{ - return m_dynamic_types; -} - -} // namespace participants - - -} // namespace ddsrecorder - - -} // namespace eprosima -// Include auxiliary functions like for serializing/deserializing. -#include "DynamicTypesCollectionCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionPubSubTypes.cpp b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionPubSubTypes.cpp deleted file mode 100644 index 0b5202d7f..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionPubSubTypes.cpp +++ /dev/null @@ -1,421 +0,0 @@ -// 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 DynamicTypesCollectionPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include -#include "DynamicTypesCollectionCdrAux.hpp" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - - -DynamicTypePubSubType::DynamicTypePubSubType() -{ - setName("eprosima::ddsrecorder::participants::DynamicType"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - DynamicType::getMaxCdrSerializedSize(); - #else - eprosima_ddsrecorder_participants_DynamicType_max_cdr_typesize; - #endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_ddsrecorder_participants_DynamicType_max_key_cdr_typesize > - 16 ? eprosima_ddsrecorder_participants_DynamicType_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DynamicTypePubSubType::~DynamicTypePubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DynamicTypePubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - DynamicType* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool DynamicTypePubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - DynamicType* 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 - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function DynamicTypePubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DynamicTypePubSubType::createData() -{ - return reinterpret_cast(new DynamicType()); -} - -void DynamicTypePubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DynamicTypePubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DynamicType* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - eprosima_ddsrecorder_participants_DynamicType_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else - eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || eprosima_ddsrecorder_participants_DynamicType_max_key_cdr_typesize > 16) - { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -DynamicTypesCollectionPubSubType::DynamicTypesCollectionPubSubType() -{ - setName("eprosima::ddsrecorder::participants::DynamicTypesCollection"); - uint32_t type_size = - #if FASTCDR_VERSION_MAJOR == 1 - DynamicTypesCollection::getMaxCdrSerializedSize(); - #else - eprosima_ddsrecorder_participants_DynamicTypesCollection_max_cdr_typesize; - #endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = eprosima_ddsrecorder_participants_DynamicTypesCollection_max_key_cdr_typesize > - 16 ? eprosima_ddsrecorder_participants_DynamicTypesCollection_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DynamicTypesCollectionPubSubType::~DynamicTypesCollectionPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DynamicTypesCollectionPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - DynamicTypesCollection* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - #if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); - #endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length - #if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); - #else - payload->length = static_cast(ser.get_serialized_data_length()); - #endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool DynamicTypesCollectionPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - DynamicTypesCollection* 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 - #if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR - #endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function DynamicTypesCollectionPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { - #if FASTCDR_VERSION_MAJOR == 1 - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - #else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } - #endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DynamicTypesCollectionPubSubType::createData() -{ - return reinterpret_cast(new DynamicTypesCollection()); -} - -void DynamicTypesCollectionPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DynamicTypesCollectionPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DynamicTypesCollection* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - eprosima_ddsrecorder_participants_DynamicTypesCollection_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); - #if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); - #else - eprosima::fastcdr::serialize_key(ser, *p_type); - #endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || eprosima_ddsrecorder_participants_DynamicTypesCollection_max_key_cdr_typesize > 16) - { - m_md5.init(); - #if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); - #else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); - #endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -} //End of namespace participants - - -} //End of namespace ddsrecorder - - -} //End of namespace eprosima diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionv1.cpp b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionv1.cpp deleted file mode 100644 index 4e97c6402..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/v2/DynamicTypesCollectionv1.cpp +++ /dev/null @@ -1,523 +0,0 @@ -// 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 DynamicTypesCollection.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define eprosima_ddsrecorder_participants_DynamicTypesCollection_max_cdr_typesize 78412ULL; -#define eprosima_ddsrecorder_participants_DynamicType_max_cdr_typesize 784ULL; - - -namespace eprosima { - -namespace ddsrecorder { - -namespace participants { - - - -DynamicType::DynamicType() -{ - // /type_d() m_type_name - - // /type_d() m_type_information - - // /type_d() m_type_object - - -} - -DynamicType::~DynamicType() -{ -} - -DynamicType::DynamicType( - const DynamicType& x) -{ - m_type_name = x.m_type_name; - - - m_type_information = x.m_type_information; - - - m_type_object = x.m_type_object; - -} - -DynamicType::DynamicType( - DynamicType&& x) noexcept -{ - m_type_name = std::move(x.m_type_name); - - - m_type_information = std::move(x.m_type_information); - - - m_type_object = std::move(x.m_type_object); - -} - -DynamicType& DynamicType::operator =( - const DynamicType& x) -{ - m_type_name = x.m_type_name; - - - m_type_information = x.m_type_information; - - - m_type_object = x.m_type_object; - - return *this; -} - -DynamicType& DynamicType::operator =( - DynamicType&& x) noexcept -{ - m_type_name = std::move(x.m_type_name); - - - m_type_information = std::move(x.m_type_information); - - - m_type_object = std::move(x.m_type_object); - - return *this; -} - -bool DynamicType::operator ==( - const DynamicType& x) const -{ - return (m_type_name == x.m_type_name && - m_type_information == x.m_type_information && - m_type_object == x.m_type_object); -} - -bool DynamicType::operator !=( - const DynamicType& x) const -{ - return !(*this == x); -} - -size_t DynamicType::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return eprosima_ddsrecorder_participants_DynamicType_max_cdr_typesize; -} - -size_t DynamicType::getCdrSerializedSize( - const DynamicType& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_name().size() + 1; - - - current_alignment += 4 + - eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_information().size() + 1; - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.type_object().size() + 1; - - - return current_alignment - initial_alignment; -} - -void DynamicType::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_type_name.c_str(); - - scdr << m_type_information.c_str(); - - scdr << m_type_object.c_str(); - -} - -void DynamicType::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_type_name; - - - - dcdr >> m_type_information; - - - - dcdr >> m_type_object; - - -} - -bool DynamicType::isKeyDefined() -{ - return false; -} - -void DynamicType::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member type_name - * @param _type_name New value to be copied in member type_name - */ -void DynamicType::type_name( - const std::string& _type_name) -{ - m_type_name = _type_name; -} - -/*! - * @brief This function moves the value in member type_name - * @param _type_name New value to be moved in member type_name - */ -void DynamicType::type_name( - std::string&& _type_name) -{ - m_type_name = std::move(_type_name); -} - -/*! - * @brief This function returns a constant reference to member type_name - * @return Constant reference to member type_name - */ -const std::string& DynamicType::type_name() const -{ - return m_type_name; -} - -/*! - * @brief This function returns a reference to member type_name - * @return Reference to member type_name - */ -std::string& DynamicType::type_name() -{ - return m_type_name; -} - -/*! - * @brief This function copies the value in member type_information - * @param _type_information New value to be copied in member type_information - */ -void DynamicType::type_information( - const std::string& _type_information) -{ - m_type_information = _type_information; -} - -/*! - * @brief This function moves the value in member type_information - * @param _type_information New value to be moved in member type_information - */ -void DynamicType::type_information( - std::string&& _type_information) -{ - m_type_information = std::move(_type_information); -} - -/*! - * @brief This function returns a constant reference to member type_information - * @return Constant reference to member type_information - */ -const std::string& DynamicType::type_information() const -{ - return m_type_information; -} - -/*! - * @brief This function returns a reference to member type_information - * @return Reference to member type_information - */ -std::string& DynamicType::type_information() -{ - return m_type_information; -} - -/*! - * @brief This function copies the value in member type_object - * @param _type_object New value to be copied in member type_object - */ -void DynamicType::type_object( - const std::string& _type_object) -{ - m_type_object = _type_object; -} - -/*! - * @brief This function moves the value in member type_object - * @param _type_object New value to be moved in member type_object - */ -void DynamicType::type_object( - std::string&& _type_object) -{ - m_type_object = std::move(_type_object); -} - -/*! - * @brief This function returns a constant reference to member type_object - * @return Constant reference to member type_object - */ -const std::string& DynamicType::type_object() const -{ - return m_type_object; -} - -/*! - * @brief This function returns a reference to member type_object - * @return Reference to member type_object - */ -std::string& DynamicType::type_object() -{ - return m_type_object; -} - -DynamicTypesCollection::DynamicTypesCollection() -{ - // sequence m_dynamic_types - - -} - -DynamicTypesCollection::~DynamicTypesCollection() -{ -} - -DynamicTypesCollection::DynamicTypesCollection( - const DynamicTypesCollection& x) -{ - m_dynamic_types = x.m_dynamic_types; - -} - -DynamicTypesCollection::DynamicTypesCollection( - DynamicTypesCollection&& x) noexcept -{ - m_dynamic_types = std::move(x.m_dynamic_types); - -} - -DynamicTypesCollection& DynamicTypesCollection::operator =( - const DynamicTypesCollection& x) -{ - m_dynamic_types = x.m_dynamic_types; - - return *this; -} - -DynamicTypesCollection& DynamicTypesCollection::operator =( - DynamicTypesCollection&& x) noexcept -{ - m_dynamic_types = std::move(x.m_dynamic_types); - - return *this; -} - -bool DynamicTypesCollection::operator ==( - const DynamicTypesCollection& x) const -{ - return (m_dynamic_types == x.m_dynamic_types); -} - -bool DynamicTypesCollection::operator !=( - const DynamicTypesCollection& x) const -{ - return !(*this == x); -} - -size_t DynamicTypesCollection::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return eprosima_ddsrecorder_participants_DynamicTypesCollection_max_cdr_typesize; -} - -size_t DynamicTypesCollection::getCdrSerializedSize( - const DynamicTypesCollection& 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.dynamic_types().size(); ++a) - { - current_alignment += eprosima::ddsrecorder::participants::DynamicType::getCdrSerializedSize( - data.dynamic_types().at(a), current_alignment); - } - - - - return current_alignment - initial_alignment; -} - -void DynamicTypesCollection::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_dynamic_types; - - -} - -void DynamicTypesCollection::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_dynamic_types; - - -} - -bool DynamicTypesCollection::isKeyDefined() -{ - return false; -} - -void DynamicTypesCollection::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member dynamic_types - * @param _dynamic_types New value to be copied in member dynamic_types - */ -void DynamicTypesCollection::dynamic_types( - const std::vector& _dynamic_types) -{ - m_dynamic_types = _dynamic_types; -} - -/*! - * @brief This function moves the value in member dynamic_types - * @param _dynamic_types New value to be moved in member dynamic_types - */ -void DynamicTypesCollection::dynamic_types( - std::vector&& _dynamic_types) -{ - m_dynamic_types = std::move(_dynamic_types); -} - -/*! - * @brief This function returns a constant reference to member dynamic_types - * @return Constant reference to member dynamic_types - */ -const std::vector& DynamicTypesCollection::dynamic_types() const -{ - return m_dynamic_types; -} - -/*! - * @brief This function returns a reference to member dynamic_types - * @return Reference to member dynamic_types - */ -std::vector& DynamicTypesCollection::dynamic_types() -{ - return m_dynamic_types; -} - -} // namespace participants - - -} // namespace ddsrecorder - - -} // namespace eprosima - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder_participants/src/cpp/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.cxx b/ddsrecorder_participants/src/cpp/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.cxx new file mode 100644 index 000000000..a9128db35 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.cxx @@ -0,0 +1,40 @@ +// 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 DdsRecorderLogEntryTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +using namespace eprosima::fastdds::dds::xtypes; + diff --git a/ddsrecorder_participants/src/cpp/common/types/logging/v1/DdsRecorderLogEntry.cxx b/ddsrecorder_participants/src/cpp/common/types/logging/v1/DdsRecorderLogEntry.cxx deleted file mode 100644 index e52d523cf..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/logging/v1/DdsRecorderLogEntry.cxx +++ /dev/null @@ -1,91 +0,0 @@ -// 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 DdsRecorderLogEntry.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper diff --git a/ddsrecorder_participants/src/cpp/common/types/logging/v2/DdsRecorderLogEntry.cxx b/ddsrecorder_participants/src/cpp/common/types/logging/v2/DdsRecorderLogEntry.cxx deleted file mode 100644 index 17c28de51..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/logging/v2/DdsRecorderLogEntry.cxx +++ /dev/null @@ -1,42 +0,0 @@ -// 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 DdsRecorderLogEntry.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder_participants/src/cpp/common/types/logging/v2/DdsRecorderLogEntryv1.cxx b/ddsrecorder_participants/src/cpp/common/types/logging/v2/DdsRecorderLogEntryv1.cxx deleted file mode 100644 index 1ecb93249..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/logging/v2/DdsRecorderLogEntryv1.cxx +++ /dev/null @@ -1,98 +0,0 @@ -// 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 DdsRecorderLogEntry.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusPubSubTypes.cxx b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx similarity index 88% rename from ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusPubSubTypes.cxx rename to ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx index de6a61a6f..852aea96d 100644 --- a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusPubSubTypes.cxx +++ b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx @@ -19,33 +19,31 @@ * This file was generated by the tool fastddsgen. */ +#include +#include #include -#include \ - -#include +#include +#include using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - DdsRecorderMonitoringErrorStatusPubSubType::DdsRecorderMonitoringErrorStatusPubSubType() { setName("DdsRecorderMonitoringErrorStatus"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - static_cast(DdsRecorderMonitoringErrorStatus::getMaxCdrSerializedSize()); + static_cast(DdsRecorderMonitoringErrorStatus::getMaxCdrSerializedSize()); #else - DdsRecorderMonitoringErrorStatus_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + DdsRecorderMonitoringErrorStatus_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; - uint32_t keyLength = DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize > - 16 ? DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize : 16; + uint32_t keyLength = DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize > 16 ? DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize : 16; m_keyBuffer = reinterpret_cast(malloc(keyLength)); memset(m_keyBuffer, 0, keyLength); } @@ -142,8 +140,7 @@ std::function DdsRecorderMonitoringErrorStatusPubSubType::getSeriali { #if FASTCDR_VERSION_MAJOR == 1 static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast( - data))) + + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else try @@ -153,8 +150,8 @@ std::function DdsRecorderMonitoringErrorStatusPubSubType::getSeriali eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -192,8 +189,7 @@ bool DdsRecorderMonitoringErrorStatusPubSubType::getKey( DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -223,20 +219,24 @@ bool DdsRecorderMonitoringErrorStatusPubSubType::getKey( return true; } +void DdsRecorderMonitoringErrorStatusPubSubType::register_type_object_representation() +{ + register_DdsRecorderMonitoringErrorStatus_type_identifier(type_identifiers_); +} + DdsRecorderMonitoringStatusPubSubType::DdsRecorderMonitoringStatusPubSubType() { setName("DdsRecorderMonitoringStatus"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - static_cast(DdsRecorderMonitoringStatus::getMaxCdrSerializedSize()); + static_cast(DdsRecorderMonitoringStatus::getMaxCdrSerializedSize()); #else - DdsRecorderMonitoringStatus_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + DdsRecorderMonitoringStatus_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; - uint32_t keyLength = DdsRecorderMonitoringStatus_max_key_cdr_typesize > - 16 ? DdsRecorderMonitoringStatus_max_key_cdr_typesize : 16; + uint32_t keyLength = DdsRecorderMonitoringStatus_max_key_cdr_typesize > 16 ? DdsRecorderMonitoringStatus_max_key_cdr_typesize : 16; m_keyBuffer = reinterpret_cast(malloc(keyLength)); memset(m_keyBuffer, 0, keyLength); } @@ -333,8 +333,7 @@ std::function DdsRecorderMonitoringStatusPubSubType::getSerializedSi { #if FASTCDR_VERSION_MAJOR == 1 static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) - + + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else try @@ -344,8 +343,8 @@ std::function DdsRecorderMonitoringStatusPubSubType::getSerializedSi eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -383,8 +382,7 @@ bool DdsRecorderMonitoringStatusPubSubType::getKey( DdsRecorderMonitoringStatus_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -413,3 +411,12 @@ bool DdsRecorderMonitoringStatusPubSubType::getKey( } return true; } + +void DdsRecorderMonitoringStatusPubSubType::register_type_object_representation() +{ + register_DdsRecorderMonitoringStatus_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include diff --git a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.cxx b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.cxx new file mode 100644 index 000000000..51610d841 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.cxx @@ -0,0 +1,209 @@ +// 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 DdsRecorderMonitoringStatusTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "ddspipe_core/types/monitoring/status/MonitoringStatus.hpp" + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_DdsRecorderMonitoringErrorStatus_type_identifier( + TypeIdentifierPair& type_ids_DdsRecorderMonitoringErrorStatus) +{ + + ReturnCode_t return_code_DdsRecorderMonitoringErrorStatus {eprosima::fastdds::dds::RETCODE_OK}; + return_code_DdsRecorderMonitoringErrorStatus = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsRecorderMonitoringErrorStatus", type_ids_DdsRecorderMonitoringErrorStatus); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsRecorderMonitoringErrorStatus) + { + StructTypeFlag struct_flags_DdsRecorderMonitoringErrorStatus = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_DdsRecorderMonitoringErrorStatus = "DdsRecorderMonitoringErrorStatus"; + eprosima::fastcdr::optional type_ann_builtin_DdsRecorderMonitoringErrorStatus; + eprosima::fastcdr::optional ann_custom_DdsRecorderMonitoringErrorStatus; + CompleteTypeDetail detail_DdsRecorderMonitoringErrorStatus = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsRecorderMonitoringErrorStatus, ann_custom_DdsRecorderMonitoringErrorStatus, type_name_DdsRecorderMonitoringErrorStatus.to_string()); + CompleteStructHeader header_DdsRecorderMonitoringErrorStatus; + header_DdsRecorderMonitoringErrorStatus = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_DdsRecorderMonitoringErrorStatus); + CompleteStructMemberSeq member_seq_DdsRecorderMonitoringErrorStatus; + { + TypeIdentifierPair type_ids_mcap_file_creation_failure; + ReturnCode_t return_code_mcap_file_creation_failure {eprosima::fastdds::dds::RETCODE_OK}; + return_code_mcap_file_creation_failure = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_bool", type_ids_mcap_file_creation_failure); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_mcap_file_creation_failure) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "mcap_file_creation_failure Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_mcap_file_creation_failure = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_mcap_file_creation_failure = 0x00000000; + bool common_mcap_file_creation_failure_ec {false}; + CommonStructMember common_mcap_file_creation_failure {TypeObjectUtils::build_common_struct_member(member_id_mcap_file_creation_failure, member_flags_mcap_file_creation_failure, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_mcap_file_creation_failure, common_mcap_file_creation_failure_ec))}; + if (!common_mcap_file_creation_failure_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure mcap_file_creation_failure member TypeIdentifier inconsistent."); + return; + } + MemberName name_mcap_file_creation_failure = "mcap_file_creation_failure"; + eprosima::fastcdr::optional member_ann_builtin_mcap_file_creation_failure; + ann_custom_DdsRecorderMonitoringErrorStatus.reset(); + CompleteMemberDetail detail_mcap_file_creation_failure = TypeObjectUtils::build_complete_member_detail(name_mcap_file_creation_failure, member_ann_builtin_mcap_file_creation_failure, ann_custom_DdsRecorderMonitoringErrorStatus); + CompleteStructMember member_mcap_file_creation_failure = TypeObjectUtils::build_complete_struct_member(common_mcap_file_creation_failure, detail_mcap_file_creation_failure); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderMonitoringErrorStatus, member_mcap_file_creation_failure); + } + { + TypeIdentifierPair type_ids_disk_full; + ReturnCode_t return_code_disk_full {eprosima::fastdds::dds::RETCODE_OK}; + return_code_disk_full = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_bool", type_ids_disk_full); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_disk_full) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "disk_full Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_disk_full = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_disk_full = 0x00000001; + bool common_disk_full_ec {false}; + CommonStructMember common_disk_full {TypeObjectUtils::build_common_struct_member(member_id_disk_full, member_flags_disk_full, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_disk_full, common_disk_full_ec))}; + if (!common_disk_full_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure disk_full member TypeIdentifier inconsistent."); + return; + } + MemberName name_disk_full = "disk_full"; + eprosima::fastcdr::optional member_ann_builtin_disk_full; + ann_custom_DdsRecorderMonitoringErrorStatus.reset(); + CompleteMemberDetail detail_disk_full = TypeObjectUtils::build_complete_member_detail(name_disk_full, member_ann_builtin_disk_full, ann_custom_DdsRecorderMonitoringErrorStatus); + CompleteStructMember member_disk_full = TypeObjectUtils::build_complete_struct_member(common_disk_full, detail_disk_full); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderMonitoringErrorStatus, member_disk_full); + } + CompleteStructType struct_type_DdsRecorderMonitoringErrorStatus = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsRecorderMonitoringErrorStatus, header_DdsRecorderMonitoringErrorStatus, member_seq_DdsRecorderMonitoringErrorStatus); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsRecorderMonitoringErrorStatus, type_name_DdsRecorderMonitoringErrorStatus.to_string(), type_ids_DdsRecorderMonitoringErrorStatus)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "DdsRecorderMonitoringErrorStatus already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_DdsRecorderMonitoringStatus_type_identifier( + TypeIdentifierPair& type_ids_DdsRecorderMonitoringStatus) +{ + + ReturnCode_t return_code_DdsRecorderMonitoringStatus {eprosima::fastdds::dds::RETCODE_OK}; + return_code_DdsRecorderMonitoringStatus = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsRecorderMonitoringStatus", type_ids_DdsRecorderMonitoringStatus); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_DdsRecorderMonitoringStatus) + { + StructTypeFlag struct_flags_DdsRecorderMonitoringStatus = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + return_code_DdsRecorderMonitoringStatus = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "MonitoringStatus", type_ids_DdsRecorderMonitoringStatus); + + if (return_code_DdsRecorderMonitoringStatus != eprosima::fastdds::dds::RETCODE_OK) + { +::register_MonitoringStatus_type_identifier(type_ids_DdsRecorderMonitoringStatus); + } + QualifiedTypeName type_name_DdsRecorderMonitoringStatus = "DdsRecorderMonitoringStatus"; + eprosima::fastcdr::optional type_ann_builtin_DdsRecorderMonitoringStatus; + eprosima::fastcdr::optional ann_custom_DdsRecorderMonitoringStatus; + CompleteTypeDetail detail_DdsRecorderMonitoringStatus = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_DdsRecorderMonitoringStatus, ann_custom_DdsRecorderMonitoringStatus, type_name_DdsRecorderMonitoringStatus.to_string()); + CompleteStructHeader header_DdsRecorderMonitoringStatus; + if (EK_COMPLETE == type_ids_DdsRecorderMonitoringStatus.type_identifier1()._d()) + { + header_DdsRecorderMonitoringStatus = TypeObjectUtils::build_complete_struct_header(type_ids_DdsRecorderMonitoringStatus.type_identifier1(), detail_DdsRecorderMonitoringStatus); + } + else if (EK_COMPLETE == type_ids_DdsRecorderMonitoringStatus.type_identifier2()._d()) + { + header_DdsRecorderMonitoringStatus = TypeObjectUtils::build_complete_struct_header(type_ids_DdsRecorderMonitoringStatus.type_identifier2(), detail_DdsRecorderMonitoringStatus); + } + else + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "DdsRecorderMonitoringStatus Structure: base_type TypeIdentifier registered in TypeObjectRegistry is inconsistent."); + return; + } + CompleteStructMemberSeq member_seq_DdsRecorderMonitoringStatus; + { + TypeIdentifierPair type_ids_ddsrecorder_error_status; + ReturnCode_t return_code_ddsrecorder_error_status {eprosima::fastdds::dds::RETCODE_OK}; + return_code_ddsrecorder_error_status = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "DdsRecorderMonitoringErrorStatus", type_ids_ddsrecorder_error_status); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_ddsrecorder_error_status) + { + ::register_DdsRecorderMonitoringErrorStatus_type_identifier(type_ids_ddsrecorder_error_status); + } + StructMemberFlag member_flags_ddsrecorder_error_status = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_ddsrecorder_error_status = 0x00000002; + bool common_ddsrecorder_error_status_ec {false}; + CommonStructMember common_ddsrecorder_error_status {TypeObjectUtils::build_common_struct_member(member_id_ddsrecorder_error_status, member_flags_ddsrecorder_error_status, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_ddsrecorder_error_status, common_ddsrecorder_error_status_ec))}; + if (!common_ddsrecorder_error_status_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure ddsrecorder_error_status member TypeIdentifier inconsistent."); + return; + } + MemberName name_ddsrecorder_error_status = "ddsrecorder_error_status"; + eprosima::fastcdr::optional member_ann_builtin_ddsrecorder_error_status; + ann_custom_DdsRecorderMonitoringStatus.reset(); + CompleteMemberDetail detail_ddsrecorder_error_status = TypeObjectUtils::build_complete_member_detail(name_ddsrecorder_error_status, member_ann_builtin_ddsrecorder_error_status, ann_custom_DdsRecorderMonitoringStatus); + CompleteStructMember member_ddsrecorder_error_status = TypeObjectUtils::build_complete_struct_member(common_ddsrecorder_error_status, detail_ddsrecorder_error_status); + TypeObjectUtils::add_complete_struct_member(member_seq_DdsRecorderMonitoringStatus, member_ddsrecorder_error_status); + } + CompleteStructType struct_type_DdsRecorderMonitoringStatus = TypeObjectUtils::build_complete_struct_type(struct_flags_DdsRecorderMonitoringStatus, header_DdsRecorderMonitoringStatus, member_seq_DdsRecorderMonitoringStatus); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_DdsRecorderMonitoringStatus, type_name_DdsRecorderMonitoringStatus.to_string(), type_ids_DdsRecorderMonitoringStatus)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "DdsRecorderMonitoringStatus already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatus.cxx b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatus.cxx deleted file mode 100644 index 0656b9eb4..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatus.cxx +++ /dev/null @@ -1,440 +0,0 @@ -// 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 DdsRecorderMonitoringStatus.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define MonitoringErrorStatus_max_cdr_typesize 6ULL; -#define DdsRecorderMonitoringErrorStatus_max_cdr_typesize 6ULL; -#define DdsRecorderMonitoringStatus_max_cdr_typesize 18ULL; -#define MonitoringStatus_max_cdr_typesize 11ULL; - - - - -DdsRecorderMonitoringErrorStatus::DdsRecorderMonitoringErrorStatus() -{ - // boolean m_mcap_file_creation_failure - m_mcap_file_creation_failure = false; - // boolean m_disk_full - m_disk_full = false; - -} - -DdsRecorderMonitoringErrorStatus::~DdsRecorderMonitoringErrorStatus() -{ -} - -DdsRecorderMonitoringErrorStatus::DdsRecorderMonitoringErrorStatus( - const DdsRecorderMonitoringErrorStatus& x) -{ - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - - - m_disk_full = x.m_disk_full; - -} - -DdsRecorderMonitoringErrorStatus::DdsRecorderMonitoringErrorStatus( - DdsRecorderMonitoringErrorStatus&& x) noexcept -{ - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - - - m_disk_full = x.m_disk_full; - -} - -DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringErrorStatus::operator =( - const DdsRecorderMonitoringErrorStatus& x) -{ - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - - - m_disk_full = x.m_disk_full; - - return *this; -} - -DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringErrorStatus::operator =( - DdsRecorderMonitoringErrorStatus&& x) noexcept -{ - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - - - m_disk_full = x.m_disk_full; - - return *this; -} - -bool DdsRecorderMonitoringErrorStatus::operator ==( - const DdsRecorderMonitoringErrorStatus& x) const -{ - return (m_mcap_file_creation_failure == x.m_mcap_file_creation_failure && - m_disk_full == x.m_disk_full); -} - -bool DdsRecorderMonitoringErrorStatus::operator !=( - const DdsRecorderMonitoringErrorStatus& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderMonitoringErrorStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderMonitoringErrorStatus_max_cdr_typesize; -} - -size_t DdsRecorderMonitoringErrorStatus::getCdrSerializedSize( - const DdsRecorderMonitoringErrorStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - return current_alignment - initial_alignment; -} - -void DdsRecorderMonitoringErrorStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_mcap_file_creation_failure; - - scdr << m_disk_full; - -} - -void DdsRecorderMonitoringErrorStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_mcap_file_creation_failure; - - - - dcdr >> m_disk_full; - - -} - -bool DdsRecorderMonitoringErrorStatus::isKeyDefined() -{ - return false; -} - -void DdsRecorderMonitoringErrorStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member mcap_file_creation_failure - * @param _mcap_file_creation_failure New value for member mcap_file_creation_failure - */ -void DdsRecorderMonitoringErrorStatus::mcap_file_creation_failure( - bool _mcap_file_creation_failure) -{ - m_mcap_file_creation_failure = _mcap_file_creation_failure; -} - -/*! - * @brief This function returns the value of member mcap_file_creation_failure - * @return Value of member mcap_file_creation_failure - */ -bool DdsRecorderMonitoringErrorStatus::mcap_file_creation_failure() const -{ - return m_mcap_file_creation_failure; -} - -/*! - * @brief This function returns a reference to member mcap_file_creation_failure - * @return Reference to member mcap_file_creation_failure - */ -bool& DdsRecorderMonitoringErrorStatus::mcap_file_creation_failure() -{ - return m_mcap_file_creation_failure; -} - -/*! - * @brief This function sets a value in member disk_full - * @param _disk_full New value for member disk_full - */ -void DdsRecorderMonitoringErrorStatus::disk_full( - bool _disk_full) -{ - m_disk_full = _disk_full; -} - -/*! - * @brief This function returns the value of member disk_full - * @return Value of member disk_full - */ -bool DdsRecorderMonitoringErrorStatus::disk_full() const -{ - return m_disk_full; -} - -/*! - * @brief This function returns a reference to member disk_full - * @return Reference to member disk_full - */ -bool& DdsRecorderMonitoringErrorStatus::disk_full() -{ - return m_disk_full; -} - -DdsRecorderMonitoringStatus::DdsRecorderMonitoringStatus() - : MonitoringStatus() -{ - // DdsRecorderMonitoringErrorStatus m_ddsrecorder_error_status - - -} - -DdsRecorderMonitoringStatus::~DdsRecorderMonitoringStatus() -{ -} - -DdsRecorderMonitoringStatus::DdsRecorderMonitoringStatus( - const DdsRecorderMonitoringStatus& x) - : MonitoringStatus(x) -{ - m_ddsrecorder_error_status = x.m_ddsrecorder_error_status; - -} - -DdsRecorderMonitoringStatus::DdsRecorderMonitoringStatus( - DdsRecorderMonitoringStatus&& x) noexcept - : MonitoringStatus(std::move(x)) -{ - m_ddsrecorder_error_status = std::move(x.m_ddsrecorder_error_status); - -} - -DdsRecorderMonitoringStatus& DdsRecorderMonitoringStatus::operator =( - const DdsRecorderMonitoringStatus& x) -{ - MonitoringStatus::operator =(x); - - m_ddsrecorder_error_status = x.m_ddsrecorder_error_status; - - return *this; -} - -DdsRecorderMonitoringStatus& DdsRecorderMonitoringStatus::operator =( - DdsRecorderMonitoringStatus&& x) noexcept -{ - MonitoringStatus::operator =(std::move(x)); - - m_ddsrecorder_error_status = std::move(x.m_ddsrecorder_error_status); - - return *this; -} - -bool DdsRecorderMonitoringStatus::operator ==( - const DdsRecorderMonitoringStatus& x) const -{ - if (MonitoringStatus::operator !=(x)) - { - return false; - } - - return (m_ddsrecorder_error_status == x.m_ddsrecorder_error_status); -} - -bool DdsRecorderMonitoringStatus::operator !=( - const DdsRecorderMonitoringStatus& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderMonitoringStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderMonitoringStatus_max_cdr_typesize; -} - -size_t DdsRecorderMonitoringStatus::getCdrSerializedSize( - const DdsRecorderMonitoringStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += MonitoringStatus::getCdrSerializedSize(data, current_alignment); - - current_alignment += DdsRecorderMonitoringErrorStatus::getCdrSerializedSize( - data.ddsrecorder_error_status(), current_alignment); - - - return current_alignment - initial_alignment; -} - -void DdsRecorderMonitoringStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - MonitoringStatus::serialize(scdr); - - scdr << m_ddsrecorder_error_status; - -} - -void DdsRecorderMonitoringStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - MonitoringStatus::deserialize(dcdr); - - dcdr >> m_ddsrecorder_error_status; - - -} - -bool DdsRecorderMonitoringStatus::isKeyDefined() -{ - if (MonitoringStatus::isKeyDefined()) - { - return true; - } - - return false; -} - -void DdsRecorderMonitoringStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - MonitoringStatus::serializeKey(scdr); -} - -/*! - * @brief This function copies the value in member ddsrecorder_error_status - * @param _ddsrecorder_error_status New value to be copied in member ddsrecorder_error_status - */ -void DdsRecorderMonitoringStatus::ddsrecorder_error_status( - const DdsRecorderMonitoringErrorStatus& _ddsrecorder_error_status) -{ - m_ddsrecorder_error_status = _ddsrecorder_error_status; -} - -/*! - * @brief This function moves the value in member ddsrecorder_error_status - * @param _ddsrecorder_error_status New value to be moved in member ddsrecorder_error_status - */ -void DdsRecorderMonitoringStatus::ddsrecorder_error_status( - DdsRecorderMonitoringErrorStatus&& _ddsrecorder_error_status) -{ - m_ddsrecorder_error_status = std::move(_ddsrecorder_error_status); -} - -/*! - * @brief This function returns a constant reference to member ddsrecorder_error_status - * @return Constant reference to member ddsrecorder_error_status - */ -const DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringStatus::ddsrecorder_error_status() const -{ - return m_ddsrecorder_error_status; -} - -/*! - * @brief This function returns a reference to member ddsrecorder_error_status - * @return Reference to member ddsrecorder_error_status - */ -DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringStatus::ddsrecorder_error_status() -{ - return m_ddsrecorder_error_status; -} diff --git a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusTypeObject.cxx b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusTypeObject.cxx deleted file mode 100644 index 3baffc20a..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v1/DdsRecorderMonitoringStatusTypeObject.cxx +++ /dev/null @@ -1,477 +0,0 @@ -// 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 DdsRecorderMonitoringStatusTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include -#include \ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerDdsRecorderMonitoringStatusTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("MonitoringErrorStatus", GetMonitoringErrorStatusIdentifier(true), - GetMonitoringErrorStatusObject(true)); - factory->add_type_object("MonitoringErrorStatus", GetMonitoringErrorStatusIdentifier(false), - GetMonitoringErrorStatusObject(false)); - - - factory->add_type_object("MonitoringStatus", GetMonitoringStatusIdentifier(true), - GetMonitoringStatusObject(true)); - factory->add_type_object("MonitoringStatus", GetMonitoringStatusIdentifier(false), - GetMonitoringStatusObject(false)); - - - factory->add_type_object("DdsRecorderMonitoringErrorStatus", - GetDdsRecorderMonitoringErrorStatusIdentifier(true), - GetDdsRecorderMonitoringErrorStatusObject(true)); - factory->add_type_object("DdsRecorderMonitoringErrorStatus", - GetDdsRecorderMonitoringErrorStatusIdentifier(false), - GetDdsRecorderMonitoringErrorStatusObject(false)); - - - factory->add_type_object("DdsRecorderMonitoringStatus", GetDdsRecorderMonitoringStatusIdentifier(true), - GetDdsRecorderMonitoringStatusObject(true)); - factory->add_type_object("DdsRecorderMonitoringStatus", GetDdsRecorderMonitoringStatusIdentifier(false), - GetDdsRecorderMonitoringStatusObject(false)); - - }); -} - -const TypeIdentifier* GetDdsRecorderMonitoringErrorStatusIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier( - "DdsRecorderMonitoringErrorStatus", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsRecorderMonitoringErrorStatusObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderMonitoringErrorStatus", complete); -} - -const TypeObject* GetDdsRecorderMonitoringErrorStatusObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object( - "DdsRecorderMonitoringErrorStatus", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsRecorderMonitoringErrorStatusObject(); - } - //else - return GetMinimalDdsRecorderMonitoringErrorStatusObject(); -} - -const TypeObject* GetMinimalDdsRecorderMonitoringErrorStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object( - "DdsRecorderMonitoringErrorStatus", 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_mcap_file_creation_failure; - mst_mcap_file_creation_failure.common().member_id(memberId++); - mst_mcap_file_creation_failure.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_mcap_file_creation_failure.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_mcap_file_creation_failure.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_mcap_file_creation_failure.common().member_flags().IS_OPTIONAL(false); - mst_mcap_file_creation_failure.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_mcap_file_creation_failure.common().member_flags().IS_KEY(false); - mst_mcap_file_creation_failure.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_mcap_file_creation_failure.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier( - "bool", false)); - - - MD5 mcap_file_creation_failure_hash("mcap_file_creation_failure"); - for (int i = 0; i < 4; ++i) - { - mst_mcap_file_creation_failure.detail().name_hash()[i] = mcap_file_creation_failure_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_mcap_file_creation_failure); - - MinimalStructMember mst_disk_full; - mst_disk_full.common().member_id(memberId++); - mst_disk_full.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_disk_full.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_disk_full.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_disk_full.common().member_flags().IS_OPTIONAL(false); - mst_disk_full.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_disk_full.common().member_flags().IS_KEY(false); - mst_disk_full.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_disk_full.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 disk_full_hash("disk_full"); - for (int i = 0; i < 4; ++i) - { - mst_disk_full.detail().name_hash()[i] = disk_full_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_disk_full); - - - // 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderMonitoringErrorStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringErrorStatus", false); -} - -const TypeObject* GetCompleteDdsRecorderMonitoringErrorStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object( - "DdsRecorderMonitoringErrorStatus", 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_mcap_file_creation_failure; - cst_mcap_file_creation_failure.common().member_id(memberId++); - cst_mcap_file_creation_failure.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_mcap_file_creation_failure.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_mcap_file_creation_failure.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_mcap_file_creation_failure.common().member_flags().IS_OPTIONAL(false); - cst_mcap_file_creation_failure.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_mcap_file_creation_failure.common().member_flags().IS_KEY(false); - cst_mcap_file_creation_failure.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_mcap_file_creation_failure.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier( - "bool", false)); - - - cst_mcap_file_creation_failure.detail().name("mcap_file_creation_failure"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_mcap_file_creation_failure); - - CompleteStructMember cst_disk_full; - cst_disk_full.common().member_id(memberId++); - cst_disk_full.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_disk_full.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_disk_full.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_disk_full.common().member_flags().IS_OPTIONAL(false); - cst_disk_full.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_disk_full.common().member_flags().IS_KEY(false); - cst_disk_full.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_disk_full.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_disk_full.detail().name("disk_full"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_disk_full); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsRecorderMonitoringErrorStatus"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderMonitoringErrorStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringErrorStatus", true); -} - -const TypeIdentifier* GetDdsRecorderMonitoringStatusIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier( - "DdsRecorderMonitoringStatus", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsRecorderMonitoringStatusObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderMonitoringStatus", complete); -} - -const TypeObject* GetDdsRecorderMonitoringStatusObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringStatus", - complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsRecorderMonitoringStatusObject(); - } - //else - return GetMinimalDdsRecorderMonitoringStatusObject(); -} - -const TypeObject* GetMinimalDdsRecorderMonitoringStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringStatus", - 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_ddsrecorder_error_status; - mst_ddsrecorder_error_status.common().member_id(memberId++); - mst_ddsrecorder_error_status.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_ddsrecorder_error_status.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_ddsrecorder_error_status.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_ddsrecorder_error_status.common().member_flags().IS_OPTIONAL(false); - mst_ddsrecorder_error_status.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_ddsrecorder_error_status.common().member_flags().IS_KEY(false); - mst_ddsrecorder_error_status.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_ddsrecorder_error_status.common().member_type_id(*GetDdsRecorderMonitoringErrorStatusIdentifier(false)); - - MD5 ddsrecorder_error_status_hash("ddsrecorder_error_status"); - for (int i = 0; i < 4; ++i) - { - mst_ddsrecorder_error_status.detail().name_hash()[i] = ddsrecorder_error_status_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_ddsrecorder_error_status); - - - // 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]; - type_object->minimal().struct_type().header().base_type(*GetMonitoringStatusIdentifier(false)); - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderMonitoringStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringStatus", false); -} - -const TypeObject* GetCompleteDdsRecorderMonitoringStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringStatus", - 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_ddsrecorder_error_status; - cst_ddsrecorder_error_status.common().member_id(memberId++); - cst_ddsrecorder_error_status.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_ddsrecorder_error_status.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_ddsrecorder_error_status.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_ddsrecorder_error_status.common().member_flags().IS_OPTIONAL(false); - cst_ddsrecorder_error_status.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_ddsrecorder_error_status.common().member_flags().IS_KEY(false); - cst_ddsrecorder_error_status.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_ddsrecorder_error_status.common().member_type_id(*GetDdsRecorderMonitoringErrorStatusIdentifier(true)); - - cst_ddsrecorder_error_status.detail().name("ddsrecorder_error_status"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_ddsrecorder_error_status); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsRecorderMonitoringStatus"); - // TODO inheritance - type_object->complete().struct_type().header().base_type(*GetMonitoringStatusIdentifier(true)); - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderMonitoringStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringStatus", true); -} diff --git a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatus.cxx b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatus.cxx deleted file mode 100644 index d34be85fa..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatus.cxx +++ /dev/null @@ -1,254 +0,0 @@ -// 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 DdsRecorderMonitoringStatus.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -DdsRecorderMonitoringErrorStatus::DdsRecorderMonitoringErrorStatus() -{ -} - -DdsRecorderMonitoringErrorStatus::~DdsRecorderMonitoringErrorStatus() -{ -} - -DdsRecorderMonitoringErrorStatus::DdsRecorderMonitoringErrorStatus( - const DdsRecorderMonitoringErrorStatus& x) -{ - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - m_disk_full = x.m_disk_full; -} - -DdsRecorderMonitoringErrorStatus::DdsRecorderMonitoringErrorStatus( - DdsRecorderMonitoringErrorStatus&& x) noexcept -{ - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - m_disk_full = x.m_disk_full; -} - -DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringErrorStatus::operator =( - const DdsRecorderMonitoringErrorStatus& x) -{ - - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - m_disk_full = x.m_disk_full; - return *this; -} - -DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringErrorStatus::operator =( - DdsRecorderMonitoringErrorStatus&& x) noexcept -{ - - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - m_disk_full = x.m_disk_full; - return *this; -} - -bool DdsRecorderMonitoringErrorStatus::operator ==( - const DdsRecorderMonitoringErrorStatus& x) const -{ - return (m_mcap_file_creation_failure == x.m_mcap_file_creation_failure && - m_disk_full == x.m_disk_full); -} - -bool DdsRecorderMonitoringErrorStatus::operator !=( - const DdsRecorderMonitoringErrorStatus& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member mcap_file_creation_failure - * @param _mcap_file_creation_failure New value for member mcap_file_creation_failure - */ -void DdsRecorderMonitoringErrorStatus::mcap_file_creation_failure( - bool _mcap_file_creation_failure) -{ - m_mcap_file_creation_failure = _mcap_file_creation_failure; -} - -/*! - * @brief This function returns the value of member mcap_file_creation_failure - * @return Value of member mcap_file_creation_failure - */ -bool DdsRecorderMonitoringErrorStatus::mcap_file_creation_failure() const -{ - return m_mcap_file_creation_failure; -} - -/*! - * @brief This function returns a reference to member mcap_file_creation_failure - * @return Reference to member mcap_file_creation_failure - */ -bool& DdsRecorderMonitoringErrorStatus::mcap_file_creation_failure() -{ - return m_mcap_file_creation_failure; -} - -/*! - * @brief This function sets a value in member disk_full - * @param _disk_full New value for member disk_full - */ -void DdsRecorderMonitoringErrorStatus::disk_full( - bool _disk_full) -{ - m_disk_full = _disk_full; -} - -/*! - * @brief This function returns the value of member disk_full - * @return Value of member disk_full - */ -bool DdsRecorderMonitoringErrorStatus::disk_full() const -{ - return m_disk_full; -} - -/*! - * @brief This function returns a reference to member disk_full - * @return Reference to member disk_full - */ -bool& DdsRecorderMonitoringErrorStatus::disk_full() -{ - return m_disk_full; -} - -DdsRecorderMonitoringStatus::DdsRecorderMonitoringStatus() - : MonitoringStatus() - -{ -} - -DdsRecorderMonitoringStatus::~DdsRecorderMonitoringStatus() -{ -} - -DdsRecorderMonitoringStatus::DdsRecorderMonitoringStatus( - const DdsRecorderMonitoringStatus& x) - : MonitoringStatus(x) - -{ - m_ddsrecorder_error_status = x.m_ddsrecorder_error_status; -} - -DdsRecorderMonitoringStatus::DdsRecorderMonitoringStatus( - DdsRecorderMonitoringStatus&& x) noexcept - : MonitoringStatus(std::move(x)) - -{ - m_ddsrecorder_error_status = std::move(x.m_ddsrecorder_error_status); -} - -DdsRecorderMonitoringStatus& DdsRecorderMonitoringStatus::operator =( - const DdsRecorderMonitoringStatus& x) -{ - MonitoringStatus::operator =(x); - - m_ddsrecorder_error_status = x.m_ddsrecorder_error_status; - return *this; -} - -DdsRecorderMonitoringStatus& DdsRecorderMonitoringStatus::operator =( - DdsRecorderMonitoringStatus&& x) noexcept -{ - MonitoringStatus::operator =(std::move(x)); - - m_ddsrecorder_error_status = std::move(x.m_ddsrecorder_error_status); - return *this; -} - -bool DdsRecorderMonitoringStatus::operator ==( - const DdsRecorderMonitoringStatus& x) const -{ - if (MonitoringStatus::operator !=(x)) - { - return false; - } - return (m_ddsrecorder_error_status == x.m_ddsrecorder_error_status); -} - -bool DdsRecorderMonitoringStatus::operator !=( - const DdsRecorderMonitoringStatus& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member ddsrecorder_error_status - * @param _ddsrecorder_error_status New value to be copied in member ddsrecorder_error_status - */ -void DdsRecorderMonitoringStatus::ddsrecorder_error_status( - const DdsRecorderMonitoringErrorStatus& _ddsrecorder_error_status) -{ - m_ddsrecorder_error_status = _ddsrecorder_error_status; -} - -/*! - * @brief This function moves the value in member ddsrecorder_error_status - * @param _ddsrecorder_error_status New value to be moved in member ddsrecorder_error_status - */ -void DdsRecorderMonitoringStatus::ddsrecorder_error_status( - DdsRecorderMonitoringErrorStatus&& _ddsrecorder_error_status) -{ - m_ddsrecorder_error_status = std::move(_ddsrecorder_error_status); -} - -/*! - * @brief This function returns a constant reference to member ddsrecorder_error_status - * @return Constant reference to member ddsrecorder_error_status - */ -const DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringStatus::ddsrecorder_error_status() const -{ - return m_ddsrecorder_error_status; -} - -/*! - * @brief This function returns a reference to member ddsrecorder_error_status - * @return Reference to member ddsrecorder_error_status - */ -DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringStatus::ddsrecorder_error_status() -{ - return m_ddsrecorder_error_status; -} - -// Include auxiliary functions like for serializing/deserializing. -#include - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusPubSubTypes.cxx b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusPubSubTypes.cxx deleted file mode 100644 index 1afbb1f0b..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusPubSubTypes.cxx +++ /dev/null @@ -1,415 +0,0 @@ -// 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 DdsRecorderMonitoringStatusPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#include - -#include \ - -#include - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - - -DdsRecorderMonitoringErrorStatusPubSubType::DdsRecorderMonitoringErrorStatusPubSubType() -{ - setName("DdsRecorderMonitoringErrorStatus"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DdsRecorderMonitoringErrorStatus::getMaxCdrSerializedSize()); -#else - DdsRecorderMonitoringErrorStatus_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize > - 16 ? DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DdsRecorderMonitoringErrorStatusPubSubType::~DdsRecorderMonitoringErrorStatusPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DdsRecorderMonitoringErrorStatusPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - DdsRecorderMonitoringErrorStatus* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool DdsRecorderMonitoringErrorStatusPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - DdsRecorderMonitoringErrorStatus* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function DdsRecorderMonitoringErrorStatusPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast( - data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DdsRecorderMonitoringErrorStatusPubSubType::createData() -{ - return reinterpret_cast(new DdsRecorderMonitoringErrorStatus()); -} - -void DdsRecorderMonitoringErrorStatusPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DdsRecorderMonitoringErrorStatusPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DdsRecorderMonitoringErrorStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || DdsRecorderMonitoringErrorStatus_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -DdsRecorderMonitoringStatusPubSubType::DdsRecorderMonitoringStatusPubSubType() -{ - setName("DdsRecorderMonitoringStatus"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(DdsRecorderMonitoringStatus::getMaxCdrSerializedSize()); -#else - DdsRecorderMonitoringStatus_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = DdsRecorderMonitoringStatus_max_key_cdr_typesize > - 16 ? DdsRecorderMonitoringStatus_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -DdsRecorderMonitoringStatusPubSubType::~DdsRecorderMonitoringStatusPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool DdsRecorderMonitoringStatusPubSubType::serialize( - void* data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - DdsRecorderMonitoringStatus* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool DdsRecorderMonitoringStatusPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - DdsRecorderMonitoringStatus* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function DdsRecorderMonitoringStatusPubSubType::getSerializedSizeProvider( - void* data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) - + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* DdsRecorderMonitoringStatusPubSubType::createData() -{ - return reinterpret_cast(new DdsRecorderMonitoringStatus()); -} - -void DdsRecorderMonitoringStatusPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool DdsRecorderMonitoringStatusPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - DdsRecorderMonitoringStatus* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - DdsRecorderMonitoringStatus_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || DdsRecorderMonitoringStatus_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusTypeObject.cxx b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusTypeObject.cxx deleted file mode 100644 index 2e47f2545..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusTypeObject.cxx +++ /dev/null @@ -1,477 +0,0 @@ -// 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 DdsRecorderMonitoringStatusTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include -#include \ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerDdsRecorderMonitoringStatusTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("MonitoringErrorStatus", GetMonitoringErrorStatusIdentifier(true), - GetMonitoringErrorStatusObject(true)); - factory->add_type_object("MonitoringErrorStatus", GetMonitoringErrorStatusIdentifier(false), - GetMonitoringErrorStatusObject(false)); - - - factory->add_type_object("MonitoringStatus", GetMonitoringStatusIdentifier(true), - GetMonitoringStatusObject(true)); - factory->add_type_object("MonitoringStatus", GetMonitoringStatusIdentifier(false), - GetMonitoringStatusObject(false)); - - - factory->add_type_object("DdsRecorderMonitoringErrorStatus", - GetDdsRecorderMonitoringErrorStatusIdentifier(true), - GetDdsRecorderMonitoringErrorStatusObject(true)); - factory->add_type_object("DdsRecorderMonitoringErrorStatus", - GetDdsRecorderMonitoringErrorStatusIdentifier(false), - GetDdsRecorderMonitoringErrorStatusObject(false)); - - - factory->add_type_object("DdsRecorderMonitoringStatus", GetDdsRecorderMonitoringStatusIdentifier(true), - GetDdsRecorderMonitoringStatusObject(true)); - factory->add_type_object("DdsRecorderMonitoringStatus", GetDdsRecorderMonitoringStatusIdentifier(false), - GetDdsRecorderMonitoringStatusObject(false)); - - }); -} - -const TypeIdentifier* GetDdsRecorderMonitoringErrorStatusIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier( - "DdsRecorderMonitoringErrorStatus", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsRecorderMonitoringErrorStatusObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderMonitoringErrorStatus", complete); -} - -const TypeObject* GetDdsRecorderMonitoringErrorStatusObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object( - "DdsRecorderMonitoringErrorStatus", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsRecorderMonitoringErrorStatusObject(); - } - //else - return GetMinimalDdsRecorderMonitoringErrorStatusObject(); -} - -const TypeObject* GetMinimalDdsRecorderMonitoringErrorStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object( - "DdsRecorderMonitoringErrorStatus", 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_mcap_file_creation_failure; - mst_mcap_file_creation_failure.common().member_id(memberId++); - mst_mcap_file_creation_failure.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_mcap_file_creation_failure.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_mcap_file_creation_failure.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_mcap_file_creation_failure.common().member_flags().IS_OPTIONAL(false); - mst_mcap_file_creation_failure.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_mcap_file_creation_failure.common().member_flags().IS_KEY(false); - mst_mcap_file_creation_failure.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_mcap_file_creation_failure.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier( - "bool", false)); - - - MD5 mcap_file_creation_failure_hash("mcap_file_creation_failure"); - for (int i = 0; i < 4; ++i) - { - mst_mcap_file_creation_failure.detail().name_hash()[i] = mcap_file_creation_failure_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_mcap_file_creation_failure); - - MinimalStructMember mst_disk_full; - mst_disk_full.common().member_id(memberId++); - mst_disk_full.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_disk_full.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_disk_full.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_disk_full.common().member_flags().IS_OPTIONAL(false); - mst_disk_full.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_disk_full.common().member_flags().IS_KEY(false); - mst_disk_full.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_disk_full.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - MD5 disk_full_hash("disk_full"); - for (int i = 0; i < 4; ++i) - { - mst_disk_full.detail().name_hash()[i] = disk_full_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_disk_full); - - - // 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderMonitoringErrorStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringErrorStatus", false); -} - -const TypeObject* GetCompleteDdsRecorderMonitoringErrorStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object( - "DdsRecorderMonitoringErrorStatus", 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_mcap_file_creation_failure; - cst_mcap_file_creation_failure.common().member_id(memberId++); - cst_mcap_file_creation_failure.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_mcap_file_creation_failure.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_mcap_file_creation_failure.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_mcap_file_creation_failure.common().member_flags().IS_OPTIONAL(false); - cst_mcap_file_creation_failure.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_mcap_file_creation_failure.common().member_flags().IS_KEY(false); - cst_mcap_file_creation_failure.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_mcap_file_creation_failure.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier( - "bool", false)); - - - cst_mcap_file_creation_failure.detail().name("mcap_file_creation_failure"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_mcap_file_creation_failure); - - CompleteStructMember cst_disk_full; - cst_disk_full.common().member_id(memberId++); - cst_disk_full.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_disk_full.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_disk_full.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_disk_full.common().member_flags().IS_OPTIONAL(false); - cst_disk_full.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_disk_full.common().member_flags().IS_KEY(false); - cst_disk_full.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_disk_full.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("bool", false)); - - - cst_disk_full.detail().name("disk_full"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_disk_full); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsRecorderMonitoringErrorStatus"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderMonitoringErrorStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringErrorStatus", true); -} - -const TypeIdentifier* GetDdsRecorderMonitoringStatusIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier( - "DdsRecorderMonitoringStatus", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetDdsRecorderMonitoringStatusObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("DdsRecorderMonitoringStatus", complete); -} - -const TypeObject* GetDdsRecorderMonitoringStatusObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringStatus", - complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteDdsRecorderMonitoringStatusObject(); - } - //else - return GetMinimalDdsRecorderMonitoringStatusObject(); -} - -const TypeObject* GetMinimalDdsRecorderMonitoringStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringStatus", - 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_ddsrecorder_error_status; - mst_ddsrecorder_error_status.common().member_id(memberId++); - mst_ddsrecorder_error_status.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_ddsrecorder_error_status.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_ddsrecorder_error_status.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_ddsrecorder_error_status.common().member_flags().IS_OPTIONAL(false); - mst_ddsrecorder_error_status.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_ddsrecorder_error_status.common().member_flags().IS_KEY(false); - mst_ddsrecorder_error_status.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_ddsrecorder_error_status.common().member_type_id(*GetDdsRecorderMonitoringErrorStatusIdentifier(false)); - - MD5 ddsrecorder_error_status_hash("ddsrecorder_error_status"); - for (int i = 0; i < 4; ++i) - { - mst_ddsrecorder_error_status.detail().name_hash()[i] = ddsrecorder_error_status_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_ddsrecorder_error_status); - - - // 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]; - type_object->minimal().struct_type().header().base_type(*GetMonitoringStatusIdentifier(false)); - - TypeIdentifier identifier; - identifier._d(EK_MINIMAL); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderMonitoringStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringStatus", false); -} - -const TypeObject* GetCompleteDdsRecorderMonitoringStatusObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringStatus", - 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_ddsrecorder_error_status; - cst_ddsrecorder_error_status.common().member_id(memberId++); - cst_ddsrecorder_error_status.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_ddsrecorder_error_status.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_ddsrecorder_error_status.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_ddsrecorder_error_status.common().member_flags().IS_OPTIONAL(false); - cst_ddsrecorder_error_status.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_ddsrecorder_error_status.common().member_flags().IS_KEY(false); - cst_ddsrecorder_error_status.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_ddsrecorder_error_status.common().member_type_id(*GetDdsRecorderMonitoringErrorStatusIdentifier(true)); - - cst_ddsrecorder_error_status.detail().name("ddsrecorder_error_status"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_ddsrecorder_error_status); - - - // Header - type_object->complete().struct_type().header().detail().type_name("DdsRecorderMonitoringStatus"); - // TODO inheritance - type_object->complete().struct_type().header().base_type(*GetMonitoringStatusIdentifier(true)); - - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("DdsRecorderMonitoringStatus", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("DdsRecorderMonitoringStatus", true); -} diff --git a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusv1.cxx b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusv1.cxx deleted file mode 100644 index 18186e8cb..000000000 --- a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/v2/DdsRecorderMonitoringStatusv1.cxx +++ /dev/null @@ -1,444 +0,0 @@ -// 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 DdsRecorderMonitoringStatus.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define MonitoringErrorStatus_max_cdr_typesize 6ULL; -#define DdsRecorderMonitoringErrorStatus_max_cdr_typesize 6ULL; -#define DdsRecorderMonitoringStatus_max_cdr_typesize 18ULL; -#define MonitoringStatus_max_cdr_typesize 11ULL; - - - - -DdsRecorderMonitoringErrorStatus::DdsRecorderMonitoringErrorStatus() -{ - // boolean m_mcap_file_creation_failure - m_mcap_file_creation_failure = false; - // boolean m_disk_full - m_disk_full = false; - -} - -DdsRecorderMonitoringErrorStatus::~DdsRecorderMonitoringErrorStatus() -{ -} - -DdsRecorderMonitoringErrorStatus::DdsRecorderMonitoringErrorStatus( - const DdsRecorderMonitoringErrorStatus& x) -{ - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - - - m_disk_full = x.m_disk_full; - -} - -DdsRecorderMonitoringErrorStatus::DdsRecorderMonitoringErrorStatus( - DdsRecorderMonitoringErrorStatus&& x) noexcept -{ - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - - - m_disk_full = x.m_disk_full; - -} - -DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringErrorStatus::operator =( - const DdsRecorderMonitoringErrorStatus& x) -{ - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - - - m_disk_full = x.m_disk_full; - - return *this; -} - -DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringErrorStatus::operator =( - DdsRecorderMonitoringErrorStatus&& x) noexcept -{ - m_mcap_file_creation_failure = x.m_mcap_file_creation_failure; - - - m_disk_full = x.m_disk_full; - - return *this; -} - -bool DdsRecorderMonitoringErrorStatus::operator ==( - const DdsRecorderMonitoringErrorStatus& x) const -{ - return (m_mcap_file_creation_failure == x.m_mcap_file_creation_failure && - m_disk_full == x.m_disk_full); -} - -bool DdsRecorderMonitoringErrorStatus::operator !=( - const DdsRecorderMonitoringErrorStatus& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderMonitoringErrorStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderMonitoringErrorStatus_max_cdr_typesize; -} - -size_t DdsRecorderMonitoringErrorStatus::getCdrSerializedSize( - const DdsRecorderMonitoringErrorStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - current_alignment += 1 + eprosima::fastcdr::Cdr::alignment(current_alignment, 1); - - - return current_alignment - initial_alignment; -} - -void DdsRecorderMonitoringErrorStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_mcap_file_creation_failure; - - scdr << m_disk_full; - -} - -void DdsRecorderMonitoringErrorStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_mcap_file_creation_failure; - - - - dcdr >> m_disk_full; - - -} - -bool DdsRecorderMonitoringErrorStatus::isKeyDefined() -{ - return false; -} - -void DdsRecorderMonitoringErrorStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member mcap_file_creation_failure - * @param _mcap_file_creation_failure New value for member mcap_file_creation_failure - */ -void DdsRecorderMonitoringErrorStatus::mcap_file_creation_failure( - bool _mcap_file_creation_failure) -{ - m_mcap_file_creation_failure = _mcap_file_creation_failure; -} - -/*! - * @brief This function returns the value of member mcap_file_creation_failure - * @return Value of member mcap_file_creation_failure - */ -bool DdsRecorderMonitoringErrorStatus::mcap_file_creation_failure() const -{ - return m_mcap_file_creation_failure; -} - -/*! - * @brief This function returns a reference to member mcap_file_creation_failure - * @return Reference to member mcap_file_creation_failure - */ -bool& DdsRecorderMonitoringErrorStatus::mcap_file_creation_failure() -{ - return m_mcap_file_creation_failure; -} - -/*! - * @brief This function sets a value in member disk_full - * @param _disk_full New value for member disk_full - */ -void DdsRecorderMonitoringErrorStatus::disk_full( - bool _disk_full) -{ - m_disk_full = _disk_full; -} - -/*! - * @brief This function returns the value of member disk_full - * @return Value of member disk_full - */ -bool DdsRecorderMonitoringErrorStatus::disk_full() const -{ - return m_disk_full; -} - -/*! - * @brief This function returns a reference to member disk_full - * @return Reference to member disk_full - */ -bool& DdsRecorderMonitoringErrorStatus::disk_full() -{ - return m_disk_full; -} - -DdsRecorderMonitoringStatus::DdsRecorderMonitoringStatus() - : MonitoringStatus() -{ - // DdsRecorderMonitoringErrorStatus m_ddsrecorder_error_status - - -} - -DdsRecorderMonitoringStatus::~DdsRecorderMonitoringStatus() -{ -} - -DdsRecorderMonitoringStatus::DdsRecorderMonitoringStatus( - const DdsRecorderMonitoringStatus& x) - : MonitoringStatus(x) -{ - m_ddsrecorder_error_status = x.m_ddsrecorder_error_status; - -} - -DdsRecorderMonitoringStatus::DdsRecorderMonitoringStatus( - DdsRecorderMonitoringStatus&& x) noexcept - : MonitoringStatus(std::move(x)) -{ - m_ddsrecorder_error_status = std::move(x.m_ddsrecorder_error_status); - -} - -DdsRecorderMonitoringStatus& DdsRecorderMonitoringStatus::operator =( - const DdsRecorderMonitoringStatus& x) -{ - MonitoringStatus::operator =(x); - - m_ddsrecorder_error_status = x.m_ddsrecorder_error_status; - - return *this; -} - -DdsRecorderMonitoringStatus& DdsRecorderMonitoringStatus::operator =( - DdsRecorderMonitoringStatus&& x) noexcept -{ - MonitoringStatus::operator =(std::move(x)); - - m_ddsrecorder_error_status = std::move(x.m_ddsrecorder_error_status); - - return *this; -} - -bool DdsRecorderMonitoringStatus::operator ==( - const DdsRecorderMonitoringStatus& x) const -{ - if (MonitoringStatus::operator !=(x)) - { - return false; - } - - return (m_ddsrecorder_error_status == x.m_ddsrecorder_error_status); -} - -bool DdsRecorderMonitoringStatus::operator !=( - const DdsRecorderMonitoringStatus& x) const -{ - return !(*this == x); -} - -size_t DdsRecorderMonitoringStatus::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return DdsRecorderMonitoringStatus_max_cdr_typesize; -} - -size_t DdsRecorderMonitoringStatus::getCdrSerializedSize( - const DdsRecorderMonitoringStatus& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += MonitoringStatus::getCdrSerializedSize(data, current_alignment); - - current_alignment += DdsRecorderMonitoringErrorStatus::getCdrSerializedSize( - data.ddsrecorder_error_status(), current_alignment); - - - return current_alignment - initial_alignment; -} - -void DdsRecorderMonitoringStatus::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - MonitoringStatus::serialize(scdr); - - scdr << m_ddsrecorder_error_status; - -} - -void DdsRecorderMonitoringStatus::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - MonitoringStatus::deserialize(dcdr); - - dcdr >> m_ddsrecorder_error_status; - - -} - -bool DdsRecorderMonitoringStatus::isKeyDefined() -{ - if (MonitoringStatus::isKeyDefined()) - { - return true; - } - - return false; -} - -void DdsRecorderMonitoringStatus::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - MonitoringStatus::serializeKey(scdr); -} - -/*! - * @brief This function copies the value in member ddsrecorder_error_status - * @param _ddsrecorder_error_status New value to be copied in member ddsrecorder_error_status - */ -void DdsRecorderMonitoringStatus::ddsrecorder_error_status( - const DdsRecorderMonitoringErrorStatus& _ddsrecorder_error_status) -{ - m_ddsrecorder_error_status = _ddsrecorder_error_status; -} - -/*! - * @brief This function moves the value in member ddsrecorder_error_status - * @param _ddsrecorder_error_status New value to be moved in member ddsrecorder_error_status - */ -void DdsRecorderMonitoringStatus::ddsrecorder_error_status( - DdsRecorderMonitoringErrorStatus&& _ddsrecorder_error_status) -{ - m_ddsrecorder_error_status = std::move(_ddsrecorder_error_status); -} - -/*! - * @brief This function returns a constant reference to member ddsrecorder_error_status - * @return Constant reference to member ddsrecorder_error_status - */ -const DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringStatus::ddsrecorder_error_status() const -{ - return m_ddsrecorder_error_status; -} - -/*! - * @brief This function returns a reference to member ddsrecorder_error_status - * @return Reference to member ddsrecorder_error_status - */ -DdsRecorderMonitoringErrorStatus& DdsRecorderMonitoringStatus::ddsrecorder_error_status() -{ - return m_ddsrecorder_error_status; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder_participants/src/cpp/recorder/logging/DdsRecorderLogConsumer.cpp b/ddsrecorder_participants/src/cpp/recorder/logging/DdsRecorderLogConsumer.cpp index 9c588dabe..deaab400f 100644 --- a/ddsrecorder_participants/src/cpp/recorder/logging/DdsRecorderLogConsumer.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/logging/DdsRecorderLogConsumer.cpp @@ -16,12 +16,7 @@ * @file DdsRecorderLogConsumer.cpp */ -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include -#else - #include -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - +#include #include namespace eprosima { diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index e565172cc..ab8c05077 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -27,32 +27,24 @@ #include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include #include -#include -#include -#include -#include -#include - #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include - #include - #include - #include - #include -#else - #include - #include - #include -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - +#include +#include #include #include #include @@ -107,7 +99,9 @@ McapHandler::~McapHandler() } void McapHandler::add_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_id) { std::lock_guard lock(mtx_); @@ -115,7 +109,7 @@ void McapHandler::add_schema( assert(nullptr != dynamic_type); - const std::string type_name = dynamic_type->get_name(); + // const std::string type_name = dynamic_type->get_name(); // Check if it exists already if (received_types_.find(type_name) != received_types_.end()) @@ -145,7 +139,7 @@ void McapHandler::add_schema( // Add schema to writer and to schemas map logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Adding schema with name " << type_name << " :\n" << data << "\n"); + "MCAP_WRITE | Adding schema with name " << dynamic_type->get_name().to_string() << " :\n" << data << "\n"); mcap_writer_.write(new_schema); @@ -164,7 +158,7 @@ void McapHandler::add_schema( if (configuration_.record_types) { // Store dynamic type in dynamic_types collection - store_dynamic_type_(type_name, dynamic_types_); + store_dynamic_type_(type_name, type_id, dynamic_types_); // Serialize dynamic types collection const auto serialized_dynamic_types = serialize_dynamic_types_(dynamic_types_); @@ -869,24 +863,31 @@ mcap::SchemaId McapHandler::get_schema_id_nts_( void McapHandler::store_dynamic_type_( const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_id, DynamicTypesCollection& dynamic_types) const { - const eprosima::fastrtps::types::TypeIdentifier* type_identifier = nullptr; - const eprosima::fastrtps::types::TypeObject* type_object = nullptr; - const eprosima::fastrtps::types::TypeInformation* type_information = nullptr; - - type_information = - eprosima::fastrtps::types::TypeObjectFactory::get_instance()->get_type_information(type_name); - if (type_information != nullptr) + fastdds::dds::xtypes::TypeIdentifierPair type_ids_pair; + type_ids_pair.type_identifier1(type_id); + + fastdds::dds::xtypes::TypeInformation type_info; + if (fastdds::dds::RETCODE_OK == fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_information( + type_ids_pair, + type_info, + true)) { - auto dependencies = type_information->complete().dependent_typeids(); std::string dependency_name; unsigned int dependency_index = 0; - for (auto dependency: dependencies) + auto type_dependencies = type_info.complete().dependent_typeids(); + for (auto dependency : type_dependencies) { - type_identifier = &dependency.type_id(); - type_object = eprosima::fastrtps::types::TypeObjectFactory::get_instance()->get_type_object( - type_identifier); + fastdds::dds::xtypes::TypeIdentifier type_identifier; + type_identifier = dependency.type_id(); + + fastdds::dds::xtypes::TypeObject type_object; + const auto ret = fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_object( + type_identifier, + type_object); + dependency_name = type_name + "_" + std::to_string(dependency_index); // Store dependency in dynamic_types collection @@ -895,57 +896,37 @@ void McapHandler::store_dynamic_type_( // Increment suffix counter dependency_index++; } - } - type_identifier = nullptr; - type_object = nullptr; - - type_identifier = eprosima::fastrtps::types::TypeObjectFactory::get_instance()->get_type_identifier(type_name, - true); - if (type_identifier) - { - type_object = - eprosima::fastrtps::types::TypeObjectFactory::get_instance()->get_type_object(type_name, true); - } - - // If complete not found, try with minimal - if (!type_object) - { - type_identifier = eprosima::fastrtps::types::TypeObjectFactory::get_instance()->get_type_identifier( - type_name, false); - if (type_identifier) + fastdds::dds::xtypes::TypeObject type_obj; + if (fastdds::dds::RETCODE_OK == fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_object( + type_id, + type_obj)) { - type_object = eprosima::fastrtps::types::TypeObjectFactory::get_instance()->get_type_object(type_name, - false); + // Store dynamic type in dynamic_types collection + store_dynamic_type_(type_id, type_obj, type_name, dynamic_types); } } - - // Store dynamic type in dynamic_types collection - store_dynamic_type_(type_identifier, type_object, type_name, dynamic_types); } void McapHandler::store_dynamic_type_( - const eprosima::fastrtps::types::TypeIdentifier* type_identifier, - const eprosima::fastrtps::types::TypeObject* type_object, + const fastdds::dds::xtypes::TypeIdentifier& type_identifier, + const fastdds::dds::xtypes::TypeObject& type_object, const std::string& type_name, DynamicTypesCollection& dynamic_types) const { - if (type_identifier != nullptr && type_object != nullptr) - { - DynamicType dynamic_type; - dynamic_type.type_name(type_name); - dynamic_type.type_information(utils::base64_encode(serialize_type_identifier_(type_identifier))); - dynamic_type.type_object(utils::base64_encode(serialize_type_object_(type_object))); + DynamicType dynamic_type; + dynamic_type.type_name(type_name); + dynamic_type.type_information(utils::base64_encode(serialize_type_identifier_(type_identifier))); + dynamic_type.type_object(utils::base64_encode(serialize_type_object_(type_object))); - dynamic_types.dynamic_types().push_back(dynamic_type); - } + dynamic_types.dynamic_types().push_back(dynamic_type); } fastrtps::rtps::SerializedPayload_t* McapHandler::serialize_dynamic_types_( DynamicTypesCollection& dynamic_types) const { // Serialize dynamic types collection using CDR - eprosima::fastdds::dds::TypeSupport type_support(new DynamicTypesCollectionPubSubType()); + fastdds::dds::TypeSupport type_support(new DynamicTypesCollectionPubSubType()); fastrtps::rtps::SerializedPayload_t* serialized_payload = new fastrtps::rtps::SerializedPayload_t( type_support.get_serialized_size_provider(&dynamic_types)()); type_support.serialize(&dynamic_types, serialized_payload); @@ -1008,52 +989,62 @@ std::string McapHandler::serialize_qos_( } std::string McapHandler::serialize_type_identifier_( - const eprosima::fastrtps::types::TypeIdentifier* type_identifier) + const fastdds::dds::xtypes::TypeIdentifier& type_identifier) { // Reserve payload and create buffer - size_t size = fastrtps::types::TypeIdentifier::getCdrSerializedSize(*type_identifier) + - eprosima::fastrtps::rtps::SerializedPayload_t::representation_header_size; + fastcdr::CdrSizeCalculator calculator(fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + size_t size = calculator.calculate_serialized_size(type_identifier, current_alignment) + + fastrtps::rtps::SerializedPayload_t::representation_header_size; + fastrtps::rtps::SerializedPayload_t payload(static_cast(size)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); // Create CDR serializer - #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - #else - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::CdrVersion::XCDRv1); - #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + fastcdr::Cdr ser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, + fastcdr::CdrVersion::XCDRv2); - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + payload.encapsulation = ser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Serialize - type_identifier->serialize(ser); -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); - size = (ser.getSerializedDataLength() + 3) & ~3; -#else + fastcdr::serialize(ser, type_identifier); payload.length = (uint32_t)ser.get_serialized_data_length(); size = (ser.get_serialized_data_length() + 3) & ~3; -#endif // if FASTCDR_VERSION_MAJOR == 1 - - // Create CDR message - // NOTE: Use 0 length to avoid allocation (memory already reserved in payload creation) - eprosima::fastrtps::rtps::CDRMessage_t* cdr_message = new eprosima::fastrtps::rtps::CDRMessage_t(0); - cdr_message->buffer = payload.data; - cdr_message->max_size = payload.max_size; - cdr_message->length = payload.length; -#if __BIG_ENDIAN__ - cdr_message->msg_endian = eprosima::fastrtps::rtps::BIGEND; -#else - cdr_message->msg_endian = eprosima::fastrtps::rtps::LITTLEEND; -#endif // if __BIG_ENDIAN__ + + // Create CDR message with payload + fastrtps::rtps::CDRMessage_t* cdr_message = new fastrtps::rtps::CDRMessage_t(payload); // Add data - bool valid = fastrtps::rtps::CDRMessage::addData(cdr_message, payload.data, payload.length); + if (!(cdr_message && (cdr_message->pos + payload.length <= cdr_message->max_size))|| (payload.length > 0 && !payload.data)) + { + // TODO Warning + } + else + { + memcpy(&cdr_message->buffer[cdr_message->pos], payload.data, payload.length); + cdr_message->pos += payload.length; + cdr_message->length += payload.length; + } + + fastrtps::rtps::octet value = 0; for (uint32_t count = payload.length; count < size; ++count) { - valid &= fastrtps::rtps::CDRMessage::addOctet(cdr_message, 0); + const uint32_t size_octet = sizeof(value); + if (!(cdr_message && (cdr_message->pos + size_octet <= cdr_message->max_size))) + { + // TODO Warning + } + else + { + for (uint32_t i = 0; i < size_octet; i++) + { + cdr_message->buffer[cdr_message->pos + i] = *((fastrtps::rtps::octet*)&value + size_octet - 1 - i); + } + cdr_message->pos += size_octet; + cdr_message->length += size_octet; + } } + // Copy buffer to string std::string typeid_str(reinterpret_cast(cdr_message->buffer), size); @@ -1066,51 +1057,60 @@ std::string McapHandler::serialize_type_identifier_( } std::string McapHandler::serialize_type_object_( - const eprosima::fastrtps::types::TypeObject* type_object) + const fastdds::dds::xtypes::TypeObject& type_object) { // Reserve payload and create buffer - size_t size = fastrtps::types::TypeObject::getCdrSerializedSize(*type_object) + - eprosima::fastrtps::rtps::SerializedPayload_t::representation_header_size; + fastcdr::CdrSizeCalculator calculator(fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + size_t size = calculator.calculate_serialized_size(type_object, current_alignment) + + fastrtps::rtps::SerializedPayload_t::representation_header_size; fastrtps::rtps::SerializedPayload_t payload(static_cast(size)); - eprosima::fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); // Create CDR serializer - #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR); - #else - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, - eprosima::fastcdr::CdrVersion::XCDRv1); - #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + fastcdr::Cdr ser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, + fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = ser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Serialize - type_object->serialize(ser); -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); - size = (ser.getSerializedDataLength() + 3) & ~3; -#else + fastcdr::serialize(ser, type_object); payload.length = (uint32_t)ser.get_serialized_data_length(); size = (ser.get_serialized_data_length() + 3) & ~3; -#endif // if FASTCDR_VERSION_MAJOR == 1 - - // Create CDR message - // NOTE: Use 0 length to avoid allocation (memory already reserved in payload creation) - eprosima::fastrtps::rtps::CDRMessage_t* cdr_message = new eprosima::fastrtps::rtps::CDRMessage_t(0); - cdr_message->buffer = payload.data; - cdr_message->max_size = payload.max_size; - cdr_message->length = payload.length; -#if __BIG_ENDIAN__ - cdr_message->msg_endian = eprosima::fastrtps::rtps::BIGEND; -#else - cdr_message->msg_endian = eprosima::fastrtps::rtps::LITTLEEND; -#endif // if __BIG_ENDIAN__ + + // Create CDR message with payload + fastrtps::rtps::CDRMessage_t* cdr_message = new fastrtps::rtps::CDRMessage_t(payload); // Add data - bool valid = fastrtps::rtps::CDRMessage::addData(cdr_message, payload.data, payload.length); + if (!(cdr_message && (cdr_message->pos + payload.length <= cdr_message->max_size))|| (payload.length > 0 && !payload.data)) + { + // TODO Warning + } + else + { + memcpy(&cdr_message->buffer[cdr_message->pos], payload.data, payload.length); + cdr_message->pos += payload.length; + cdr_message->length += payload.length; + } + + fastrtps::rtps::octet value = 0; for (uint32_t count = payload.length; count < size; ++count) { - valid &= fastrtps::rtps::CDRMessage::addOctet(cdr_message, 0); + const uint32_t size_octet = sizeof(value); + if (!(cdr_message && (cdr_message->pos + size_octet <= cdr_message->max_size))) + { + // TODO Warning + } + else + { + for (uint32_t i = 0; i < size_octet; i++) + { + cdr_message->buffer[cdr_message->pos + i] = *((fastrtps::rtps::octet*)&value + size_octet - 1 - i); + } + cdr_message->pos += size_octet; + cdr_message->length += size_octet; + } } + // Copy buffer to string std::string typeobj_str(reinterpret_cast(cdr_message->buffer), size); diff --git a/ddsrecorder_participants/src/cpp/recorder/monitoring/DdsRecorderMonitor.cpp b/ddsrecorder_participants/src/cpp/recorder/monitoring/DdsRecorderMonitor.cpp index f08f02284..02019ddea 100644 --- a/ddsrecorder_participants/src/cpp/recorder/monitoring/DdsRecorderMonitor.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/monitoring/DdsRecorderMonitor.cpp @@ -19,15 +19,8 @@ #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include \ - -#else - #include - #include \ - -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) +#include +#include #include diff --git a/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/CMakeLists.txt b/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/CMakeLists.txt index d05c6a247..a870980e5 100644 --- a/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/CMakeLists.txt +++ b/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/CMakeLists.txt @@ -29,13 +29,6 @@ file( "${PROJECT_SOURCE_DIR}/include/recorder/monitoring/*.h*" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - all_library_sources( "${TEST_SOURCES}" "${LIBRARY_SOURCES}" @@ -50,7 +43,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/DdsMonitorDdsRecorderStatusTest.cpp b/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/DdsMonitorDdsRecorderStatusTest.cpp index 2fb848c2d..da25a2798 100644 --- a/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/DdsMonitorDdsRecorderStatusTest.cpp +++ b/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/DdsMonitorDdsRecorderStatusTest.cpp @@ -30,15 +30,8 @@ #include #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include - #include \ - -#else - #include - #include \ - -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) +#include +#include #include "../../constants.hpp" @@ -134,7 +127,7 @@ TEST_F(DdsMonitorDdsRecorderStatusTest, type_mismatch) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&status, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&status, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); // Verify that the content of the DdsRecorderMonitoringStatus published by the Monitor is correct @@ -160,7 +153,7 @@ TEST_F(DdsMonitorDdsRecorderStatusTest, qos_mismatch) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&status, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&status, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); // Verify that the content of the DdsRecorderMonitoringStatus published by the Monitor is correct @@ -186,7 +179,7 @@ TEST_F(DdsMonitorDdsRecorderStatusTest, mcap_file_creation_failure) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&status, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&status, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); // Verify that the content of the DdsRecorderMonitoringStatus published by the Monitor is correct @@ -214,7 +207,7 @@ TEST_F(DdsMonitorDdsRecorderStatusTest, disk_full) // Wait for the monitor to publish the next message ASSERT_TRUE(reader_->wait_for_unread_message(test::monitor::MAX_WAITING_TIME)); - ASSERT_EQ(reader_->take_next_sample(&status, &info), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(reader_->take_next_sample(&status, &info), RETCODE_OK); ASSERT_EQ(info.instance_state, ALIVE_INSTANCE_STATE); // Verify that the content of the DdsRecorderMonitoringStatus published by the Monitor is correct diff --git a/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/logging/CMakeLists.txt b/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/logging/CMakeLists.txt index 0324a062b..39d8c1efc 100644 --- a/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/logging/CMakeLists.txt +++ b/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/logging/CMakeLists.txt @@ -29,13 +29,6 @@ file( "${PROJECT_SOURCE_DIR}/include/recorder/monitoring/*.h*" ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - all_library_sources( "${TEST_SOURCES}" "${LIBRARY_SOURCES}" @@ -50,7 +43,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddsrecorder_yaml/project_settings.cmake b/ddsrecorder_yaml/project_settings.cmake index 3476a2610..1b6605aa3 100644 --- a/ddsrecorder_yaml/project_settings.cmake +++ b/ddsrecorder_yaml/project_settings.cmake @@ -25,7 +25,7 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants @@ -46,7 +46,7 @@ set(MODULE_DEPENDENCIES $<$:iphlpapi$Shlwapi> yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddsrecorder_yaml/test/CMakeLists.txt b/ddsrecorder_yaml/test/CMakeLists.txt index 0fe6cb2eb..91e9bd91d 100644 --- a/ddsrecorder_yaml/test/CMakeLists.txt +++ b/ddsrecorder_yaml/test/CMakeLists.txt @@ -30,7 +30,7 @@ set(TEST_LIST set(TEST_EXTRA_LIBRARIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddsreplayer/project_settings.cmake b/ddsreplayer/project_settings.cmake index 00eac2e1a..ecbac9c8c 100644 --- a/ddsreplayer/project_settings.cmake +++ b/ddsreplayer/project_settings.cmake @@ -25,7 +25,7 @@ set(MODULE_SUMMARY set(MODULE_FIND_PACKAGES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants @@ -43,7 +43,7 @@ endif() set(MODULE_DEPENDENCIES yaml-cpp fastcdr - fastrtps + fastdds cpp_utils ddspipe_core ddspipe_participants diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index 3e066c755..81268cbb6 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -21,7 +21,6 @@ #include #include -#include #include #include @@ -29,27 +28,19 @@ #include #include #include -#include +#include +#include +#include +#include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include - #include -#else - #include - #include -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 +#include +#include #include -#if FASTRTPS_VERSION_MINOR < 13 - #include - #include - #include -#else - #include -#endif // if FASTRTPS_VERSION_MINOR < 13 +#include #include "DdsReplayer.hpp" @@ -67,8 +58,6 @@ using namespace eprosima::utils; DdsReplayer::DdsReplayer( yaml::ReplayerConfiguration& configuration, std::string& input_file) - : dyn_participant_(nullptr) - , dyn_publisher_(nullptr) { // Create Discovery Database discovery_database_ = std::make_shared(); @@ -121,29 +110,6 @@ DdsReplayer::DdsReplayer( "fastdds.application.metadata", configuration.replayer_configuration->app_metadata, "true"); - - // Set as server in TypeLookup service - pqos.wire_protocol().builtin.typelookup_config.use_client = false; - pqos.wire_protocol().builtin.typelookup_config.use_server = true; - - // Participant creation via factory - dyn_participant_ = fastdds::dds::DomainParticipantFactory::get_instance()->create_participant( - configuration.replayer_configuration->domain, pqos); - if (nullptr == dyn_participant_) - { - throw utils::InitializationException( - STR_ENTRY << "Failed to create dynamic types participant." - ); - } - - // Create publisher - dyn_publisher_ = dyn_participant_->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT); - if (nullptr == dyn_publisher_) - { - throw utils::InitializationException( - STR_ENTRY << "Failed to create dynamic types publisher." - ); - } } // Generate builtin-topics from the topics in the MCAP file @@ -160,28 +126,6 @@ DdsReplayer::DdsReplayer( DdsReplayer::~DdsReplayer() { - if (dyn_participant_ != nullptr) - { - if (dyn_publisher_ != nullptr) - { - for (auto writer : dyn_writers_) - { - if (writer.second != nullptr) - { - dyn_publisher_->delete_datawriter(writer.second); - } - } - dyn_participant_->delete_publisher(dyn_publisher_); - } - for (auto topic : dyn_topics_) - { - if (topic.second != nullptr) - { - dyn_participant_->delete_topic(topic.second); - } - } - fastdds::dds::DomainParticipantFactory::get_instance()->delete_participant(dyn_participant_); - } } utils::ReturnCode DdsReplayer::reload_configuration( @@ -275,14 +219,12 @@ std::set> DdsReplayer::generate_builtin_topic dynamic_attachment.dataSize); type_support.deserialize(&serialized_payload, &dynamic_types); - std::set registered_types{}; if (configuration.replay_types) { // Register in factory dynamic types from attachment - for (auto& dynamic_type: dynamic_types.dynamic_types()) + for (auto& dynamic_type : dynamic_types.dynamic_types()) { register_dynamic_type_(dynamic_type); - registered_types.insert(dynamic_type.type_name()); } } @@ -299,6 +241,7 @@ std::set> DdsReplayer::generate_builtin_topic auto channel_topic = utils::Heritable::make_heritable(); channel_topic->m_topic_name = topic_name; channel_topic->type_name = type_name; + channel_topic->type_ids = registered_types_[type_name]; // Apply the QoS stored in the MCAP file as if they were the discovered QoS. channel_topic->topic_qos.set_qos( @@ -308,7 +251,7 @@ std::set> DdsReplayer::generate_builtin_topic // Insert channel topic in builtin topics list builtin_topics.insert(channel_topic); - if (configuration.replay_types && registered_types.count(type_name) != 0) + if (configuration.replay_types && registered_types_.count(type_name) != 0) { // Make a copy of the Topic to customize it according to the Participant's configured QoS. utils::Heritable topic = channel_topic->copy(); @@ -318,10 +261,6 @@ std::set> DdsReplayer::generate_builtin_topic { topic->topic_qos.set_qos(manual_topic.first->topic_qos, utils::FuzzyLevelValues::fuzzy_level_hard); } - - // Create Datawriter in this topic so dynamic type can be shared in EDP - // TODO: Avoid creating the dynamic writer when the topic is not allowed. - create_dynamic_writer_(topic); } } @@ -338,95 +277,24 @@ void DdsReplayer::register_dynamic_type_( std::string typeobj_str = utils::base64_decode(dynamic_type.type_object()); // Deserialize type identifer and object strings - fastrtps::types::TypeIdentifier type_identifier = deserialize_type_identifier_(typeid_str); - fastrtps::types::TypeObject type_object = deserialize_type_object_(typeobj_str); - - // Register in factory - fastrtps::types::TypeObjectFactory::get_instance()->add_type_object( - dynamic_type.type_name(), &type_identifier, &type_object); -} - -void DdsReplayer::create_dynamic_writer_( - utils::Heritable topic) -{ - auto type_identifier = fastrtps::types::TypeObjectFactory::get_instance()->get_type_identifier(topic->type_name, - true); - auto type_object = fastrtps::types::TypeObjectFactory::get_instance()->get_type_object(topic->type_name, true); - fastrtps::types::DynamicType_ptr dyn_type = fastrtps::types::TypeObjectFactory::get_instance()->build_dynamic_type( - topic->type_name, - type_identifier, - type_object); - - if (nullptr == dyn_type) - { - logWarning(DDSREPLAYER_REPLAYER, - "Failed to create " << topic->type_name << " DynamicType, aborting dynamic writer creation..."); - return; - } - - fastdds::dds::TypeSupport type(new fastrtps::types::DynamicPubSubType(dyn_type)); - - if (nullptr == type) - { - logWarning(DDSREPLAYER_REPLAYER, - "Failed to create " << topic->type_name << " TypeSupport, aborting dynamic writer creation..."); - return; - } - - // Only enable sharing dynamic types through TypeLookup Service - type->auto_fill_type_information(true); - type->auto_fill_type_object(false); + fastdds::dds::xtypes::TypeIdentifier type_identifier = deserialize_type_identifier_(typeid_str); + fastdds::dds::xtypes::TypeObject type_object = deserialize_type_object_(typeobj_str); - // Register type - if (ReturnCode_t::RETCODE_OK != dyn_participant_->register_type(type)) - { - logWarning(DDSREPLAYER_REPLAYER, - "Failed to register " << topic->type_name << " type, aborting dynamic writer creation..."); - return; - } + // Create a TypeIdentifierPair to use in register_type_identifier + fastdds::dds::xtypes::TypeIdentifierPair type_identifiers; + type_identifiers.type_identifier1(type_identifier); - // Create DDS topic - fastdds::dds::Topic* dyn_topic = dyn_participant_->create_topic(topic->m_topic_name, topic->type_name, - fastdds::dds::TOPIC_QOS_DEFAULT); - if (nullptr == dyn_topic) + // // Register in factory + if (fastdds::dds::RETCODE_OK != fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().register_type_object( + type_object, type_identifiers)) { logWarning(DDSREPLAYER_REPLAYER, - "Failed to create {" << topic->m_topic_name << ";" << topic->type_name << - "} DDS topic, aborting dynamic writer creation..."); - return; + "Failed to register " << dynamic_type.type_name() << " DynamicType."); } - // Store pointer to be freed on destruction - dyn_topics_[topic] = dyn_topic; - - // Create DDS writer QoS - fastdds::dds::DataWriterQos wqos = fastdds::dds::DATAWRITER_QOS_DEFAULT; - wqos.durability().kind = - ( topic->topic_qos.is_transient_local() ? - fastdds::dds::DurabilityQosPolicyKind::TRANSIENT_LOCAL_DURABILITY_QOS : - fastdds::dds::DurabilityQosPolicyKind::VOLATILE_DURABILITY_QOS - ); - wqos.reliability().kind = - ( topic->topic_qos.is_reliable() ? - fastdds::dds::ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS : - fastdds::dds::ReliabilityQosPolicyKind::BEST_EFFORT_RELIABILITY_QOS - ); - wqos.ownership().kind = - ( topic->topic_qos.has_ownership() ? - fastdds::dds::OwnershipQosPolicyKind::EXCLUSIVE_OWNERSHIP_QOS : - fastdds::dds::OwnershipQosPolicyKind::SHARED_OWNERSHIP_QOS - ); - - // Create DDS writer - fastdds::dds::DataWriter* dyn_writer = dyn_publisher_->create_datawriter(dyn_topic, wqos); - if (nullptr == dyn_writer) + else { - logWarning(DDSREPLAYER_REPLAYER, - "Failed to create {" << topic->m_topic_name << ";" << topic->type_name << - "} DDS writer, aborting dynamic writer creation..."); - return; + registered_types_.insert({dynamic_type.type_name(), type_identifiers}); } - // Store pointer to be freed on destruction - dyn_writers_[topic] = dyn_writer; } TopicQoS DdsReplayer::deserialize_qos_( @@ -478,7 +346,7 @@ TopicQoS DdsReplayer::deserialize_qos_( return qos; } -fastrtps::types::TypeIdentifier DdsReplayer::deserialize_type_identifier_( +fastdds::dds::xtypes::TypeIdentifier DdsReplayer::deserialize_type_identifier_( const std::string& typeid_str) { // Create CDR message from string @@ -498,19 +366,28 @@ fastrtps::types::TypeIdentifier DdsReplayer::deserialize_type_identifier_( fastcdr::FastBuffer fastbuffer((char*)payload.data, parameter_length); // Read data - fastrtps::rtps::CDRMessage::readData(cdr_message, payload.data, parameter_length); + if (cdr_message != nullptr) + { + if (cdr_message->length >= cdr_message->pos + parameter_length) + { + if (parameter_length > 0) + { + if (payload.data != nullptr) + { + memcpy(payload.data, &cdr_message->buffer[cdr_message->pos], parameter_length); + cdr_message->pos += parameter_length; + } + } + } + } // Create CDR deserializer - #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::Cdr::DDS_CDR); - #else - fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::CdrVersion::XCDRv1); - #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::CdrVersion::XCDRv2); payload.encapsulation = deser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize - fastrtps::types::TypeIdentifier type_identifier; - type_identifier.deserialize(deser); + fastdds::dds::xtypes::TypeIdentifier type_identifier; + fastcdr::deserialize(deser, type_identifier); // Delete CDR message // NOTE: set wraps attribute to avoid double free (buffer released by string on destruction) @@ -520,7 +397,7 @@ fastrtps::types::TypeIdentifier DdsReplayer::deserialize_type_identifier_( return type_identifier; } -fastrtps::types::TypeObject DdsReplayer::deserialize_type_object_( +fastdds::dds::xtypes::TypeObject DdsReplayer::deserialize_type_object_( const std::string& typeobj_str) { // Create CDR message from string @@ -540,19 +417,28 @@ fastrtps::types::TypeObject DdsReplayer::deserialize_type_object_( fastcdr::FastBuffer fastbuffer((char*)payload.data, parameter_length); // Read data - fastrtps::rtps::CDRMessage::readData(cdr_message, payload.data, parameter_length); + if (cdr_message != nullptr) + { + if (cdr_message->length >= cdr_message->pos + parameter_length) + { + if (parameter_length > 0) + { + if (payload.data != nullptr) + { + memcpy(payload.data, &cdr_message->buffer[cdr_message->pos], parameter_length); + cdr_message->pos += parameter_length; + } + } + } + } // Create CDR deserializer - #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::Cdr::DDS_CDR); - #else - fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::CdrVersion::XCDRv1); - #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::CdrVersion::XCDRv2); payload.encapsulation = deser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize - fastrtps::types::TypeObject type_object; - type_object.deserialize(deser); + fastdds::dds::xtypes::TypeObject type_object; + fastcdr::deserialize(deser, type_object); // Delete CDR message // NOTE: set wraps attribute to avoid double free (buffer released by string on destruction) diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp index 2ca97e7f2..49e45d929 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -33,13 +34,7 @@ #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include -#else - #include -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - - +#include #include #include @@ -143,7 +138,7 @@ class DdsReplayer * @param [in] typeid_str Serialized \c TypeIdentifier string * @return Deserialized TypeIdentifier */ - static fastrtps::types::TypeIdentifier deserialize_type_identifier_( + static fastdds::dds::xtypes::TypeIdentifier deserialize_type_identifier_( const std::string& typeid_str); /** @@ -152,7 +147,7 @@ class DdsReplayer * @param [in] typeobj_str Serialized \c TypeObject string * @return Deserialized TypeObject */ - static fastrtps::types::TypeObject deserialize_type_object_( + static fastdds::dds::xtypes::TypeObject deserialize_type_object_( const std::string& typeobj_str); //! Payload Pool @@ -187,6 +182,9 @@ class DdsReplayer //! Dynamic DDS DataWriters map std::map, fastdds::dds::DataWriter*> dyn_writers_; + + //! Map of TypeName-TypeIdentifierPair for the registered types + std::map registered_types_{}; }; } /* namespace replayer */ diff --git a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt index b7eabc386..20c5e2c09 100644 --- a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt +++ b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt @@ -18,20 +18,13 @@ set(TEST_NAME McapFileReadTest) -# Determine Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(DDS_TYPES_VERSION "v1") -else() - set(DDS_TYPES_VERSION "v2") -endif() - set(TEST_SOURCES McapFileReadTest.cpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/${DDS_TYPES_VERSION}/hello_world/HelloWorld.cxx - $<$:${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.cxx> - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/${DDS_TYPES_VERSION}/hello_world/HelloWorldPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorld.hpp + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.cxx ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp -) + ) set(TEST_LIST trivial @@ -72,6 +65,10 @@ set(TEST_NAME McapFileReadWithTypeTest) set(TEST_SOURCES McapFileReadWithTypeTest.cpp + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.hpp + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.cpp ) diff --git a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.cpp b/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.cpp index aa40faeab..3510e0bfc 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.cpp +++ b/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.cpp @@ -20,19 +20,24 @@ #include #include +#include #include #include #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "HelloWorldDynTypesSubscriber.h" -using namespace eprosima::fastdds::dds; +using namespace eprosima; +using namespace fastdds::dds; std::atomic HelloWorldDynTypesSubscriber::type_discovered_(false); std::atomic HelloWorldDynTypesSubscriber::type_registered_(false); @@ -57,8 +62,8 @@ HelloWorldDynTypesSubscriber::HelloWorldDynTypesSubscriber( DomainParticipantQos pqos; pqos.name("HelloWorldDynTypes_Subscriber"); - pqos.wire_protocol().builtin.typelookup_config.use_client = true; - pqos.wire_protocol().builtin.typelookup_config.use_server = false; + // pqos.wire_protocol().builtin.typelookup_config.use_client = true; + // pqos.wire_protocol().builtin.typelookup_config.use_server = false; // Create listener mask so the data do not go to on_data_on_readers from subscriber StatusMask mask; @@ -125,15 +130,14 @@ void HelloWorldDynTypesSubscriber::on_subscription_matched( void HelloWorldDynTypesSubscriber::on_data_available( DataReader* reader) { - // Create a new DynamicData to read the sample - eprosima::fastrtps::types::DynamicData_ptr new_dynamic_data; - new_dynamic_data = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dynamic_type_); + // Dynamic DataType + eprosima::fastdds::dds::DynamicData::_ref_type new_data = + eprosima::fastdds::dds::DynamicDataFactory::get_instance()->create_data(dynamic_type_); SampleInfo info; // Take next sample - while ((reader->take_next_sample(new_dynamic_data.get(), - &info) == ReturnCode_t::RETCODE_OK)) + while ((reader->take_next_sample(&new_data, &info) == fastdds::dds::RETCODE_OK)) { if (info.instance_state == ALIVE_INSTANCE_STATE) { @@ -142,32 +146,52 @@ void HelloWorldDynTypesSubscriber::on_data_available( samples_++; - if (new_dynamic_data->get_name() == "std_msgs::msg::dds_::String_") + if (dynamic_type_->get_name() == "std_msgs::msg::dds_::String_") { - std::string message = new_dynamic_data->get_string_value(0); + std::string message = "HelloWorld"; + // new_data->get_string_value(message, new_data->get_member_id_by_name("index")); fill_info(static_cast(0), message, current_time); } - else if (new_dynamic_data->get_name() == "HelloWorld") + else if (dynamic_type_->get_name() == "HelloWorld") { - int32_t index = new_dynamic_data->get_uint32_value(0); - std::string message = new_dynamic_data->get_string_value(1); + uint32_t index; + new_data->get_uint32_value(index, new_data->get_member_id_by_name("index")); + std::string message = "HelloWorld"; + // new_data->get_string_value(message, new_data->get_member_id_by_name("message")); fill_info(static_cast(index), message, current_time); } std::cout << "Message " << samples_ << " received:\n" << std::endl; - eprosima::fastrtps::types::DynamicDataHelper::print(new_dynamic_data); + std::stringstream ss; + ss << std::setw(4); + auto ret = fastdds::dds::json_serialize(new_data, ss, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + std::cout << ss.str() << std::endl; std::cout << "-----------------------------------------------------" << std::endl; } } } -void HelloWorldDynTypesSubscriber::on_type_information_received( - eprosima::fastdds::dds::DomainParticipant*, - const eprosima::fastrtps::string_255 topic_name, - const eprosima::fastrtps::string_255 type_name, - const eprosima::fastrtps::types::TypeInformation& type_information) +void HelloWorldDynTypesSubscriber::on_data_writer_discovery( + fastdds::dds::DomainParticipant*, + fastrtps::rtps::WriterDiscoveryInfo&& info, + bool&) +{ + fastrtps::rtps::WriterProxyData proxy_copy(info.info); + + // Get type information + const auto type_info = proxy_copy.type_information().type_information; + const auto type_name = proxy_copy.typeName(); + const auto topic_name = proxy_copy.topicName(); + + notify_type_discovered_(type_info, type_name, topic_name); +} + +void HelloWorldDynTypesSubscriber::notify_type_discovered_( + const fastdds::dds::xtypes::TypeInformation& type_info, + const fastcdr::string_255& type_name, + const fastcdr::string_255& topic_name) { // First check if the topic received is the one we are expecting if (topic_name.to_string() != topic_name_) @@ -185,74 +209,46 @@ void HelloWorldDynTypesSubscriber::on_type_information_received( } std::string type_name_ = type_name.to_string(); - const eprosima::fastrtps::types::TypeIdentifier* type_identifier = nullptr; - const eprosima::fastrtps::types::TypeObject* type_object = nullptr; - eprosima::fastrtps::types::DynamicType_ptr dynamic_type(nullptr); - - // Check if complete identifier already present in factory - type_identifier = - eprosima::fastrtps::types::TypeObjectFactory::get_instance()->get_type_identifier(type_name_, true); - if (type_identifier) - { - type_object = eprosima::fastrtps::types::TypeObjectFactory::get_instance()->get_type_object(type_name_, true); - } - // If complete not found, try with minimal - if (!type_object) + const auto type_identifier = type_info.complete().typeid_with_size().type_id(); + fastdds::dds::xtypes::TypeObject dyn_type_object; + if (fastdds::dds::RETCODE_OK != fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_object( + type_identifier, + dyn_type_object)) { - type_identifier = eprosima::fastrtps::types::TypeObjectFactory::get_instance()->get_type_identifier(type_name_, - false); - if (type_identifier) - { - type_object = eprosima::fastrtps::types::TypeObjectFactory::get_instance()->get_type_object(type_name_, - false); - } + return; } - // Build dynamic type if type identifier and object found in factory - if (type_identifier && type_object) + // Create Dynamic Type + fastdds::dds::DynamicType::_ref_type dyn_type = fastdds::dds::DynamicTypeBuilderFactory::get_instance()->create_type_w_type_object( + dyn_type_object)->build(); + if (!dyn_type) { - dynamic_type = eprosima::fastrtps::types::TypeObjectFactory::get_instance()->build_dynamic_type(type_name_, - type_identifier, - type_object); + return; } - if (!dynamic_type) - { - // Create the callback to register the remote dynamic type - std::function callback( - [this] - (const std::string& name, const eprosima::fastrtps::types::DynamicType_ptr type) - { - this->register_remote_type_callback_(name, type); - }); - - // Register the discovered type and create a DataReader on this topic - participant_->register_remote_type( - type_information, - type_name.to_string(), - callback); - } - else - { - register_remote_type_callback_(type_name_, dynamic_type); - } + // Notify type_identifier and its associated tyme_name. + // NOTE: We assume each type_name corresponds to only one type_identifier + // logInfo("Participant " << this->id() << " discovered type object " << dyn_type->get_name()); + + // Register DynamicType + register_remote_type_callback_(type_name_, dyn_type); } void HelloWorldDynTypesSubscriber::register_remote_type_callback_( const std::string&, - const eprosima::fastrtps::types::DynamicType_ptr dynamic_type) + const fastdds::dds::traits::ref_type dynamic_type) { //////////////////// // Register the type - TypeSupport type(new eprosima::fastrtps::types::DynamicPubSubType(dynamic_type)); + TypeSupport type(new fastdds::dds::DynamicPubSubType(dynamic_type)); type.register_type(participant_); /////////////////////// // Create the DDS Topic topic_ = participant_->create_topic( topic_name_, - dynamic_type->get_name(), + dynamic_type->get_name().to_string(), TOPIC_QOS_DEFAULT); if (topic_ == nullptr) @@ -260,7 +256,7 @@ void HelloWorldDynTypesSubscriber::register_remote_type_callback_( return; } - init_info(dynamic_type->get_name()); + init_info(dynamic_type->get_name().to_string()); //////////////////////// // Create the DataReader diff --git a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.h b/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.h index 591b166da..726372048 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.h +++ b/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.h @@ -22,12 +22,17 @@ #include #include #include +#include #include #include #include -#include #include +#include +#include +#include + +#include "types/hello_world_basic/HelloWorldPubSubTypes.h" struct DataToCheck { @@ -74,12 +79,18 @@ class HelloWorldDynTypesSubscriber : public eprosima::fastdds::dds::DomainPartic eprosima::fastdds::dds::DataReader* reader, const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) override; - //! Callback to receive the remote data type information - virtual void on_type_information_received( + //! DomainParticipant callback to inform new data readers discovered + void on_data_writer_discovery( eprosima::fastdds::dds::DomainParticipant* participant, - const eprosima::fastrtps::string_255 topic_name, - const eprosima::fastrtps::string_255 type_name, - const eprosima::fastrtps::types::TypeInformation& type_information) override; + eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, + bool& /*should_be_ignored*/) override; + + // //! Callback to receive the remote data type information + // virtual void on_type_information_received( + // eprosima::fastdds::dds::DomainParticipant* participant, + // const eprosima::fastcdr::string_255 topic_name, + // const eprosima::fastcdr::string_255 type_name, + // const eprosima::fastcdr::types::TypeInformation& type_information) override; void init_info( const std::string& type_name); @@ -91,6 +102,11 @@ class HelloWorldDynTypesSubscriber : public eprosima::fastdds::dds::DomainPartic protected: + void notify_type_discovered_( + const eprosima::fastdds::dds::xtypes::TypeInformation& type_info, + const eprosima::fastcdr::string_255& type_name, + const eprosima::fastcdr::string_255& topic_name); + /** * @brief Custom callback to register the type, create the topic and create the DataReader once the data * type information is received. @@ -98,7 +114,7 @@ class HelloWorldDynTypesSubscriber : public eprosima::fastdds::dds::DomainPartic */ void register_remote_type_callback_( const std::string& name, - const eprosima::fastrtps::types::DynamicType_ptr dynamic_type); + const eprosima::fastdds::dds::traits::ref_type dynamic_type); // Fast DDS entities eprosima::fastdds::dds::DomainParticipant* participant_; @@ -113,13 +129,15 @@ class HelloWorldDynTypesSubscriber : public eprosima::fastdds::dds::DomainPartic //! Name of the received DDS Topic type std::string type_name_; //! DynamicType generated with the received type information - eprosima::fastrtps::types::DynamicType_ptr dynamic_type_; + eprosima::fastdds::dds::traits::ref_type dynamic_type_; //! Number of samples received uint32_t samples_; //! The time in milliseconds when the previous message arrived double prev_time_; + HelloWorld hello_world_; + //! Atomic variables to check whether the type has been discovered and registered static std::atomic type_discovered_; static std::atomic type_registered_; diff --git a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp b/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp index 7caee2b9f..5b18c9853 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp +++ b/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp @@ -20,16 +20,17 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include -#include -#include +// #include #include "HelloWorldSubscriber.h" @@ -152,7 +153,7 @@ void HelloWorldSubscriber::on_data_available( SampleInfo info; while ((reader->take_next_sample(&hello_, - &info) == ReturnCode_t::RETCODE_OK)) + &info) == RETCODE_OK)) { if (info.instance_state == ALIVE_INSTANCE_STATE) { diff --git a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h b/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h index ecf4dc2f7..f01da79e4 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h +++ b/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h @@ -24,11 +24,7 @@ #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include "types/v1/hello_world/HelloWorldPubSubTypes.h" -#else - #include "types/v2/hello_world/HelloWorldPubSubTypes.h" -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 +#include "types/hello_world/HelloWorldPubSubTypes.h" struct DataToCheck { diff --git a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorld.h b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.hpp similarity index 69% rename from ddsrecorder/test/resources/types/hello_world/v2/HelloWorld.h rename to ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.hpp index 5cd0ddba5..971fea8d9 100644 --- a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorld.h +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file HelloWorld.h + * @file HelloWorld.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "HelloWorldv1.h" +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_H_ - -#include -#include #include -#include #include -#include - +#include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +51,6 @@ #define HELLOWORLD_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -86,73 +62,117 @@ class HelloWorld /*! * @brief Default constructor. */ - eProsima_user_DllExport HelloWorld(); + eProsima_user_DllExport HelloWorld() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~HelloWorld(); + eProsima_user_DllExport ~HelloWorld() + { + } /*! * @brief Copy constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - const HelloWorld& x); + const HelloWorld& x) + { + m_index = x.m_index; + + m_message = x.m_message; + + } /*! * @brief Move constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + m_index = x.m_index; + m_message = std::move(x.m_message); + } /*! * @brief Copy assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); + const HelloWorld& x) + { + + m_index = x.m_index; + + m_message = x.m_message; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + + m_index = x.m_index; + m_message = std::move(x.m_message); + return *this; + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return (m_index == x.m_index && + m_message == x.m_message); + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member index * @param _index New value for member index */ eProsima_user_DllExport void index( - uint32_t _index); + uint32_t _index) + { + m_index = _index; + } /*! * @brief This function returns the value of member index * @return Value of member index */ - eProsima_user_DllExport uint32_t index() const; + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } /*! * @brief This function returns a reference to member index * @return Reference to member index */ - eProsima_user_DllExport uint32_t& index(); + eProsima_user_DllExport uint32_t& index() + { + return m_index; + } /*! @@ -160,26 +180,40 @@ class HelloWorld * @param _message New value to be copied in member message */ eProsima_user_DllExport void message( - const std::string& _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 */ eProsima_user_DllExport void message( - std::string&& _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 */ - eProsima_user_DllExport const std::string& message() const; + eProsima_user_DllExport const std::string& message() const + { + return m_message; + } /*! * @brief This function returns a reference to member message * @return Reference to member message */ - eProsima_user_DllExport std::string& message(); + eProsima_user_DllExport std::string& message() + { + return m_message; + } + + private: @@ -188,8 +222,6 @@ class HelloWorld }; -#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ - +#endif // _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.idl b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.idl similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.idl rename to ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.idl diff --git a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldCdrAux.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp similarity index 98% rename from ddsrecorder/test/resources/types/hello_world/v2/HelloWorldCdrAux.hpp rename to ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp index 9f346d306..6feb8a9da 100644 --- a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldCdrAux.hpp +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp @@ -22,7 +22,7 @@ #ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ #define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#include "HelloWorld.h" +#include "HelloWorld.hpp" constexpr uint32_t HelloWorld_max_cdr_typesize {268UL}; constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data); diff --git a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldCdrAux.ipp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp similarity index 84% rename from ddsrecorder/test/resources/types/hello_world/v2/HelloWorldCdrAux.ipp rename to ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp index ec08b909a..97df3fe9d 100644 --- a/ddsrecorder/test/resources/types/hello_world/v2/HelloWorldCdrAux.ipp +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,11 +50,11 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.index(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.index(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.message(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.message(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -78,7 +76,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.index() << eprosima::fastcdr::MemberId(1) << data.message() - ; +; scdr.end_serialize_type(current_state); } @@ -95,13 +93,13 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.index(); - break; + case 0: + dcdr >> data.index(); + break; - case 1: - dcdr >> data.message(); - break; + case 1: + dcdr >> data.message(); + break; default: ret_value = false; @@ -119,6 +117,8 @@ void serialize_key( static_cast(data); } + + } // namespace fastcdr } // namespace eprosima diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx similarity index 91% rename from ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldPubSubTypes.cxx rename to ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx index ef09d8f97..aa161b2e1 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldPubSubTypes.cxx +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx @@ -19,27 +19,27 @@ * This file was generated by the tool fastddsgen. */ +#include "HelloWorldPubSubTypes.h" +#include #include -#include "HelloWorldPubSubTypes.h" #include "HelloWorldCdrAux.hpp" +#include "HelloWorldTypeObjectSupport.hpp" using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - HelloWorldPubSubType::HelloWorldPubSubType() { setName("HelloWorld"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - HelloWorld::getMaxCdrSerializedSize(); + static_cast(HelloWorld::getMaxCdrSerializedSize()); #else - HelloWorld_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + HelloWorld_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -139,6 +139,7 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -149,8 +150,8 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -188,8 +189,7 @@ bool HelloWorldPubSubType::getKey( HelloWorld_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -218,3 +218,12 @@ bool HelloWorldPubSubType::getKey( } return true; } + +void HelloWorldPubSubType::register_type_object_representation() +{ + register_HelloWorld_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "HelloWorldCdrAux.ipp" diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldPubSubTypes.h b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h similarity index 92% rename from ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldPubSubTypes.h rename to ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h index f8186b177..7c83d2b30 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldPubSubTypes.h +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h @@ -27,9 +27,9 @@ #include #include #include -#include +#include -#include "HelloWorld.h" +#include "HelloWorld.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -90,6 +88,9 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -105,7 +106,7 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.cxx new file mode 100644 index 000000000..58928b6f0 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.cxx @@ -0,0 +1,138 @@ +// 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 HelloWorldTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "HelloWorldTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "HelloWorld.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_HelloWorld_type_identifier( + TypeIdentifierPair& type_ids_HelloWorld) +{ + + ReturnCode_t return_code_HelloWorld {eprosima::fastdds::dds::RETCODE_OK}; + return_code_HelloWorld = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "HelloWorld", type_ids_HelloWorld); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloWorld) + { + StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_HelloWorld = "HelloWorld"; + eprosima::fastcdr::optional type_ann_builtin_HelloWorld; + eprosima::fastcdr::optional ann_custom_HelloWorld; + CompleteTypeDetail detail_HelloWorld = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloWorld, ann_custom_HelloWorld, type_name_HelloWorld.to_string()); + CompleteStructHeader header_HelloWorld; + header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld); + CompleteStructMemberSeq member_seq_HelloWorld; + { + TypeIdentifierPair type_ids_index; + ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; + return_code_index = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_index); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_index = 0x00000000; + bool common_index_ec {false}; + CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; + if (!common_index_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); + return; + } + MemberName name_index = "index"; + eprosima::fastcdr::optional member_ann_builtin_index; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_HelloWorld); + CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index); + } + { + TypeIdentifierPair type_ids_message; + ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_message)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_message = 0x00000001; + bool common_message_ec {false}; + CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; + if (!common_message_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); + return; + } + MemberName name_message = "message"; + eprosima::fastcdr::optional member_ann_builtin_message; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_HelloWorld); + CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_message); + } + CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_ids_HelloWorld)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "HelloWorld already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.hpp new file mode 100644 index 000000000..2eba797b0 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 HelloWorldTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register HelloWorld related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_HelloWorld_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.h b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.hpp similarity index 56% rename from ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.h rename to ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.hpp index aae554340..138a79db5 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.h +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.hpp @@ -13,28 +13,18 @@ // limitations under the License. /*! - * @file HelloWorld.h + * @file HelloWorld.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_H_ - - -#include - -#include #include -#include -#include -#include -#include +#include +#include #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -60,16 +50,6 @@ #define HELLOWORLD_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -81,73 +61,117 @@ class HelloWorld /*! * @brief Default constructor. */ - eProsima_user_DllExport HelloWorld(); + eProsima_user_DllExport HelloWorld() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~HelloWorld(); + eProsima_user_DllExport ~HelloWorld() + { + } /*! * @brief Copy constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - const HelloWorld& x); + const HelloWorld& x) + { + m_index = x.m_index; + + m_message = x.m_message; + + } /*! * @brief Move constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + m_index = x.m_index; + m_message = std::move(x.m_message); + } /*! * @brief Copy assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); + const HelloWorld& x) + { + + m_index = x.m_index; + + m_message = x.m_message; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + + m_index = x.m_index; + m_message = std::move(x.m_message); + return *this; + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return (m_index == x.m_index && + m_message == x.m_message); + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member index * @param _index New value for member index */ eProsima_user_DllExport void index( - uint32_t _index); + uint32_t _index) + { + m_index = _index; + } /*! * @brief This function returns the value of member index * @return Value of member index */ - eProsima_user_DllExport uint32_t index() const; + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } /*! * @brief This function returns a reference to member index * @return Reference to member index */ - eProsima_user_DllExport uint32_t& index(); + eProsima_user_DllExport uint32_t& index() + { + return m_index; + } /*! @@ -155,88 +179,48 @@ class HelloWorld * @param _message New value to be copied in member message */ eProsima_user_DllExport void message( - const std::string& _message); + const std::array& _message) + { + m_message = _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); + std::array&& _message) + { + m_message = std::move(_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; + eProsima_user_DllExport const std::array& message() const + { + return m_message; + } /*! * @brief This function returns a reference to member message * @return Reference to member message */ - eProsima_user_DllExport std::string& message(); + eProsima_user_DllExport std::array& message() + { + return m_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 HelloWorld& 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 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; + uint32_t m_index{0}; + std::array m_message{0}; }; - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ - +#endif // _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.idl b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.idl similarity index 70% rename from ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.idl rename to ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.idl index 0fd2c355a..9750fbe18 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.idl +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.idl @@ -1,5 +1,5 @@ struct HelloWorld { unsigned long index; - string message; + char message[20]; }; diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.hpp new file mode 100644 index 000000000..de0e84c6e --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.hpp @@ -0,0 +1,46 @@ +// 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 HelloWorldCdrAux.hpp + * This source file contains some definitions of CDR related functions. + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ + +#include "HelloWorld.hpp" + +constexpr uint32_t HelloWorld_max_cdr_typesize {28UL}; +constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; + + +namespace eprosima { +namespace fastcdr { + +class Cdr; +class CdrSizeCalculator; + +eProsima_user_DllExport void serialize_key( + eprosima::fastcdr::Cdr& scdr, + const HelloWorld& data); + + +} // namespace fastcdr +} // namespace eprosima + +#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ + diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldCdrAux.ipp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.ipp similarity index 84% rename from ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldCdrAux.ipp rename to ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.ipp index ec08b909a..97df3fe9d 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldCdrAux.ipp +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,11 +50,11 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.index(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.index(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.message(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.message(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -78,7 +76,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.index() << eprosima::fastcdr::MemberId(1) << data.message() - ; +; scdr.end_serialize_type(current_state); } @@ -95,13 +93,13 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.index(); - break; + case 0: + dcdr >> data.index(); + break; - case 1: - dcdr >> data.message(); - break; + case 1: + dcdr >> data.message(); + break; default: ret_value = false; @@ -119,6 +117,8 @@ void serialize_key( static_cast(data); } + + } // namespace fastcdr } // namespace eprosima diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx similarity index 91% rename from resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldPubSubTypes.cxx rename to ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx index ef09d8f97..aa161b2e1 100644 --- a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldPubSubTypes.cxx +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx @@ -19,27 +19,27 @@ * This file was generated by the tool fastddsgen. */ +#include "HelloWorldPubSubTypes.h" +#include #include -#include "HelloWorldPubSubTypes.h" #include "HelloWorldCdrAux.hpp" +#include "HelloWorldTypeObjectSupport.hpp" using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - HelloWorldPubSubType::HelloWorldPubSubType() { setName("HelloWorld"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - HelloWorld::getMaxCdrSerializedSize(); + static_cast(HelloWorld::getMaxCdrSerializedSize()); #else - HelloWorld_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + HelloWorld_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -139,6 +139,7 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -149,8 +150,8 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -188,8 +189,7 @@ bool HelloWorldPubSubType::getKey( HelloWorld_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -218,3 +218,12 @@ bool HelloWorldPubSubType::getKey( } return true; } + +void HelloWorldPubSubType::register_type_object_representation() +{ + register_HelloWorld_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "HelloWorldCdrAux.ipp" diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h new file mode 100644 index 000000000..4b09a679e --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h @@ -0,0 +1,133 @@ +// 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 HelloWorldPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ + +#include +#include +#include +#include +#include + +#include "HelloWorld.hpp" + + +#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#error \ + Generated HelloWorld 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 HelloWorld defined by the user in the IDL file. + * @ingroup HelloWorld + */ +class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef HelloWorld type; + + eProsima_user_DllExport HelloWorldPubSubType(); + + eProsima_user_DllExport ~HelloWorldPubSubType() override; + + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport bool serialize( + void* data, + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool deserialize( + eprosima::fastrtps::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport std::function getSerializedSizeProvider( + void* data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool getKey( + void* data, + eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport void* createData() override; + + eProsima_user_DllExport void deleteData( + void* data) override; + + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() 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; + } + + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + 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 + { + static_cast(memory); + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; + +}; + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ + diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.cxx new file mode 100644 index 000000000..0b3e68810 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.cxx @@ -0,0 +1,164 @@ +// 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 HelloWorldTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "HelloWorldTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "HelloWorld.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_HelloWorld_type_identifier( + TypeIdentifierPair& type_ids_HelloWorld) +{ + + ReturnCode_t return_code_HelloWorld {eprosima::fastdds::dds::RETCODE_OK}; + return_code_HelloWorld = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "HelloWorld", type_ids_HelloWorld); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloWorld) + { + StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_HelloWorld = "HelloWorld"; + eprosima::fastcdr::optional type_ann_builtin_HelloWorld; + eprosima::fastcdr::optional ann_custom_HelloWorld; + CompleteTypeDetail detail_HelloWorld = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloWorld, ann_custom_HelloWorld, type_name_HelloWorld.to_string()); + CompleteStructHeader header_HelloWorld; + header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld); + CompleteStructMemberSeq member_seq_HelloWorld; + { + TypeIdentifierPair type_ids_index; + ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; + return_code_index = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_index); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_index = 0x00000000; + bool common_index_ec {false}; + CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; + if (!common_index_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); + return; + } + MemberName name_index = "index"; + eprosima::fastcdr::optional member_ann_builtin_index; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_HelloWorld); + CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index); + } + { + TypeIdentifierPair type_ids_message; + ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_array_char_20", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_char", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Array element TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + bool element_identifier_anonymous_array_char_20_ec {false}; + TypeIdentifier* element_identifier_anonymous_array_char_20 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, element_identifier_anonymous_array_char_20_ec))}; + if (!element_identifier_anonymous_array_char_20_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Array element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_array_char_20 = EK_COMPLETE; + if (TK_NONE == type_ids_message.type_identifier2()._d()) + { + equiv_kind_anonymous_array_char_20 = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_array_char_20 = 0; + PlainCollectionHeader header_anonymous_array_char_20 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_array_char_20, element_flags_anonymous_array_char_20); + { + SBoundSeq array_bound_seq; + TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast(20)); + + PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_anonymous_array_char_20, array_bound_seq, + eprosima::fastcdr::external(element_identifier_anonymous_array_char_20)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "anonymous_array_char_20", type_ids_message)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_array_char_20 already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_message = 0x00000001; + bool common_message_ec {false}; + CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; + if (!common_message_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); + return; + } + MemberName name_message = "message"; + eprosima::fastcdr::optional member_ann_builtin_message; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_HelloWorld); + CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_message); + } + CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_ids_HelloWorld)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "HelloWorld already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.hpp new file mode 100644 index 000000000..2eba797b0 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 HelloWorldTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register HelloWorld related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_HelloWorld_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.cxx deleted file mode 100644 index 6a3b213cd..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.cxx +++ /dev/null @@ -1,236 +0,0 @@ -// 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 HelloWorld.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 "HelloWorld.h" -#include - -#include -using namespace eprosima::fastcdr::exception; - -#include - -HelloWorld::HelloWorld() -{ - // m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@627551fb - m_index = 0; - // m_message com.eprosima.idl.parser.typecode.StringTypeCode@2758fe70 - m_message =""; - -} - -HelloWorld::~HelloWorld() -{ - - -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - m_message = x.m_message; -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - m_message = std::move(x.m_message); -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - - m_index = x.m_index; - m_message = x.m_message; - - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - - m_index = x.m_index; - m_message = std::move(x.m_message); - - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - - return (m_index == x.m_index && m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -size_t HelloWorld::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 HelloWorld::getCdrSerializedSize( - const HelloWorld& 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 HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - - scdr << m_index; - scdr << m_message.c_str(); - -} - -void HelloWorld::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 HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::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 HelloWorld::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& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& HelloWorld::message() -{ - return m_message; -} - -size_t HelloWorld::getKeyMaxCdrSerializedSize( - size_t current_alignment) -{ - size_t current_align = current_alignment; - - - - - - return current_align; -} - -bool HelloWorld::isKeyDefined() -{ - return false; -} - -void HelloWorld::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; - -} diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.h b/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.h deleted file mode 100644 index cb7885b35..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.h +++ /dev/null @@ -1,234 +0,0 @@ -// 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 HelloWorld.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_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_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(HelloWorld_SOURCE) -#define HelloWorld_DllAPI __declspec( dllexport ) -#else -#define HelloWorld_DllAPI __declspec( dllimport ) -#endif // HelloWorld_SOURCE -#else -#define HelloWorld_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HelloWorld_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - -/*! - * @brief This class represents the structure HelloWorld defined by the user in the IDL file. - * @ingroup HELLOWORLD - */ -class HelloWorld -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport HelloWorld(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~HelloWorld(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - const HelloWorld& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator !=( - const HelloWorld& 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 HelloWorld& 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_HELLOWORLD_H_ diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorldPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorldPubSubTypes.cxx deleted file mode 100644 index 1159fb042..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorldPubSubTypes.cxx +++ /dev/null @@ -1,169 +0,0 @@ -// 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 HelloWorldPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#include -#include - -#include "HelloWorldPubSubTypes.h" - -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; - -HelloWorldPubSubType::HelloWorldPubSubType() -{ - setName("HelloWorld"); - auto type_size = HelloWorld::getMaxCdrSerializedSize(); - type_size += eprosima::fastcdr::Cdr::alignment(type_size, 4); /* possible submessage alignment */ - m_typeSize = static_cast(type_size) + 4; /*encapsulation*/ - m_isGetKeyDefined = HelloWorld::isKeyDefined(); - size_t keyLength = HelloWorld::getKeyMaxCdrSerializedSize() > 16 ? - HelloWorld::getKeyMaxCdrSerializedSize() : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -HelloWorldPubSubType::~HelloWorldPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool HelloWorldPubSubType::serialize( - void* data, - SerializedPayload_t* payload) -{ - HelloWorld* 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 HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - //Convert DATA to pointer of your type - HelloWorld* 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 HelloWorldPubSubType::getSerializedSizeProvider( - void* data) -{ - return [data]() -> uint32_t - { - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; - }; -} - -void* HelloWorldPubSubType::createData() -{ - return reinterpret_cast(new HelloWorld()); -} - -void HelloWorldPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool HelloWorldPubSubType::getKey( - void* data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - HelloWorld::getKeyMaxCdrSerializedSize()); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); - p_type->serializeKey(ser); - if (force_md5 || HelloWorld::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/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorldPubSubTypes.h b/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorldPubSubTypes.h deleted file mode 100644 index 3ec5efa14..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorldPubSubTypes.h +++ /dev/null @@ -1,101 +0,0 @@ -// 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 HelloWorldPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastcdrgen. - */ - - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ - -#include -#include - -#include "HelloWorld.h" - -#if !defined(GEN_API_VER) || (GEN_API_VER != 1) -#error \ - Generated HelloWorld 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 HelloWorld defined by the user in the IDL file. - * @ingroup HELLOWORLD - */ -class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef HelloWorld type; - - eProsima_user_DllExport HelloWorldPubSubType(); - - eProsima_user_DllExport virtual ~HelloWorldPubSubType() 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_HELLOWORLD_PUBSUBTYPES_H_ diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.cxx deleted file mode 100644 index 4ec5b6d01..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.cxx +++ /dev/null @@ -1,166 +0,0 @@ -// 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 HelloWorld.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -HelloWorld::HelloWorld() -{ -} - -HelloWorld::~HelloWorld() -{ -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - m_message = x.m_message; -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - m_message = std::move(x.m_message); -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - - m_index = x.m_index; - m_message = x.m_message; - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - - m_index = x.m_index; - m_message = std::move(x.m_message); - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::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 HelloWorld::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& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& HelloWorld::message() -{ - return m_message; -} - -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.cxx deleted file mode 100644 index 8206d9414..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.cxx +++ /dev/null @@ -1,289 +0,0 @@ -// 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 HelloWorld.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define HelloWorld_max_cdr_typesize 268ULL; - - - - -HelloWorld::HelloWorld() -{ - // unsigned long m_index - m_index = 0; - // /type_d() m_message - - -} - -HelloWorld::~HelloWorld() -{ -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -size_t HelloWorld::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return HelloWorld_max_cdr_typesize; -} - -size_t HelloWorld::getCdrSerializedSize( - const HelloWorld& 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 HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_index; - - scdr << m_message.c_str(); - -} - -void HelloWorld::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_index; - - - - dcdr >> m_message; - - -} - -bool HelloWorld::isKeyDefined() -{ - return false; -} - -void HelloWorld::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::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 HelloWorld::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& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& HelloWorld::message() -{ - return m_message; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsreplayer/test/blackbox/mcap/resources/helloworld_withtype_file.mcap b/ddsreplayer/test/blackbox/mcap/resources/helloworld_withtype_file.mcap index 85a787ed44aec962059fd9131c136f015b3d0dcc..2ae20ee2a245404f1fa6f2d56673e3dffd3af7eb 100644 GIT binary patch literal 2809 zcmbVOdvFug8sGHYltNns2DSIb3guB~^JwS`yxpWp(^9HQZ`(8|cC))px83ZfyGh#M z)z%73MXDeb#10@@9WU2=^;Sgjf%ghh0j+GOMA?{%dY<$8X)2)8=N9Jbr+KhNBI?7eBy*y$ z5|Ih$qeZ`;3ob+yQ^e>COa|I(DlnML`9@Q|ms)0|3aKWhz|7LDfuf4c3|jz`NG#7% zG7A%g^|_{8eS#|n(Fl7Vd-7=M)>CtavK!4L>iZ!ogf~`xF#zORIml#V+l4RZ{o2?c zdoGQr`_x;Ow&kN6wOuhCaf{Za&+A+Hm^10{{lfG^7JXdX2mAk?zvX>H{Nc)m6SJB& zba(kiMw?I6)ZenNxH#?L_S0+twq`GT_{y%ARzK0%llj!G|NH7()`3DpOnlfeX3nX9J|$yt-&N-z zbG&8n)Z!J>gIo8P?D=+1!R3*Zxi5Zq;ruZ!Jb3k%Z7rkb&fVJ|n)l`WBXP4&8h32# znQNS1T-EvW1Fm(hquobOUrtY4Ftf7kzUfu5MB;6EbCT`Ht2R|>xOckucD-bpv+;-X zKQaIQtM6~c1@FGry-57HwdO+m?Y|5hbI11g%v)d4x2N>Ix7z;UAR?E)$QZbCbLI@~ zlCtH`R-F4juzcbCSXj${tbD*Cka{%JdoKGKjM z(tR~_Y1$~?x0&g$o@orvKAU{zY_?Q-;^B^#+jN)CCJw!xlF?hSw3t0^ctzawcxT)C zRU5uZNSv({5JAKcX^8sZV(WWQU=CbFiO*uShIkTD(fa!tOFc8TkAQg(Hs3k4=?w6P zF#ms{=OXY|F~4N2^D^*7vFZe&BcXVx;~?f|7X{LRe*yD%dALmAzs0;epI!v~d|da@ zeb9*claGqnp$(PBOE9ctvPK?r0kGMa>WXyBKDw<_K_rcN2QDOkzPby2WvYL*_wH8 zc}KX;SQPP=I}tB}ofVpLXjE88lE!2M>Ma4U-^H^au>wybJ%ZEfEQC2RZ&#(jS3u*f zuUktS?Scon0YID?=qqDn7fXv0!%8(lDj0$VQ1S~nXs0WO^pgggr9D{H?keD;`5izu zKJcaH$0-v|X>5?c&DBa9D)|PKpQpSoQfqQGGmg5oU|Orhx(Y})G%9S6X(iCKqmpO* ze3)@7Hl!WqBW=)FNJn&$stvSI$$JHyltr;s){k^rkcV0@N9*MY!@y|#GbiV5MTapZ zME_UW9I4dX^Tjr)j4G=Oc!T!*=(sItoM$5M7In_atqt^3@^%`Fg5G+2$b(eXO5Vy} zQa>?L$y*VkwHmhty)xf5d0QaWa(l#MQrCspTz$|z1D8394^=G6M1h9TqJE-q;ocDa zK91q-h?0X+hz{x|)Y^NrI)soQb3TD(bi63|bezDj9VLo_Zl)xipOt0G$F4T&?<&#W zTcVAU24!N0qdN{Fmhf{3~)3Y88jo& zr~|T1lwr4_%bTOT9M1(K#X7Y1td_4-gHl5F6++g!TvV GgZDRYu>n>9 literal 2302 zcmeD5b#@Fe;N@bJWPkt`AXSuKY{Uzsb25{1lM@RR4D>AY4A_jBAS%qhi8G0>PZF1p zobeSzPXTEGg4zERxj@XS;*u10s9KG!`hOFqFu&zz*e0Fg_F;ns*P1yNZ(mofDY|2zfAY;mDTPFR1FJSa&6kmchi!6 z7jFBy_DI&r-_>jMUO(>pCVqDki>I*na@pW5PtHxWKX6-O$K#U{Z6$~9uieZ1E`IhC zmxm>%0zUQExip<* z!x^Vzj;yGJ3s(+I@%ZVkC^>yf-x;nsljB*c3okG@!P6vS_Y^7-%0zX;;*fb!?8ntd0+E_LV**E;phk#b94+uh=N$o&IEi(P}VlMTIcB7y#n zau2HvH4e&1@d&E|I|&pnFyP^$?+gkS52wngh^T@jW2hQD;ffv(k;Y+_$+=;rDZqe) z8H*AxU_ofO1MPDH+2@{98kK7SQI3c=B>iA1TZYHKUy1TVQzS4f7#NtX!4xRhaRFI~ zM8po{fy(&Y;&d4xvotfW#Mnq7GcP5zf~&ZsC^IizAvd+SI59nyi#ZT#1`~rIkcAO3 zNJeP`<)OL@ic-rm^Gl0irX`ma6{Y5tz_^)tY580%8BmiMq3+X9Nh#JZ$uG!E24%bC zlp=2+1!5NF7drr{qSTzs#H7re%#ungg_5GuRIZfLB2LIfz8 z0@a!g)rekr!OAJDg%}?wv48;c9aacq9)x0m%dk|jL4;nT%W$WHQWX$@5&#Im^>A!} k$|OQ05HehX91tNls0`_ -.. literalinclude:: ../../../resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.idl +.. literalinclude:: ../../../resources/dds/TypeLookupService/types/hello_world/HelloWorld.idl * `Complete.idl `_ -.. literalinclude:: ../../../resources/dds/TypeLookupService/types/v2/complete/Complete.idl +.. literalinclude:: ../../../resources/dds/TypeLookupService/types/complete/Complete.idl Examining the code ================== diff --git a/resources/dds/TypeLookupService/CMakeLists.txt b/resources/dds/TypeLookupService/CMakeLists.txt index 873c4058a..86e1eaa07 100644 --- a/resources/dds/TypeLookupService/CMakeLists.txt +++ b/resources/dds/TypeLookupService/CMakeLists.txt @@ -26,8 +26,8 @@ if(NOT fastcdr_FOUND) find_package(fastcdr REQUIRED) endif() -if(NOT fastrtps_FOUND) - find_package(fastrtps REQUIRED) +if(NOT fastdds_FOUND) + find_package(fastdds REQUIRED) endif() #Check C++11 @@ -58,4 +58,4 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE $<$>,$>:__DEBUG> $<$:__INTERNALDEBUG> # Internal debug activated. ) -target_link_libraries(${PROJECT_NAME} fastrtps fastcdr fastdds::optionparser) +target_link_libraries(${PROJECT_NAME} fastdds fastcdr fastdds::optionparser) diff --git a/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp b/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp index 025af4143..1b258a97d 100644 --- a/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp +++ b/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp @@ -25,14 +25,14 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include + +#include +#include +#include +#include +#include +#include +#include #include "TypeLookupServicePublisher.h" #include "types/complete/CompleteTypeObject.h" @@ -85,7 +85,7 @@ TypeLookupServicePublisher::TypeLookupServicePublisher( break; } - TypeSupport type(new eprosima::fastrtps::types::DynamicPubSubType(dynamic_type_)); + TypeSupport type(new eprosima::fastdds::dds::DynamicPubSubType(dynamic_type_)); // Send type information so the type can be discovered type->auto_fill_type_information(true); @@ -229,7 +229,7 @@ void TypeLookupServicePublisher::run( void TypeLookupServicePublisher::publish(unsigned int msg_index) { // Get the dynamic data depending on the data type - eprosima::fastrtps::types::DynamicData_ptr dynamic_data_; + eprosima::fastdds::dds::DynamicData::_ref_type dynamic_data_; switch (data_type_kind_) { case DataTypeKind::HELLO_WORLD: @@ -290,12 +290,12 @@ eprosima::fastrtps::types::DynamicType_ptr type_object); } -eprosima::fastrtps::types::DynamicData_ptr +eprosima::fastdds::dds::DynamicData::_ref_type TypeLookupServicePublisher::fill_helloworld_data_( const unsigned int& index) { // Create and initialize new dynamic data - eprosima::fastrtps::types::DynamicData_ptr new_data; + eprosima::fastdds::dds::DynamicData::_ref_type new_data; new_data = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dynamic_type_); // Set index @@ -306,12 +306,12 @@ eprosima::fastrtps::types::DynamicData_ptr return new_data; } -eprosima::fastrtps::types::DynamicData_ptr +eprosima::fastdds::dds::DynamicData::_ref_type TypeLookupServicePublisher::fill_complete_data_( const unsigned int& index) { // Create and initialize new dynamic data - eprosima::fastrtps::types::DynamicData_ptr new_data; + eprosima::fastdds::dds::DynamicData::_ref_type new_data; new_data = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dynamic_type_); // Set index @@ -328,7 +328,7 @@ eprosima::fastrtps::types::DynamicData_ptr eprosima::fastrtps::types::DynamicData* points_sequence = new_data->loan_value(2); eprosima::fastrtps::types::DynamicType_ptr seq_elem_type = points_sequence->get_type()->get_descriptor()->get_element_type(); - eprosima::fastrtps::types::DynamicData_ptr seq_elem; + eprosima::fastdds::dds::DynamicData::_ref_type seq_elem; eprosima::fastrtps::types::MemberId id; // internal_data sequence element 1 diff --git a/resources/dds/TypeLookupService/TypeLookupServicePublisher.h b/resources/dds/TypeLookupService/TypeLookupServicePublisher.h index 9a1859d7d..de39bacfe 100644 --- a/resources/dds/TypeLookupService/TypeLookupServicePublisher.h +++ b/resources/dds/TypeLookupService/TypeLookupServicePublisher.h @@ -115,9 +115,9 @@ class TypeLookupServicePublisher : public eprosima::fastdds::dds::DomainParticip * * @param index Index of the sample to be published. This parameter is used to modify the content of the message * depending on the number of the sample to be sent. - * @return eprosima::fastrtps::types::DynamicData_ptr The generated data to be published + * @return eprosima::fastdds::dds::DynamicData::_ref_type The generated data to be published */ - eprosima::fastrtps::types::DynamicData_ptr fill_helloworld_data_( + eprosima::fastdds::dds::DynamicData::_ref_type fill_helloworld_data_( const unsigned int& index); /** @@ -125,9 +125,9 @@ class TypeLookupServicePublisher : public eprosima::fastdds::dds::DomainParticip * * @param index Index of the sample to be published. This parameter is used to modify the content of the message * depending on the number of the sample to be sent. - * @return eprosima::fastrtps::types::DynamicData_ptr The generated data to be published + * @return eprosima::fastdds::dds::DynamicData::_ref_type The generated data to be published */ - eprosima::fastrtps::types::DynamicData_ptr fill_complete_data_( + eprosima::fastdds::dds::DynamicData::_ref_type fill_complete_data_( const unsigned int& index); // Fast DDS entities diff --git a/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp b/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp index ef689a060..c2f8d838b 100644 --- a/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp +++ b/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp @@ -25,10 +25,9 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include #include "TypeLookupServiceSubscriber.h" @@ -144,7 +143,7 @@ void TypeLookupServiceSubscriber::on_data_available( DataReader* reader) { // Create a new DynamicData to read the sample - eprosima::fastrtps::types::DynamicData_ptr new_dynamic_data; + eprosima::fastdds::dds::DynamicData::_ref_type new_dynamic_data; new_dynamic_data = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dynamic_type_); SampleInfo info; @@ -171,9 +170,9 @@ void TypeLookupServiceSubscriber::on_data_available( void TypeLookupServiceSubscriber::on_type_information_received( eprosima::fastdds::dds::DomainParticipant*, - const eprosima::fastrtps::string_255 topic_name, - const eprosima::fastrtps::string_255 type_name, - const eprosima::fastrtps::types::TypeInformation& type_information) + const eprosima::fastcdr::string_255 topic_name, + const eprosima::fastcdr::string_255 type_name, + const eprosima::fastdds::dds::xtypes::TypeInformation& type_information) { // First check if the topic received is the one we are expecting if (topic_name.to_string() != topic_name_) @@ -281,7 +280,7 @@ void TypeLookupServiceSubscriber::register_remote_type_callback_( { //////////////////// // Register the type - TypeSupport type(new eprosima::fastrtps::types::DynamicPubSubType(dynamic_type)); + TypeSupport type(new eprosima::fastdds::dds::DynamicPubSubType(dynamic_type)); type.register_type(participant_); /////////////////////// diff --git a/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.h b/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.h index 7d6d31eb9..0158712b0 100644 --- a/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.h +++ b/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.h @@ -74,9 +74,9 @@ class TypeLookupServiceSubscriber : public eprosima::fastdds::dds::DomainPartici //! Callback to receive the remote data type information virtual void on_type_information_received( eprosima::fastdds::dds::DomainParticipant* participant, - const eprosima::fastrtps::string_255 topic_name, - const eprosima::fastrtps::string_255 type_name, - const eprosima::fastrtps::types::TypeInformation& type_information) override; + const eprosima::fastcdr::string_255 topic_name, + const eprosima::fastcdr::string_255 type_name, + const eprosima::fastdds::dds::xtypes::TypeInformation& type_information) override; //! Return the current state of execution static bool is_stopped(); diff --git a/resources/dds/TypeLookupService/types/v2/complete/Complete.h b/resources/dds/TypeLookupService/types/complete/Complete.hpp similarity index 62% rename from resources/dds/TypeLookupService/types/v2/complete/Complete.h rename to resources/dds/TypeLookupService/types/complete/Complete.hpp index 066c14641..9d1b91cb4 100644 --- a/resources/dds/TypeLookupService/types/v2/complete/Complete.h +++ b/resources/dds/TypeLookupService/types/complete/Complete.hpp @@ -13,32 +13,22 @@ // limitations under the License. /*! - * @file Complete.h + * @file Complete.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "Completev1.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_COMPLETE_H_ -#define _FAST_DDS_GENERATED_COMPLETE_H_ +#ifndef _FAST_DDS_GENERATED_COMPLETE_HPP_ +#define _FAST_DDS_GENERATED_COMPLETE_HPP_ #include -#include #include -#include #include +#include #include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +54,6 @@ #define COMPLETE_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure Timestamp defined by the user in the IDL file. * @ingroup Complete @@ -86,73 +65,117 @@ class Timestamp /*! * @brief Default constructor. */ - eProsima_user_DllExport Timestamp(); + eProsima_user_DllExport Timestamp() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~Timestamp(); + eProsima_user_DllExport ~Timestamp() + { + } /*! * @brief Copy constructor. * @param x Reference to the object Timestamp that will be copied. */ eProsima_user_DllExport Timestamp( - const Timestamp& x); + const Timestamp& x) + { + m_seconds = x.m_seconds; + + m_milliseconds = x.m_milliseconds; + + } /*! * @brief Move constructor. * @param x Reference to the object Timestamp that will be copied. */ eProsima_user_DllExport Timestamp( - Timestamp&& x) noexcept; + Timestamp&& x) noexcept + { + m_seconds = x.m_seconds; + m_milliseconds = x.m_milliseconds; + } /*! * @brief Copy assignment. * @param x Reference to the object Timestamp that will be copied. */ eProsima_user_DllExport Timestamp& operator =( - const Timestamp& x); + const Timestamp& x) + { + + m_seconds = x.m_seconds; + + m_milliseconds = x.m_milliseconds; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object Timestamp that will be copied. */ eProsima_user_DllExport Timestamp& operator =( - Timestamp&& x) noexcept; + Timestamp&& x) noexcept + { + + m_seconds = x.m_seconds; + m_milliseconds = x.m_milliseconds; + return *this; + } /*! * @brief Comparison operator. * @param x Timestamp object to compare. */ eProsima_user_DllExport bool operator ==( - const Timestamp& x) const; + const Timestamp& x) const + { + return (m_seconds == x.m_seconds && + m_milliseconds == x.m_milliseconds); + } /*! * @brief Comparison operator. * @param x Timestamp object to compare. */ eProsima_user_DllExport bool operator !=( - const Timestamp& x) const; + const Timestamp& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member seconds * @param _seconds New value for member seconds */ eProsima_user_DllExport void seconds( - int32_t _seconds); + int32_t _seconds) + { + m_seconds = _seconds; + } /*! * @brief This function returns the value of member seconds * @return Value of member seconds */ - eProsima_user_DllExport int32_t seconds() const; + eProsima_user_DllExport int32_t seconds() const + { + return m_seconds; + } /*! * @brief This function returns a reference to member seconds * @return Reference to member seconds */ - eProsima_user_DllExport int32_t& seconds(); + eProsima_user_DllExport int32_t& seconds() + { + return m_seconds; + } /*! @@ -160,19 +183,30 @@ class Timestamp * @param _milliseconds New value for member milliseconds */ eProsima_user_DllExport void milliseconds( - int32_t _milliseconds); + int32_t _milliseconds) + { + m_milliseconds = _milliseconds; + } /*! * @brief This function returns the value of member milliseconds * @return Value of member milliseconds */ - eProsima_user_DllExport int32_t milliseconds() const; + eProsima_user_DllExport int32_t milliseconds() const + { + return m_milliseconds; + } /*! * @brief This function returns a reference to member milliseconds * @return Reference to member milliseconds */ - eProsima_user_DllExport int32_t& milliseconds(); + eProsima_user_DllExport int32_t& milliseconds() + { + return m_milliseconds; + } + + private: @@ -180,8 +214,6 @@ class Timestamp int32_t m_milliseconds{0}; }; - - /*! * @brief This class represents the structure Point defined by the user in the IDL file. * @ingroup Complete @@ -193,73 +225,124 @@ class Point /*! * @brief Default constructor. */ - eProsima_user_DllExport Point(); + eProsima_user_DllExport Point() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~Point(); + eProsima_user_DllExport ~Point() + { + } /*! * @brief Copy constructor. * @param x Reference to the object Point that will be copied. */ eProsima_user_DllExport Point( - const Point& x); + const Point& x) + { + m_x = x.m_x; + + m_y = x.m_y; + + m_z = x.m_z; + + } /*! * @brief Move constructor. * @param x Reference to the object Point that will be copied. */ eProsima_user_DllExport Point( - Point&& x) noexcept; + Point&& x) noexcept + { + m_x = x.m_x; + m_y = x.m_y; + m_z = x.m_z; + } /*! * @brief Copy assignment. * @param x Reference to the object Point that will be copied. */ eProsima_user_DllExport Point& operator =( - const Point& x); + const Point& x) + { + + m_x = x.m_x; + + m_y = x.m_y; + + m_z = x.m_z; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object Point that will be copied. */ eProsima_user_DllExport Point& operator =( - Point&& x) noexcept; + Point&& x) noexcept + { + + m_x = x.m_x; + m_y = x.m_y; + m_z = x.m_z; + return *this; + } /*! * @brief Comparison operator. * @param x Point object to compare. */ eProsima_user_DllExport bool operator ==( - const Point& x) const; + const Point& x) const + { + return (m_x == x.m_x && + m_y == x.m_y && + m_z == x.m_z); + } /*! * @brief Comparison operator. * @param x Point object to compare. */ eProsima_user_DllExport bool operator !=( - const Point& x) const; + const Point& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member x * @param _x New value for member x */ eProsima_user_DllExport void x( - int32_t _x); + int32_t _x) + { + m_x = _x; + } /*! * @brief This function returns the value of member x * @return Value of member x */ - eProsima_user_DllExport int32_t x() const; + eProsima_user_DllExport int32_t x() const + { + return m_x; + } /*! * @brief This function returns a reference to member x * @return Reference to member x */ - eProsima_user_DllExport int32_t& x(); + eProsima_user_DllExport int32_t& x() + { + return m_x; + } /*! @@ -267,19 +350,28 @@ class Point * @param _y New value for member y */ eProsima_user_DllExport void y( - int32_t _y); + int32_t _y) + { + m_y = _y; + } /*! * @brief This function returns the value of member y * @return Value of member y */ - eProsima_user_DllExport int32_t y() const; + eProsima_user_DllExport int32_t y() const + { + return m_y; + } /*! * @brief This function returns a reference to member y * @return Reference to member y */ - eProsima_user_DllExport int32_t& y(); + eProsima_user_DllExport int32_t& y() + { + return m_y; + } /*! @@ -287,19 +379,30 @@ class Point * @param _z New value for member z */ eProsima_user_DllExport void z( - int32_t _z); + int32_t _z) + { + m_z = _z; + } /*! * @brief This function returns the value of member z * @return Value of member z */ - eProsima_user_DllExport int32_t z() const; + eProsima_user_DllExport int32_t z() const + { + return m_z; + } /*! * @brief This function returns a reference to member z * @return Reference to member z */ - eProsima_user_DllExport int32_t& z(); + eProsima_user_DllExport int32_t& z() + { + return m_z; + } + + private: @@ -308,8 +411,6 @@ class Point int32_t m_z{0}; }; - - /*! * @brief This class represents the structure MessageDescriptor defined by the user in the IDL file. * @ingroup Complete @@ -321,73 +422,124 @@ class MessageDescriptor /*! * @brief Default constructor. */ - eProsima_user_DllExport MessageDescriptor(); + eProsima_user_DllExport MessageDescriptor() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~MessageDescriptor(); + eProsima_user_DllExport ~MessageDescriptor() + { + } /*! * @brief Copy constructor. * @param x Reference to the object MessageDescriptor that will be copied. */ eProsima_user_DllExport MessageDescriptor( - const MessageDescriptor& x); + const MessageDescriptor& x) + { + m_id = x.m_id; + + m_topic = x.m_topic; + + m_time = x.m_time; + + } /*! * @brief Move constructor. * @param x Reference to the object MessageDescriptor that will be copied. */ eProsima_user_DllExport MessageDescriptor( - MessageDescriptor&& x) noexcept; + MessageDescriptor&& x) noexcept + { + m_id = x.m_id; + m_topic = std::move(x.m_topic); + m_time = std::move(x.m_time); + } /*! * @brief Copy assignment. * @param x Reference to the object MessageDescriptor that will be copied. */ eProsima_user_DllExport MessageDescriptor& operator =( - const MessageDescriptor& x); + const MessageDescriptor& x) + { + + m_id = x.m_id; + + m_topic = x.m_topic; + + m_time = x.m_time; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object MessageDescriptor that will be copied. */ eProsima_user_DllExport MessageDescriptor& operator =( - MessageDescriptor&& x) noexcept; + MessageDescriptor&& x) noexcept + { + + m_id = x.m_id; + m_topic = std::move(x.m_topic); + m_time = std::move(x.m_time); + return *this; + } /*! * @brief Comparison operator. * @param x MessageDescriptor object to compare. */ eProsima_user_DllExport bool operator ==( - const MessageDescriptor& x) const; + const MessageDescriptor& x) const + { + return (m_id == x.m_id && + m_topic == x.m_topic && + m_time == x.m_time); + } /*! * @brief Comparison operator. * @param x MessageDescriptor object to compare. */ eProsima_user_DllExport bool operator !=( - const MessageDescriptor& x) const; + const MessageDescriptor& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member id * @param _id New value for member id */ eProsima_user_DllExport void id( - uint32_t _id); + uint32_t _id) + { + m_id = _id; + } /*! * @brief This function returns the value of member id * @return Value of member id */ - eProsima_user_DllExport uint32_t id() const; + eProsima_user_DllExport uint32_t id() const + { + return m_id; + } /*! * @brief This function returns a reference to member id * @return Reference to member id */ - eProsima_user_DllExport uint32_t& id(); + eProsima_user_DllExport uint32_t& id() + { + return m_id; + } /*! @@ -395,26 +547,38 @@ class MessageDescriptor * @param _topic New value to be copied in member topic */ eProsima_user_DllExport void topic( - const std::string& _topic); + const std::string& _topic) + { + m_topic = _topic; + } /*! * @brief This function moves the value in member topic * @param _topic New value to be moved in member topic */ eProsima_user_DllExport void topic( - std::string&& _topic); + std::string&& _topic) + { + m_topic = std::move(_topic); + } /*! * @brief This function returns a constant reference to member topic * @return Constant reference to member topic */ - eProsima_user_DllExport const std::string& topic() const; + eProsima_user_DllExport const std::string& topic() const + { + return m_topic; + } /*! * @brief This function returns a reference to member topic * @return Reference to member topic */ - eProsima_user_DllExport std::string& topic(); + eProsima_user_DllExport std::string& topic() + { + return m_topic; + } /*! @@ -422,26 +586,40 @@ class MessageDescriptor * @param _time New value to be copied in member time */ eProsima_user_DllExport void time( - const Timestamp& _time); + const Timestamp& _time) + { + m_time = _time; + } /*! * @brief This function moves the value in member time * @param _time New value to be moved in member time */ eProsima_user_DllExport void time( - Timestamp&& _time); + Timestamp&& _time) + { + m_time = std::move(_time); + } /*! * @brief This function returns a constant reference to member time * @return Constant reference to member time */ - eProsima_user_DllExport const Timestamp& time() const; + eProsima_user_DllExport const Timestamp& time() const + { + return m_time; + } /*! * @brief This function returns a reference to member time * @return Reference to member time */ - eProsima_user_DllExport Timestamp& time(); + eProsima_user_DllExport Timestamp& time() + { + return m_time; + } + + private: @@ -450,8 +628,6 @@ class MessageDescriptor Timestamp m_time; }; - - /*! * @brief This class represents the structure Message defined by the user in the IDL file. * @ingroup Complete @@ -463,80 +639,127 @@ class Message /*! * @brief Default constructor. */ - eProsima_user_DllExport Message(); + eProsima_user_DllExport Message() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~Message(); + eProsima_user_DllExport ~Message() + { + } /*! * @brief Copy constructor. * @param x Reference to the object Message that will be copied. */ eProsima_user_DllExport Message( - const Message& x); + const Message& x) + { + m_descriptor = x.m_descriptor; + + m_message = x.m_message; + + } /*! * @brief Move constructor. * @param x Reference to the object Message that will be copied. */ eProsima_user_DllExport Message( - Message&& x) noexcept; + Message&& x) noexcept + { + m_descriptor = std::move(x.m_descriptor); + m_message = std::move(x.m_message); + } /*! * @brief Copy assignment. * @param x Reference to the object Message that will be copied. */ eProsima_user_DllExport Message& operator =( - const Message& x); + const Message& x) + { + + m_descriptor = x.m_descriptor; + + m_message = x.m_message; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object Message that will be copied. */ eProsima_user_DllExport Message& operator =( - Message&& x) noexcept; + Message&& x) noexcept + { + + m_descriptor = std::move(x.m_descriptor); + m_message = std::move(x.m_message); + return *this; + } /*! * @brief Comparison operator. * @param x Message object to compare. */ eProsima_user_DllExport bool operator ==( - const Message& x) const; + const Message& x) const + { + return (m_descriptor == x.m_descriptor && + m_message == x.m_message); + } /*! * @brief Comparison operator. * @param x Message object to compare. */ eProsima_user_DllExport bool operator !=( - const Message& x) const; + const Message& x) const + { + return !(*this == x); + } /*! * @brief This function copies the value in member descriptor * @param _descriptor New value to be copied in member descriptor */ eProsima_user_DllExport void descriptor( - const MessageDescriptor& _descriptor); + const MessageDescriptor& _descriptor) + { + m_descriptor = _descriptor; + } /*! * @brief This function moves the value in member descriptor * @param _descriptor New value to be moved in member descriptor */ eProsima_user_DllExport void descriptor( - MessageDescriptor&& _descriptor); + MessageDescriptor&& _descriptor) + { + m_descriptor = std::move(_descriptor); + } /*! * @brief This function returns a constant reference to member descriptor * @return Constant reference to member descriptor */ - eProsima_user_DllExport const MessageDescriptor& descriptor() const; + eProsima_user_DllExport const MessageDescriptor& descriptor() const + { + return m_descriptor; + } /*! * @brief This function returns a reference to member descriptor * @return Reference to member descriptor */ - eProsima_user_DllExport MessageDescriptor& descriptor(); + eProsima_user_DllExport MessageDescriptor& descriptor() + { + return m_descriptor; + } /*! @@ -544,26 +767,40 @@ class Message * @param _message New value to be copied in member message */ eProsima_user_DllExport void message( - const std::string& _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 */ eProsima_user_DllExport void message( - std::string&& _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 */ - eProsima_user_DllExport const std::string& message() const; + eProsima_user_DllExport const std::string& message() const + { + return m_message; + } /*! * @brief This function returns a reference to member message * @return Reference to member message */ - eProsima_user_DllExport std::string& message(); + eProsima_user_DllExport std::string& message() + { + return m_message; + } + + private: @@ -571,8 +808,6 @@ class Message std::string m_message; }; - - /*! * @brief This class represents the structure CompleteData defined by the user in the IDL file. * @ingroup Complete @@ -584,73 +819,131 @@ class CompleteData /*! * @brief Default constructor. */ - eProsima_user_DllExport CompleteData(); + eProsima_user_DllExport CompleteData() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~CompleteData(); + eProsima_user_DllExport ~CompleteData() + { + } /*! * @brief Copy constructor. * @param x Reference to the object CompleteData that will be copied. */ eProsima_user_DllExport CompleteData( - const CompleteData& x); + const CompleteData& x) + { + m_index = x.m_index; + + m_main_point = x.m_main_point; + + m_internal_data = x.m_internal_data; + + m_messages = x.m_messages; + + } /*! * @brief Move constructor. * @param x Reference to the object CompleteData that will be copied. */ eProsima_user_DllExport CompleteData( - CompleteData&& x) noexcept; + CompleteData&& x) noexcept + { + m_index = x.m_index; + m_main_point = std::move(x.m_main_point); + m_internal_data = std::move(x.m_internal_data); + m_messages = std::move(x.m_messages); + } /*! * @brief Copy assignment. * @param x Reference to the object CompleteData that will be copied. */ eProsima_user_DllExport CompleteData& operator =( - const CompleteData& x); + const CompleteData& x) + { + + m_index = x.m_index; + + m_main_point = x.m_main_point; + + m_internal_data = x.m_internal_data; + + m_messages = x.m_messages; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object CompleteData that will be copied. */ eProsima_user_DllExport CompleteData& operator =( - CompleteData&& x) noexcept; + CompleteData&& x) noexcept + { + + m_index = x.m_index; + m_main_point = std::move(x.m_main_point); + m_internal_data = std::move(x.m_internal_data); + m_messages = std::move(x.m_messages); + return *this; + } /*! * @brief Comparison operator. * @param x CompleteData object to compare. */ eProsima_user_DllExport bool operator ==( - const CompleteData& x) const; + const CompleteData& x) const + { + return (m_index == x.m_index && + m_main_point == x.m_main_point && + m_internal_data == x.m_internal_data && + m_messages == x.m_messages); + } /*! * @brief Comparison operator. * @param x CompleteData object to compare. */ eProsima_user_DllExport bool operator !=( - const CompleteData& x) const; + const CompleteData& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member index * @param _index New value for member index */ eProsima_user_DllExport void index( - uint32_t _index); + uint32_t _index) + { + m_index = _index; + } /*! * @brief This function returns the value of member index * @return Value of member index */ - eProsima_user_DllExport uint32_t index() const; + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } /*! * @brief This function returns a reference to member index * @return Reference to member index */ - eProsima_user_DllExport uint32_t& index(); + eProsima_user_DllExport uint32_t& index() + { + return m_index; + } /*! @@ -658,26 +951,38 @@ class CompleteData * @param _main_point New value to be copied in member main_point */ eProsima_user_DllExport void main_point( - const Point& _main_point); + const Point& _main_point) + { + m_main_point = _main_point; + } /*! * @brief This function moves the value in member main_point * @param _main_point New value to be moved in member main_point */ eProsima_user_DllExport void main_point( - Point&& _main_point); + Point&& _main_point) + { + m_main_point = std::move(_main_point); + } /*! * @brief This function returns a constant reference to member main_point * @return Constant reference to member main_point */ - eProsima_user_DllExport const Point& main_point() const; + eProsima_user_DllExport const Point& main_point() const + { + return m_main_point; + } /*! * @brief This function returns a reference to member main_point * @return Reference to member main_point */ - eProsima_user_DllExport Point& main_point(); + eProsima_user_DllExport Point& main_point() + { + return m_main_point; + } /*! @@ -685,26 +990,38 @@ class CompleteData * @param _internal_data New value to be copied in member internal_data */ eProsima_user_DllExport void internal_data( - const std::vector& _internal_data); + const std::vector& _internal_data) + { + m_internal_data = _internal_data; + } /*! * @brief This function moves the value in member internal_data * @param _internal_data New value to be moved in member internal_data */ eProsima_user_DllExport void internal_data( - std::vector&& _internal_data); + std::vector&& _internal_data) + { + m_internal_data = std::move(_internal_data); + } /*! * @brief This function returns a constant reference to member internal_data * @return Constant reference to member internal_data */ - eProsima_user_DllExport const std::vector& internal_data() const; + eProsima_user_DllExport const std::vector& internal_data() const + { + return m_internal_data; + } /*! * @brief This function returns a reference to member internal_data * @return Reference to member internal_data */ - eProsima_user_DllExport std::vector& internal_data(); + eProsima_user_DllExport std::vector& internal_data() + { + return m_internal_data; + } /*! @@ -712,26 +1029,40 @@ class CompleteData * @param _messages New value to be copied in member messages */ eProsima_user_DllExport void messages( - const std::array& _messages); + const std::array& _messages) + { + m_messages = _messages; + } /*! * @brief This function moves the value in member messages * @param _messages New value to be moved in member messages */ eProsima_user_DllExport void messages( - std::array&& _messages); + std::array&& _messages) + { + m_messages = std::move(_messages); + } /*! * @brief This function returns a constant reference to member messages * @return Constant reference to member messages */ - eProsima_user_DllExport const std::array& messages() const; + eProsima_user_DllExport const std::array& messages() const + { + return m_messages; + } /*! * @brief This function returns a reference to member messages * @return Reference to member messages */ - eProsima_user_DllExport std::array& messages(); + eProsima_user_DllExport std::array& messages() + { + return m_messages; + } + + private: @@ -742,8 +1073,6 @@ class CompleteData }; -#endif // _FAST_DDS_GENERATED_COMPLETE_H_ - +#endif // _FAST_DDS_GENERATED_COMPLETE_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/resources/dds/TypeLookupService/types/v2/complete/Complete.idl b/resources/dds/TypeLookupService/types/complete/Complete.idl similarity index 100% rename from resources/dds/TypeLookupService/types/v2/complete/Complete.idl rename to resources/dds/TypeLookupService/types/complete/Complete.idl diff --git a/resources/dds/TypeLookupService/types/v2/complete/CompleteCdrAux.hpp b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp similarity index 95% rename from resources/dds/TypeLookupService/types/v2/complete/CompleteCdrAux.hpp rename to resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp index 0c2aedb11..c896c558e 100644 --- a/resources/dds/TypeLookupService/types/v2/complete/CompleteCdrAux.hpp +++ b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp @@ -22,12 +22,12 @@ #ifndef _FAST_DDS_GENERATED_COMPLETECDRAUX_HPP_ #define _FAST_DDS_GENERATED_COMPLETECDRAUX_HPP_ -#include "Complete.h" +#include "Complete.hpp" constexpr uint32_t MessageDescriptor_max_cdr_typesize {280UL}; constexpr uint32_t MessageDescriptor_max_key_cdr_typesize {0UL}; -constexpr uint32_t CompleteData_max_cdr_typesize {2724UL}; +constexpr uint32_t CompleteData_max_cdr_typesize {1124UL}; constexpr uint32_t CompleteData_max_key_cdr_typesize {0UL}; constexpr uint32_t Message_max_cdr_typesize {544UL}; @@ -46,32 +46,22 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const Timestamp& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const Point& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const MessageDescriptor& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const Message& data); - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const CompleteData& data); diff --git a/resources/dds/TypeLookupService/types/v2/complete/CompleteCdrAux.ipp b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp similarity index 74% rename from resources/dds/TypeLookupService/types/v2/complete/CompleteCdrAux.ipp rename to resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp index b478298e4..df1837e67 100644 --- a/resources/dds/TypeLookupService/types/v2/complete/CompleteCdrAux.ipp +++ b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp @@ -34,8 +34,6 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { - - template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -52,11 +50,11 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.seconds(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.seconds(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.milliseconds(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.milliseconds(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -78,7 +76,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.seconds() << eprosima::fastcdr::MemberId(1) << data.milliseconds() - ; +; scdr.end_serialize_type(current_state); } @@ -95,13 +93,13 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.seconds(); - break; + case 0: + dcdr >> data.seconds(); + break; - case 1: - dcdr >> data.milliseconds(); - break; + case 1: + dcdr >> data.milliseconds(); + break; default: ret_value = false; @@ -119,6 +117,7 @@ void serialize_key( static_cast(data); } + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -135,14 +134,14 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.x(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.x(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.y(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.y(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.z(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.z(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -165,7 +164,7 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(0) << data.x() << eprosima::fastcdr::MemberId(1) << data.y() << eprosima::fastcdr::MemberId(2) << data.z() - ; +; scdr.end_serialize_type(current_state); } @@ -182,17 +181,17 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.x(); - break; + case 0: + dcdr >> data.x(); + break; - case 1: - dcdr >> data.y(); - break; + case 1: + dcdr >> data.y(); + break; - case 2: - dcdr >> data.z(); - break; + case 2: + dcdr >> data.z(); + break; default: ret_value = false; @@ -210,6 +209,7 @@ void serialize_key( static_cast(data); } + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -226,14 +226,14 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.id(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.id(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.topic(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.topic(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.time(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.time(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -256,7 +256,7 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(0) << data.id() << eprosima::fastcdr::MemberId(1) << data.topic() << eprosima::fastcdr::MemberId(2) << data.time() - ; +; scdr.end_serialize_type(current_state); } @@ -273,17 +273,17 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.id(); - break; + case 0: + dcdr >> data.id(); + break; - case 1: - dcdr >> data.topic(); - break; + case 1: + dcdr >> data.topic(); + break; - case 2: - dcdr >> data.time(); - break; + case 2: + dcdr >> data.time(); + break; default: ret_value = false; @@ -301,6 +301,7 @@ void serialize_key( static_cast(data); } + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -317,11 +318,11 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.descriptor(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.descriptor(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.message(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.message(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -343,7 +344,7 @@ eProsima_user_DllExport void serialize( scdr << eprosima::fastcdr::MemberId(0) << data.descriptor() << eprosima::fastcdr::MemberId(1) << data.message() - ; +; scdr.end_serialize_type(current_state); } @@ -360,13 +361,13 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.descriptor(); - break; + case 0: + dcdr >> data.descriptor(); + break; - case 1: - dcdr >> data.message(); - break; + case 1: + dcdr >> data.message(); + break; default: ret_value = false; @@ -384,6 +385,7 @@ void serialize_key( static_cast(data); } + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -400,17 +402,17 @@ eProsima_user_DllExport size_t calculate_serialized_size( current_alignment)}; - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.index(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.index(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.main_point(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.main_point(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), - data.internal_data(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.internal_data(), current_alignment); - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), - data.messages(), current_alignment); + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(3), + data.messages(), current_alignment); calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); @@ -434,7 +436,7 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(1) << data.main_point() << eprosima::fastcdr::MemberId(2) << data.internal_data() << eprosima::fastcdr::MemberId(3) << data.messages() - ; +; scdr.end_serialize_type(current_state); } @@ -451,21 +453,21 @@ eProsima_user_DllExport void deserialize( bool ret_value = true; switch (mid.id) { - case 0: - dcdr >> data.index(); - break; + case 0: + dcdr >> data.index(); + break; - case 1: - dcdr >> data.main_point(); - break; + case 1: + dcdr >> data.main_point(); + break; - case 2: - dcdr >> data.internal_data(); - break; + case 2: + dcdr >> data.internal_data(); + break; - case 3: - dcdr >> data.messages(); - break; + case 3: + dcdr >> data.messages(); + break; default: ret_value = false; @@ -483,6 +485,8 @@ void serialize_key( static_cast(data); } + + } // namespace fastcdr } // namespace eprosima diff --git a/resources/dds/TypeLookupService/types/v2/complete/CompletePubSubTypes.cxx b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx similarity index 92% rename from resources/dds/TypeLookupService/types/v2/complete/CompletePubSubTypes.cxx rename to resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx index e762d59f1..13588d163 100644 --- a/resources/dds/TypeLookupService/types/v2/complete/CompletePubSubTypes.cxx +++ b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx @@ -19,27 +19,27 @@ * This file was generated by the tool fastddsgen. */ +#include "CompletePubSubTypes.h" +#include #include -#include "CompletePubSubTypes.h" #include "CompleteCdrAux.hpp" +#include "CompleteTypeObjectSupport.hpp" using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - - TimestampPubSubType::TimestampPubSubType() { setName("Timestamp"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - Timestamp::getMaxCdrSerializedSize(); + static_cast(Timestamp::getMaxCdrSerializedSize()); #else - Timestamp_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + Timestamp_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -139,6 +139,7 @@ std::function TimestampPubSubType::getSerializedSizeProvider( return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -149,8 +150,8 @@ std::function TimestampPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -188,8 +189,7 @@ bool TimestampPubSubType::getKey( Timestamp_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -219,15 +219,20 @@ bool TimestampPubSubType::getKey( return true; } +void TimestampPubSubType::register_type_object_representation() +{ + register_Timestamp_type_identifier(type_identifiers_); +} + PointPubSubType::PointPubSubType() { setName("Point"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - Point::getMaxCdrSerializedSize(); + static_cast(Point::getMaxCdrSerializedSize()); #else - Point_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + Point_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -327,6 +332,7 @@ std::function PointPubSubType::getSerializedSizeProvider( return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -337,8 +343,8 @@ std::function PointPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -376,8 +382,7 @@ bool PointPubSubType::getKey( Point_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -407,15 +412,20 @@ bool PointPubSubType::getKey( return true; } +void PointPubSubType::register_type_object_representation() +{ + register_Point_type_identifier(type_identifiers_); +} + MessageDescriptorPubSubType::MessageDescriptorPubSubType() { setName("MessageDescriptor"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - MessageDescriptor::getMaxCdrSerializedSize(); + static_cast(MessageDescriptor::getMaxCdrSerializedSize()); #else - MessageDescriptor_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + MessageDescriptor_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -515,6 +525,7 @@ std::function MessageDescriptorPubSubType::getSerializedSizeProvider return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -525,8 +536,8 @@ std::function MessageDescriptorPubSubType::getSerializedSizeProvider eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -564,8 +575,7 @@ bool MessageDescriptorPubSubType::getKey( MessageDescriptor_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -595,15 +605,20 @@ bool MessageDescriptorPubSubType::getKey( return true; } +void MessageDescriptorPubSubType::register_type_object_representation() +{ + register_MessageDescriptor_type_identifier(type_identifiers_); +} + MessagePubSubType::MessagePubSubType() { setName("Message"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - Message::getMaxCdrSerializedSize(); + static_cast(Message::getMaxCdrSerializedSize()); #else - Message_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + Message_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -703,6 +718,7 @@ std::function MessagePubSubType::getSerializedSizeProvider( return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -713,8 +729,8 @@ std::function MessagePubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -752,8 +768,7 @@ bool MessagePubSubType::getKey( Message_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -783,15 +798,20 @@ bool MessagePubSubType::getKey( return true; } +void MessagePubSubType::register_type_object_representation() +{ + register_Message_type_identifier(type_identifiers_); +} + CompleteDataPubSubType::CompleteDataPubSubType() { setName("CompleteData"); uint32_t type_size = #if FASTCDR_VERSION_MAJOR == 1 - CompleteData::getMaxCdrSerializedSize(); + static_cast(CompleteData::getMaxCdrSerializedSize()); #else - CompleteData_max_cdr_typesize; -#endif // if FASTCDR_VERSION_MAJOR == 1 + CompleteData_max_cdr_typesize; +#endif type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -891,6 +911,7 @@ std::function CompleteDataPubSubType::getSerializedSizeProvider( return [data, data_representation]() -> uint32_t { #if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); return static_cast(type::getCdrSerializedSize(*static_cast(data))) + 4u /*encapsulation*/; #else @@ -901,8 +922,8 @@ std::function CompleteDataPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) { @@ -940,8 +961,7 @@ bool CompleteDataPubSubType::getKey( CompleteData_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, - eprosima::fastcdr::CdrVersion::XCDRv1); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); #if FASTCDR_VERSION_MAJOR == 1 p_type->serializeKey(ser); #else @@ -970,3 +990,12 @@ bool CompleteDataPubSubType::getKey( } return true; } + +void CompleteDataPubSubType::register_type_object_representation() +{ + register_CompleteData_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "CompleteCdrAux.ipp" diff --git a/resources/dds/TypeLookupService/types/v2/complete/CompletePubSubTypes.h b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h similarity index 91% rename from resources/dds/TypeLookupService/types/v2/complete/CompletePubSubTypes.h rename to resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h index 81829b9b7..53524c491 100644 --- a/resources/dds/TypeLookupService/types/v2/complete/CompletePubSubTypes.h +++ b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h @@ -27,9 +27,9 @@ #include #include #include -#include +#include -#include "Complete.h" +#include "Complete.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type Timestamp defined by the user in the IDL file. * @ingroup Complete @@ -90,6 +88,9 @@ class TimestampPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -105,7 +106,7 @@ class TimestampPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -128,8 +129,6 @@ class TimestampPubSubType : public eprosima::fastdds::dds::TopicDataType }; - - /*! * @brief This class represents the TopicDataType of the type Point defined by the user in the IDL file. * @ingroup Complete @@ -180,6 +179,9 @@ class PointPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -195,7 +197,7 @@ class PointPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -218,8 +220,6 @@ class PointPubSubType : public eprosima::fastdds::dds::TopicDataType }; - - /*! * @brief This class represents the TopicDataType of the type MessageDescriptor defined by the user in the IDL file. * @ingroup Complete @@ -270,6 +270,9 @@ class MessageDescriptorPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -285,7 +288,7 @@ class MessageDescriptorPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -308,8 +311,6 @@ class MessageDescriptorPubSubType : public eprosima::fastdds::dds::TopicDataType }; - - /*! * @brief This class represents the TopicDataType of the type Message defined by the user in the IDL file. * @ingroup Complete @@ -360,6 +361,9 @@ class MessagePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -375,7 +379,7 @@ class MessagePubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -398,8 +402,6 @@ class MessagePubSubType : public eprosima::fastdds::dds::TopicDataType }; - - /*! * @brief This class represents the TopicDataType of the type CompleteData defined by the user in the IDL file. * @ingroup Complete @@ -450,6 +452,9 @@ class CompleteDataPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -465,7 +470,7 @@ class CompleteDataPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; diff --git a/resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.cxx b/resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.cxx new file mode 100644 index 000000000..8cfe32a43 --- /dev/null +++ b/resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.cxx @@ -0,0 +1,678 @@ +// 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 CompleteTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "CompleteTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Complete.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_Timestamp_type_identifier( + TypeIdentifierPair& type_ids_Timestamp) +{ + + ReturnCode_t return_code_Timestamp {eprosima::fastdds::dds::RETCODE_OK}; + return_code_Timestamp = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "Timestamp", type_ids_Timestamp); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_Timestamp) + { + StructTypeFlag struct_flags_Timestamp = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_Timestamp = "Timestamp"; + eprosima::fastcdr::optional type_ann_builtin_Timestamp; + eprosima::fastcdr::optional ann_custom_Timestamp; + CompleteTypeDetail detail_Timestamp = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_Timestamp, ann_custom_Timestamp, type_name_Timestamp.to_string()); + CompleteStructHeader header_Timestamp; + header_Timestamp = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_Timestamp); + CompleteStructMemberSeq member_seq_Timestamp; + { + TypeIdentifierPair type_ids_seconds; + ReturnCode_t return_code_seconds {eprosima::fastdds::dds::RETCODE_OK}; + return_code_seconds = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_int32_t", type_ids_seconds); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_seconds) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "seconds Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_seconds = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_seconds = 0x00000000; + bool common_seconds_ec {false}; + CommonStructMember common_seconds {TypeObjectUtils::build_common_struct_member(member_id_seconds, member_flags_seconds, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_seconds, common_seconds_ec))}; + if (!common_seconds_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure seconds member TypeIdentifier inconsistent."); + return; + } + MemberName name_seconds = "seconds"; + eprosima::fastcdr::optional member_ann_builtin_seconds; + ann_custom_Timestamp.reset(); + CompleteMemberDetail detail_seconds = TypeObjectUtils::build_complete_member_detail(name_seconds, member_ann_builtin_seconds, ann_custom_Timestamp); + CompleteStructMember member_seconds = TypeObjectUtils::build_complete_struct_member(common_seconds, detail_seconds); + TypeObjectUtils::add_complete_struct_member(member_seq_Timestamp, member_seconds); + } + { + TypeIdentifierPair type_ids_milliseconds; + ReturnCode_t return_code_milliseconds {eprosima::fastdds::dds::RETCODE_OK}; + return_code_milliseconds = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_int32_t", type_ids_milliseconds); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_milliseconds) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "milliseconds Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_milliseconds = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_milliseconds = 0x00000001; + bool common_milliseconds_ec {false}; + CommonStructMember common_milliseconds {TypeObjectUtils::build_common_struct_member(member_id_milliseconds, member_flags_milliseconds, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_milliseconds, common_milliseconds_ec))}; + if (!common_milliseconds_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure milliseconds member TypeIdentifier inconsistent."); + return; + } + MemberName name_milliseconds = "milliseconds"; + eprosima::fastcdr::optional member_ann_builtin_milliseconds; + ann_custom_Timestamp.reset(); + CompleteMemberDetail detail_milliseconds = TypeObjectUtils::build_complete_member_detail(name_milliseconds, member_ann_builtin_milliseconds, ann_custom_Timestamp); + CompleteStructMember member_milliseconds = TypeObjectUtils::build_complete_struct_member(common_milliseconds, detail_milliseconds); + TypeObjectUtils::add_complete_struct_member(member_seq_Timestamp, member_milliseconds); + } + CompleteStructType struct_type_Timestamp = TypeObjectUtils::build_complete_struct_type(struct_flags_Timestamp, header_Timestamp, member_seq_Timestamp); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_Timestamp, type_name_Timestamp.to_string(), type_ids_Timestamp)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Timestamp already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_Point_type_identifier( + TypeIdentifierPair& type_ids_Point) +{ + + ReturnCode_t return_code_Point {eprosima::fastdds::dds::RETCODE_OK}; + return_code_Point = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "Point", type_ids_Point); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_Point) + { + StructTypeFlag struct_flags_Point = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_Point = "Point"; + eprosima::fastcdr::optional type_ann_builtin_Point; + eprosima::fastcdr::optional ann_custom_Point; + CompleteTypeDetail detail_Point = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_Point, ann_custom_Point, type_name_Point.to_string()); + CompleteStructHeader header_Point; + header_Point = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_Point); + CompleteStructMemberSeq member_seq_Point; + { + TypeIdentifierPair type_ids_x; + ReturnCode_t return_code_x {eprosima::fastdds::dds::RETCODE_OK}; + return_code_x = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_int32_t", type_ids_x); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_x) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "x Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_x = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_x = 0x00000000; + bool common_x_ec {false}; + CommonStructMember common_x {TypeObjectUtils::build_common_struct_member(member_id_x, member_flags_x, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_x, common_x_ec))}; + if (!common_x_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure x member TypeIdentifier inconsistent."); + return; + } + MemberName name_x = "x"; + eprosima::fastcdr::optional member_ann_builtin_x; + ann_custom_Point.reset(); + CompleteMemberDetail detail_x = TypeObjectUtils::build_complete_member_detail(name_x, member_ann_builtin_x, ann_custom_Point); + CompleteStructMember member_x = TypeObjectUtils::build_complete_struct_member(common_x, detail_x); + TypeObjectUtils::add_complete_struct_member(member_seq_Point, member_x); + } + { + TypeIdentifierPair type_ids_y; + ReturnCode_t return_code_y {eprosima::fastdds::dds::RETCODE_OK}; + return_code_y = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_int32_t", type_ids_y); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_y) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "y Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_y = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_y = 0x00000001; + bool common_y_ec {false}; + CommonStructMember common_y {TypeObjectUtils::build_common_struct_member(member_id_y, member_flags_y, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_y, common_y_ec))}; + if (!common_y_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure y member TypeIdentifier inconsistent."); + return; + } + MemberName name_y = "y"; + eprosima::fastcdr::optional member_ann_builtin_y; + ann_custom_Point.reset(); + CompleteMemberDetail detail_y = TypeObjectUtils::build_complete_member_detail(name_y, member_ann_builtin_y, ann_custom_Point); + CompleteStructMember member_y = TypeObjectUtils::build_complete_struct_member(common_y, detail_y); + TypeObjectUtils::add_complete_struct_member(member_seq_Point, member_y); + } + { + TypeIdentifierPair type_ids_z; + ReturnCode_t return_code_z {eprosima::fastdds::dds::RETCODE_OK}; + return_code_z = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_int32_t", type_ids_z); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_z) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "z Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_z = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_z = 0x00000002; + bool common_z_ec {false}; + CommonStructMember common_z {TypeObjectUtils::build_common_struct_member(member_id_z, member_flags_z, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_z, common_z_ec))}; + if (!common_z_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure z member TypeIdentifier inconsistent."); + return; + } + MemberName name_z = "z"; + eprosima::fastcdr::optional member_ann_builtin_z; + ann_custom_Point.reset(); + CompleteMemberDetail detail_z = TypeObjectUtils::build_complete_member_detail(name_z, member_ann_builtin_z, ann_custom_Point); + CompleteStructMember member_z = TypeObjectUtils::build_complete_struct_member(common_z, detail_z); + TypeObjectUtils::add_complete_struct_member(member_seq_Point, member_z); + } + CompleteStructType struct_type_Point = TypeObjectUtils::build_complete_struct_type(struct_flags_Point, header_Point, member_seq_Point); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_Point, type_name_Point.to_string(), type_ids_Point)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Point already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_MessageDescriptor_type_identifier( + TypeIdentifierPair& type_ids_MessageDescriptor) +{ + + ReturnCode_t return_code_MessageDescriptor {eprosima::fastdds::dds::RETCODE_OK}; + return_code_MessageDescriptor = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "MessageDescriptor", type_ids_MessageDescriptor); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_MessageDescriptor) + { + StructTypeFlag struct_flags_MessageDescriptor = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_MessageDescriptor = "MessageDescriptor"; + eprosima::fastcdr::optional type_ann_builtin_MessageDescriptor; + eprosima::fastcdr::optional ann_custom_MessageDescriptor; + CompleteTypeDetail detail_MessageDescriptor = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_MessageDescriptor, ann_custom_MessageDescriptor, type_name_MessageDescriptor.to_string()); + CompleteStructHeader header_MessageDescriptor; + header_MessageDescriptor = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_MessageDescriptor); + CompleteStructMemberSeq member_seq_MessageDescriptor; + { + TypeIdentifierPair type_ids_id; + ReturnCode_t return_code_id {eprosima::fastdds::dds::RETCODE_OK}; + return_code_id = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_id); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_id) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "id Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_id = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_id = 0x00000000; + bool common_id_ec {false}; + CommonStructMember common_id {TypeObjectUtils::build_common_struct_member(member_id_id, member_flags_id, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_id, common_id_ec))}; + if (!common_id_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure id member TypeIdentifier inconsistent."); + return; + } + MemberName name_id = "id"; + eprosima::fastcdr::optional member_ann_builtin_id; + ann_custom_MessageDescriptor.reset(); + CompleteMemberDetail detail_id = TypeObjectUtils::build_complete_member_detail(name_id, member_ann_builtin_id, ann_custom_MessageDescriptor); + CompleteStructMember member_id = TypeObjectUtils::build_complete_struct_member(common_id, detail_id); + TypeObjectUtils::add_complete_struct_member(member_seq_MessageDescriptor, member_id); + } + { + TypeIdentifierPair type_ids_topic; + ReturnCode_t return_code_topic {eprosima::fastdds::dds::RETCODE_OK}; + return_code_topic = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_topic); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_topic) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_topic)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_topic = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_topic = 0x00000001; + bool common_topic_ec {false}; + CommonStructMember common_topic {TypeObjectUtils::build_common_struct_member(member_id_topic, member_flags_topic, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_topic, common_topic_ec))}; + if (!common_topic_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure topic member TypeIdentifier inconsistent."); + return; + } + MemberName name_topic = "topic"; + eprosima::fastcdr::optional member_ann_builtin_topic; + ann_custom_MessageDescriptor.reset(); + CompleteMemberDetail detail_topic = TypeObjectUtils::build_complete_member_detail(name_topic, member_ann_builtin_topic, ann_custom_MessageDescriptor); + CompleteStructMember member_topic = TypeObjectUtils::build_complete_struct_member(common_topic, detail_topic); + TypeObjectUtils::add_complete_struct_member(member_seq_MessageDescriptor, member_topic); + } + { + TypeIdentifierPair type_ids_time; + ReturnCode_t return_code_time {eprosima::fastdds::dds::RETCODE_OK}; + return_code_time = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "Timestamp", type_ids_time); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_time) + { + ::register_Timestamp_type_identifier(type_ids_time); + } + StructMemberFlag member_flags_time = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_time = 0x00000002; + bool common_time_ec {false}; + CommonStructMember common_time {TypeObjectUtils::build_common_struct_member(member_id_time, member_flags_time, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_time, common_time_ec))}; + if (!common_time_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure time member TypeIdentifier inconsistent."); + return; + } + MemberName name_time = "time"; + eprosima::fastcdr::optional member_ann_builtin_time; + ann_custom_MessageDescriptor.reset(); + CompleteMemberDetail detail_time = TypeObjectUtils::build_complete_member_detail(name_time, member_ann_builtin_time, ann_custom_MessageDescriptor); + CompleteStructMember member_time = TypeObjectUtils::build_complete_struct_member(common_time, detail_time); + TypeObjectUtils::add_complete_struct_member(member_seq_MessageDescriptor, member_time); + } + CompleteStructType struct_type_MessageDescriptor = TypeObjectUtils::build_complete_struct_type(struct_flags_MessageDescriptor, header_MessageDescriptor, member_seq_MessageDescriptor); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_MessageDescriptor, type_name_MessageDescriptor.to_string(), type_ids_MessageDescriptor)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "MessageDescriptor already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_Message_type_identifier( + TypeIdentifierPair& type_ids_Message) +{ + + ReturnCode_t return_code_Message {eprosima::fastdds::dds::RETCODE_OK}; + return_code_Message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "Message", type_ids_Message); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_Message) + { + StructTypeFlag struct_flags_Message = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_Message = "Message"; + eprosima::fastcdr::optional type_ann_builtin_Message; + eprosima::fastcdr::optional ann_custom_Message; + CompleteTypeDetail detail_Message = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_Message, ann_custom_Message, type_name_Message.to_string()); + CompleteStructHeader header_Message; + header_Message = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_Message); + CompleteStructMemberSeq member_seq_Message; + { + TypeIdentifierPair type_ids_descriptor; + ReturnCode_t return_code_descriptor {eprosima::fastdds::dds::RETCODE_OK}; + return_code_descriptor = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "MessageDescriptor", type_ids_descriptor); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_descriptor) + { + ::register_MessageDescriptor_type_identifier(type_ids_descriptor); + } + StructMemberFlag member_flags_descriptor = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_descriptor = 0x00000000; + bool common_descriptor_ec {false}; + CommonStructMember common_descriptor {TypeObjectUtils::build_common_struct_member(member_id_descriptor, member_flags_descriptor, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_descriptor, common_descriptor_ec))}; + if (!common_descriptor_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure descriptor member TypeIdentifier inconsistent."); + return; + } + MemberName name_descriptor = "descriptor"; + eprosima::fastcdr::optional member_ann_builtin_descriptor; + ann_custom_Message.reset(); + CompleteMemberDetail detail_descriptor = TypeObjectUtils::build_complete_member_detail(name_descriptor, member_ann_builtin_descriptor, ann_custom_Message); + CompleteStructMember member_descriptor = TypeObjectUtils::build_complete_struct_member(common_descriptor, detail_descriptor); + TypeObjectUtils::add_complete_struct_member(member_seq_Message, member_descriptor); + } + { + TypeIdentifierPair type_ids_message; + ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_message)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_message = 0x00000001; + bool common_message_ec {false}; + CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; + if (!common_message_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); + return; + } + MemberName name_message = "message"; + eprosima::fastcdr::optional member_ann_builtin_message; + ann_custom_Message.reset(); + CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_Message); + CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); + TypeObjectUtils::add_complete_struct_member(member_seq_Message, member_message); + } + CompleteStructType struct_type_Message = TypeObjectUtils::build_complete_struct_type(struct_flags_Message, header_Message, member_seq_Message); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_Message, type_name_Message.to_string(), type_ids_Message)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Message already registered in TypeObjectRegistry for a different type."); + } + } +} +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_CompleteData_type_identifier( + TypeIdentifierPair& type_ids_CompleteData) +{ + + ReturnCode_t return_code_CompleteData {eprosima::fastdds::dds::RETCODE_OK}; + return_code_CompleteData = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "CompleteData", type_ids_CompleteData); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_CompleteData) + { + StructTypeFlag struct_flags_CompleteData = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_CompleteData = "CompleteData"; + eprosima::fastcdr::optional type_ann_builtin_CompleteData; + eprosima::fastcdr::optional ann_custom_CompleteData; + CompleteTypeDetail detail_CompleteData = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_CompleteData, ann_custom_CompleteData, type_name_CompleteData.to_string()); + CompleteStructHeader header_CompleteData; + header_CompleteData = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_CompleteData); + CompleteStructMemberSeq member_seq_CompleteData; + { + TypeIdentifierPair type_ids_index; + ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; + return_code_index = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_index); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_index = 0x00000000; + bool common_index_ec {false}; + CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; + if (!common_index_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); + return; + } + MemberName name_index = "index"; + eprosima::fastcdr::optional member_ann_builtin_index; + ann_custom_CompleteData.reset(); + CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_CompleteData); + CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); + TypeObjectUtils::add_complete_struct_member(member_seq_CompleteData, member_index); + } + { + TypeIdentifierPair type_ids_main_point; + ReturnCode_t return_code_main_point {eprosima::fastdds::dds::RETCODE_OK}; + return_code_main_point = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "Point", type_ids_main_point); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_main_point) + { + ::register_Point_type_identifier(type_ids_main_point); + } + StructMemberFlag member_flags_main_point = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_main_point = 0x00000001; + bool common_main_point_ec {false}; + CommonStructMember common_main_point {TypeObjectUtils::build_common_struct_member(member_id_main_point, member_flags_main_point, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_main_point, common_main_point_ec))}; + if (!common_main_point_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure main_point member TypeIdentifier inconsistent."); + return; + } + MemberName name_main_point = "main_point"; + eprosima::fastcdr::optional member_ann_builtin_main_point; + ann_custom_CompleteData.reset(); + CompleteMemberDetail detail_main_point = TypeObjectUtils::build_complete_member_detail(name_main_point, member_ann_builtin_main_point, ann_custom_CompleteData); + CompleteStructMember member_main_point = TypeObjectUtils::build_complete_struct_member(common_main_point, detail_main_point); + TypeObjectUtils::add_complete_struct_member(member_seq_CompleteData, member_main_point); + } + { + TypeIdentifierPair type_ids_internal_data; + ReturnCode_t return_code_internal_data {eprosima::fastdds::dds::RETCODE_OK}; + return_code_internal_data = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_Point_unbounded", type_ids_internal_data); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_internal_data) + { + return_code_internal_data = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "Point", type_ids_internal_data); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_internal_data) + { + ::register_Point_type_identifier(type_ids_internal_data); + } + bool element_identifier_anonymous_sequence_Point_unbounded_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_Point_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_internal_data, element_identifier_anonymous_sequence_Point_unbounded_ec))}; + if (!element_identifier_anonymous_sequence_Point_unbounded_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_Point_unbounded = EK_COMPLETE; + if (TK_NONE == type_ids_internal_data.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_Point_unbounded = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_Point_unbounded = 0; + PlainCollectionHeader header_anonymous_sequence_Point_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_Point_unbounded, element_flags_anonymous_sequence_Point_unbounded); + { + SBound bound = 0; + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_Point_unbounded, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_Point_unbounded)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_Point_unbounded", type_ids_internal_data)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_Point_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_internal_data = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_internal_data = 0x00000002; + bool common_internal_data_ec {false}; + CommonStructMember common_internal_data {TypeObjectUtils::build_common_struct_member(member_id_internal_data, member_flags_internal_data, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_internal_data, common_internal_data_ec))}; + if (!common_internal_data_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure internal_data member TypeIdentifier inconsistent."); + return; + } + MemberName name_internal_data = "internal_data"; + eprosima::fastcdr::optional member_ann_builtin_internal_data; + ann_custom_CompleteData.reset(); + CompleteMemberDetail detail_internal_data = TypeObjectUtils::build_complete_member_detail(name_internal_data, member_ann_builtin_internal_data, ann_custom_CompleteData); + CompleteStructMember member_internal_data = TypeObjectUtils::build_complete_struct_member(common_internal_data, detail_internal_data); + TypeObjectUtils::add_complete_struct_member(member_seq_CompleteData, member_internal_data); + } + { + TypeIdentifierPair type_ids_messages; + ReturnCode_t return_code_messages {eprosima::fastdds::dds::RETCODE_OK}; + return_code_messages = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_array_Message_2", type_ids_messages); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_messages) + { + return_code_messages = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "Message", type_ids_messages); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_messages) + { + ::register_Message_type_identifier(type_ids_messages); + } + bool element_identifier_anonymous_array_Message_2_ec {false}; + TypeIdentifier* element_identifier_anonymous_array_Message_2 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_messages, element_identifier_anonymous_array_Message_2_ec))}; + if (!element_identifier_anonymous_array_Message_2_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Array element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_array_Message_2 = EK_COMPLETE; + if (TK_NONE == type_ids_messages.type_identifier2()._d()) + { + equiv_kind_anonymous_array_Message_2 = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_array_Message_2 = 0; + PlainCollectionHeader header_anonymous_array_Message_2 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_array_Message_2, element_flags_anonymous_array_Message_2); + { + SBoundSeq array_bound_seq; + TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast(2)); + + PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_anonymous_array_Message_2, array_bound_seq, + eprosima::fastcdr::external(element_identifier_anonymous_array_Message_2)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "anonymous_array_Message_2", type_ids_messages)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_array_Message_2 already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_messages = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_messages = 0x00000003; + bool common_messages_ec {false}; + CommonStructMember common_messages {TypeObjectUtils::build_common_struct_member(member_id_messages, member_flags_messages, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_messages, common_messages_ec))}; + if (!common_messages_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure messages member TypeIdentifier inconsistent."); + return; + } + MemberName name_messages = "messages"; + eprosima::fastcdr::optional member_ann_builtin_messages; + ann_custom_CompleteData.reset(); + CompleteMemberDetail detail_messages = TypeObjectUtils::build_complete_member_detail(name_messages, member_ann_builtin_messages, ann_custom_CompleteData); + CompleteStructMember member_messages = TypeObjectUtils::build_complete_struct_member(common_messages, detail_messages); + TypeObjectUtils::add_complete_struct_member(member_seq_CompleteData, member_messages); + } + CompleteStructType struct_type_CompleteData = TypeObjectUtils::build_complete_struct_type(struct_flags_CompleteData, header_CompleteData, member_seq_CompleteData); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_CompleteData, type_name_CompleteData.to_string(), type_ids_CompleteData)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "CompleteData already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.hpp b/resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.hpp new file mode 100644 index 000000000..c2a1ef6ef --- /dev/null +++ b/resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.hpp @@ -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 CompleteTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_COMPLETE_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_COMPLETE_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register Timestamp related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_Timestamp_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register Point related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_Point_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register MessageDescriptor related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_MessageDescriptor_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register Message related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_Message_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); +/** + * @brief Register CompleteData related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_CompleteData_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_COMPLETE_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.h b/resources/dds/TypeLookupService/types/hello_world/HelloWorld.hpp similarity index 69% rename from resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.h rename to resources/dds/TypeLookupService/types/hello_world/HelloWorld.hpp index 5cd0ddba5..971fea8d9 100644 --- a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.h +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorld.hpp @@ -13,32 +13,19 @@ // limitations under the License. /*! - * @file HelloWorld.h + * @file HelloWorld.hpp * This header file contains the declaration of the described types in the IDL file. * * This file was generated by the tool fastddsgen. */ -#include -#include "HelloWorldv1.h" +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#if FASTCDR_VERSION_MAJOR > 1 - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_H_ - -#include -#include #include -#include #include -#include - +#include #include -#include -#include - - #if defined(_WIN32) #if defined(EPROSIMA_USER_DLL_EXPORT) @@ -64,17 +51,6 @@ #define HELLOWORLD_DllAPI #endif // _WIN32 -namespace eprosima { -namespace fastcdr { -class Cdr; -class CdrSizeCalculator; -} // namespace fastcdr -} // namespace eprosima - - - - - /*! * @brief This class represents the structure HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -86,73 +62,117 @@ class HelloWorld /*! * @brief Default constructor. */ - eProsima_user_DllExport HelloWorld(); + eProsima_user_DllExport HelloWorld() + { + } /*! * @brief Default destructor. */ - eProsima_user_DllExport ~HelloWorld(); + eProsima_user_DllExport ~HelloWorld() + { + } /*! * @brief Copy constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - const HelloWorld& x); + const HelloWorld& x) + { + m_index = x.m_index; + + m_message = x.m_message; + + } /*! * @brief Move constructor. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + m_index = x.m_index; + m_message = std::move(x.m_message); + } /*! * @brief Copy assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); + const HelloWorld& x) + { + + m_index = x.m_index; + + m_message = x.m_message; + + return *this; + } /*! * @brief Move assignment. * @param x Reference to the object HelloWorld that will be copied. */ eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; + HelloWorld&& x) noexcept + { + + m_index = x.m_index; + m_message = std::move(x.m_message); + return *this; + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return (m_index == x.m_index && + m_message == x.m_message); + } /*! * @brief Comparison operator. * @param x HelloWorld object to compare. */ eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const; + const HelloWorld& x) const + { + return !(*this == x); + } /*! * @brief This function sets a value in member index * @param _index New value for member index */ eProsima_user_DllExport void index( - uint32_t _index); + uint32_t _index) + { + m_index = _index; + } /*! * @brief This function returns the value of member index * @return Value of member index */ - eProsima_user_DllExport uint32_t index() const; + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } /*! * @brief This function returns a reference to member index * @return Reference to member index */ - eProsima_user_DllExport uint32_t& index(); + eProsima_user_DllExport uint32_t& index() + { + return m_index; + } /*! @@ -160,26 +180,40 @@ class HelloWorld * @param _message New value to be copied in member message */ eProsima_user_DllExport void message( - const std::string& _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 */ eProsima_user_DllExport void message( - std::string&& _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 */ - eProsima_user_DllExport const std::string& message() const; + eProsima_user_DllExport const std::string& message() const + { + return m_message; + } /*! * @brief This function returns a reference to member message * @return Reference to member message */ - eProsima_user_DllExport std::string& message(); + eProsima_user_DllExport std::string& message() + { + return m_message; + } + + private: @@ -188,8 +222,6 @@ class HelloWorld }; -#endif // _FAST_DDS_GENERATED_HELLOWORLD_H_ - +#endif // _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.idl b/resources/dds/TypeLookupService/types/hello_world/HelloWorld.idl similarity index 100% rename from resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.idl rename to resources/dds/TypeLookupService/types/hello_world/HelloWorld.idl diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldCdrAux.hpp b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp similarity index 98% rename from ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldCdrAux.hpp rename to resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp index 9f346d306..6feb8a9da 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldCdrAux.hpp +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp @@ -22,7 +22,7 @@ #ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ #define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#include "HelloWorld.h" +#include "HelloWorld.hpp" constexpr uint32_t HelloWorld_max_cdr_typesize {268UL}; constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; @@ -34,8 +34,6 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; - - eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const HelloWorld& data); diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp new file mode 100644 index 000000000..97df3fe9d --- /dev/null +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp @@ -0,0 +1,126 @@ +// 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 HelloWorldCdrAux.ipp + * This source file contains some declarations of CDR related functions. + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ + +#include "HelloWorldCdrAux.hpp" + +#include +#include + + +#include +using namespace eprosima::fastcdr::exception; + +namespace eprosima { +namespace fastcdr { + +template<> +eProsima_user_DllExport size_t calculate_serialized_size( + eprosima::fastcdr::CdrSizeCalculator& calculator, + const HelloWorld& data, + size_t& current_alignment) +{ + static_cast(data); + + eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); + size_t calculated_size {calculator.begin_calculate_type_serialized_size( + eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, + current_alignment)}; + + + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.index(), current_alignment); + + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.message(), current_alignment); + + + calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); + + return calculated_size; +} + +template<> +eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& scdr, + const HelloWorld& data) +{ + eprosima::fastcdr::Cdr::state current_state(scdr); + scdr.begin_serialize_type(current_state, + eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); + + scdr + << eprosima::fastcdr::MemberId(0) << data.index() + << eprosima::fastcdr::MemberId(1) << data.message() +; + scdr.end_serialize_type(current_state); +} + +template<> +eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr, + HelloWorld& data) +{ + cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, + [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool + { + bool ret_value = true; + switch (mid.id) + { + case 0: + dcdr >> data.index(); + break; + + case 1: + dcdr >> data.message(); + break; + + default: + ret_value = false; + break; + } + return ret_value; + }); +} + +void serialize_key( + eprosima::fastcdr::Cdr& scdr, + const HelloWorld& data) +{ + static_cast(scdr); + static_cast(data); +} + + + +} // namespace fastcdr +} // namespace eprosima + +#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ + diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx new file mode 100644 index 000000000..aa161b2e1 --- /dev/null +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.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 HelloWorldPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include "HelloWorldPubSubTypes.h" + +#include +#include + +#include "HelloWorldCdrAux.hpp" +#include "HelloWorldTypeObjectSupport.hpp" + +using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +HelloWorldPubSubType::HelloWorldPubSubType() +{ + setName("HelloWorld"); + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(HelloWorld::getMaxCdrSerializedSize()); +#else + HelloWorld_max_cdr_typesize; +#endif + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + m_typeSize = type_size + 4; /*encapsulation*/ + m_isGetKeyDefined = false; + uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +HelloWorldPubSubType::~HelloWorldPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool HelloWorldPubSubType::serialize( + void* data, + SerializedPayload_t* payload, + DataRepresentationId_t data_representation) +{ + HelloWorld* 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, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); +#endif // FASTCDR_VERSION_MAJOR > 1 + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length +#if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast(ser.getSerializedDataLength()); +#else + payload->length = static_cast(ser.get_serialized_data_length()); +#endif // FASTCDR_VERSION_MAJOR == 1 + return true; +} + +bool HelloWorldPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + HelloWorld* 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 +#if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR +#endif // FASTCDR_VERSION_MAJOR == 1 + ); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function HelloWorldPubSubType::getSerializedSizeProvider( + void* data, + DataRepresentationId_t data_representation) +{ + return [data, data_representation]() -> uint32_t + { +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 + }; +} + +void* HelloWorldPubSubType::createData() +{ + return reinterpret_cast(new HelloWorld()); +} + +void HelloWorldPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool HelloWorldPubSubType::getKey( + void* data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + HelloWorld* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + HelloWorld_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else + eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 + if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) + { + m_md5.init(); +#if FASTCDR_VERSION_MAJOR == 1 + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); +#else + m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); +#endif // FASTCDR_VERSION_MAJOR == 1 + 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; +} + +void HelloWorldPubSubType::register_type_object_representation() +{ + register_HelloWorld_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "HelloWorldCdrAux.ipp" diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldPubSubTypes.h b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h similarity index 92% rename from resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldPubSubTypes.h rename to resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h index f8186b177..7c83d2b30 100644 --- a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldPubSubTypes.h +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h @@ -27,9 +27,9 @@ #include #include #include -#include +#include -#include "HelloWorld.h" +#include "HelloWorld.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -38,8 +38,6 @@ #endif // GEN_API_VER - - /*! * @brief This class represents the TopicDataType of the type HelloWorld defined by the user in the IDL file. * @ingroup HelloWorld @@ -90,6 +88,9 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport void deleteData( void* data) override; + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() override; + #ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED eProsima_user_DllExport inline bool is_bounded() const override { @@ -105,7 +106,7 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.cxx b/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.cxx new file mode 100644 index 000000000..58928b6f0 --- /dev/null +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.cxx @@ -0,0 +1,138 @@ +// 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 HelloWorldTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "HelloWorldTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "HelloWorld.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_HelloWorld_type_identifier( + TypeIdentifierPair& type_ids_HelloWorld) +{ + + ReturnCode_t return_code_HelloWorld {eprosima::fastdds::dds::RETCODE_OK}; + return_code_HelloWorld = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "HelloWorld", type_ids_HelloWorld); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloWorld) + { + StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_HelloWorld = "HelloWorld"; + eprosima::fastcdr::optional type_ann_builtin_HelloWorld; + eprosima::fastcdr::optional ann_custom_HelloWorld; + CompleteTypeDetail detail_HelloWorld = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloWorld, ann_custom_HelloWorld, type_name_HelloWorld.to_string()); + CompleteStructHeader header_HelloWorld; + header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld); + CompleteStructMemberSeq member_seq_HelloWorld; + { + TypeIdentifierPair type_ids_index; + ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; + return_code_index = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_index); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_index = 0x00000000; + bool common_index_ec {false}; + CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; + if (!common_index_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); + return; + } + MemberName name_index = "index"; + eprosima::fastcdr::optional member_ann_builtin_index; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_HelloWorld); + CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index); + } + { + TypeIdentifierPair type_ids_message; + ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_string_unbounded", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + { + SBound bound = 0; + StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, + "anonymous_string_unbounded", type_ids_message)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_message = 0x00000001; + bool common_message_ec {false}; + CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; + if (!common_message_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); + return; + } + MemberName name_message = "message"; + eprosima::fastcdr::optional member_ann_builtin_message; + ann_custom_HelloWorld.reset(); + CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_HelloWorld); + CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); + TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_message); + } + CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_ids_HelloWorld)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "HelloWorld already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.hpp b/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.hpp new file mode 100644 index 000000000..2eba797b0 --- /dev/null +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 HelloWorldTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register HelloWorld related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_HelloWorld_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/resources/dds/TypeLookupService/types/v2/complete/Complete.cxx b/resources/dds/TypeLookupService/types/v2/complete/Complete.cxx deleted file mode 100644 index a4cfc4e50..000000000 --- a/resources/dds/TypeLookupService/types/v2/complete/Complete.cxx +++ /dev/null @@ -1,806 +0,0 @@ -// 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 Complete.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "Complete.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "CompleteTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -Timestamp::Timestamp() -{ - // Just to register all known types - registerCompleteTypes(); -} - -Timestamp::~Timestamp() -{ -} - -Timestamp::Timestamp( - const Timestamp& x) -{ - m_seconds = x.m_seconds; - m_milliseconds = x.m_milliseconds; -} - -Timestamp::Timestamp( - Timestamp&& x) noexcept -{ - m_seconds = x.m_seconds; - m_milliseconds = x.m_milliseconds; -} - -Timestamp& Timestamp::operator =( - const Timestamp& x) -{ - - m_seconds = x.m_seconds; - m_milliseconds = x.m_milliseconds; - return *this; -} - -Timestamp& Timestamp::operator =( - Timestamp&& x) noexcept -{ - - m_seconds = x.m_seconds; - m_milliseconds = x.m_milliseconds; - return *this; -} - -bool Timestamp::operator ==( - const Timestamp& x) const -{ - return (m_seconds == x.m_seconds && - m_milliseconds == x.m_milliseconds); -} - -bool Timestamp::operator !=( - const Timestamp& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member seconds - * @param _seconds New value for member seconds - */ -void Timestamp::seconds( - int32_t _seconds) -{ - m_seconds = _seconds; -} - -/*! - * @brief This function returns the value of member seconds - * @return Value of member seconds - */ -int32_t Timestamp::seconds() const -{ - return m_seconds; -} - -/*! - * @brief This function returns a reference to member seconds - * @return Reference to member seconds - */ -int32_t& Timestamp::seconds() -{ - return m_seconds; -} - -/*! - * @brief This function sets a value in member milliseconds - * @param _milliseconds New value for member milliseconds - */ -void Timestamp::milliseconds( - int32_t _milliseconds) -{ - m_milliseconds = _milliseconds; -} - -/*! - * @brief This function returns the value of member milliseconds - * @return Value of member milliseconds - */ -int32_t Timestamp::milliseconds() const -{ - return m_milliseconds; -} - -/*! - * @brief This function returns a reference to member milliseconds - * @return Reference to member milliseconds - */ -int32_t& Timestamp::milliseconds() -{ - return m_milliseconds; -} - -Point::Point() -{ - // Just to register all known types - registerCompleteTypes(); -} - -Point::~Point() -{ -} - -Point::Point( - const Point& x) -{ - m_x = x.m_x; - m_y = x.m_y; - m_z = x.m_z; -} - -Point::Point( - Point&& x) noexcept -{ - m_x = x.m_x; - m_y = x.m_y; - m_z = x.m_z; -} - -Point& Point::operator =( - const Point& x) -{ - - m_x = x.m_x; - m_y = x.m_y; - m_z = x.m_z; - return *this; -} - -Point& Point::operator =( - Point&& x) noexcept -{ - - m_x = x.m_x; - m_y = x.m_y; - m_z = x.m_z; - return *this; -} - -bool Point::operator ==( - const Point& x) const -{ - return (m_x == x.m_x && - m_y == x.m_y && - m_z == x.m_z); -} - -bool Point::operator !=( - const Point& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ -void Point::x( - int32_t _x) -{ - m_x = _x; -} - -/*! - * @brief This function returns the value of member x - * @return Value of member x - */ -int32_t Point::x() const -{ - return m_x; -} - -/*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ -int32_t& Point::x() -{ - return m_x; -} - -/*! - * @brief This function sets a value in member y - * @param _y New value for member y - */ -void Point::y( - int32_t _y) -{ - m_y = _y; -} - -/*! - * @brief This function returns the value of member y - * @return Value of member y - */ -int32_t Point::y() const -{ - return m_y; -} - -/*! - * @brief This function returns a reference to member y - * @return Reference to member y - */ -int32_t& Point::y() -{ - return m_y; -} - -/*! - * @brief This function sets a value in member z - * @param _z New value for member z - */ -void Point::z( - int32_t _z) -{ - m_z = _z; -} - -/*! - * @brief This function returns the value of member z - * @return Value of member z - */ -int32_t Point::z() const -{ - return m_z; -} - -/*! - * @brief This function returns a reference to member z - * @return Reference to member z - */ -int32_t& Point::z() -{ - return m_z; -} - -MessageDescriptor::MessageDescriptor() -{ - // Just to register all known types - registerCompleteTypes(); -} - -MessageDescriptor::~MessageDescriptor() -{ -} - -MessageDescriptor::MessageDescriptor( - const MessageDescriptor& x) -{ - m_id = x.m_id; - m_topic = x.m_topic; - m_time = x.m_time; -} - -MessageDescriptor::MessageDescriptor( - MessageDescriptor&& x) noexcept -{ - m_id = x.m_id; - m_topic = std::move(x.m_topic); - m_time = std::move(x.m_time); -} - -MessageDescriptor& MessageDescriptor::operator =( - const MessageDescriptor& x) -{ - - m_id = x.m_id; - m_topic = x.m_topic; - m_time = x.m_time; - return *this; -} - -MessageDescriptor& MessageDescriptor::operator =( - MessageDescriptor&& x) noexcept -{ - - m_id = x.m_id; - m_topic = std::move(x.m_topic); - m_time = std::move(x.m_time); - return *this; -} - -bool MessageDescriptor::operator ==( - const MessageDescriptor& x) const -{ - return (m_id == x.m_id && - m_topic == x.m_topic && - m_time == x.m_time); -} - -bool MessageDescriptor::operator !=( - const MessageDescriptor& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member id - * @param _id New value for member id - */ -void MessageDescriptor::id( - uint32_t _id) -{ - m_id = _id; -} - -/*! - * @brief This function returns the value of member id - * @return Value of member id - */ -uint32_t MessageDescriptor::id() const -{ - return m_id; -} - -/*! - * @brief This function returns a reference to member id - * @return Reference to member id - */ -uint32_t& MessageDescriptor::id() -{ - return m_id; -} - -/*! - * @brief This function copies the value in member topic - * @param _topic New value to be copied in member topic - */ -void MessageDescriptor::topic( - const std::string& _topic) -{ - m_topic = _topic; -} - -/*! - * @brief This function moves the value in member topic - * @param _topic New value to be moved in member topic - */ -void MessageDescriptor::topic( - std::string&& _topic) -{ - m_topic = std::move(_topic); -} - -/*! - * @brief This function returns a constant reference to member topic - * @return Constant reference to member topic - */ -const std::string& MessageDescriptor::topic() const -{ - return m_topic; -} - -/*! - * @brief This function returns a reference to member topic - * @return Reference to member topic - */ -std::string& MessageDescriptor::topic() -{ - return m_topic; -} - -/*! - * @brief This function copies the value in member time - * @param _time New value to be copied in member time - */ -void MessageDescriptor::time( - const Timestamp& _time) -{ - m_time = _time; -} - -/*! - * @brief This function moves the value in member time - * @param _time New value to be moved in member time - */ -void MessageDescriptor::time( - Timestamp&& _time) -{ - m_time = std::move(_time); -} - -/*! - * @brief This function returns a constant reference to member time - * @return Constant reference to member time - */ -const Timestamp& MessageDescriptor::time() const -{ - return m_time; -} - -/*! - * @brief This function returns a reference to member time - * @return Reference to member time - */ -Timestamp& MessageDescriptor::time() -{ - return m_time; -} - -Message::Message() -{ - // Just to register all known types - registerCompleteTypes(); -} - -Message::~Message() -{ -} - -Message::Message( - const Message& x) -{ - m_descriptor = x.m_descriptor; - m_message = x.m_message; -} - -Message::Message( - Message&& x) noexcept -{ - m_descriptor = std::move(x.m_descriptor); - m_message = std::move(x.m_message); -} - -Message& Message::operator =( - const Message& x) -{ - - m_descriptor = x.m_descriptor; - m_message = x.m_message; - return *this; -} - -Message& Message::operator =( - Message&& x) noexcept -{ - - m_descriptor = std::move(x.m_descriptor); - m_message = std::move(x.m_message); - return *this; -} - -bool Message::operator ==( - const Message& x) const -{ - return (m_descriptor == x.m_descriptor && - m_message == x.m_message); -} - -bool Message::operator !=( - const Message& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function copies the value in member descriptor - * @param _descriptor New value to be copied in member descriptor - */ -void Message::descriptor( - const MessageDescriptor& _descriptor) -{ - m_descriptor = _descriptor; -} - -/*! - * @brief This function moves the value in member descriptor - * @param _descriptor New value to be moved in member descriptor - */ -void Message::descriptor( - MessageDescriptor&& _descriptor) -{ - m_descriptor = std::move(_descriptor); -} - -/*! - * @brief This function returns a constant reference to member descriptor - * @return Constant reference to member descriptor - */ -const MessageDescriptor& Message::descriptor() const -{ - return m_descriptor; -} - -/*! - * @brief This function returns a reference to member descriptor - * @return Reference to member descriptor - */ -MessageDescriptor& Message::descriptor() -{ - return m_descriptor; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void Message::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 Message::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& Message::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& Message::message() -{ - return m_message; -} - -CompleteData::CompleteData() -{ - // Just to register all known types - registerCompleteTypes(); -} - -CompleteData::~CompleteData() -{ -} - -CompleteData::CompleteData( - const CompleteData& x) -{ - m_index = x.m_index; - m_main_point = x.m_main_point; - m_internal_data = x.m_internal_data; - m_messages = x.m_messages; -} - -CompleteData::CompleteData( - CompleteData&& x) noexcept -{ - m_index = x.m_index; - m_main_point = std::move(x.m_main_point); - m_internal_data = std::move(x.m_internal_data); - m_messages = std::move(x.m_messages); -} - -CompleteData& CompleteData::operator =( - const CompleteData& x) -{ - - m_index = x.m_index; - m_main_point = x.m_main_point; - m_internal_data = x.m_internal_data; - m_messages = x.m_messages; - return *this; -} - -CompleteData& CompleteData::operator =( - CompleteData&& x) noexcept -{ - - m_index = x.m_index; - m_main_point = std::move(x.m_main_point); - m_internal_data = std::move(x.m_internal_data); - m_messages = std::move(x.m_messages); - return *this; -} - -bool CompleteData::operator ==( - const CompleteData& x) const -{ - return (m_index == x.m_index && - m_main_point == x.m_main_point && - m_internal_data == x.m_internal_data && - m_messages == x.m_messages); -} - -bool CompleteData::operator !=( - const CompleteData& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void CompleteData::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t CompleteData::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& CompleteData::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member main_point - * @param _main_point New value to be copied in member main_point - */ -void CompleteData::main_point( - const Point& _main_point) -{ - m_main_point = _main_point; -} - -/*! - * @brief This function moves the value in member main_point - * @param _main_point New value to be moved in member main_point - */ -void CompleteData::main_point( - Point&& _main_point) -{ - m_main_point = std::move(_main_point); -} - -/*! - * @brief This function returns a constant reference to member main_point - * @return Constant reference to member main_point - */ -const Point& CompleteData::main_point() const -{ - return m_main_point; -} - -/*! - * @brief This function returns a reference to member main_point - * @return Reference to member main_point - */ -Point& CompleteData::main_point() -{ - return m_main_point; -} - -/*! - * @brief This function copies the value in member internal_data - * @param _internal_data New value to be copied in member internal_data - */ -void CompleteData::internal_data( - const std::vector& _internal_data) -{ - m_internal_data = _internal_data; -} - -/*! - * @brief This function moves the value in member internal_data - * @param _internal_data New value to be moved in member internal_data - */ -void CompleteData::internal_data( - std::vector&& _internal_data) -{ - m_internal_data = std::move(_internal_data); -} - -/*! - * @brief This function returns a constant reference to member internal_data - * @return Constant reference to member internal_data - */ -const std::vector& CompleteData::internal_data() const -{ - return m_internal_data; -} - -/*! - * @brief This function returns a reference to member internal_data - * @return Reference to member internal_data - */ -std::vector& CompleteData::internal_data() -{ - return m_internal_data; -} - -/*! - * @brief This function copies the value in member messages - * @param _messages New value to be copied in member messages - */ -void CompleteData::messages( - const std::array& _messages) -{ - m_messages = _messages; -} - -/*! - * @brief This function moves the value in member messages - * @param _messages New value to be moved in member messages - */ -void CompleteData::messages( - std::array&& _messages) -{ - m_messages = std::move(_messages); -} - -/*! - * @brief This function returns a constant reference to member messages - * @return Constant reference to member messages - */ -const std::array& CompleteData::messages() const -{ - return m_messages; -} - -/*! - * @brief This function returns a reference to member messages - * @return Reference to member messages - */ -std::array& CompleteData::messages() -{ - return m_messages; -} - -// Include auxiliary functions like for serializing/deserializing. -#include "CompleteCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.cxx b/resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.cxx deleted file mode 100644 index c155e5dfe..000000000 --- a/resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.cxx +++ /dev/null @@ -1,1271 +0,0 @@ -// 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 CompleteTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include "Complete.h" -#include "CompleteTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerCompleteTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("Timestamp", GetTimestampIdentifier(true), - GetTimestampObject(true)); - factory->add_type_object("Timestamp", GetTimestampIdentifier(false), - GetTimestampObject(false)); - - - factory->add_type_object("Point", GetPointIdentifier(true), - GetPointObject(true)); - factory->add_type_object("Point", GetPointIdentifier(false), - GetPointObject(false)); - - - factory->add_type_object("MessageDescriptor", GetMessageDescriptorIdentifier(true), - GetMessageDescriptorObject(true)); - factory->add_type_object("MessageDescriptor", GetMessageDescriptorIdentifier(false), - GetMessageDescriptorObject(false)); - - - factory->add_type_object("Message", GetMessageIdentifier(true), - GetMessageObject(true)); - factory->add_type_object("Message", GetMessageIdentifier(false), - GetMessageObject(false)); - - - factory->add_type_object("CompleteData", GetCompleteDataIdentifier(true), - GetCompleteDataObject(true)); - factory->add_type_object("CompleteData", GetCompleteDataIdentifier(false), - GetCompleteDataObject(false)); - - }); -} - -const TypeIdentifier* GetTimestampIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("Timestamp", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetTimestampObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("Timestamp", complete); -} - -const TypeObject* GetTimestampObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Timestamp", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteTimestampObject(); - } - //else - return GetMinimalTimestampObject(); -} - -const TypeObject* GetMinimalTimestampObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Timestamp", 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_seconds; - mst_seconds.common().member_id(memberId++); - mst_seconds.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_seconds.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_seconds.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_seconds.common().member_flags().IS_OPTIONAL(false); - mst_seconds.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_seconds.common().member_flags().IS_KEY(false); - mst_seconds.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_seconds.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - MD5 seconds_hash("seconds"); - for (int i = 0; i < 4; ++i) - { - mst_seconds.detail().name_hash()[i] = seconds_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_seconds); - - MinimalStructMember mst_milliseconds; - mst_milliseconds.common().member_id(memberId++); - mst_milliseconds.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_milliseconds.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_milliseconds.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_milliseconds.common().member_flags().IS_OPTIONAL(false); - mst_milliseconds.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_milliseconds.common().member_flags().IS_KEY(false); - mst_milliseconds.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_milliseconds.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - MD5 milliseconds_hash("milliseconds"); - for (int i = 0; i < 4; ++i) - { - mst_milliseconds.detail().name_hash()[i] = milliseconds_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_milliseconds); - - - // 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("Timestamp", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("Timestamp", false); -} - -const TypeObject* GetCompleteTimestampObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Timestamp", 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_seconds; - cst_seconds.common().member_id(memberId++); - cst_seconds.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_seconds.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_seconds.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_seconds.common().member_flags().IS_OPTIONAL(false); - cst_seconds.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_seconds.common().member_flags().IS_KEY(false); - cst_seconds.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_seconds.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - cst_seconds.detail().name("seconds"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_seconds); - - CompleteStructMember cst_milliseconds; - cst_milliseconds.common().member_id(memberId++); - cst_milliseconds.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_milliseconds.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_milliseconds.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_milliseconds.common().member_flags().IS_OPTIONAL(false); - cst_milliseconds.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_milliseconds.common().member_flags().IS_KEY(false); - cst_milliseconds.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_milliseconds.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - cst_milliseconds.detail().name("milliseconds"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_milliseconds); - - - // Header - type_object->complete().struct_type().header().detail().type_name("Timestamp"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("Timestamp", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("Timestamp", true); -} - -const TypeIdentifier* GetPointIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("Point", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetPointObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("Point", complete); -} - -const TypeObject* GetPointObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Point", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompletePointObject(); - } - //else - return GetMinimalPointObject(); -} - -const TypeObject* GetMinimalPointObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Point", 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("int32_t", 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("int32_t", 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); - - MinimalStructMember mst_z; - mst_z.common().member_id(memberId++); - mst_z.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_z.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_z.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_z.common().member_flags().IS_OPTIONAL(false); - mst_z.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_z.common().member_flags().IS_KEY(false); - mst_z.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_z.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - MD5 z_hash("z"); - for (int i = 0; i < 4; ++i) - { - mst_z.detail().name_hash()[i] = z_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_z); - - - // 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("Point", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("Point", false); -} - -const TypeObject* GetCompletePointObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Point", 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("int32_t", 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("int32_t", false)); - - - cst_y.detail().name("y"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_y); - - CompleteStructMember cst_z; - cst_z.common().member_id(memberId++); - cst_z.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_z.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_z.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_z.common().member_flags().IS_OPTIONAL(false); - cst_z.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_z.common().member_flags().IS_KEY(false); - cst_z.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_z.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("int32_t", false)); - - - cst_z.detail().name("z"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_z); - - - // Header - type_object->complete().struct_type().header().detail().type_name("Point"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("Point", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("Point", true); -} - -const TypeIdentifier* GetMessageDescriptorIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("MessageDescriptor", - complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMessageDescriptorObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("MessageDescriptor", complete); -} - -const TypeObject* GetMessageDescriptorObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MessageDescriptor", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMessageDescriptorObject(); - } - //else - return GetMinimalMessageDescriptorObject(); -} - -const TypeObject* GetMinimalMessageDescriptorObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MessageDescriptor", 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_id; - mst_id.common().member_id(memberId++); - mst_id.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_id.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_id.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_id.common().member_flags().IS_OPTIONAL(false); - mst_id.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_id.common().member_flags().IS_KEY(false); - mst_id.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_id.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - MD5 id_hash("id"); - for (int i = 0; i < 4; ++i) - { - mst_id.detail().name_hash()[i] = id_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_id); - - MinimalStructMember mst_topic; - mst_topic.common().member_id(memberId++); - mst_topic.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_topic.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_topic.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_topic.common().member_flags().IS_OPTIONAL(false); - mst_topic.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_topic.common().member_flags().IS_KEY(false); - mst_topic.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_topic.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - MD5 topic_hash("topic"); - for (int i = 0; i < 4; ++i) - { - mst_topic.detail().name_hash()[i] = topic_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_topic); - - MinimalStructMember mst_time; - mst_time.common().member_id(memberId++); - mst_time.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_time.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_time.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_time.common().member_flags().IS_OPTIONAL(false); - mst_time.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_time.common().member_flags().IS_KEY(false); - mst_time.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_time.common().member_type_id(*GetTimestampIdentifier(false)); - - MD5 time_hash("time"); - for (int i = 0; i < 4; ++i) - { - mst_time.detail().name_hash()[i] = time_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_time); - - - // 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("MessageDescriptor", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MessageDescriptor", false); -} - -const TypeObject* GetCompleteMessageDescriptorObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("MessageDescriptor", 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_id; - cst_id.common().member_id(memberId++); - cst_id.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_id.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_id.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_id.common().member_flags().IS_OPTIONAL(false); - cst_id.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_id.common().member_flags().IS_KEY(false); - cst_id.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_id.common().member_type_id(*TypeObjectFactory::get_instance()->get_type_identifier("uint32_t", false)); - - - cst_id.detail().name("id"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_id); - - CompleteStructMember cst_topic; - cst_topic.common().member_id(memberId++); - cst_topic.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_topic.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_topic.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_topic.common().member_flags().IS_OPTIONAL(false); - cst_topic.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_topic.common().member_flags().IS_KEY(false); - cst_topic.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_topic.common().member_type_id(*TypeObjectFactory::get_instance()->get_string_identifier(255, false)); - - cst_topic.detail().name("topic"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_topic); - - CompleteStructMember cst_time; - cst_time.common().member_id(memberId++); - cst_time.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_time.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_time.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_time.common().member_flags().IS_OPTIONAL(false); - cst_time.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_time.common().member_flags().IS_KEY(false); - cst_time.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_time.common().member_type_id(*GetTimestampIdentifier(true)); - - cst_time.detail().name("time"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_time); - - - // Header - type_object->complete().struct_type().header().detail().type_name("MessageDescriptor"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("MessageDescriptor", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("MessageDescriptor", true); -} - -const TypeIdentifier* GetMessageIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("Message", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetMessageObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("Message", complete); -} - -const TypeObject* GetMessageObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Message", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteMessageObject(); - } - //else - return GetMinimalMessageObject(); -} - -const TypeObject* GetMinimalMessageObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Message", 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_descriptor; - mst_descriptor.common().member_id(memberId++); - mst_descriptor.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_descriptor.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_descriptor.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_descriptor.common().member_flags().IS_OPTIONAL(false); - mst_descriptor.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_descriptor.common().member_flags().IS_KEY(false); - mst_descriptor.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_descriptor.common().member_type_id(*GetMessageDescriptorIdentifier(false)); - - MD5 descriptor_hash("descriptor"); - for (int i = 0; i < 4; ++i) - { - mst_descriptor.detail().name_hash()[i] = descriptor_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_descriptor); - - 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("Message", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("Message", false); -} - -const TypeObject* GetCompleteMessageObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("Message", 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_descriptor; - cst_descriptor.common().member_id(memberId++); - cst_descriptor.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_descriptor.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_descriptor.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_descriptor.common().member_flags().IS_OPTIONAL(false); - cst_descriptor.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_descriptor.common().member_flags().IS_KEY(false); - cst_descriptor.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_descriptor.common().member_type_id(*GetMessageDescriptorIdentifier(true)); - - cst_descriptor.detail().name("descriptor"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_descriptor); - - 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("Message"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("Message", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("Message", true); -} - -const TypeIdentifier* GetCompleteDataIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = - TypeObjectFactory::get_instance()->get_type_identifier("CompleteData", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetCompleteDataObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("CompleteData", complete); -} - -const TypeObject* GetCompleteDataObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("CompleteData", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteCompleteDataObject(); - } - //else - return GetMinimalCompleteDataObject(); -} - -const TypeObject* GetMinimalCompleteDataObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("CompleteData", 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_main_point; - mst_main_point.common().member_id(memberId++); - mst_main_point.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_main_point.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_main_point.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_main_point.common().member_flags().IS_OPTIONAL(false); - mst_main_point.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_main_point.common().member_flags().IS_KEY(false); - mst_main_point.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_main_point.common().member_type_id(*GetPointIdentifier(false)); - - MD5 main_point_hash("main_point"); - for (int i = 0; i < 4; ++i) - { - mst_main_point.detail().name_hash()[i] = main_point_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_main_point); - - MinimalStructMember mst_internal_data; - mst_internal_data.common().member_id(memberId++); - mst_internal_data.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_internal_data.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_internal_data.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_internal_data.common().member_flags().IS_OPTIONAL(false); - mst_internal_data.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_internal_data.common().member_flags().IS_KEY(false); - mst_internal_data.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_internal_data.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("Point", 100, - false)); - - MD5 internal_data_hash("internal_data"); - for (int i = 0; i < 4; ++i) - { - mst_internal_data.detail().name_hash()[i] = internal_data_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_internal_data); - - MinimalStructMember mst_messages; - mst_messages.common().member_id(memberId++); - mst_messages.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - mst_messages.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - mst_messages.common().member_flags().IS_EXTERNAL(false); // Unsupported - mst_messages.common().member_flags().IS_OPTIONAL(false); - mst_messages.common().member_flags().IS_MUST_UNDERSTAND(false); - mst_messages.common().member_flags().IS_KEY(false); - mst_messages.common().member_flags().IS_DEFAULT(false); // Doesn't apply - mst_messages.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("Message", {2}, - false)); - - MD5 messages_hash("messages"); - for (int i = 0; i < 4; ++i) - { - mst_messages.detail().name_hash()[i] = messages_hash.digest[i]; - } - type_object->minimal().struct_type().member_seq().emplace_back(mst_messages); - - - // 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("CompleteData", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("CompleteData", false); -} - -const TypeObject* GetCompleteCompleteDataObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("CompleteData", 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_main_point; - cst_main_point.common().member_id(memberId++); - cst_main_point.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_main_point.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_main_point.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_main_point.common().member_flags().IS_OPTIONAL(false); - cst_main_point.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_main_point.common().member_flags().IS_KEY(false); - cst_main_point.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_main_point.common().member_type_id(*GetPointIdentifier(true)); - - cst_main_point.detail().name("main_point"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_main_point); - - CompleteStructMember cst_internal_data; - cst_internal_data.common().member_id(memberId++); - cst_internal_data.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_internal_data.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_internal_data.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_internal_data.common().member_flags().IS_OPTIONAL(false); - cst_internal_data.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_internal_data.common().member_flags().IS_KEY(false); - cst_internal_data.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_internal_data.common().member_type_id(*TypeObjectFactory::get_instance()->get_sequence_identifier("Point", 100, - true)); - - cst_internal_data.detail().name("internal_data"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_internal_data); - - CompleteStructMember cst_messages; - cst_messages.common().member_id(memberId++); - cst_messages.common().member_flags().TRY_CONSTRUCT1(false); // Unsupported - cst_messages.common().member_flags().TRY_CONSTRUCT2(false); // Unsupported - cst_messages.common().member_flags().IS_EXTERNAL(false); // Unsupported - cst_messages.common().member_flags().IS_OPTIONAL(false); - cst_messages.common().member_flags().IS_MUST_UNDERSTAND(false); - cst_messages.common().member_flags().IS_KEY(false); - cst_messages.common().member_flags().IS_DEFAULT(false); // Doesn't apply - cst_messages.common().member_type_id(*TypeObjectFactory::get_instance()->get_array_identifier("Message", {2}, - true)); - - cst_messages.detail().name("messages"); - - type_object->complete().struct_type().member_seq().emplace_back(cst_messages); - - - // Header - type_object->complete().struct_type().header().detail().type_name("CompleteData"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("CompleteData", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("CompleteData", true); -} diff --git a/resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.h b/resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.h deleted file mode 100644 index 24ccb60b0..000000000 --- a/resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.h +++ /dev/null @@ -1,103 +0,0 @@ -// 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 CompleteTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_COMPLETE_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_COMPLETE_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(Complete_SOURCE) -#define Complete_DllAPI __declspec( dllexport ) -#else -#define Complete_DllAPI __declspec( dllimport ) -#endif // Complete_SOURCE -#else -#define Complete_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define Complete_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerCompleteTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetTimestampIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetTimestampObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalTimestampObject(); -eProsima_user_DllExport const TypeObject* GetCompleteTimestampObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetPointIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetPointObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalPointObject(); -eProsima_user_DllExport const TypeObject* GetCompletePointObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetMessageDescriptorIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMessageDescriptorObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalMessageDescriptorObject(); -eProsima_user_DllExport const TypeObject* GetCompleteMessageDescriptorObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetMessageIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMessageObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalMessageObject(); -eProsima_user_DllExport const TypeObject* GetCompleteMessageObject(); - - - -eProsima_user_DllExport const TypeIdentifier* GetCompleteDataIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetCompleteDataObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalCompleteDataObject(); -eProsima_user_DllExport const TypeObject* GetCompleteCompleteDataObject(); - - -#endif // _FAST_DDS_GENERATED_COMPLETE_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/resources/dds/TypeLookupService/types/v2/complete/Completev1.cxx b/resources/dds/TypeLookupService/types/v2/complete/Completev1.cxx deleted file mode 100644 index bdd2ded30..000000000 --- a/resources/dds/TypeLookupService/types/v2/complete/Completev1.cxx +++ /dev/null @@ -1,1304 +0,0 @@ -// 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 Complete.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "Complete.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "CompleteTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define MessageDescriptor_max_cdr_typesize 280ULL; -#define CompleteData_max_cdr_typesize 2724ULL; -#define Message_max_cdr_typesize 544ULL; -#define Point_max_cdr_typesize 16ULL; -#define Timestamp_max_cdr_typesize 12ULL; - - - - -Timestamp::Timestamp() -{ - // long m_seconds - m_seconds = 0; - // long m_milliseconds - m_milliseconds = 0; - - // Just to register all known types - registerCompleteTypes(); -} - -Timestamp::~Timestamp() -{ -} - -Timestamp::Timestamp( - const Timestamp& x) -{ - m_seconds = x.m_seconds; - - - m_milliseconds = x.m_milliseconds; - -} - -Timestamp::Timestamp( - Timestamp&& x) noexcept -{ - m_seconds = x.m_seconds; - - - m_milliseconds = x.m_milliseconds; - -} - -Timestamp& Timestamp::operator =( - const Timestamp& x) -{ - m_seconds = x.m_seconds; - - - m_milliseconds = x.m_milliseconds; - - return *this; -} - -Timestamp& Timestamp::operator =( - Timestamp&& x) noexcept -{ - m_seconds = x.m_seconds; - - - m_milliseconds = x.m_milliseconds; - - return *this; -} - -bool Timestamp::operator ==( - const Timestamp& x) const -{ - return (m_seconds == x.m_seconds && - m_milliseconds == x.m_milliseconds); -} - -bool Timestamp::operator !=( - const Timestamp& x) const -{ - return !(*this == x); -} - -size_t Timestamp::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return Timestamp_max_cdr_typesize; -} - -size_t Timestamp::getCdrSerializedSize( - const Timestamp& 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 Timestamp::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_seconds; - - scdr << m_milliseconds; - -} - -void Timestamp::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_seconds; - - - - dcdr >> m_milliseconds; - - -} - -bool Timestamp::isKeyDefined() -{ - return false; -} - -void Timestamp::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member seconds - * @param _seconds New value for member seconds - */ -void Timestamp::seconds( - int32_t _seconds) -{ - m_seconds = _seconds; -} - -/*! - * @brief This function returns the value of member seconds - * @return Value of member seconds - */ -int32_t Timestamp::seconds() const -{ - return m_seconds; -} - -/*! - * @brief This function returns a reference to member seconds - * @return Reference to member seconds - */ -int32_t& Timestamp::seconds() -{ - return m_seconds; -} - -/*! - * @brief This function sets a value in member milliseconds - * @param _milliseconds New value for member milliseconds - */ -void Timestamp::milliseconds( - int32_t _milliseconds) -{ - m_milliseconds = _milliseconds; -} - -/*! - * @brief This function returns the value of member milliseconds - * @return Value of member milliseconds - */ -int32_t Timestamp::milliseconds() const -{ - return m_milliseconds; -} - -/*! - * @brief This function returns a reference to member milliseconds - * @return Reference to member milliseconds - */ -int32_t& Timestamp::milliseconds() -{ - return m_milliseconds; -} - -Point::Point() -{ - // long m_x - m_x = 0; - // long m_y - m_y = 0; - // long m_z - m_z = 0; - - // Just to register all known types - registerCompleteTypes(); -} - -Point::~Point() -{ -} - -Point::Point( - const Point& x) -{ - m_x = x.m_x; - - - m_y = x.m_y; - - - m_z = x.m_z; - -} - -Point::Point( - Point&& x) noexcept -{ - m_x = x.m_x; - - - m_y = x.m_y; - - - m_z = x.m_z; - -} - -Point& Point::operator =( - const Point& x) -{ - m_x = x.m_x; - - - m_y = x.m_y; - - - m_z = x.m_z; - - return *this; -} - -Point& Point::operator =( - Point&& x) noexcept -{ - m_x = x.m_x; - - - m_y = x.m_y; - - - m_z = x.m_z; - - return *this; -} - -bool Point::operator ==( - const Point& x) const -{ - return (m_x == x.m_x && - m_y == x.m_y && - m_z == x.m_z); -} - -bool Point::operator !=( - const Point& x) const -{ - return !(*this == x); -} - -size_t Point::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return Point_max_cdr_typesize; -} - -size_t Point::getCdrSerializedSize( - const Point& 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); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - return current_alignment - initial_alignment; -} - -void Point::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_x; - - scdr << m_y; - - scdr << m_z; - -} - -void Point::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_x; - - - - dcdr >> m_y; - - - - dcdr >> m_z; - - -} - -bool Point::isKeyDefined() -{ - return false; -} - -void Point::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ -void Point::x( - int32_t _x) -{ - m_x = _x; -} - -/*! - * @brief This function returns the value of member x - * @return Value of member x - */ -int32_t Point::x() const -{ - return m_x; -} - -/*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ -int32_t& Point::x() -{ - return m_x; -} - -/*! - * @brief This function sets a value in member y - * @param _y New value for member y - */ -void Point::y( - int32_t _y) -{ - m_y = _y; -} - -/*! - * @brief This function returns the value of member y - * @return Value of member y - */ -int32_t Point::y() const -{ - return m_y; -} - -/*! - * @brief This function returns a reference to member y - * @return Reference to member y - */ -int32_t& Point::y() -{ - return m_y; -} - -/*! - * @brief This function sets a value in member z - * @param _z New value for member z - */ -void Point::z( - int32_t _z) -{ - m_z = _z; -} - -/*! - * @brief This function returns the value of member z - * @return Value of member z - */ -int32_t Point::z() const -{ - return m_z; -} - -/*! - * @brief This function returns a reference to member z - * @return Reference to member z - */ -int32_t& Point::z() -{ - return m_z; -} - -MessageDescriptor::MessageDescriptor() -{ - // unsigned long m_id - m_id = 0; - // /type_d() m_topic - - // Timestamp m_time - - - // Just to register all known types - registerCompleteTypes(); -} - -MessageDescriptor::~MessageDescriptor() -{ -} - -MessageDescriptor::MessageDescriptor( - const MessageDescriptor& x) -{ - m_id = x.m_id; - - - m_topic = x.m_topic; - - - m_time = x.m_time; - -} - -MessageDescriptor::MessageDescriptor( - MessageDescriptor&& x) noexcept -{ - m_id = x.m_id; - - - m_topic = std::move(x.m_topic); - - - m_time = std::move(x.m_time); - -} - -MessageDescriptor& MessageDescriptor::operator =( - const MessageDescriptor& x) -{ - m_id = x.m_id; - - - m_topic = x.m_topic; - - - m_time = x.m_time; - - return *this; -} - -MessageDescriptor& MessageDescriptor::operator =( - MessageDescriptor&& x) noexcept -{ - m_id = x.m_id; - - - m_topic = std::move(x.m_topic); - - - m_time = std::move(x.m_time); - - return *this; -} - -bool MessageDescriptor::operator ==( - const MessageDescriptor& x) const -{ - return (m_id == x.m_id && - m_topic == x.m_topic && - m_time == x.m_time); -} - -bool MessageDescriptor::operator !=( - const MessageDescriptor& x) const -{ - return !(*this == x); -} - -size_t MessageDescriptor::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return MessageDescriptor_max_cdr_typesize; -} - -size_t MessageDescriptor::getCdrSerializedSize( - const MessageDescriptor& 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.topic().size() + 1; - - - current_alignment += Timestamp::getCdrSerializedSize(data.time(), current_alignment); - - - return current_alignment - initial_alignment; -} - -void MessageDescriptor::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_id; - - scdr << m_topic.c_str(); - - scdr << m_time; - -} - -void MessageDescriptor::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_id; - - - - dcdr >> m_topic; - - - - dcdr >> m_time; - - -} - -bool MessageDescriptor::isKeyDefined() -{ - return false; -} - -void MessageDescriptor::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member id - * @param _id New value for member id - */ -void MessageDescriptor::id( - uint32_t _id) -{ - m_id = _id; -} - -/*! - * @brief This function returns the value of member id - * @return Value of member id - */ -uint32_t MessageDescriptor::id() const -{ - return m_id; -} - -/*! - * @brief This function returns a reference to member id - * @return Reference to member id - */ -uint32_t& MessageDescriptor::id() -{ - return m_id; -} - -/*! - * @brief This function copies the value in member topic - * @param _topic New value to be copied in member topic - */ -void MessageDescriptor::topic( - const std::string& _topic) -{ - m_topic = _topic; -} - -/*! - * @brief This function moves the value in member topic - * @param _topic New value to be moved in member topic - */ -void MessageDescriptor::topic( - std::string&& _topic) -{ - m_topic = std::move(_topic); -} - -/*! - * @brief This function returns a constant reference to member topic - * @return Constant reference to member topic - */ -const std::string& MessageDescriptor::topic() const -{ - return m_topic; -} - -/*! - * @brief This function returns a reference to member topic - * @return Reference to member topic - */ -std::string& MessageDescriptor::topic() -{ - return m_topic; -} - -/*! - * @brief This function copies the value in member time - * @param _time New value to be copied in member time - */ -void MessageDescriptor::time( - const Timestamp& _time) -{ - m_time = _time; -} - -/*! - * @brief This function moves the value in member time - * @param _time New value to be moved in member time - */ -void MessageDescriptor::time( - Timestamp&& _time) -{ - m_time = std::move(_time); -} - -/*! - * @brief This function returns a constant reference to member time - * @return Constant reference to member time - */ -const Timestamp& MessageDescriptor::time() const -{ - return m_time; -} - -/*! - * @brief This function returns a reference to member time - * @return Reference to member time - */ -Timestamp& MessageDescriptor::time() -{ - return m_time; -} - -Message::Message() -{ - // MessageDescriptor m_descriptor - - // /type_d() m_message - - - // Just to register all known types - registerCompleteTypes(); -} - -Message::~Message() -{ -} - -Message::Message( - const Message& x) -{ - m_descriptor = x.m_descriptor; - - - m_message = x.m_message; - -} - -Message::Message( - Message&& x) noexcept -{ - m_descriptor = std::move(x.m_descriptor); - - - m_message = std::move(x.m_message); - -} - -Message& Message::operator =( - const Message& x) -{ - m_descriptor = x.m_descriptor; - - - m_message = x.m_message; - - return *this; -} - -Message& Message::operator =( - Message&& x) noexcept -{ - m_descriptor = std::move(x.m_descriptor); - - - m_message = std::move(x.m_message); - - return *this; -} - -bool Message::operator ==( - const Message& x) const -{ - return (m_descriptor == x.m_descriptor && - m_message == x.m_message); -} - -bool Message::operator !=( - const Message& x) const -{ - return !(*this == x); -} - -size_t Message::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return Message_max_cdr_typesize; -} - -size_t Message::getCdrSerializedSize( - const Message& data, - size_t current_alignment) -{ - (void)data; - size_t initial_alignment = current_alignment; - - current_alignment += MessageDescriptor::getCdrSerializedSize(data.descriptor(), current_alignment); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.message().size() + 1; - - - return current_alignment - initial_alignment; -} - -void Message::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_descriptor; - - scdr << m_message.c_str(); - -} - -void Message::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_descriptor; - - - - dcdr >> m_message; - - -} - -bool Message::isKeyDefined() -{ - return false; -} - -void Message::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function copies the value in member descriptor - * @param _descriptor New value to be copied in member descriptor - */ -void Message::descriptor( - const MessageDescriptor& _descriptor) -{ - m_descriptor = _descriptor; -} - -/*! - * @brief This function moves the value in member descriptor - * @param _descriptor New value to be moved in member descriptor - */ -void Message::descriptor( - MessageDescriptor&& _descriptor) -{ - m_descriptor = std::move(_descriptor); -} - -/*! - * @brief This function returns a constant reference to member descriptor - * @return Constant reference to member descriptor - */ -const MessageDescriptor& Message::descriptor() const -{ - return m_descriptor; -} - -/*! - * @brief This function returns a reference to member descriptor - * @return Reference to member descriptor - */ -MessageDescriptor& Message::descriptor() -{ - return m_descriptor; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void Message::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 Message::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& Message::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& Message::message() -{ - return m_message; -} - -CompleteData::CompleteData() -{ - // unsigned long m_index - m_index = 0; - // Point m_main_point - - // sequence m_internal_data - - // Message m_messages - - - // Just to register all known types - registerCompleteTypes(); -} - -CompleteData::~CompleteData() -{ -} - -CompleteData::CompleteData( - const CompleteData& x) -{ - m_index = x.m_index; - - - m_main_point = x.m_main_point; - - - m_internal_data = x.m_internal_data; - - - m_messages = x.m_messages; - -} - -CompleteData::CompleteData( - CompleteData&& x) noexcept -{ - m_index = x.m_index; - - - m_main_point = std::move(x.m_main_point); - - - m_internal_data = std::move(x.m_internal_data); - - - m_messages = std::move(x.m_messages); - -} - -CompleteData& CompleteData::operator =( - const CompleteData& x) -{ - m_index = x.m_index; - - - m_main_point = x.m_main_point; - - - m_internal_data = x.m_internal_data; - - - m_messages = x.m_messages; - - return *this; -} - -CompleteData& CompleteData::operator =( - CompleteData&& x) noexcept -{ - m_index = x.m_index; - - - m_main_point = std::move(x.m_main_point); - - - m_internal_data = std::move(x.m_internal_data); - - - m_messages = std::move(x.m_messages); - - return *this; -} - -bool CompleteData::operator ==( - const CompleteData& x) const -{ - return (m_index == x.m_index && - m_main_point == x.m_main_point && - m_internal_data == x.m_internal_data && - m_messages == x.m_messages); -} - -bool CompleteData::operator !=( - const CompleteData& x) const -{ - return !(*this == x); -} - -size_t CompleteData::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return CompleteData_max_cdr_typesize; -} - -size_t CompleteData::getCdrSerializedSize( - const CompleteData& 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 += Point::getCdrSerializedSize(data.main_point(), current_alignment); - - - current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); - - - for (size_t a = 0; a < data.internal_data().size(); ++a) - { - current_alignment += Point::getCdrSerializedSize(data.internal_data().at(a), current_alignment); - } - - - - - for (size_t a = 0; a < data.messages().size(); ++a) - { - current_alignment += Message::getCdrSerializedSize(data.messages().at(a), current_alignment); - - } - - - - return current_alignment - initial_alignment; -} - -void CompleteData::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_index; - - scdr << m_main_point; - - scdr << m_internal_data; - - - scdr << m_messages; - - -} - -void CompleteData::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_index; - - - - dcdr >> m_main_point; - - - - dcdr >> m_internal_data; - - - - dcdr >> m_messages; - - -} - -bool CompleteData::isKeyDefined() -{ - return false; -} - -void CompleteData::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void CompleteData::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t CompleteData::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& CompleteData::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member main_point - * @param _main_point New value to be copied in member main_point - */ -void CompleteData::main_point( - const Point& _main_point) -{ - m_main_point = _main_point; -} - -/*! - * @brief This function moves the value in member main_point - * @param _main_point New value to be moved in member main_point - */ -void CompleteData::main_point( - Point&& _main_point) -{ - m_main_point = std::move(_main_point); -} - -/*! - * @brief This function returns a constant reference to member main_point - * @return Constant reference to member main_point - */ -const Point& CompleteData::main_point() const -{ - return m_main_point; -} - -/*! - * @brief This function returns a reference to member main_point - * @return Reference to member main_point - */ -Point& CompleteData::main_point() -{ - return m_main_point; -} - -/*! - * @brief This function copies the value in member internal_data - * @param _internal_data New value to be copied in member internal_data - */ -void CompleteData::internal_data( - const std::vector& _internal_data) -{ - m_internal_data = _internal_data; -} - -/*! - * @brief This function moves the value in member internal_data - * @param _internal_data New value to be moved in member internal_data - */ -void CompleteData::internal_data( - std::vector&& _internal_data) -{ - m_internal_data = std::move(_internal_data); -} - -/*! - * @brief This function returns a constant reference to member internal_data - * @return Constant reference to member internal_data - */ -const std::vector& CompleteData::internal_data() const -{ - return m_internal_data; -} - -/*! - * @brief This function returns a reference to member internal_data - * @return Reference to member internal_data - */ -std::vector& CompleteData::internal_data() -{ - return m_internal_data; -} - -/*! - * @brief This function copies the value in member messages - * @param _messages New value to be copied in member messages - */ -void CompleteData::messages( - const std::array& _messages) -{ - m_messages = _messages; -} - -/*! - * @brief This function moves the value in member messages - * @param _messages New value to be moved in member messages - */ -void CompleteData::messages( - std::array&& _messages) -{ - m_messages = std::move(_messages); -} - -/*! - * @brief This function returns a constant reference to member messages - * @return Constant reference to member messages - */ -const std::array& CompleteData::messages() const -{ - return m_messages; -} - -/*! - * @brief This function returns a reference to member messages - * @return Reference to member messages - */ -std::array& CompleteData::messages() -{ - return m_messages; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/resources/dds/TypeLookupService/types/v2/complete/Completev1.h b/resources/dds/TypeLookupService/types/v2/complete/Completev1.h deleted file mode 100644 index b3b76494d..000000000 --- a/resources/dds/TypeLookupService/types/v2/complete/Completev1.h +++ /dev/null @@ -1,1004 +0,0 @@ -// 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 Complete.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_COMPLETE_H_ -#define _FAST_DDS_GENERATED_COMPLETE_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(COMPLETE_SOURCE) -#define COMPLETE_DllAPI __declspec( dllexport ) -#else -#define COMPLETE_DllAPI __declspec( dllimport ) -#endif // COMPLETE_SOURCE -#else -#define COMPLETE_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define COMPLETE_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure Timestamp defined by the user in the IDL file. - * @ingroup Complete - */ -class Timestamp -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport Timestamp(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~Timestamp(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object Timestamp that will be copied. - */ - eProsima_user_DllExport Timestamp( - const Timestamp& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object Timestamp that will be copied. - */ - eProsima_user_DllExport Timestamp( - Timestamp&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object Timestamp that will be copied. - */ - eProsima_user_DllExport Timestamp& operator =( - const Timestamp& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object Timestamp that will be copied. - */ - eProsima_user_DllExport Timestamp& operator =( - Timestamp&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x Timestamp object to compare. - */ - eProsima_user_DllExport bool operator ==( - const Timestamp& x) const; - - /*! - * @brief Comparison operator. - * @param x Timestamp object to compare. - */ - eProsima_user_DllExport bool operator !=( - const Timestamp& x) const; - - /*! - * @brief This function sets a value in member seconds - * @param _seconds New value for member seconds - */ - eProsima_user_DllExport void seconds( - int32_t _seconds); - - /*! - * @brief This function returns the value of member seconds - * @return Value of member seconds - */ - eProsima_user_DllExport int32_t seconds() const; - - /*! - * @brief This function returns a reference to member seconds - * @return Reference to member seconds - */ - eProsima_user_DllExport int32_t& seconds(); - - - /*! - * @brief This function sets a value in member milliseconds - * @param _milliseconds New value for member milliseconds - */ - eProsima_user_DllExport void milliseconds( - int32_t _milliseconds); - - /*! - * @brief This function returns the value of member milliseconds - * @return Value of member milliseconds - */ - eProsima_user_DllExport int32_t milliseconds() const; - - /*! - * @brief This function returns a reference to member milliseconds - * @return Reference to member milliseconds - */ - eProsima_user_DllExport int32_t& milliseconds(); - - - /*! - * @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 Timestamp& 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 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_seconds; - int32_t m_milliseconds; - -}; - - - -/*! - * @brief This class represents the structure Point defined by the user in the IDL file. - * @ingroup Complete - */ -class Point -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport Point(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~Point(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object Point that will be copied. - */ - eProsima_user_DllExport Point( - const Point& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object Point that will be copied. - */ - eProsima_user_DllExport Point( - Point&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object Point that will be copied. - */ - eProsima_user_DllExport Point& operator =( - const Point& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object Point that will be copied. - */ - eProsima_user_DllExport Point& operator =( - Point&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x Point object to compare. - */ - eProsima_user_DllExport bool operator ==( - const Point& x) const; - - /*! - * @brief Comparison operator. - * @param x Point object to compare. - */ - eProsima_user_DllExport bool operator !=( - const Point& x) const; - - /*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ - eProsima_user_DllExport void x( - int32_t _x); - - /*! - * @brief This function returns the value of member x - * @return Value of member x - */ - eProsima_user_DllExport int32_t x() const; - - /*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ - eProsima_user_DllExport int32_t& x(); - - - /*! - * @brief This function sets a value in member y - * @param _y New value for member y - */ - eProsima_user_DllExport void y( - int32_t _y); - - /*! - * @brief This function returns the value of member y - * @return Value of member y - */ - eProsima_user_DllExport int32_t y() const; - - /*! - * @brief This function returns a reference to member y - * @return Reference to member y - */ - eProsima_user_DllExport int32_t& y(); - - - /*! - * @brief This function sets a value in member z - * @param _z New value for member z - */ - eProsima_user_DllExport void z( - int32_t _z); - - /*! - * @brief This function returns the value of member z - * @return Value of member z - */ - eProsima_user_DllExport int32_t z() const; - - /*! - * @brief This function returns a reference to member z - * @return Reference to member z - */ - eProsima_user_DllExport int32_t& z(); - - - /*! - * @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 Point& 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 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_x; - int32_t m_y; - int32_t m_z; - -}; - - - -/*! - * @brief This class represents the structure MessageDescriptor defined by the user in the IDL file. - * @ingroup Complete - */ -class MessageDescriptor -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport MessageDescriptor(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~MessageDescriptor(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object MessageDescriptor that will be copied. - */ - eProsima_user_DllExport MessageDescriptor( - const MessageDescriptor& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object MessageDescriptor that will be copied. - */ - eProsima_user_DllExport MessageDescriptor( - MessageDescriptor&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object MessageDescriptor that will be copied. - */ - eProsima_user_DllExport MessageDescriptor& operator =( - const MessageDescriptor& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object MessageDescriptor that will be copied. - */ - eProsima_user_DllExport MessageDescriptor& operator =( - MessageDescriptor&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x MessageDescriptor object to compare. - */ - eProsima_user_DllExport bool operator ==( - const MessageDescriptor& x) const; - - /*! - * @brief Comparison operator. - * @param x MessageDescriptor object to compare. - */ - eProsima_user_DllExport bool operator !=( - const MessageDescriptor& x) const; - - /*! - * @brief This function sets a value in member id - * @param _id New value for member id - */ - eProsima_user_DllExport void id( - uint32_t _id); - - /*! - * @brief This function returns the value of member id - * @return Value of member id - */ - eProsima_user_DllExport uint32_t id() const; - - /*! - * @brief This function returns a reference to member id - * @return Reference to member id - */ - eProsima_user_DllExport uint32_t& id(); - - - /*! - * @brief This function copies the value in member topic - * @param _topic New value to be copied in member topic - */ - eProsima_user_DllExport void topic( - const std::string& _topic); - - /*! - * @brief This function moves the value in member topic - * @param _topic New value to be moved in member topic - */ - eProsima_user_DllExport void topic( - std::string&& _topic); - - /*! - * @brief This function returns a constant reference to member topic - * @return Constant reference to member topic - */ - eProsima_user_DllExport const std::string& topic() const; - - /*! - * @brief This function returns a reference to member topic - * @return Reference to member topic - */ - eProsima_user_DllExport std::string& topic(); - - - /*! - * @brief This function copies the value in member time - * @param _time New value to be copied in member time - */ - eProsima_user_DllExport void time( - const Timestamp& _time); - - /*! - * @brief This function moves the value in member time - * @param _time New value to be moved in member time - */ - eProsima_user_DllExport void time( - Timestamp&& _time); - - /*! - * @brief This function returns a constant reference to member time - * @return Constant reference to member time - */ - eProsima_user_DllExport const Timestamp& time() const; - - /*! - * @brief This function returns a reference to member time - * @return Reference to member time - */ - eProsima_user_DllExport Timestamp& time(); - - - /*! - * @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 MessageDescriptor& 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 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_id; - std::string m_topic; - Timestamp m_time; - -}; - - - -/*! - * @brief This class represents the structure Message defined by the user in the IDL file. - * @ingroup Complete - */ -class Message -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport Message(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~Message(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object Message that will be copied. - */ - eProsima_user_DllExport Message( - const Message& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object Message that will be copied. - */ - eProsima_user_DllExport Message( - Message&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object Message that will be copied. - */ - eProsima_user_DllExport Message& operator =( - const Message& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object Message that will be copied. - */ - eProsima_user_DllExport Message& operator =( - Message&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x Message object to compare. - */ - eProsima_user_DllExport bool operator ==( - const Message& x) const; - - /*! - * @brief Comparison operator. - * @param x Message object to compare. - */ - eProsima_user_DllExport bool operator !=( - const Message& x) const; - - /*! - * @brief This function copies the value in member descriptor - * @param _descriptor New value to be copied in member descriptor - */ - eProsima_user_DllExport void descriptor( - const MessageDescriptor& _descriptor); - - /*! - * @brief This function moves the value in member descriptor - * @param _descriptor New value to be moved in member descriptor - */ - eProsima_user_DllExport void descriptor( - MessageDescriptor&& _descriptor); - - /*! - * @brief This function returns a constant reference to member descriptor - * @return Constant reference to member descriptor - */ - eProsima_user_DllExport const MessageDescriptor& descriptor() const; - - /*! - * @brief This function returns a reference to member descriptor - * @return Reference to member descriptor - */ - eProsima_user_DllExport MessageDescriptor& descriptor(); - - - /*! - * @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 Message& 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 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: - - MessageDescriptor m_descriptor; - std::string m_message; - -}; - - - -/*! - * @brief This class represents the structure CompleteData defined by the user in the IDL file. - * @ingroup Complete - */ -class CompleteData -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport CompleteData(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~CompleteData(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object CompleteData that will be copied. - */ - eProsima_user_DllExport CompleteData( - const CompleteData& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object CompleteData that will be copied. - */ - eProsima_user_DllExport CompleteData( - CompleteData&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object CompleteData that will be copied. - */ - eProsima_user_DllExport CompleteData& operator =( - const CompleteData& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object CompleteData that will be copied. - */ - eProsima_user_DllExport CompleteData& operator =( - CompleteData&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x CompleteData object to compare. - */ - eProsima_user_DllExport bool operator ==( - const CompleteData& x) const; - - /*! - * @brief Comparison operator. - * @param x CompleteData object to compare. - */ - eProsima_user_DllExport bool operator !=( - const CompleteData& 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 main_point - * @param _main_point New value to be copied in member main_point - */ - eProsima_user_DllExport void main_point( - const Point& _main_point); - - /*! - * @brief This function moves the value in member main_point - * @param _main_point New value to be moved in member main_point - */ - eProsima_user_DllExport void main_point( - Point&& _main_point); - - /*! - * @brief This function returns a constant reference to member main_point - * @return Constant reference to member main_point - */ - eProsima_user_DllExport const Point& main_point() const; - - /*! - * @brief This function returns a reference to member main_point - * @return Reference to member main_point - */ - eProsima_user_DllExport Point& main_point(); - - - /*! - * @brief This function copies the value in member internal_data - * @param _internal_data New value to be copied in member internal_data - */ - eProsima_user_DllExport void internal_data( - const std::vector& _internal_data); - - /*! - * @brief This function moves the value in member internal_data - * @param _internal_data New value to be moved in member internal_data - */ - eProsima_user_DllExport void internal_data( - std::vector&& _internal_data); - - /*! - * @brief This function returns a constant reference to member internal_data - * @return Constant reference to member internal_data - */ - eProsima_user_DllExport const std::vector& internal_data() const; - - /*! - * @brief This function returns a reference to member internal_data - * @return Reference to member internal_data - */ - eProsima_user_DllExport std::vector& internal_data(); - - - /*! - * @brief This function copies the value in member messages - * @param _messages New value to be copied in member messages - */ - eProsima_user_DllExport void messages( - const std::array& _messages); - - /*! - * @brief This function moves the value in member messages - * @param _messages New value to be moved in member messages - */ - eProsima_user_DllExport void messages( - std::array&& _messages); - - /*! - * @brief This function returns a constant reference to member messages - * @return Constant reference to member messages - */ - eProsima_user_DllExport const std::array& messages() const; - - /*! - * @brief This function returns a reference to member messages - * @return Reference to member messages - */ - eProsima_user_DllExport std::array& messages(); - - - /*! - * @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 CompleteData& 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 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; - Point m_main_point; - std::vector m_internal_data; - std::array m_messages; - -}; - - -#endif // _FAST_DDS_GENERATED_COMPLETE_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.cxx b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.cxx deleted file mode 100644 index ed390c241..000000000 --- a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.cxx +++ /dev/null @@ -1,170 +0,0 @@ -// 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 HelloWorld.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" - -#if FASTCDR_VERSION_MAJOR > 1 - -#include "HelloWorldTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - - - - -HelloWorld::HelloWorld() -{ - // Just to register all known types - registerHelloWorldTypes(); -} - -HelloWorld::~HelloWorld() -{ -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - m_message = x.m_message; -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - m_message = std::move(x.m_message); -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - - m_index = x.m_index; - m_message = x.m_message; - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - - m_index = x.m_index; - m_message = std::move(x.m_message); - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::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 HelloWorld::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& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& HelloWorld::message() -{ - return m_message; -} - -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" - -#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.cxx b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.cxx deleted file mode 100644 index ff56e98c4..000000000 --- a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.cxx +++ /dev/null @@ -1,265 +0,0 @@ -// 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 HelloWorldTypeObject.cpp - * This source file contains the definition of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // ifdef _WIN32 - -#include "HelloWorld.h" -#include "HelloWorldTypeObject.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace eprosima::fastrtps::rtps; - -void registerHelloWorldTypes() -{ - static std::once_flag once_flag; - std::call_once(once_flag, []() - { - TypeObjectFactory* factory = TypeObjectFactory::get_instance(); - factory->add_type_object("HelloWorld", GetHelloWorldIdentifier(true), - GetHelloWorldObject(true)); - factory->add_type_object("HelloWorld", GetHelloWorldIdentifier(false), - GetHelloWorldObject(false)); - - }); -} - -const TypeIdentifier* GetHelloWorldIdentifier( - bool complete) -{ - const TypeIdentifier* c_identifier = TypeObjectFactory::get_instance()->get_type_identifier("HelloWorld", complete); - if (c_identifier != nullptr && (!complete || c_identifier->_d() == EK_COMPLETE)) - { - return c_identifier; - } - - GetHelloWorldObject(complete); // Generated inside - return TypeObjectFactory::get_instance()->get_type_identifier("HelloWorld", complete); -} - -const TypeObject* GetHelloWorldObject( - bool complete) -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("HelloWorld", complete); - if (c_type_object != nullptr) - { - return c_type_object; - } - else if (complete) - { - return GetCompleteHelloWorldObject(); - } - //else - return GetMinimalHelloWorldObject(); -} - -const TypeObject* GetMinimalHelloWorldObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("HelloWorld", 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); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->minimal().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("HelloWorld", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("HelloWorld", false); -} - -const TypeObject* GetCompleteHelloWorldObject() -{ - const TypeObject* c_type_object = TypeObjectFactory::get_instance()->get_type_object("HelloWorld", 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("HelloWorld"); - // TODO inheritance - TypeIdentifier identifier; - identifier._d(EK_COMPLETE); - - eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1); - size_t current_alignment {0}; - SerializedPayload_t payload(static_cast( - calculator.calculate_serialized_size(type_object->complete().struct_type(), current_alignment) + 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::CdrVersion::XCDRv1); // Object that serializes the data. - payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - ser << *type_object; -#if FASTCDR_VERSION_MAJOR == 1 - payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length -#else - payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length -#endif // FASTCDR_VERSION_MAJOR == 1 - 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("HelloWorld", &identifier, type_object); - delete type_object; - return TypeObjectFactory::get_instance()->get_type_object("HelloWorld", true); -} diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.h b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.h deleted file mode 100644 index 480d05f15..000000000 --- a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.h +++ /dev/null @@ -1,67 +0,0 @@ -// 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 HelloWorldTypeObject.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_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(HelloWorld_SOURCE) -#define HelloWorld_DllAPI __declspec( dllexport ) -#else -#define HelloWorld_DllAPI __declspec( dllimport ) -#endif // HelloWorld_SOURCE -#else -#define HelloWorld_DllAPI -#endif // if defined(EPROSIMA_USER_DLL_EXPORT) -#else -#define HelloWorld_DllAPI -#endif // _WIN32 - -using namespace eprosima::fastrtps::types; - -eProsima_user_DllExport void registerHelloWorldTypes(); - - - -eProsima_user_DllExport const TypeIdentifier* GetHelloWorldIdentifier( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetHelloWorldObject( - bool complete = false); -eProsima_user_DllExport const TypeObject* GetMinimalHelloWorldObject(); -eProsima_user_DllExport const TypeObject* GetCompleteHelloWorldObject(); - - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_H_ \ No newline at end of file diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.cxx b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.cxx deleted file mode 100644 index 745d9517d..000000000 --- a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.cxx +++ /dev/null @@ -1,293 +0,0 @@ -// 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 HelloWorld.cpp - * This source file contains the implementation of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifdef _WIN32 -// Remove linker warning LNK4221 on Visual Studio -namespace { -char dummy; -} // namespace -#endif // _WIN32 - -#include "HelloWorld.h" - -#if FASTCDR_VERSION_MAJOR == 1 - -#include "HelloWorldTypeObject.h" - -#include - - -#include -using namespace eprosima::fastcdr::exception; - -#include - -namespace helper { -namespace internal { - -enum class Size -{ - UInt8, - UInt16, - UInt32, - UInt64, -}; - -constexpr Size get_size( - int s) -{ - return (s <= 8 ) ? Size::UInt8: - (s <= 16) ? Size::UInt16: - (s <= 32) ? Size::UInt32: Size::UInt64; -} - -template -struct FindTypeH; - -template<> -struct FindTypeH -{ - using type = std::uint8_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint16_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint32_t; -}; - -template<> -struct FindTypeH -{ - using type = std::uint64_t; -}; -} // namespace internal - -template -struct FindType -{ - using type = typename internal::FindTypeH::type; -}; -} // namespace helper - -#define HelloWorld_max_cdr_typesize 268ULL; - - - - -HelloWorld::HelloWorld() -{ - // unsigned long m_index - m_index = 0; - // /type_d() m_message - - - // Just to register all known types - registerHelloWorldTypes(); -} - -HelloWorld::~HelloWorld() -{ -} - -HelloWorld::HelloWorld( - const HelloWorld& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - -} - -HelloWorld::HelloWorld( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - -} - -HelloWorld& HelloWorld::operator =( - const HelloWorld& x) -{ - m_index = x.m_index; - - - m_message = x.m_message; - - return *this; -} - -HelloWorld& HelloWorld::operator =( - HelloWorld&& x) noexcept -{ - m_index = x.m_index; - - - m_message = std::move(x.m_message); - - return *this; -} - -bool HelloWorld::operator ==( - const HelloWorld& x) const -{ - return (m_index == x.m_index && - m_message == x.m_message); -} - -bool HelloWorld::operator !=( - const HelloWorld& x) const -{ - return !(*this == x); -} - -size_t HelloWorld::getMaxCdrSerializedSize( - size_t current_alignment) -{ - static_cast(current_alignment); - return HelloWorld_max_cdr_typesize; -} - -size_t HelloWorld::getCdrSerializedSize( - const HelloWorld& 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 HelloWorld::serialize( - eprosima::fastcdr::Cdr& scdr) const -{ - scdr << m_index; - - scdr << m_message.c_str(); - -} - -void HelloWorld::deserialize( - eprosima::fastcdr::Cdr& dcdr) -{ - dcdr >> m_index; - - - - dcdr >> m_message; - - -} - -bool HelloWorld::isKeyDefined() -{ - return false; -} - -void HelloWorld::serializeKey( - eprosima::fastcdr::Cdr& scdr) const -{ - (void) scdr; -} - -/*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ -void HelloWorld::index( - uint32_t _index) -{ - m_index = _index; -} - -/*! - * @brief This function returns the value of member index - * @return Value of member index - */ -uint32_t HelloWorld::index() const -{ - return m_index; -} - -/*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ -uint32_t& HelloWorld::index() -{ - return m_index; -} - -/*! - * @brief This function copies the value in member message - * @param _message New value to be copied in member message - */ -void HelloWorld::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 HelloWorld::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& HelloWorld::message() const -{ - return m_message; -} - -/*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ -std::string& HelloWorld::message() -{ - return m_message; -} - -#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.h b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.h deleted file mode 100644 index aae554340..000000000 --- a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.h +++ /dev/null @@ -1,242 +0,0 @@ -// 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 HelloWorld.h - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#include - -#if FASTCDR_VERSION_MAJOR == 1 - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_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(HELLOWORLD_SOURCE) -#define HELLOWORLD_DllAPI __declspec( dllexport ) -#else -#define HELLOWORLD_DllAPI __declspec( dllimport ) -#endif // HELLOWORLD_SOURCE -#else -#define HELLOWORLD_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HELLOWORLD_DllAPI -#endif // _WIN32 - -namespace eprosima { -namespace fastcdr { -class Cdr; -} // namespace fastcdr -} // namespace eprosima - - - - - -/*! - * @brief This class represents the structure HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorld -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport HelloWorld(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~HelloWorld(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - const HelloWorld& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const; - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator !=( - const HelloWorld& 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 HelloWorld& 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 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_HELLOWORLD_H_ - - - -#endif // FASTCDR_VERSION_MAJOR == 1 From 3bc2971c881d85dac547a19256002143643af049 Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Wed, 26 Jun 2024 09:49:19 +0200 Subject: [PATCH 02/52] Fix compilation after rebase to FastDDS master Signed-off-by: Lucia Echevarria --- .../DdsRecorderCommandPubSubTypes.cxx | 16 +- .../DdsRecorderCommandPubSubTypes.h | 18 +- .../DdsRecorderStatusPubSubTypes.cxx | 16 +- .../DdsRecorderStatusPubSubTypes.h | 18 +- .../cpp/command_receiver/CommandReceiver.cpp | 14 +- .../DdsRecorderCommandPubSubTypes.cxx | 16 +- .../DdsRecorderCommandPubSubTypes.h | 18 +- .../DdsRecorderStatusPubSubTypes.cxx | 16 +- .../DdsRecorderStatusPubSubTypes.h | 18 +- ddsrecorder/test/blackbox/constants.hpp | 2 +- .../blackbox/mcap/McapFileCreationTest.cpp | 144 ++++----- .../test/blackbox/mcap/McapLogErrorTests.cpp | 28 +- .../resource_limits/ResourceLimitsTest.cpp | 19 +- .../hello_world/HelloWorldPubSubTypes.cxx | 16 +- .../types/hello_world/HelloWorldPubSubTypes.h | 18 +- .../DynamicTypesCollectionPubSubTypes.h | 36 +-- .../DdsRecorderMonitoringStatusPubSubTypes.h | 36 +-- .../recorder/mcap/McapHandler.hpp | 2 +- .../recorder/mcap/McapMessage.hpp | 2 +- .../recorder/mcap/McapWriter.hpp | 4 +- .../DynamicTypesCollectionPubSubTypes.cxx | 28 +- ...DdsRecorderMonitoringStatusPubSubTypes.cxx | 28 +- .../src/cpp/recorder/mcap/McapHandler.cpp | 31 +- .../src/cpp/recorder/mcap/McapMessage.cpp | 4 - .../src/cpp/recorder/mcap/McapWriter.cpp | 4 +- .../cpp/replayer/McapReaderParticipant.cpp | 8 +- .../test/unittest/monitoring/constants.hpp | 2 +- ddsreplayer/src/cpp/tool/DdsReplayer.cpp | 20 +- ddsreplayer/test/blackbox/mcap/CMakeLists.txt | 46 ++- .../test/blackbox/mcap/McapFileReadTest.cpp | 57 ++-- .../mcap/McapFileReadWithTypeTest.cpp | 97 ++---- ...pp => ConfigurationDynTypesSubscriber.cpp} | 76 ++--- ...er.h => ConfigurationDynTypesSubscriber.h} | 23 +- ...criber.cpp => ConfigurationSubscriber.cpp} | 39 ++- ...Subscriber.h => ConfigurationSubscriber.h} | 15 +- .../dds/types/configuration/Configuration.hpp | 275 ++++++++++++++++++ .../dds/types/configuration/Configuration.idl | 7 + .../configuration/ConfigurationCdrAux.hpp | 46 +++ .../configuration/ConfigurationCdrAux.ipp | 134 +++++++++ .../ConfigurationPubSubTypes.cxx | 229 +++++++++++++++ .../configuration/ConfigurationPubSubTypes.h | 133 +++++++++ .../ConfigurationTypeObjectSupport.cxx | 233 +++++++++++++++ .../ConfigurationTypeObjectSupport.hpp | 56 ++++ .../hello_world/HelloWorldPubSubTypes.cxx | 16 +- .../types/hello_world/HelloWorldPubSubTypes.h | 18 +- .../HelloWorldPubSubTypes.cxx | 16 +- .../hello_world_basic/HelloWorldPubSubTypes.h | 18 +- ...aml => config_file_begin_time_notype.yaml} | 7 +- .../config_file_begin_time_with_types.yaml | 7 +- ....yaml => config_file_end_time_notype.yaml} | 7 +- .../config_file_end_time_with_types.yaml | 6 +- .../resources/config_file_less_hz_notype.yaml | 12 + ...aml => config_file_less_hz_withtypes.yaml} | 5 +- .../resources/config_file_more_hz_notype.yaml | 12 + ...aml => config_file_more_hz_withtypes.yaml} | 5 +- .../mcap/resources/config_file_notype.yaml | 11 + ...ile_start_replay_time_earlier_notype.yaml} | 5 +- ..._start_replay_time_earlier_with_types.yaml | 5 +- ...g_file.yaml => config_file_withtypes.yaml} | 4 +- .../resources/configuration_withtypes.mcap | Bin 0 -> 2944 bytes .../resources/helloworld_withtype_file.mcap | Bin 2809 -> 0 bytes .../TypeLookupServicePublisher.cpp | 185 ++++++------ .../TypeLookupServicePublisher.h | 4 +- .../TypeLookupServiceSubscriber.cpp | 6 +- .../TypeLookupServiceSubscriber.h | 4 +- .../types/complete/CompletePubSubTypes.cxx | 64 ++-- .../types/complete/CompletePubSubTypes.h | 90 +++--- .../hello_world/HelloWorldPubSubTypes.cxx | 16 +- .../types/hello_world/HelloWorldPubSubTypes.h | 18 +- 69 files changed, 1847 insertions(+), 742 deletions(-) rename ddsreplayer/test/blackbox/mcap/dds/{HelloWorldDynTypesSubscriber.cpp => ConfigurationDynTypesSubscriber.cpp} (79%) rename ddsreplayer/test/blackbox/mcap/dds/{HelloWorldDynTypesSubscriber.h => ConfigurationDynTypesSubscriber.h} (83%) rename ddsreplayer/test/blackbox/mcap/dds/{HelloWorldSubscriber.cpp => ConfigurationSubscriber.cpp} (86%) rename ddsreplayer/test/blackbox/mcap/dds/{HelloWorldSubscriber.h => ConfigurationSubscriber.h} (88%) create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.hpp create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.idl create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.hpp create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.ipp create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.h create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.cxx create mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.hpp rename ddsreplayer/test/blackbox/mcap/resources/{config_file_begin_time.yaml => config_file_begin_time_notype.yaml} (61%) rename ddsreplayer/test/blackbox/mcap/resources/{config_file_end_time.yaml => config_file_end_time_notype.yaml} (61%) create mode 100644 ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_notype.yaml rename ddsreplayer/test/blackbox/mcap/resources/{config_file_less_hz.yaml => config_file_less_hz_withtypes.yaml} (63%) create mode 100644 ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_notype.yaml rename ddsreplayer/test/blackbox/mcap/resources/{config_file_more_hz.yaml => config_file_more_hz_withtypes.yaml} (63%) create mode 100644 ddsreplayer/test/blackbox/mcap/resources/config_file_notype.yaml rename ddsreplayer/test/blackbox/mcap/resources/{config_file_start_replay_time_earlier.yaml => config_file_start_replay_time_earlier_notype.yaml} (74%) rename ddsreplayer/test/blackbox/mcap/resources/{config_file.yaml => config_file_withtypes.yaml} (71%) create mode 100644 ddsreplayer/test/blackbox/mcap/resources/configuration_withtypes.mcap delete mode 100644 ddsreplayer/test/blackbox/mcap/resources/helloworld_withtype_file.mcap diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx index d0ac3c025..f39246e75 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -27,8 +27,8 @@ #include "DdsRecorderCommandCdrAux.hpp" #include "DdsRecorderCommandTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; DdsRecorderCommandPubSubType::DdsRecorderCommandPubSubType() @@ -57,11 +57,11 @@ DdsRecorderCommandPubSubType::~DdsRecorderCommandPubSubType() } bool DdsRecorderCommandPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - DdsRecorderCommand* p_type = static_cast(data); + const DdsRecorderCommand* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool DdsRecorderCommandPubSubType::deserialize( } std::function DdsRecorderCommandPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function DdsRecorderCommandPubSubType::getSerializedSizeProvide eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void DdsRecorderCommandPubSubType::deleteData( } bool DdsRecorderCommandPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool DdsRecorderCommandPubSubType::getKey( return false; } - DdsRecorderCommand* p_type = static_cast(data); + const DdsRecorderCommand* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h index df428fcb8..cd9fadaa2 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h @@ -53,34 +53,34 @@ class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport ~DdsRecorderCommandPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx index 9a4dbdfe6..6f3b01252 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -27,8 +27,8 @@ #include "DdsRecorderStatusCdrAux.hpp" #include "DdsRecorderStatusTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; DdsRecorderStatusPubSubType::DdsRecorderStatusPubSubType() @@ -57,11 +57,11 @@ DdsRecorderStatusPubSubType::~DdsRecorderStatusPubSubType() } bool DdsRecorderStatusPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - DdsRecorderStatus* p_type = static_cast(data); + const DdsRecorderStatus* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool DdsRecorderStatusPubSubType::deserialize( } std::function DdsRecorderStatusPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function DdsRecorderStatusPubSubType::getSerializedSizeProvider eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void DdsRecorderStatusPubSubType::deleteData( } bool DdsRecorderStatusPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool DdsRecorderStatusPubSubType::getKey( return false; } - DdsRecorderStatus* p_type = static_cast(data); + const DdsRecorderStatus* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h index af1c8bd29..1955d866c 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h @@ -53,34 +53,34 @@ class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~DdsRecorderStatusPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; diff --git a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp index 277fd4dc9..2f5434d2a 100644 --- a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp +++ b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp @@ -115,25 +115,25 @@ bool CommandReceiver::init() { case ddspipe::core::types::IgnoreParticipantFlags::no_filter: pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::NO_FILTER; + eprosima::fastdds::rtps::ParticipantFilteringFlags::NO_FILTER; break; case ddspipe::core::types::IgnoreParticipantFlags::filter_different_host: pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_HOST; + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_HOST; break; case ddspipe::core::types::IgnoreParticipantFlags::filter_different_process: pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS; + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_PROCESS; break; case ddspipe::core::types::IgnoreParticipantFlags::filter_same_process: pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_SAME_PROCESS; + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_SAME_PROCESS; break; case ddspipe::core::types::IgnoreParticipantFlags::filter_different_and_same_process: pqos.wire_protocol().builtin.discovery_config.ignoreParticipantFlags = - static_cast( - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS | - eprosima::fastrtps::rtps::ParticipantFilteringFlags_t::FILTER_SAME_PROCESS); + static_cast( + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_DIFFERENT_PROCESS | + eprosima::fastdds::rtps::ParticipantFilteringFlags::FILTER_SAME_PROCESS); break; default: break; diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx index d0ac3c025..f39246e75 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -27,8 +27,8 @@ #include "DdsRecorderCommandCdrAux.hpp" #include "DdsRecorderCommandTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; DdsRecorderCommandPubSubType::DdsRecorderCommandPubSubType() @@ -57,11 +57,11 @@ DdsRecorderCommandPubSubType::~DdsRecorderCommandPubSubType() } bool DdsRecorderCommandPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - DdsRecorderCommand* p_type = static_cast(data); + const DdsRecorderCommand* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool DdsRecorderCommandPubSubType::deserialize( } std::function DdsRecorderCommandPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function DdsRecorderCommandPubSubType::getSerializedSizeProvide eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void DdsRecorderCommandPubSubType::deleteData( } bool DdsRecorderCommandPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool DdsRecorderCommandPubSubType::getKey( return false; } - DdsRecorderCommand* p_type = static_cast(data); + const DdsRecorderCommand* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h index df428fcb8..cd9fadaa2 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h @@ -53,34 +53,34 @@ class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataTyp eProsima_user_DllExport ~DdsRecorderCommandPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx index 9a4dbdfe6..6f3b01252 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -27,8 +27,8 @@ #include "DdsRecorderStatusCdrAux.hpp" #include "DdsRecorderStatusTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; DdsRecorderStatusPubSubType::DdsRecorderStatusPubSubType() @@ -57,11 +57,11 @@ DdsRecorderStatusPubSubType::~DdsRecorderStatusPubSubType() } bool DdsRecorderStatusPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - DdsRecorderStatus* p_type = static_cast(data); + const DdsRecorderStatus* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool DdsRecorderStatusPubSubType::deserialize( } std::function DdsRecorderStatusPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function DdsRecorderStatusPubSubType::getSerializedSizeProvider eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void DdsRecorderStatusPubSubType::deleteData( } bool DdsRecorderStatusPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool DdsRecorderStatusPubSubType::getKey( return false; } - DdsRecorderStatus* p_type = static_cast(data); + const DdsRecorderStatus* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h index af1c8bd29..1955d866c 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h @@ -53,34 +53,34 @@ class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~DdsRecorderStatusPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; diff --git a/ddsrecorder/test/blackbox/constants.hpp b/ddsrecorder/test/blackbox/constants.hpp index d14b5644a..37d42e7c0 100644 --- a/ddsrecorder/test/blackbox/constants.hpp +++ b/ddsrecorder/test/blackbox/constants.hpp @@ -40,7 +40,7 @@ const std::string TOPIC_NAME = "DdsRecorderBlackboxTestTopic"; const ParticipantId PARTICIPANT_ID = "DdsRecorderBlackboxTestParticipant"; // The maximum amount of time (in seconds) to wait for the subscriber to acknowledge messages. -const fastrtps::Duration_t MAX_WAITING_TIME(10); +const fastdds::Duration_t MAX_WAITING_TIME(10); namespace limits { diff --git a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp index 627c1b9b6..3cf4a7255 100644 --- a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp @@ -12,10 +12,24 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include +#include +#include +#include + #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include +#include #include #include @@ -23,29 +37,11 @@ #include -#include -#include -#include -#include -#include -#include -#include - #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include "../../resources/types/hello_world/v1/HelloWorld.h" - #include "../../resources/types/hello_world/v1/HelloWorldPubSubTypes.h" - #include "../../resources/types/hello_world/v1/HelloWorldTypeObject.h" -#else - #include "../../resources/types/hello_world/v2/HelloWorld.h" - #include "../../resources/types/hello_world/v2/HelloWorldPubSubTypes.h" - #include "../../resources/types/hello_world/v2/HelloWorldTypeObject.h" -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - -#include -#include -#include +#include "../../resources/types/hello_world/HelloWorld.hpp" +#include "../../resources/types/hello_world/HelloWorldPubSubTypes.h" +#include "../../resources/types/hello_world/HelloWorldTypeObjectSupport.hpp" using namespace eprosima::ddspipe; using namespace eprosima::ddsrecorder; @@ -86,7 +82,7 @@ const unsigned int index = 6; const unsigned int downsampling = 3; eprosima::fastdds::dds::DataWriter* writer_; -eprosima::fastrtps::types::DynamicType_ptr dynamic_type_; +eprosima::fastdds::dds::traits::ref_type dynamic_type_; } // test @@ -126,24 +122,30 @@ void create_publisher( { eprosima::fastdds::dds::DomainParticipantQos pqos; pqos.name("TypeIntrospectionExample_Participant_Publisher"); - pqos.wire_protocol().builtin.typelookup_config.use_client = false; - pqos.wire_protocol().builtin.typelookup_config.use_server = true; // Create the Participant eprosima::fastdds::dds::DomainParticipant* participant_ = DomainParticipantFactory::get_instance()->create_participant(domain, pqos); // Register the type - registerHelloWorldTypes(); - test::dynamic_type_ = eprosima::fastrtps::types::TypeObjectFactory::get_instance()->build_dynamic_type( - type_name, - GetHelloWorldIdentifier(true), - GetHelloWorldObject(true)); + eprosima::fastdds::dds::TypeSupport type(new HelloWorldPubSubType()); + type->register_type_object_representation(); + + eprosima::fastdds::dds::xtypes::TypeObjectPair dyn_type_objects; + if (eprosima::fastdds::dds::RETCODE_OK != + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_objects( + type_name, + dyn_type_objects)) + { + return; + } + + test::dynamic_type_ = eprosima::fastdds::dds::DynamicTypeBuilderFactory::get_instance()->create_type_w_type_object( + dyn_type_objects.complete_type_object)->build(); - TypeSupport type(new eprosima::fastdds::dds::DynamicPubSubType(test::dynamic_type_)); // Set type so introspection info is sent type->auto_fill_type_information(true); - type->auto_fill_type_object(false); + // Register the type in the Participant participant_->register_type(type); @@ -158,18 +160,24 @@ void create_publisher( test::writer_ = publisher_->create_datawriter(topic_, DATAWRITER_QOS_DEFAULT, nullptr); } -eprosima::fastrtps::types::DynamicData_ptr send_sample( +eprosima::fastdds::dds::traits::ref_type send_sample( const unsigned int index = 1, const unsigned int time_sleep = 100) { // Create and initialize new dynamic data - eprosima::fastrtps::types::DynamicData_ptr dynamic_data_; - dynamic_data_ = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(test::dynamic_type_); + // eprosima::fastdds::dds::traits::ref_type dynamic_data_; + + if (test::dynamic_type_ == nullptr) + { + return nullptr; + } + + auto dynamic_data_ = eprosima::fastdds::dds::DynamicDataFactory::get_instance()->create_data(test::dynamic_type_); // Set index - dynamic_data_->set_uint32_value(index, 0); + dynamic_data_->set_uint32_value(dynamic_data_->get_member_id_by_name("index"), 0); // Set message - dynamic_data_->set_string_value(test::send_message, 1); + dynamic_data_->set_string_value(dynamic_data_->get_member_id_by_name("message"), test::send_message); test::writer_->write(dynamic_data_.get()); logInfo(DDSRECORDER_EXECUTION, "Message published."); @@ -179,19 +187,19 @@ eprosima::fastrtps::types::DynamicData_ptr send_sample( return dynamic_data_; } -eprosima::fastrtps::types::DynamicData_ptr record( +eprosima::fastdds::dds::traits::ref_type record( const std::string file_name, const unsigned int num_msgs = 1, const unsigned int downsampling = 1, const bool ros2_types = false) { - eprosima::fastrtps::types::DynamicData_ptr send_data; + eprosima::fastdds::dds::traits::ref_type send_data; { // Create Recorder auto recorder = create_recorder(file_name, downsampling, DdsRecorderState::RUNNING, 20, ros2_types); // Create Publisher - ros2_types ? create_publisher(test::ros2_topic_name, test::ros2_type_name, test::DOMAIN) : create_publisher( + ros2_types ? create_publisher(test::ros2_topic_name, test::dds_type_name, test::DOMAIN) : create_publisher( test::dds_topic_name, test::dds_type_name, test::DOMAIN); // Send data @@ -315,37 +323,37 @@ std::tuple record_with_transitions( return std::tuple{n_received_msgs, max_timestamp}; } -TEST(McapFileCreationTest, mcap_data_msgs) -{ +// TEST(McapFileCreationTest, mcap_data_msgs) +// { - const std::string file_name = "output_mcap_data_msgs"; - eprosima::fastrtps::types::DynamicData_ptr send_data; - send_data = record(file_name); +// const std::string file_name = "output_mcap_data_msgs"; +// eprosima::fastdds::dds::traits::ref_type send_data; +// send_data = record(file_name); - eprosima::fastdds::dds::DynamicPubSubType pubsubType; - eprosima::fastrtps::rtps::SerializedPayload_t payload; - payload.reserve( - pubsubType.getSerializedSizeProvider( - send_data.get() - )() - ); - pubsubType.serialize(send_data.get(), &payload); +// eprosima::fastdds::dds::DynamicPubSubType pubsubType; +// eprosima::fastdds::rtps::SerializedPayload_t payload; +// payload.reserve( +// pubsubType.getSerializedSizeProvider( +// send_data.get() +// )() +// ); +// pubsubType.serialize(send_data.get(), &payload); - mcap::McapReader mcap_reader; - auto messages = get_msgs_mcap(file_name, mcap_reader); +// mcap::McapReader mcap_reader; +// auto messages = get_msgs_mcap(file_name, mcap_reader); - for (auto it = messages.begin(); it != messages.end(); it++) - { - auto received_msg = reinterpret_cast(it->message.data); - for (unsigned int i = 0; i < payload.length; i++) - { - ASSERT_EQ(payload.data[i], received_msg[i]) << "wrong data !!"; - } - ASSERT_EQ(payload.length, it->message.dataSize) << "length fails !!"; - } - mcap_reader.close(); +// for (auto it = messages.begin(); it != messages.end(); it++) +// { +// auto received_msg = reinterpret_cast(it->message.data); +// for (unsigned int i = 0; i < payload.length; i++) +// { +// ASSERT_EQ(payload.data[i], received_msg[i]) << "wrong data !!"; +// } +// ASSERT_EQ(payload.length, it->message.dataSize) << "length fails !!"; +// } +// mcap_reader.close(); -} +// } TEST(McapFileCreationTest, mcap_dds_topic) { @@ -384,7 +392,7 @@ TEST(McapFileCreationTest, mcap_ros2_topic) auto messages = get_msgs_mcap(file_name, mcap_reader); std::string received_topic = ""; - std::string received_data_type_name = ""; + std::string received_data_type_name = ""; for (auto it = messages.begin(); it != messages.end(); it++) { @@ -395,7 +403,7 @@ TEST(McapFileCreationTest, mcap_ros2_topic) // Test data ASSERT_EQ(received_topic, eprosima::utils::demangle_if_ros_topic(test::ros2_topic_name)); - ASSERT_EQ(received_data_type_name, eprosima::utils::demangle_if_ros_type(test::ros2_type_name)); + ASSERT_EQ(received_data_type_name, test::dds_type_name); } diff --git a/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp b/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp index c46ce394f..8a1cc545b 100644 --- a/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp @@ -14,14 +14,14 @@ #include #include +const int MAX_PENDING_SAMPLES = 1024; const int BUFFER_SIZE = 100; -const int MAX_FILE_SIZE = 1024; -const int MAX_FILE_AGE = 60; -const int MAX_FILE_COUNT = 3600; -const bool AUTO_START = true; -const bool AUTO_STOP = false; -const bool COMPRESS = true; -const bool ENCRYPT = false; +const int EVENT_WINDOW = 60; +const int CLEANUP_PERIOD = 3600; +const bool LOG_PUBLISH_TIME = true; +const bool ONLY_WITH_SCHEMA = false; +const bool RECORD_TYPES = true; +const bool ROS2_TYPES = false; /** * Test case to verify a logError is displayed when the opening mcap file fails @@ -56,15 +56,15 @@ TEST(McapLogErrorTests, fail_to_open_file) { eprosima::ddsrecorder::participants::McapHandlerConfiguration config( output_settings, + MAX_PENDING_SAMPLES, BUFFER_SIZE, - MAX_FILE_SIZE, - MAX_FILE_AGE, - MAX_FILE_COUNT, - AUTO_START, - AUTO_STOP, + EVENT_WINDOW, + CLEANUP_PERIOD, + LOG_PUBLISH_TIME, + ONLY_WITH_SCHEMA, mcap_writer_options, - COMPRESS, - ENCRYPT + RECORD_TYPES, + ROS2_TYPES ); std::shared_ptr payload_pool; diff --git a/ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp b/ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp index b9cf171f1..7ef00b89e 100644 --- a/ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp +++ b/ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp @@ -35,13 +35,8 @@ #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include "../../resources/types/hello_world/v1/HelloWorld.h" - #include "../../resources/types/hello_world/v1/HelloWorldPubSubTypes.h" -#else - #include "../../resources/types/hello_world/v2/HelloWorld.h" - #include "../../resources/types/hello_world/v2/HelloWorldPubSubTypes.h" -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) +#include "../../resources/types/hello_world/HelloWorld.hpp" +#include "../../resources/types/hello_world/HelloWorldPubSubTypes.h" #include "../constants.hpp" @@ -219,7 +214,7 @@ TEST_F(ResourceLimitsTest, max_file_size) publish_msgs_(WAY_TOO_MANY_MSGS); // Make sure the DDS Recorder has received all the messages - ASSERT_EQ(writer_->wait_for_acknowledgments(test::MAX_WAITING_TIME), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(writer_->wait_for_acknowledgments(test::MAX_WAITING_TIME), RETCODE_OK); // All the messages have been sent. Stop the DDS Recorder. recorder.stop(); @@ -266,7 +261,7 @@ TEST_F(ResourceLimitsTest, max_size) publish_msgs_(test::limits::FILE_OVERFLOW_THRESHOLD); // Make sure the DDS Recorder has received all the messages - ASSERT_EQ(writer_->wait_for_acknowledgments(test::MAX_WAITING_TIME), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(writer_->wait_for_acknowledgments(test::MAX_WAITING_TIME), RETCODE_OK); // All the messages have been sent. Stop the DDS Recorder. if (i == test::limits::MAX_FILES - 1) @@ -292,7 +287,7 @@ TEST_F(ResourceLimitsTest, max_size) publish_msgs_(test::limits::FILE_OVERFLOW_THRESHOLD); // Make sure the DDS Recorder has received all the messages - ASSERT_EQ(writer_->wait_for_acknowledgments(test::MAX_WAITING_TIME), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(writer_->wait_for_acknowledgments(test::MAX_WAITING_TIME), RETCODE_OK); // Verify that the DDS Recorder hasn't created an extra file, since it would exceed the max-size ASSERT_FALSE(std::filesystem::exists(OUTPUT_FILE_PATHS[4])); @@ -347,7 +342,7 @@ TEST_F(ResourceLimitsTest, file_rotation) publish_msgs_(test::limits::FILE_OVERFLOW_THRESHOLD); // Make sure the DDS Recorder has received all the messages - ASSERT_EQ(writer_->wait_for_acknowledgments(test::MAX_WAITING_TIME), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(writer_->wait_for_acknowledgments(test::MAX_WAITING_TIME), RETCODE_OK); // Verify that the DDS Recorder has created the expected number of output files for (std::uint32_t j = 0; j <= i; j++) @@ -369,7 +364,7 @@ TEST_F(ResourceLimitsTest, file_rotation) publish_msgs_(test::limits::FILE_OVERFLOW_THRESHOLD); // Make sure the DDS Recorder has received all the messages - ASSERT_EQ(writer_->wait_for_acknowledgments(test::MAX_WAITING_TIME), ReturnCode_t::RETCODE_OK); + ASSERT_EQ(writer_->wait_for_acknowledgments(test::MAX_WAITING_TIME), RETCODE_OK); // Verify that the DDS Recorder has removed the oldest files for (std::uint32_t j = 0; j <= i; j++) diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx index aa161b2e1..41da39407 100644 --- a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx @@ -27,8 +27,8 @@ #include "HelloWorldCdrAux.hpp" #include "HelloWorldTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() @@ -57,11 +57,11 @@ HelloWorldPubSubType::~HelloWorldPubSubType() } bool HelloWorldPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - HelloWorld* p_type = static_cast(data); + const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool HelloWorldPubSubType::deserialize( } std::function HelloWorldPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void HelloWorldPubSubType::deleteData( } bool HelloWorldPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool HelloWorldPubSubType::getKey( return false; } - HelloWorld* p_type = static_cast(data); + const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.h b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.h index 7c83d2b30..3db9ca964 100644 --- a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.h +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.h @@ -53,34 +53,34 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~HelloWorldPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h index c09fa6e58..0d1a3c9a3 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h @@ -59,34 +59,34 @@ namespace eprosima eProsima_user_DllExport ~DynamicTypePubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; @@ -150,34 +150,34 @@ namespace eprosima eProsima_user_DllExport ~DynamicTypesCollectionPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.h index 80f85a4f9..471170f99 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.h +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.h @@ -54,34 +54,34 @@ class DdsRecorderMonitoringErrorStatusPubSubType : public eprosima::fastdds::dds eProsima_user_DllExport ~DdsRecorderMonitoringErrorStatusPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; @@ -145,34 +145,34 @@ class DdsRecorderMonitoringStatusPubSubType : public eprosima::fastdds::dds::Top eProsima_user_DllExport ~DdsRecorderMonitoringStatusPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index 3aa797cd4..11d89f360 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -416,7 +416,7 @@ class McapHandler : public ddspipe::participants::ISchemaHandler * @param [in] dynamic_types Dynamic types collection to be serialized. * @return Serialized payload for the given dynamic types collection. */ - fastrtps::rtps::SerializedPayload_t* serialize_dynamic_types_( + fastdds::rtps::SerializedPayload_t* serialize_dynamic_types_( DynamicTypesCollection& dynamic_types) const; /** diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapMessage.hpp index 1c399a647..726f890fc 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapMessage.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapMessage.hpp @@ -58,7 +58,7 @@ struct McapMessage : public mcap::Message ~McapMessage(); //! Serialized payload - ddspipe::core::types::Payload payload{}; + fastdds::rtps::SerializedPayload_t payload{}; //! Payload owner (reference to \c PayloadPool which created/reserved it) ddspipe::core::PayloadPool* payload_owner{nullptr}; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp index 3848ce7b0..7e89da2ad 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp @@ -95,7 +95,7 @@ class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter * - @throws \c InitializationException if the MCAP library fails to open a new file. */ void update_dynamic_types( - const fastrtps::rtps::SerializedPayload_t& dynamic_types_payload); + const fastdds::rtps::SerializedPayload_t& dynamic_types_payload); /** * @brief Sets the callback to be called when the disk is full. @@ -210,7 +210,7 @@ class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter mcap::McapWriter writer_; // The dynamic types payload to be written as an attachment - std::unique_ptr dynamic_types_payload_; + std::unique_ptr dynamic_types_payload_; // The channels that have been written std::map channels_; diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx index 503bb7a20..56d45e7fc 100644 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx +++ b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx @@ -27,8 +27,8 @@ #include "DynamicTypesCollectionCdrAux.hpp" #include -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; namespace eprosima { @@ -60,11 +60,11 @@ namespace eprosima { } bool DynamicTypePubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - DynamicType* p_type = static_cast(data); + const DynamicType* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -136,7 +136,7 @@ namespace eprosima { } std::function DynamicTypePubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -153,7 +153,7 @@ namespace eprosima { eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -176,7 +176,7 @@ namespace eprosima { } bool DynamicTypePubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -185,7 +185,7 @@ namespace eprosima { return false; } - DynamicType* p_type = static_cast(data); + const DynamicType* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), @@ -253,11 +253,11 @@ namespace eprosima { } bool DynamicTypesCollectionPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - DynamicTypesCollection* p_type = static_cast(data); + const DynamicTypesCollection* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -329,7 +329,7 @@ namespace eprosima { } std::function DynamicTypesCollectionPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -346,7 +346,7 @@ namespace eprosima { eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -369,7 +369,7 @@ namespace eprosima { } bool DynamicTypesCollectionPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -378,7 +378,7 @@ namespace eprosima { return false; } - DynamicTypesCollection* p_type = static_cast(data); + const DynamicTypesCollection* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx index 852aea96d..2d798f5de 100644 --- a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx +++ b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx @@ -27,8 +27,8 @@ #include #include -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; DdsRecorderMonitoringErrorStatusPubSubType::DdsRecorderMonitoringErrorStatusPubSubType() @@ -57,11 +57,11 @@ DdsRecorderMonitoringErrorStatusPubSubType::~DdsRecorderMonitoringErrorStatusPub } bool DdsRecorderMonitoringErrorStatusPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - DdsRecorderMonitoringErrorStatus* p_type = static_cast(data); + const DdsRecorderMonitoringErrorStatus* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool DdsRecorderMonitoringErrorStatusPubSubType::deserialize( } std::function DdsRecorderMonitoringErrorStatusPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function DdsRecorderMonitoringErrorStatusPubSubType::getSeriali eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void DdsRecorderMonitoringErrorStatusPubSubType::deleteData( } bool DdsRecorderMonitoringErrorStatusPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool DdsRecorderMonitoringErrorStatusPubSubType::getKey( return false; } - DdsRecorderMonitoringErrorStatus* p_type = static_cast(data); + const DdsRecorderMonitoringErrorStatus* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), @@ -250,11 +250,11 @@ DdsRecorderMonitoringStatusPubSubType::~DdsRecorderMonitoringStatusPubSubType() } bool DdsRecorderMonitoringStatusPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - DdsRecorderMonitoringStatus* p_type = static_cast(data); + const DdsRecorderMonitoringStatus* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -326,7 +326,7 @@ bool DdsRecorderMonitoringStatusPubSubType::deserialize( } std::function DdsRecorderMonitoringStatusPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -343,7 +343,7 @@ std::function DdsRecorderMonitoringStatusPubSubType::getSerializedSi eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -366,7 +366,7 @@ void DdsRecorderMonitoringStatusPubSubType::deleteData( } bool DdsRecorderMonitoringStatusPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -375,7 +375,7 @@ bool DdsRecorderMonitoringStatusPubSubType::getKey( return false; } - DdsRecorderMonitoringStatus* p_type = static_cast(data); + const DdsRecorderMonitoringStatus* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index ab8c05077..8c3a7a5f5 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -209,15 +209,10 @@ void McapHandler::add_data( if (data.payload.length > 0) { - auto payload_owner = - const_cast((eprosima::fastrtps::rtps::IPayloadPool*)data. - payload_owner); - - if (payload_owner) + if (data.payload_owner != nullptr) { payload_pool_->get_payload( data.payload, - payload_owner, msg.payload); msg.payload_owner = payload_pool_.get(); @@ -922,12 +917,12 @@ void McapHandler::store_dynamic_type_( dynamic_types.dynamic_types().push_back(dynamic_type); } -fastrtps::rtps::SerializedPayload_t* McapHandler::serialize_dynamic_types_( +fastdds::rtps::SerializedPayload_t* McapHandler::serialize_dynamic_types_( DynamicTypesCollection& dynamic_types) const { // Serialize dynamic types collection using CDR fastdds::dds::TypeSupport type_support(new DynamicTypesCollectionPubSubType()); - fastrtps::rtps::SerializedPayload_t* serialized_payload = new fastrtps::rtps::SerializedPayload_t( + fastdds::rtps::SerializedPayload_t* serialized_payload = new fastdds::rtps::SerializedPayload_t( type_support.get_serialized_size_provider(&dynamic_types)()); type_support.serialize(&dynamic_types, serialized_payload); @@ -995,9 +990,9 @@ std::string McapHandler::serialize_type_identifier_( fastcdr::CdrSizeCalculator calculator(fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; size_t size = calculator.calculate_serialized_size(type_identifier, current_alignment) + - fastrtps::rtps::SerializedPayload_t::representation_header_size; + fastdds::rtps::SerializedPayload_t::representation_header_size; - fastrtps::rtps::SerializedPayload_t payload(static_cast(size)); + fastdds::rtps::SerializedPayload_t payload(static_cast(size)); fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); // Create CDR serializer @@ -1012,7 +1007,7 @@ std::string McapHandler::serialize_type_identifier_( size = (ser.get_serialized_data_length() + 3) & ~3; // Create CDR message with payload - fastrtps::rtps::CDRMessage_t* cdr_message = new fastrtps::rtps::CDRMessage_t(payload); + fastdds::rtps::CDRMessage_t* cdr_message = new fastdds::rtps::CDRMessage_t(payload); // Add data if (!(cdr_message && (cdr_message->pos + payload.length <= cdr_message->max_size))|| (payload.length > 0 && !payload.data)) @@ -1026,7 +1021,7 @@ std::string McapHandler::serialize_type_identifier_( cdr_message->length += payload.length; } - fastrtps::rtps::octet value = 0; + fastdds::rtps::octet value = 0; for (uint32_t count = payload.length; count < size; ++count) { const uint32_t size_octet = sizeof(value); @@ -1038,7 +1033,7 @@ std::string McapHandler::serialize_type_identifier_( { for (uint32_t i = 0; i < size_octet; i++) { - cdr_message->buffer[cdr_message->pos + i] = *((fastrtps::rtps::octet*)&value + size_octet - 1 - i); + cdr_message->buffer[cdr_message->pos + i] = *((fastdds::rtps::octet*)&value + size_octet - 1 - i); } cdr_message->pos += size_octet; cdr_message->length += size_octet; @@ -1063,8 +1058,8 @@ std::string McapHandler::serialize_type_object_( fastcdr::CdrSizeCalculator calculator(fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; size_t size = calculator.calculate_serialized_size(type_object, current_alignment) + - fastrtps::rtps::SerializedPayload_t::representation_header_size; - fastrtps::rtps::SerializedPayload_t payload(static_cast(size)); + fastdds::rtps::SerializedPayload_t::representation_header_size; + fastdds::rtps::SerializedPayload_t payload(static_cast(size)); fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); // Create CDR serializer @@ -1078,7 +1073,7 @@ std::string McapHandler::serialize_type_object_( size = (ser.get_serialized_data_length() + 3) & ~3; // Create CDR message with payload - fastrtps::rtps::CDRMessage_t* cdr_message = new fastrtps::rtps::CDRMessage_t(payload); + fastdds::rtps::CDRMessage_t* cdr_message = new fastdds::rtps::CDRMessage_t(payload); // Add data if (!(cdr_message && (cdr_message->pos + payload.length <= cdr_message->max_size))|| (payload.length > 0 && !payload.data)) @@ -1092,7 +1087,7 @@ std::string McapHandler::serialize_type_object_( cdr_message->length += payload.length; } - fastrtps::rtps::octet value = 0; + fastdds::rtps::octet value = 0; for (uint32_t count = payload.length; count < size; ++count) { const uint32_t size_octet = sizeof(value); @@ -1104,7 +1099,7 @@ std::string McapHandler::serialize_type_object_( { for (uint32_t i = 0; i < size_octet; i++) { - cdr_message->buffer[cdr_message->pos + i] = *((fastrtps::rtps::octet*)&value + size_octet - 1 - i); + cdr_message->buffer[cdr_message->pos + i] = *((fastdds::rtps::octet*)&value + size_octet - 1 - i); } cdr_message->pos += size_octet; cdr_message->length += size_octet; diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp index 916617a8a..afcf758db 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp @@ -29,13 +29,9 @@ McapMessage::McapMessage( const McapMessage& msg) : mcap::Message(msg) { - auto ipayload_owner = const_cast( - static_cast(msg.payload_owner)); - payload_owner = msg.payload_owner; payload_owner->get_payload( msg.payload, - ipayload_owner, this->payload); } diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp index 6d24e07a6..d9ad8144e 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp @@ -102,7 +102,7 @@ void McapWriter::disable() } void McapWriter::update_dynamic_types( - const fastrtps::rtps::SerializedPayload_t& dynamic_types_payload) + const fastdds::rtps::SerializedPayload_t& dynamic_types_payload) { std::lock_guard lock(mutex_); @@ -146,7 +146,7 @@ void McapWriter::update_dynamic_types( } } - dynamic_types_payload_.reset(const_cast(&dynamic_types_payload)); + dynamic_types_payload_.reset(const_cast(&dynamic_types_payload)); file_tracker_->set_current_file_size(size_tracker_.get_potential_mcap_size()); } diff --git a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp index 02643e03b..94344cf76 100644 --- a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp @@ -18,6 +18,8 @@ #include +#include + #include #include #include @@ -183,9 +185,7 @@ void McapReaderParticipant::process_mcap() mcap_payload.data = (unsigned char*)reinterpret_cast(it->message.data); // Copy payload from MCAP file to RTPS data through payload pool - eprosima::fastrtps::rtps::IPayloadPool* null_payload_pool = nullptr; - payload_pool_->get_payload(mcap_payload, null_payload_pool, data->payload); // this reserves and copies payload - data->payload_owner = payload_pool_.get(); + payload_pool_->get_payload(mcap_payload, data->payload); // this reserves and copies payload mcap_payload.data = nullptr; // Set to nullptr after copy to avoid free on destruction // Set publication delay from original log time and configured playback rate @@ -196,7 +196,7 @@ void McapReaderParticipant::process_mcap() // Set source timestamp // NOTE: this is important for QoS such as LifespanQosPolicy data->source_timestamp = - fastrtps::rtps::Time_t(std::chrono::duration_cast(scheduled_write_ts + fastdds::rtps::Time_t(std::chrono::duration_cast(scheduled_write_ts .time_since_epoch()).count() / 1e9); // Create topic on which this message should be published diff --git a/ddsrecorder_participants/test/unittest/monitoring/constants.hpp b/ddsrecorder_participants/test/unittest/monitoring/constants.hpp index 4d8e702a6..a7579eb97 100644 --- a/ddsrecorder_participants/test/unittest/monitoring/constants.hpp +++ b/ddsrecorder_participants/test/unittest/monitoring/constants.hpp @@ -37,7 +37,7 @@ constexpr std::uint32_t PERIOD_MS = 500; constexpr double PERIOD_SECS = (double) PERIOD_MS / 1000; // Maximum time to wait for a sample to arrive. -const auto MAX_WAITING_TIME = fastrtps::Duration_t(PERIOD_SECS * 3); +const auto MAX_WAITING_TIME = fastdds::Duration_t(PERIOD_SECS * 3); // The domain and topic the Monitor should publish its data in. constexpr DomainIdType DOMAIN = 84; diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index 81268cbb6..229308fd3 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -210,8 +210,8 @@ std::set> DdsReplayer::generate_builtin_topic // Deserialize dynamic types collection using CDR DynamicTypesCollection dynamic_types; eprosima::fastdds::dds::TypeSupport type_support(new DynamicTypesCollectionPubSubType()); - eprosima::fastrtps::rtps::SerializedPayload_t serialized_payload = - eprosima::fastrtps::rtps::SerializedPayload_t(dynamic_attachment.dataSize); + eprosima::fastdds::rtps::SerializedPayload_t serialized_payload = + eprosima::fastdds::rtps::SerializedPayload_t(dynamic_attachment.dataSize); serialized_payload.length = dynamic_attachment.dataSize; std::memcpy( serialized_payload.data, @@ -351,18 +351,18 @@ fastdds::dds::xtypes::TypeIdentifier DdsReplayer::deserialize_type_identifier_( { // Create CDR message from string // NOTE: Use 0 length to avoid allocation - fastrtps::rtps::CDRMessage_t* cdr_message = new fastrtps::rtps::CDRMessage_t(0); + fastdds::rtps::CDRMessage_t* cdr_message = new fastdds::rtps::CDRMessage_t(0); cdr_message->buffer = (unsigned char*)reinterpret_cast(typeid_str.c_str()); cdr_message->length = typeid_str.length(); #if __BIG_ENDIAN__ - cdr_message->msg_endian = fastrtps::rtps::BIGEND; + cdr_message->msg_endian = fastdds::rtps::BIGEND; #else - cdr_message->msg_endian = fastrtps::rtps::LITTLEEND; + cdr_message->msg_endian = fastdds::rtps::LITTLEEND; #endif // if __BIG_ENDIAN__ // Reserve payload and create buffer const auto parameter_length = cdr_message->length; - fastrtps::rtps::SerializedPayload_t payload(parameter_length); + fastdds::rtps::SerializedPayload_t payload(parameter_length); fastcdr::FastBuffer fastbuffer((char*)payload.data, parameter_length); // Read data @@ -402,18 +402,18 @@ fastdds::dds::xtypes::TypeObject DdsReplayer::deserialize_type_object_( { // Create CDR message from string // NOTE: Use 0 length to avoid allocation - fastrtps::rtps::CDRMessage_t* cdr_message = new fastrtps::rtps::CDRMessage_t(0); + fastdds::rtps::CDRMessage_t* cdr_message = new fastdds::rtps::CDRMessage_t(0); cdr_message->buffer = (unsigned char*)reinterpret_cast(typeobj_str.c_str()); cdr_message->length = typeobj_str.length(); #if __BIG_ENDIAN__ - cdr_message->msg_endian = fastrtps::rtps::BIGEND; + cdr_message->msg_endian = fastdds::rtps::BIGEND; #else - cdr_message->msg_endian = fastrtps::rtps::LITTLEEND; + cdr_message->msg_endian = fastdds::rtps::LITTLEEND; #endif // if __BIG_ENDIAN__ // Reserve payload and create buffer const auto parameter_length = cdr_message->length; - fastrtps::rtps::SerializedPayload_t payload(parameter_length); + fastdds::rtps::SerializedPayload_t payload(parameter_length); fastcdr::FastBuffer fastbuffer((char*)payload.data, parameter_length); // Read data diff --git a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt index 20c5e2c09..f65e65bf1 100644 --- a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt +++ b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt @@ -20,11 +20,11 @@ set(TEST_NAME McapFileReadTest) set(TEST_SOURCES McapFileReadTest.cpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorld.hpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp - ) + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/Configuration.hpp + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp +) set(TEST_LIST trivial @@ -37,13 +37,13 @@ set(TEST_LIST ) set(TEST_NEEDED_SOURCES - resources/helloworld_file.mcap - resources/config_file.yaml - resources/config_file_less_hz.yaml - resources/config_file_more_hz.yaml - resources/config_file_begin_time.yaml - resources/config_file_end_time.yaml - resources/config_file_start_replay_time_earlier.yaml + resources/configuration_withtypes.mcap + resources/config_file_notype.yaml + resources/config_file_less_hz_notype.yaml + resources/config_file_more_hz_notype.yaml + resources/config_file_begin_time_notype.yaml + resources/config_file_end_time_notype.yaml + resources/config_file_start_replay_time_earlier_notype.yaml ) set(TEST_EXTRA_HEADERS @@ -65,32 +65,28 @@ set(TEST_NAME McapFileReadWithTypeTest) set(TEST_SOURCES McapFileReadWithTypeTest.cpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.hpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.cpp + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/Configuration.hpp + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp ) set(TEST_LIST trivial dds_data_to_check - ros2_data_to_check dds_less_playback_rate - ros2_less_playback_rate dds_more_playback_rate - ros2_more_playback_rate begin_time end_time start_replay_time_earlier ) set(TEST_NEEDED_SOURCES - resources/helloworld_withtype_file.mcap - resources/ros2_file.mcap - resources/config_file.yaml - resources/config_file_less_hz.yaml - resources/config_file_more_hz.yaml + resources/configuration_withtypes.mcap + resources/config_file_withtypes.yaml + resources/config_file_less_hz_withtypes.yaml + resources/config_file_more_hz_withtypes.yaml resources/config_file_begin_time_with_types.yaml resources/config_file_end_time_with_types.yaml resources/config_file_start_replay_time_earlier_with_types.yaml diff --git a/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp b/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp index 981e1c0a8..6afc2b390 100644 --- a/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp +++ b/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp @@ -17,7 +17,7 @@ #include #include -#include "dds/HelloWorldSubscriber.h" +#include "dds/ConfigurationSubscriber.h" #include "tool/DdsReplayer.hpp" @@ -26,8 +26,8 @@ #include using namespace eprosima::fastdds::dds; -using namespace eprosima::fastrtps::rtps; -using namespace eprosima::fastrtps; +using namespace eprosima::fastdds::rtps; +using namespace eprosima::fastdds; using namespace eprosima::ddsrecorder::replayer; namespace test { @@ -36,19 +36,19 @@ namespace test { const unsigned int DOMAIN = 110; -const std::string topic_name = "/dds/topic"; +const std::string topic_name = "configuration_topic"; } // test void create_subscriber_replayer( DataToCheck& data, - const std::string& configuration_path = "resources/config_file.yaml", - std::string input_file = "resources/helloworld_file.mcap") + const std::string& configuration_path = "resources/config_file_notype.yaml", + std::string input_file = "resources/configuration_withtypes.mcap") { { // Create Subscriber - HelloWorldSubscriber subscriber( + ConfigurationSubscriber subscriber( test::topic_name, static_cast(test::DOMAIN), data); @@ -110,46 +110,45 @@ TEST(McapFileReadTest, dds_data_to_check) // info to check DataToCheck data; create_subscriber_replayer(data); - ASSERT_EQ(data.n_received_msgs, 11); - ASSERT_EQ(data.type_msg, "HelloWorld"); - ASSERT_EQ(data.message_msg, "Hello World"); - ASSERT_EQ(data.min_index_msg, 0); + ASSERT_EQ(data.n_received_msgs, 10); + ASSERT_EQ(data.type_msg, "Configuration"); + ASSERT_EQ(data.min_index_msg, 1); ASSERT_EQ(data.max_index_msg, 10); // ms ~ 200 - ASSERT_GT(data.mean_ms_between_msgs, 197.5); - ASSERT_LT(data.mean_ms_between_msgs, 202.5); + ASSERT_GT(data.mean_ms_between_msgs, 1197.5); + ASSERT_LT(data.mean_ms_between_msgs, 1202.5); } TEST(McapFileReadTest, more_playback_rate) { // info to check DataToCheck data; - const std::string configuration = "resources/config_file_more_hz.yaml"; + const std::string configuration = "resources/config_file_more_hz_notype.yaml"; create_subscriber_replayer(data, configuration); // ms ~ 100 - ASSERT_GT(data.mean_ms_between_msgs, 97.5); - ASSERT_LT(data.mean_ms_between_msgs, 102.5); + ASSERT_GT(data.mean_ms_between_msgs, 597.5); + ASSERT_LT(data.mean_ms_between_msgs, 602.5); } TEST(McapFileReadTest, less_playback_rate) { // info to check DataToCheck data; - const std::string configuration = "resources/config_file_less_hz.yaml"; + const std::string configuration = "resources/config_file_less_hz_notype.yaml"; create_subscriber_replayer(data, configuration); // ms ~ 400 - ASSERT_GT(data.mean_ms_between_msgs, 397.5); - ASSERT_LT(data.mean_ms_between_msgs, 402.5); + ASSERT_GT(data.mean_ms_between_msgs, 2397.5); + ASSERT_LT(data.mean_ms_between_msgs, 2403.5); } TEST(McapFileReadTest, begin_time) { // info to check DataToCheck data; - const std::string configuration = "resources/config_file_begin_time.yaml"; + const std::string configuration = "resources/config_file_begin_time_notype.yaml"; create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 3); - ASSERT_EQ(data.min_index_msg, 8); + ASSERT_EQ(data.n_received_msgs, 7); + ASSERT_EQ(data.min_index_msg, 4); ASSERT_EQ(data.max_index_msg, 10); } @@ -157,21 +156,21 @@ TEST(McapFileReadTest, end_time) { // info to check DataToCheck data; - const std::string configuration = "resources/config_file_end_time.yaml"; + const std::string configuration = "resources/config_file_end_time_notype.yaml"; create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 8); - ASSERT_EQ(data.min_index_msg, 0); - ASSERT_EQ(data.max_index_msg, 7); + ASSERT_EQ(data.n_received_msgs, 3); + ASSERT_EQ(data.min_index_msg, 1); + ASSERT_EQ(data.max_index_msg, 3); } TEST(McapFileReadTest, start_replay_time_earlier) { // info to check DataToCheck data; - const std::string configuration = "resources/config_file_start_replay_time_earlier.yaml"; + const std::string configuration = "resources/config_file_start_replay_time_earlier_notype.yaml"; create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 11); - ASSERT_EQ(data.min_index_msg, 0); + ASSERT_EQ(data.n_received_msgs, 10); + ASSERT_EQ(data.min_index_msg, 1); ASSERT_EQ(data.max_index_msg, 10); } diff --git a/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp b/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp index 1b4de3942..932a0121c 100644 --- a/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp +++ b/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp @@ -15,7 +15,7 @@ #include #include -#include "dds/HelloWorldDynTypesSubscriber.h" +#include "dds/ConfigurationDynTypesSubscriber.h" #include "tool/DdsReplayer.hpp" @@ -24,8 +24,8 @@ #include using namespace eprosima::fastdds::dds; -using namespace eprosima::fastrtps::rtps; -using namespace eprosima::fastrtps; +using namespace eprosima::fastdds::rtps; +using namespace eprosima::fastdds; using namespace eprosima::ddsrecorder::replayer; namespace test { @@ -34,10 +34,10 @@ namespace test { const unsigned int DOMAIN = 110; -const std::string dds_topic_name = "/dds/topic"; +const std::string dds_topic_name = "configuration_topic"; const std::string ros2_topic_name = "rt/topic"; -const std::string dds_type_name = "HelloWorld"; +const std::string dds_type_name = "Configuration"; const std::string ros2_type_name = "std_msgs::msg::dds_::String_"; @@ -54,15 +54,15 @@ const std::string ros2_type_name = "std_msgs::msg::dds_::String_"; */ void create_subscriber_replayer( DataToCheck& data, - const std::string& configuration_path = "resources/config_file.yaml", - std::string input_file = "resources/helloworld_withtype_file.mcap", + const std::string& configuration_path = "resources/config_file_withtypes.yaml", + std::string input_file = "resources/configuration_withtypes.mcap", bool ros2 = false) { { std::string topic_name = ros2 ? test::ros2_topic_name : test::dds_topic_name; // Create Subscriber - HelloWorldDynTypesSubscriber subscriber( + ConfigurationDynTypesSubscriber subscriber( topic_name, static_cast(test::DOMAIN), data); @@ -122,75 +122,36 @@ TEST(McapFileReadWithTypeTest, dds_data_to_check) // info to check DataToCheck data; create_subscriber_replayer(data); - ASSERT_EQ(data.n_received_msgs, 13); + ASSERT_EQ(data.n_received_msgs, 10); ASSERT_EQ(data.type_msg, test::dds_type_name); - ASSERT_EQ(data.message_msg, "Hello World"); - ASSERT_EQ(data.min_index_msg, 0); - ASSERT_EQ(data.max_index_msg, 12); + // ASSERT_EQ(data.message_msg, "Configuration"); + ASSERT_EQ(data.min_index_msg, 1); + ASSERT_EQ(data.max_index_msg, 10); // ms ~ 200 - ASSERT_GT(data.mean_ms_between_msgs, 197.5); - ASSERT_LT(data.mean_ms_between_msgs, 202.5); -} - -TEST(McapFileReadWithTypeTest, ros2_data_to_check) -{ - // info to check - DataToCheck data; - const std::string ros2_mcap = "resources/ros2_file.mcap"; - create_subscriber_replayer(data, "resources/config_file.yaml", ros2_mcap, true); - ASSERT_EQ(data.n_received_msgs, 17); - ASSERT_EQ(data.type_msg, test::ros2_type_name); - const std::regex base_regex("Hello, world! \\d*"); - ASSERT_TRUE(std::regex_match(data.message_msg, base_regex)); - // ms ~ 500 - ASSERT_GT(data.mean_ms_between_msgs, 497.5); - ASSERT_LT(data.mean_ms_between_msgs, 502.5); + ASSERT_GT(data.mean_ms_between_msgs, 1197.5); + ASSERT_LT(data.mean_ms_between_msgs, 1202.5); } TEST(McapFileReadWithTypeTest, dds_more_playback_rate) { // info to check DataToCheck data; - const std::string configuration = "resources/config_file_more_hz.yaml"; + const std::string configuration = "resources/config_file_more_hz_withtypes.yaml"; create_subscriber_replayer(data, configuration); // ms ~ 100 - ASSERT_GT(data.mean_ms_between_msgs, 97.5); - ASSERT_LT(data.mean_ms_between_msgs, 102.5); -} - -TEST(McapFileReadWithTypeTest, ros2_more_playback_rate) -{ - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_more_hz.yaml"; - const std::string ros2_mcap = "resources/ros2_file.mcap"; - create_subscriber_replayer(data, configuration, ros2_mcap, true); - // ms ~ 250 - ASSERT_GT(data.mean_ms_between_msgs, 247.5); - ASSERT_LT(data.mean_ms_between_msgs, 252.5); + ASSERT_GT(data.mean_ms_between_msgs, 597.5); + ASSERT_LT(data.mean_ms_between_msgs, 602.5); } TEST(McapFileReadWithTypeTest, dds_less_playback_rate) { // info to check DataToCheck data; - const std::string configuration = "resources/config_file_less_hz.yaml"; + const std::string configuration = "resources/config_file_less_hz_withtypes.yaml"; create_subscriber_replayer(data, configuration); // ms ~ 400 - ASSERT_GT(data.mean_ms_between_msgs, 397.5); - ASSERT_LT(data.mean_ms_between_msgs, 402.5); -} - -TEST(McapFileReadWithTypeTest, ros2_less_playback_rate) -{ - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_less_hz.yaml"; - const std::string ros2_mcap = "resources/ros2_file.mcap"; - create_subscriber_replayer(data, configuration, ros2_mcap, true); - // ms ~ 1000 - ASSERT_GT(data.mean_ms_between_msgs, 997.5); - ASSERT_LT(data.mean_ms_between_msgs, 1002.5); + ASSERT_GT(data.mean_ms_between_msgs, 2397.5); + ASSERT_LT(data.mean_ms_between_msgs, 2403.5); } TEST(McapFileReadWithTypeTest, begin_time) @@ -199,9 +160,9 @@ TEST(McapFileReadWithTypeTest, begin_time) DataToCheck data; const std::string configuration = "resources/config_file_begin_time_with_types.yaml"; create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 6); - ASSERT_EQ(data.min_index_msg, 7); - ASSERT_EQ(data.max_index_msg, 12); + ASSERT_EQ(data.n_received_msgs, 7); + ASSERT_EQ(data.min_index_msg, 4); + ASSERT_EQ(data.max_index_msg, 10); } TEST(McapFileReadWithTypeTest, end_time) @@ -210,9 +171,9 @@ TEST(McapFileReadWithTypeTest, end_time) DataToCheck data; const std::string configuration = "resources/config_file_end_time_with_types.yaml"; create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 7); - ASSERT_EQ(data.min_index_msg, 0); - ASSERT_EQ(data.max_index_msg, 6); + ASSERT_EQ(data.n_received_msgs, 3); + ASSERT_EQ(data.min_index_msg, 1); + ASSERT_EQ(data.max_index_msg, 3); } TEST(McapFileReadWithTypeTest, start_replay_time_earlier) @@ -221,9 +182,9 @@ TEST(McapFileReadWithTypeTest, start_replay_time_earlier) DataToCheck data; const std::string configuration = "resources/config_file_start_replay_time_earlier_with_types.yaml"; create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 13); - ASSERT_EQ(data.min_index_msg, 0); - ASSERT_EQ(data.max_index_msg, 12); + ASSERT_EQ(data.n_received_msgs, 10); + ASSERT_EQ(data.min_index_msg, 1); + ASSERT_EQ(data.max_index_msg, 10); } int main( diff --git a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.cpp b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp similarity index 79% rename from ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.cpp rename to ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp index 3510e0bfc..93b5e25c4 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.cpp +++ b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file HelloWorldDynTypesSubscriber.cpp + * @file ConfigurationDynTypesSubscriber.cpp * */ @@ -31,20 +31,20 @@ #include #include #include -#include +// #include #include -#include "HelloWorldDynTypesSubscriber.h" +#include "ConfigurationDynTypesSubscriber.h" using namespace eprosima; using namespace fastdds::dds; -std::atomic HelloWorldDynTypesSubscriber::type_discovered_(false); -std::atomic HelloWorldDynTypesSubscriber::type_registered_(false); -std::mutex HelloWorldDynTypesSubscriber::type_discovered_cv_mtx_; -std::condition_variable HelloWorldDynTypesSubscriber::type_discovered_cv_; +std::atomic ConfigurationDynTypesSubscriber::type_discovered_(false); +std::atomic ConfigurationDynTypesSubscriber::type_registered_(false); +std::mutex ConfigurationDynTypesSubscriber::type_discovered_cv_mtx_; +std::condition_variable ConfigurationDynTypesSubscriber::type_discovered_cv_; -HelloWorldDynTypesSubscriber::HelloWorldDynTypesSubscriber( +ConfigurationDynTypesSubscriber::ConfigurationDynTypesSubscriber( const std::string& topic_name, uint32_t domain, DataToCheck& data) @@ -60,10 +60,7 @@ HelloWorldDynTypesSubscriber::HelloWorldDynTypesSubscriber( /////////////////////////////// // Create the DomainParticipant DomainParticipantQos pqos; - pqos.name("HelloWorldDynTypes_Subscriber"); - - // pqos.wire_protocol().builtin.typelookup_config.use_client = true; - // pqos.wire_protocol().builtin.typelookup_config.use_server = false; + pqos.name("ConfigurationDynTypes_Subscriber"); // Create listener mask so the data do not go to on_data_on_readers from subscriber StatusMask mask; @@ -88,7 +85,7 @@ HelloWorldDynTypesSubscriber::HelloWorldDynTypesSubscriber( } } -HelloWorldDynTypesSubscriber::~HelloWorldDynTypesSubscriber() +ConfigurationDynTypesSubscriber::~ConfigurationDynTypesSubscriber() { if (participant_ != nullptr) { @@ -108,7 +105,7 @@ HelloWorldDynTypesSubscriber::~HelloWorldDynTypesSubscriber() } } -void HelloWorldDynTypesSubscriber::on_subscription_matched( +void ConfigurationDynTypesSubscriber::on_subscription_matched( DataReader*, const SubscriptionMatchedStatus& info) { @@ -127,7 +124,7 @@ void HelloWorldDynTypesSubscriber::on_subscription_matched( } } -void HelloWorldDynTypesSubscriber::on_data_available( +void ConfigurationDynTypesSubscriber::on_data_available( DataReader* reader) { // Dynamic DataType @@ -146,39 +143,31 @@ void HelloWorldDynTypesSubscriber::on_data_available( samples_++; - if (dynamic_type_->get_name() == "std_msgs::msg::dds_::String_") - { - std::string message = "HelloWorld"; - // new_data->get_string_value(message, new_data->get_member_id_by_name("index")); - - fill_info(static_cast(0), message, current_time); - } - else if (dynamic_type_->get_name() == "HelloWorld") + if (dynamic_type_->get_name() == "Configuration") { uint32_t index; + char message; new_data->get_uint32_value(index, new_data->get_member_id_by_name("index")); - std::string message = "HelloWorld"; - // new_data->get_string_value(message, new_data->get_member_id_by_name("message")); - fill_info(static_cast(index), message, current_time); - } + fill_info(static_cast(index), current_time); - std::cout << "Message " << samples_ << " received:\n" << std::endl; - std::stringstream ss; - ss << std::setw(4); - auto ret = fastdds::dds::json_serialize(new_data, ss, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); - std::cout << ss.str() << std::endl; - std::cout << "-----------------------------------------------------" << std::endl; + std::cout << "Message " << samples_ << " received:\n" << std::endl; + std::stringstream ss; + ss << std::setw(4); + // auto ret = fastdds::dds::json_serialize(new_data, ss, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + std::cout << ss.str() << std::endl; + std::cout << "-----------------------------------------------------" << std::endl; + } } } } -void HelloWorldDynTypesSubscriber::on_data_writer_discovery( +void ConfigurationDynTypesSubscriber::on_data_writer_discovery( fastdds::dds::DomainParticipant*, - fastrtps::rtps::WriterDiscoveryInfo&& info, + fastdds::rtps::WriterDiscoveryInfo&& info, bool&) { - fastrtps::rtps::WriterProxyData proxy_copy(info.info); + fastdds::rtps::WriterProxyData proxy_copy(info.info); // Get type information const auto type_info = proxy_copy.type_information().type_information; @@ -188,7 +177,7 @@ void HelloWorldDynTypesSubscriber::on_data_writer_discovery( notify_type_discovered_(type_info, type_name, topic_name); } -void HelloWorldDynTypesSubscriber::notify_type_discovered_( +void ConfigurationDynTypesSubscriber::notify_type_discovered_( const fastdds::dds::xtypes::TypeInformation& type_info, const fastcdr::string_255& type_name, const fastcdr::string_255& topic_name) @@ -235,7 +224,7 @@ void HelloWorldDynTypesSubscriber::notify_type_discovered_( register_remote_type_callback_(type_name_, dyn_type); } -void HelloWorldDynTypesSubscriber::register_remote_type_callback_( +void ConfigurationDynTypesSubscriber::register_remote_type_callback_( const std::string&, const fastdds::dds::traits::ref_type dynamic_type) { @@ -278,7 +267,7 @@ void HelloWorldDynTypesSubscriber::register_remote_type_callback_( " > with data type < " << dynamic_type->get_name() << " > " << std::endl; - // Update HelloWorldDynTypesSubscriber members + // Update ConfigurationDynTypesSubscriber members dynamic_type_ = dynamic_type; type_discovered_.store(true); type_registered_.store(true); @@ -286,26 +275,25 @@ void HelloWorldDynTypesSubscriber::register_remote_type_callback_( type_discovered_cv_.notify_all(); } -void HelloWorldDynTypesSubscriber::init_info( +void ConfigurationDynTypesSubscriber::init_info( const std::string& type_name) { data_->n_received_msgs = 0; data_->type_msg = type_name; - data_->message_msg = ""; + // data_->message_msg = ""; data_->min_index_msg = -1; data_->max_index_msg = -1; data_->cummulated_ms_between_msgs = -1; data_->mean_ms_between_msgs = -1; } -void HelloWorldDynTypesSubscriber::fill_info( +void ConfigurationDynTypesSubscriber::fill_info( int index, - const std::string& message, uint64_t time_arrive_msg) { data_->n_received_msgs++; - data_->message_msg = message; + if (data_->min_index_msg == -1 || data_->min_index_msg > index) { data_->min_index_msg = index; diff --git a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.h b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.h similarity index 83% rename from ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.h rename to ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.h index 726372048..ab04e38fc 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldDynTypesSubscriber.h +++ b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.h @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file HelloWorldDynTypesSubscriber.h + * @file ConfigurationDynTypesSubscriber.h * */ @@ -32,13 +32,12 @@ #include #include -#include "types/hello_world_basic/HelloWorldPubSubTypes.h" +#include "types/configuration/ConfigurationPubSubTypes.h" struct DataToCheck { unsigned int n_received_msgs; std::string type_msg; - std::string message_msg; int min_index_msg; int max_index_msg; double mean_ms_between_msgs; @@ -49,7 +48,7 @@ struct DataToCheck * @brief Class used to group into a single working unit a Subscriber with a DataReader and its listener. * */ -class HelloWorldDynTypesSubscriber : public eprosima::fastdds::dds::DomainParticipantListener +class ConfigurationDynTypesSubscriber : public eprosima::fastdds::dds::DomainParticipantListener { public: @@ -59,7 +58,7 @@ class HelloWorldDynTypesSubscriber : public eprosima::fastdds::dds::DomainPartic * @param topic_name Name of the DDS Topic * @param domain DDS Domain of the DomainParticipant */ - HelloWorldDynTypesSubscriber( + ConfigurationDynTypesSubscriber( const std::string& topic_name, uint32_t domain, DataToCheck& data); @@ -68,7 +67,7 @@ class HelloWorldDynTypesSubscriber : public eprosima::fastdds::dds::DomainPartic * @brief Destroy the Type Lookup Service Publisher object * */ - virtual ~HelloWorldDynTypesSubscriber(); + virtual ~ConfigurationDynTypesSubscriber(); //! DataReader callback executed when a new sample is received void on_data_available( @@ -82,22 +81,14 @@ class HelloWorldDynTypesSubscriber : public eprosima::fastdds::dds::DomainPartic //! DomainParticipant callback to inform new data readers discovered void on_data_writer_discovery( eprosima::fastdds::dds::DomainParticipant* participant, - eprosima::fastrtps::rtps::WriterDiscoveryInfo&& info, + eprosima::fastdds::rtps::WriterDiscoveryInfo&& info, bool& /*should_be_ignored*/) override; - // //! Callback to receive the remote data type information - // virtual void on_type_information_received( - // eprosima::fastdds::dds::DomainParticipant* participant, - // const eprosima::fastcdr::string_255 topic_name, - // const eprosima::fastcdr::string_255 type_name, - // const eprosima::fastcdr::types::TypeInformation& type_information) override; - void init_info( const std::string& type_name); void fill_info( int index, - const std::string& message, uint64_t time_arrive_msg); protected: @@ -136,7 +127,7 @@ class HelloWorldDynTypesSubscriber : public eprosima::fastdds::dds::DomainPartic //! The time in milliseconds when the previous message arrived double prev_time_; - HelloWorld hello_world_; + Configuration configuration_; //! Atomic variables to check whether the type has been discovered and registered static std::atomic type_discovered_; diff --git a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp similarity index 86% rename from ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp rename to ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp index 5b18c9853..ca6cb97bb 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp +++ b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp @@ -30,13 +30,13 @@ #include #include #include -// #include -#include "HelloWorldSubscriber.h" +#include "types/configuration/ConfigurationPubSubTypes.h" +#include "ConfigurationSubscriber.h" using namespace eprosima::fastdds::dds; -HelloWorldSubscriber::HelloWorldSubscriber( +ConfigurationSubscriber::ConfigurationSubscriber( const std::string& topic_name, uint32_t domain, DataToCheck& data) @@ -44,7 +44,7 @@ HelloWorldSubscriber::HelloWorldSubscriber( , subscriber_(nullptr) , topic_(nullptr) , datareader_(nullptr) - , type_(new HelloWorldPubSubType()) + , type_(new ConfigurationPubSubType()) , data_(&data) , samples_(0) , prev_time_(0) @@ -52,7 +52,7 @@ HelloWorldSubscriber::HelloWorldSubscriber( /////////////////////////////// // Create the DomainParticipant DomainParticipantQos pqos; - pqos.name("HelloWorld_Subscriber"); + pqos.name("Configuration_Subscriber"); participant_ = DomainParticipantFactory::get_instance()->create_participant(domain, pqos); @@ -108,7 +108,7 @@ HelloWorldSubscriber::HelloWorldSubscriber( std::endl; } -HelloWorldSubscriber::~HelloWorldSubscriber() +ConfigurationSubscriber::~ConfigurationSubscriber() { if (participant_ != nullptr) { @@ -128,7 +128,7 @@ HelloWorldSubscriber::~HelloWorldSubscriber() } } -void HelloWorldSubscriber::on_subscription_matched( +void ConfigurationSubscriber::on_subscription_matched( DataReader*, const SubscriptionMatchedStatus& info) { @@ -147,12 +147,12 @@ void HelloWorldSubscriber::on_subscription_matched( } } -void HelloWorldSubscriber::on_data_available( +void ConfigurationSubscriber::on_data_available( DataReader* reader) { SampleInfo info; - while ((reader->take_next_sample(&hello_, + while ((reader->take_next_sample(&configuration_, &info) == RETCODE_OK)) { if (info.instance_state == ALIVE_INSTANCE_STATE) @@ -162,41 +162,40 @@ void HelloWorldSubscriber::on_data_available( samples_++; - fill_info(hello_, current_time); + fill_info(configuration_, current_time); // Print your structure data here. - std::cout << "Message " << " " << hello_.index() << " RECEIVED" << std::endl; + std::cout << "Message " << " " << configuration_.index() << " RECEIVED" << std::endl; std::cout << "-----------------------------------------------------" << std::endl; } } } -void HelloWorldSubscriber::init_info( +void ConfigurationSubscriber::init_info( const std::string& type_name) { data_->n_received_msgs = 0; data_->type_msg = type_name; - data_->message_msg = ""; data_->min_index_msg = -1; data_->max_index_msg = -1; data_->cummulated_ms_between_msgs = -1; data_->mean_ms_between_msgs = -1; } -void HelloWorldSubscriber::fill_info( - HelloWorld hello_, +void ConfigurationSubscriber::fill_info( + Configuration configuration_, uint64_t time_arrive_msg) { data_->n_received_msgs++; - data_->message_msg = hello_.message(); - if (data_->min_index_msg == -1 || data_->min_index_msg > static_cast(hello_.index())) + + if (data_->min_index_msg == -1 || data_->min_index_msg > static_cast(configuration_.index())) { - data_->min_index_msg = hello_.index(); + data_->min_index_msg = configuration_.index(); } - if (data_->max_index_msg == -1 || data_->max_index_msg < static_cast(hello_.index())) + if (data_->max_index_msg == -1 || data_->max_index_msg < static_cast(configuration_.index())) { - data_->max_index_msg = hello_.index(); + data_->max_index_msg = configuration_.index(); } if (prev_time_ == 0) diff --git a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h similarity index 88% rename from ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h rename to ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h index f01da79e4..6c171c083 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h +++ b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file HelloWorldSubscriber.h + * @file ConfigurationSubscriber.h * */ @@ -24,13 +24,12 @@ #include #include -#include "types/hello_world/HelloWorldPubSubTypes.h" +#include "types/configuration/ConfigurationPubSubTypes.h" struct DataToCheck { unsigned int n_received_msgs; std::string type_msg; - std::string message_msg; int min_index_msg; int max_index_msg; double mean_ms_between_msgs; @@ -41,7 +40,7 @@ struct DataToCheck * @brief Class used to group into a single working unit a Subscriber with a DataReader and its listener. * */ -class HelloWorldSubscriber : public eprosima::fastdds::dds::DomainParticipantListener +class ConfigurationSubscriber : public eprosima::fastdds::dds::DomainParticipantListener { public: @@ -51,7 +50,7 @@ class HelloWorldSubscriber : public eprosima::fastdds::dds::DomainParticipantLis * @param topic_name Name of the DDS Topic * @param domain DDS Domain of the DomainParticipant */ - HelloWorldSubscriber( + ConfigurationSubscriber( const std::string& topic_name, uint32_t domain, DataToCheck& data); @@ -60,7 +59,7 @@ class HelloWorldSubscriber : public eprosima::fastdds::dds::DomainParticipantLis * @brief Destroy the Type Lookup Service Publisher object * */ - virtual ~HelloWorldSubscriber(); + virtual ~ConfigurationSubscriber(); //! DataReader callback executed when a new sample is received void on_data_available( @@ -75,7 +74,7 @@ class HelloWorldSubscriber : public eprosima::fastdds::dds::DomainParticipantLis const std::string& type_name); void fill_info( - HelloWorld hello_, + Configuration configuration_, uint64_t time_arrive_msg); protected: @@ -89,7 +88,7 @@ class HelloWorldSubscriber : public eprosima::fastdds::dds::DomainParticipantLis DataToCheck* data_; - HelloWorld hello_; + Configuration configuration_; //! Number of samples received uint32_t samples_; diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.hpp new file mode 100644 index 000000000..14df67704 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.hpp @@ -0,0 +1,275 @@ +// 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 Configuration.hpp + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_CONFIGURATION_HPP_ +#define _FAST_DDS_GENERATED_CONFIGURATION_HPP_ + +#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(CONFIGURATION_SOURCE) +#define CONFIGURATION_DllAPI __declspec( dllexport ) +#else +#define CONFIGURATION_DllAPI __declspec( dllimport ) +#endif // CONFIGURATION_SOURCE +#else +#define CONFIGURATION_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define CONFIGURATION_DllAPI +#endif // _WIN32 + +/*! + * @brief This class represents the structure Configuration defined by the user in the IDL file. + * @ingroup Configuration + */ +class Configuration +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport Configuration() + { + } + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~Configuration() + { + } + + /*! + * @brief Copy constructor. + * @param x Reference to the object Configuration that will be copied. + */ + eProsima_user_DllExport Configuration( + const Configuration& x) + { + m_index = x.m_index; + + m_message = x.m_message; + + m_data = x.m_data; + + } + + /*! + * @brief Move constructor. + * @param x Reference to the object Configuration that will be copied. + */ + eProsima_user_DllExport Configuration( + Configuration&& x) noexcept + { + m_index = x.m_index; + m_message = std::move(x.m_message); + m_data = std::move(x.m_data); + } + + /*! + * @brief Copy assignment. + * @param x Reference to the object Configuration that will be copied. + */ + eProsima_user_DllExport Configuration& operator =( + const Configuration& x) + { + + m_index = x.m_index; + + m_message = x.m_message; + + m_data = x.m_data; + + return *this; + } + + /*! + * @brief Move assignment. + * @param x Reference to the object Configuration that will be copied. + */ + eProsima_user_DllExport Configuration& operator =( + Configuration&& x) noexcept + { + + m_index = x.m_index; + m_message = std::move(x.m_message); + m_data = std::move(x.m_data); + return *this; + } + + /*! + * @brief Comparison operator. + * @param x Configuration object to compare. + */ + eProsima_user_DllExport bool operator ==( + const Configuration& x) const + { + return (m_index == x.m_index && + m_message == x.m_message && + m_data == x.m_data); + } + + /*! + * @brief Comparison operator. + * @param x Configuration object to compare. + */ + eProsima_user_DllExport bool operator !=( + const Configuration& x) const + { + return !(*this == x); + } + + /*! + * @brief This function sets a value in member index + * @param _index New value for member index + */ + eProsima_user_DllExport void index( + uint32_t _index) + { + m_index = _index; + } + + /*! + * @brief This function returns the value of member index + * @return Value of member index + */ + eProsima_user_DllExport uint32_t index() const + { + return m_index; + } + + /*! + * @brief This function returns a reference to member index + * @return Reference to member index + */ + eProsima_user_DllExport uint32_t& index() + { + return m_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::array& _message) + { + m_message = _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::array&& _message) + { + m_message = std::move(_message); + } + + /*! + * @brief This function returns a constant reference to member message + * @return Constant reference to member message + */ + eProsima_user_DllExport const std::array& message() const + { + return m_message; + } + + /*! + * @brief This function returns a reference to member message + * @return Reference to member message + */ + eProsima_user_DllExport std::array& message() + { + return m_message; + } + + + /*! + * @brief This function copies the value in member data + * @param _data New value to be copied in member data + */ + eProsima_user_DllExport void data( + const std::vector& _data) + { + m_data = _data; + } + + /*! + * @brief This function moves the value in member data + * @param _data New value to be moved in member data + */ + eProsima_user_DllExport void data( + std::vector&& _data) + { + m_data = std::move(_data); + } + + /*! + * @brief This function returns a constant reference to member data + * @return Constant reference to member data + */ + eProsima_user_DllExport const std::vector& data() const + { + return m_data; + } + + /*! + * @brief This function returns a reference to member data + * @return Reference to member data + */ + eProsima_user_DllExport std::vector& data() + { + return m_data; + } + + + +private: + + uint32_t m_index{0}; + std::array m_message{0}; + std::vector m_data; + +}; + +#endif // _FAST_DDS_GENERATED_CONFIGURATION_HPP_ + + diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.idl b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.idl new file mode 100644 index 000000000..063cd25a3 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.idl @@ -0,0 +1,7 @@ +@extensibility(APPENDABLE) +struct Configuration +{ + unsigned long index; + char message[20]; + sequence data; +}; diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.hpp new file mode 100644 index 000000000..c496adce2 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.hpp @@ -0,0 +1,46 @@ +// 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 ConfigurationCdrAux.hpp + * This source file contains some definitions of CDR related functions. + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_HPP_ +#define _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_HPP_ + +#include "Configuration.hpp" + +constexpr uint32_t Configuration_max_cdr_typesize {32UL}; +constexpr uint32_t Configuration_max_key_cdr_typesize {0UL}; + + +namespace eprosima { +namespace fastcdr { + +class Cdr; +class CdrSizeCalculator; + +eProsima_user_DllExport void serialize_key( + eprosima::fastcdr::Cdr& scdr, + const Configuration& data); + + +} // namespace fastcdr +} // namespace eprosima + +#endif // _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_HPP_ + diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.ipp b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.ipp new file mode 100644 index 000000000..15e6a23f8 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.ipp @@ -0,0 +1,134 @@ +// 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 ConfigurationCdrAux.ipp + * This source file contains some declarations of CDR related functions. + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_IPP_ +#define _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_IPP_ + +#include "ConfigurationCdrAux.hpp" + +#include +#include + + +#include +using namespace eprosima::fastcdr::exception; + +namespace eprosima { +namespace fastcdr { + +template<> +eProsima_user_DllExport size_t calculate_serialized_size( + eprosima::fastcdr::CdrSizeCalculator& calculator, + const Configuration& data, + size_t& current_alignment) +{ + static_cast(data); + + eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); + size_t calculated_size {calculator.begin_calculate_type_serialized_size( + eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, + current_alignment)}; + + + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), + data.index(), current_alignment); + + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), + data.message(), current_alignment); + + calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(2), + data.data(), current_alignment); + + + calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); + + return calculated_size; +} + +template<> +eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& scdr, + const Configuration& data) +{ + eprosima::fastcdr::Cdr::state current_state(scdr); + scdr.begin_serialize_type(current_state, + eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); + + scdr + << eprosima::fastcdr::MemberId(0) << data.index() + << eprosima::fastcdr::MemberId(1) << data.message() + << eprosima::fastcdr::MemberId(2) << data.data() +; + scdr.end_serialize_type(current_state); +} + +template<> +eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr, + Configuration& data) +{ + cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, + [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool + { + bool ret_value = true; + switch (mid.id) + { + case 0: + dcdr >> data.index(); + break; + + case 1: + dcdr >> data.message(); + break; + + case 2: + dcdr >> data.data(); + break; + + default: + ret_value = false; + break; + } + return ret_value; + }); +} + +void serialize_key( + eprosima::fastcdr::Cdr& scdr, + const Configuration& data) +{ + static_cast(scdr); + static_cast(data); +} + + + +} // namespace fastcdr +} // namespace eprosima + +#endif // _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_IPP_ + diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx new file mode 100644 index 000000000..fbdbb9bf3 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.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 ConfigurationPubSubTypes.cpp + * This header file contains the implementation of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + +#include "ConfigurationPubSubTypes.h" + +#include +#include + +#include "ConfigurationCdrAux.hpp" +#include "ConfigurationTypeObjectSupport.hpp" + +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; +using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + +ConfigurationPubSubType::ConfigurationPubSubType() +{ + setName("Configuration"); + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(Configuration::getMaxCdrSerializedSize()); +#else + Configuration_max_cdr_typesize; +#endif + type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ + m_typeSize = type_size + 4; /*encapsulation*/ + m_isGetKeyDefined = false; + uint32_t keyLength = Configuration_max_key_cdr_typesize > 16 ? Configuration_max_key_cdr_typesize : 16; + m_keyBuffer = reinterpret_cast(malloc(keyLength)); + memset(m_keyBuffer, 0, keyLength); +} + +ConfigurationPubSubType::~ConfigurationPubSubType() +{ + if (m_keyBuffer != nullptr) + { + free(m_keyBuffer); + } +} + +bool ConfigurationPubSubType::serialize( + const void* const data, + SerializedPayload_t* payload, + DataRepresentationId_t data_representation) +{ + const Configuration* 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, + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); + payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; +#if FASTCDR_VERSION_MAJOR > 1 + ser.set_encoding_flag( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : + eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); +#endif // FASTCDR_VERSION_MAJOR > 1 + + try + { + // Serialize encapsulation + ser.serialize_encapsulation(); + // Serialize the object. + ser << *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + // Get the serialized length +#if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast(ser.getSerializedDataLength()); +#else + payload->length = static_cast(ser.get_serialized_data_length()); +#endif // FASTCDR_VERSION_MAJOR == 1 + return true; +} + +bool ConfigurationPubSubType::deserialize( + SerializedPayload_t* payload, + void* data) +{ + try + { + // Convert DATA to pointer of your type + Configuration* 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 +#if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR +#endif // FASTCDR_VERSION_MAJOR == 1 + ); + + // Deserialize encapsulation. + deser.read_encapsulation(); + payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize the object. + deser >> *p_type; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return false; + } + + return true; +} + +std::function ConfigurationPubSubType::getSerializedSizeProvider( + const void* const data, + DataRepresentationId_t data_representation) +{ + return [data, data_representation]() -> uint32_t + { +#if FASTCDR_VERSION_MAJOR == 1 + static_cast(data_representation); + return static_cast(type::getCdrSerializedSize(*static_cast(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast(calculator.calculate_serialized_size( + *static_cast(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 + }; +} + +void* ConfigurationPubSubType::createData() +{ + return reinterpret_cast(new Configuration()); +} + +void ConfigurationPubSubType::deleteData( + void* data) +{ + delete(reinterpret_cast(data)); +} + +bool ConfigurationPubSubType::getKey( + const void* const data, + InstanceHandle_t* handle, + bool force_md5) +{ + if (!m_isGetKeyDefined) + { + return false; + } + + const Configuration* p_type = static_cast(data); + + // Object that manages the raw buffer. + eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), + Configuration_max_key_cdr_typesize); + + // Object that serializes the data. + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else + eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 + if (force_md5 || Configuration_max_key_cdr_typesize > 16) + { + m_md5.init(); +#if FASTCDR_VERSION_MAJOR == 1 + m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); +#else + m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); +#endif // FASTCDR_VERSION_MAJOR == 1 + 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; +} + +void ConfigurationPubSubType::register_type_object_representation() +{ + register_Configuration_type_identifier(type_identifiers_); +} + + +// Include auxiliary functions like for serializing/deserializing. +#include "ConfigurationCdrAux.ipp" diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.h b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.h new file mode 100644 index 000000000..a2a5c95ac --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.h @@ -0,0 +1,133 @@ +// 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 ConfigurationPubSubTypes.h + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + + +#ifndef _FAST_DDS_GENERATED_CONFIGURATION_PUBSUBTYPES_H_ +#define _FAST_DDS_GENERATED_CONFIGURATION_PUBSUBTYPES_H_ + +#include +#include +#include +#include +#include + +#include "Configuration.hpp" + + +#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#error \ + Generated Configuration 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 Configuration defined by the user in the IDL file. + * @ingroup Configuration + */ +class ConfigurationPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef Configuration type; + + eProsima_user_DllExport ConfigurationPubSubType(); + + eProsima_user_DllExport ~ConfigurationPubSubType() override; + + eProsima_user_DllExport bool serialize( + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport bool serialize( + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool deserialize( + eprosima::fastdds::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport std::function getSerializedSizeProvider( + const void* const data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport std::function getSerializedSizeProvider( + const void* const data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool getKey( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport void* createData() override; + + eProsima_user_DllExport void deleteData( + void* data) override; + + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() 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; + } + + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + 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 + { + static_cast(memory); + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + MD5 m_md5; + unsigned char* m_keyBuffer; + +}; + +#endif // _FAST_DDS_GENERATED_CONFIGURATION_PUBSUBTYPES_H_ + diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.cxx new file mode 100644 index 000000000..3c502b812 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.cxx @@ -0,0 +1,233 @@ +// 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 ConfigurationTypeObjectSupport.cxx + * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#include "ConfigurationTypeObjectSupport.hpp" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Configuration.hpp" + + +using namespace eprosima::fastdds::dds::xtypes; + +// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method +void register_Configuration_type_identifier( + TypeIdentifierPair& type_ids_Configuration) +{ + + ReturnCode_t return_code_Configuration {eprosima::fastdds::dds::RETCODE_OK}; + return_code_Configuration = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "Configuration", type_ids_Configuration); + if (eprosima::fastdds::dds::RETCODE_OK != return_code_Configuration) + { + StructTypeFlag struct_flags_Configuration = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, + false, false); + QualifiedTypeName type_name_Configuration = "Configuration"; + eprosima::fastcdr::optional type_ann_builtin_Configuration; + eprosima::fastcdr::optional ann_custom_Configuration; + AppliedAnnotationSeq tmp_ann_custom_Configuration; + eprosima::fastcdr::optional verbatim_Configuration; + if (!tmp_ann_custom_Configuration.empty()) + { + ann_custom_Configuration = tmp_ann_custom_Configuration; + } + + CompleteTypeDetail detail_Configuration = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_Configuration, ann_custom_Configuration, type_name_Configuration.to_string()); + CompleteStructHeader header_Configuration; + header_Configuration = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_Configuration); + CompleteStructMemberSeq member_seq_Configuration; + { + TypeIdentifierPair type_ids_index; + ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; + return_code_index = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_uint32_t", type_ids_index); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_index = 0x00000000; + bool common_index_ec {false}; + CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; + if (!common_index_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); + return; + } + MemberName name_index = "index"; + eprosima::fastcdr::optional member_ann_builtin_index; + ann_custom_Configuration.reset(); + CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_Configuration); + CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); + TypeObjectUtils::add_complete_struct_member(member_seq_Configuration, member_index); + } + { + TypeIdentifierPair type_ids_message; + ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_array_char_20", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + return_code_message = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_char", type_ids_message); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Array element TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + bool element_identifier_anonymous_array_char_20_ec {false}; + TypeIdentifier* element_identifier_anonymous_array_char_20 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, element_identifier_anonymous_array_char_20_ec))}; + if (!element_identifier_anonymous_array_char_20_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Array element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_array_char_20 = EK_COMPLETE; + if (TK_NONE == type_ids_message.type_identifier2()._d()) + { + equiv_kind_anonymous_array_char_20 = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_array_char_20 = 0; + PlainCollectionHeader header_anonymous_array_char_20 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_array_char_20, element_flags_anonymous_array_char_20); + { + SBoundSeq array_bound_seq; + TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast(20)); + + PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_anonymous_array_char_20, array_bound_seq, + eprosima::fastcdr::external(element_identifier_anonymous_array_char_20)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "anonymous_array_char_20", type_ids_message)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_array_char_20 already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_message = 0x00000001; + bool common_message_ec {false}; + CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; + if (!common_message_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); + return; + } + MemberName name_message = "message"; + eprosima::fastcdr::optional member_ann_builtin_message; + ann_custom_Configuration.reset(); + CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_Configuration); + CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); + TypeObjectUtils::add_complete_struct_member(member_seq_Configuration, member_message); + } + { + TypeIdentifierPair type_ids_data; + ReturnCode_t return_code_data {eprosima::fastdds::dds::RETCODE_OK}; + return_code_data = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "anonymous_sequence_uint8_t_unbounded", type_ids_data); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_data) + { + return_code_data = + eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( + "_byte", type_ids_data); + + if (eprosima::fastdds::dds::RETCODE_OK != return_code_data) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Sequence element TypeIdentifier unknown to TypeObjectRegistry."); + return; + } + bool element_identifier_anonymous_sequence_uint8_t_unbounded_ec {false}; + TypeIdentifier* element_identifier_anonymous_sequence_uint8_t_unbounded {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_data, element_identifier_anonymous_sequence_uint8_t_unbounded_ec))}; + if (!element_identifier_anonymous_sequence_uint8_t_unbounded_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Sequence element TypeIdentifier inconsistent."); + return; + } + EquivalenceKind equiv_kind_anonymous_sequence_uint8_t_unbounded = EK_COMPLETE; + if (TK_NONE == type_ids_data.type_identifier2()._d()) + { + equiv_kind_anonymous_sequence_uint8_t_unbounded = EK_BOTH; + } + CollectionElementFlag element_flags_anonymous_sequence_uint8_t_unbounded = 0; + PlainCollectionHeader header_anonymous_sequence_uint8_t_unbounded = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_sequence_uint8_t_unbounded, element_flags_anonymous_sequence_uint8_t_unbounded); + { + SBound bound = 0; + PlainSequenceSElemDefn seq_sdefn = TypeObjectUtils::build_plain_sequence_s_elem_defn(header_anonymous_sequence_uint8_t_unbounded, bound, + eprosima::fastcdr::external(element_identifier_anonymous_sequence_uint8_t_unbounded)); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_s_sequence_type_identifier(seq_sdefn, "anonymous_sequence_uint8_t_unbounded", type_ids_data)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "anonymous_sequence_uint8_t_unbounded already registered in TypeObjectRegistry for a different type."); + } + } + } + StructMemberFlag member_flags_data = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, + false, false, false, false); + MemberId member_id_data = 0x00000002; + bool common_data_ec {false}; + CommonStructMember common_data {TypeObjectUtils::build_common_struct_member(member_id_data, member_flags_data, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_data, common_data_ec))}; + if (!common_data_ec) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure data member TypeIdentifier inconsistent."); + return; + } + MemberName name_data = "data"; + eprosima::fastcdr::optional member_ann_builtin_data; + ann_custom_Configuration.reset(); + CompleteMemberDetail detail_data = TypeObjectUtils::build_complete_member_detail(name_data, member_ann_builtin_data, ann_custom_Configuration); + CompleteStructMember member_data = TypeObjectUtils::build_complete_struct_member(common_data, detail_data); + TypeObjectUtils::add_complete_struct_member(member_seq_Configuration, member_data); + } + CompleteStructType struct_type_Configuration = TypeObjectUtils::build_complete_struct_type(struct_flags_Configuration, header_Configuration, member_seq_Configuration); + if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == + TypeObjectUtils::build_and_register_struct_type_object(struct_type_Configuration, type_name_Configuration.to_string(), type_ids_Configuration)) + { + EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, + "Configuration already registered in TypeObjectRegistry for a different type."); + } + } +} + diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.hpp new file mode 100644 index 000000000..c59a74172 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.hpp @@ -0,0 +1,56 @@ +// 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 ConfigurationTypeObjectSupport.hpp + * Header file containing the API required to register the TypeObject representation of the described types in the IDL file + * + * This file was generated by the tool fastddsgen. + */ + +#ifndef _FAST_DDS_GENERATED_CONFIGURATION_TYPE_OBJECT_SUPPORT_HPP_ +#define _FAST_DDS_GENERATED_CONFIGURATION_TYPE_OBJECT_SUPPORT_HPP_ + +#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 + +#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +/** + * @brief Register Configuration related TypeIdentifier. + * Fully-descriptive TypeIdentifiers are directly registered. + * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is + * indirectly registered as well. + * + * @param[out] TypeIdentifier of the registered type. + * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. + * Invalid TypeIdentifier is returned in case of error. + */ +eProsima_user_DllExport void register_Configuration_type_identifier( + eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); + + +#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC + +#endif // _FAST_DDS_GENERATED_CONFIGURATION_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx index aa161b2e1..41da39407 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx @@ -27,8 +27,8 @@ #include "HelloWorldCdrAux.hpp" #include "HelloWorldTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() @@ -57,11 +57,11 @@ HelloWorldPubSubType::~HelloWorldPubSubType() } bool HelloWorldPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - HelloWorld* p_type = static_cast(data); + const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool HelloWorldPubSubType::deserialize( } std::function HelloWorldPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void HelloWorldPubSubType::deleteData( } bool HelloWorldPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool HelloWorldPubSubType::getKey( return false; } - HelloWorld* p_type = static_cast(data); + const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h index 7c83d2b30..3db9ca964 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h @@ -53,34 +53,34 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~HelloWorldPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx index aa161b2e1..41da39407 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx @@ -27,8 +27,8 @@ #include "HelloWorldCdrAux.hpp" #include "HelloWorldTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() @@ -57,11 +57,11 @@ HelloWorldPubSubType::~HelloWorldPubSubType() } bool HelloWorldPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - HelloWorld* p_type = static_cast(data); + const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool HelloWorldPubSubType::deserialize( } std::function HelloWorldPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void HelloWorldPubSubType::deleteData( } bool HelloWorldPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool HelloWorldPubSubType::getKey( return false; } - HelloWorld* p_type = static_cast(data); + const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h index 4b09a679e..b161b42f7 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h +++ b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h @@ -53,34 +53,34 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~HelloWorldPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_notype.yaml similarity index 61% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time.yaml rename to ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_notype.yaml index ccebb9e5a..51362440d 100644 --- a/ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time.yaml +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_notype.yaml @@ -1,14 +1,15 @@ topics: - - name: /dds/topic - type: HelloWorld + - name: configuration_topic + type: Configuration qos: reliability: true # Use QoS RELIABLE replayer: + replay-types: false begin-time: local: false format: "%H-%M-%S_%Y-%m-%d" - datetime: 14-06-18_2023-05-17 + datetime: 13-04-45_2024-06-25 specs: wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_with_types.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_with_types.yaml index b2785096d..74c1f534b 100644 --- a/ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_with_types.yaml +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_with_types.yaml @@ -1,14 +1,15 @@ topics: - - name: /dds/topic - type: HelloWorld + - name: configuration_topic + type: Configuration qos: reliability: true # Use QoS RELIABLE replayer: + replay-types: true begin-time: local: false format: "%H-%M-%S_%Y-%m-%d" - datetime: 11-48-47_2023-05-26 + datetime: 13-04-45_2024-06-25 specs: wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_end_time.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_notype.yaml similarity index 61% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_end_time.yaml rename to ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_notype.yaml index e241002ff..f2c8a9f5e 100644 --- a/ddsreplayer/test/blackbox/mcap/resources/config_file_end_time.yaml +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_notype.yaml @@ -1,14 +1,15 @@ topics: - - name: /dds/topic - type: HelloWorld + - name: configuration_topic + type: Configuration qos: reliability: true # Use QoS RELIABLE replayer: + replay-types: false end-time: local: false format: "%H-%M-%S_%Y-%m-%d" - datetime: 14-06-18_2023-05-17 + datetime: 13-04-45_2024-06-25 specs: wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_with_types.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_with_types.yaml index febc859a6..adcbb749e 100644 --- a/ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_with_types.yaml +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_with_types.yaml @@ -1,13 +1,15 @@ topics: - - name: /dds/topic + - name: configuration_topic + type: Configuration qos: reliability: true # Use QoS RELIABLE replayer: + replay-types: true end-time: local: false format: "%H-%M-%S_%Y-%m-%d" - datetime: 11-48-47_2023-05-26 + datetime: 13-04-45_2024-06-25 specs: wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_notype.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_notype.yaml new file mode 100644 index 000000000..0400e749a --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_notype.yaml @@ -0,0 +1,12 @@ +topics: + - name: configuration_topic + type: Configuration + qos: + reliability: true # Use QoS RELIABLE + +replayer: + replay-types: false + rate: 0.5 + +specs: + wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_withtypes.yaml similarity index 63% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz.yaml rename to ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_withtypes.yaml index 42beefa28..6c8167c04 100644 --- a/ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz.yaml +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_withtypes.yaml @@ -1,10 +1,11 @@ topics: - - name: /dds/topic - type: HelloWorld + - name: configuration_topic + type: Configuration qos: reliability: true # Use QoS RELIABLE replayer: + replay-types: true rate: 0.5 specs: diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_notype.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_notype.yaml new file mode 100644 index 000000000..219b7f985 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_notype.yaml @@ -0,0 +1,12 @@ +topics: + - name: configuration_topic + type: Configuration + qos: + reliability: true # Use QoS RELIABLE + +replayer: + replay-types: false + rate: 2.0 + +specs: + wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_withtypes.yaml similarity index 63% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz.yaml rename to ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_withtypes.yaml index 65045ef01..9c218bf6f 100644 --- a/ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz.yaml +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_withtypes.yaml @@ -1,10 +1,11 @@ topics: - - name: /dds/topic - type: HelloWorld + - name: configuration_topic + type: Configuration qos: reliability: true # Use QoS RELIABLE replayer: + replay-types: true rate: 2.0 specs: diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_notype.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_notype.yaml new file mode 100644 index 000000000..9a9f25d33 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_notype.yaml @@ -0,0 +1,11 @@ +topics: + - name: configuration_topic + type: Configuration + qos: + reliability: true # Use QoS RELIABLE + +replayer: + replay-types: false + +specs: + wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_notype.yaml similarity index 74% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier.yaml rename to ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_notype.yaml index c6e6b3499..4a3e41aef 100644 --- a/ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier.yaml +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_notype.yaml @@ -1,10 +1,11 @@ topics: - - name: /dds/topic - type: HelloWorld + - name: configuration_topic + type: Configuration qos: reliability: true # Use QoS RELIABLE replayer: + replay-types: false start-replay-time: local: false format: "%H-%M-%S_%Y-%m-%d" diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_with_types.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_with_types.yaml index c6e6b3499..89ed409aa 100644 --- a/ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_with_types.yaml +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_with_types.yaml @@ -1,10 +1,11 @@ topics: - - name: /dds/topic - type: HelloWorld + - name: configuration_topic + type: Configuration qos: reliability: true # Use QoS RELIABLE replayer: + replay-types: true start-replay-time: local: false format: "%H-%M-%S_%Y-%m-%d" diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file.yaml b/ddsreplayer/test/blackbox/mcap/resources/config_file_withtypes.yaml similarity index 71% rename from ddsreplayer/test/blackbox/mcap/resources/config_file.yaml rename to ddsreplayer/test/blackbox/mcap/resources/config_file_withtypes.yaml index 39ab008a0..ba243c206 100644 --- a/ddsreplayer/test/blackbox/mcap/resources/config_file.yaml +++ b/ddsreplayer/test/blackbox/mcap/resources/config_file_withtypes.yaml @@ -1,6 +1,6 @@ topics: - - name: /dds/topic - type: HelloWorld + - name: configuration_topic + type: Configuration qos: reliability: true # Use QoS RELIABLE diff --git a/ddsreplayer/test/blackbox/mcap/resources/configuration_withtypes.mcap b/ddsreplayer/test/blackbox/mcap/resources/configuration_withtypes.mcap new file mode 100644 index 0000000000000000000000000000000000000000..fb9f2c4fd833c167bfc2328991135f25328a1e32 GIT binary patch literal 2944 zcmbUjTW}P|adkQg=|C?;@i17NvB46L)9D^Mon;~K>Fy-XM$rj953sbiyE?7dduVs> zlp{qj3c(WCWea1B<6sj<1;~iRrXs}{T(}Z~2 zMxOKfX)2`E>k4%GX&x*w1;z*~ zh+Hu6D4>bZ=%C-vN!frIX|u`LWTCta!&oe|!E4E9OpGPZlt(cpplRA@F&K>|w1~j+ zEG4pNfrwsb)aesLD!>5}&K&>aH1fi%%j75FG#En(%6!K+-z`T5t`{Z7j%Bm^a&I?= z)SqM!JG1gTR@)}q}*7^Of zwcVr1S&-?R_W81-YoEGT+Enwysh0TRxqz`6&9&rM#w)_(Z(sjt&$mp=lXvbLJaWFT z=Zyn9wwe34jU@25#f0bnGPkU3`7exIFjlzOLbphWxF2T7SFd^!ZIkvbz3xd5}z6vOjZb{0_~x z-70tB=)7?H;W<`WMd~HT$_7p*?3!oE zOxjx9Z5m>-Z<&ZiB?j}I={ZSRWf_~#ja+?Br_Cs+BKop5*BXAmJ<&mWuX79IinUi% zFE03g#?{W}=RekTuwS>;t{xqzSah*;=bt*7Tig0CK4`7E&spYg`Xc$?{=N^c-}89N()R`zy<77cab<~97anqa zaHBVU{^*GQ^x+fI%n#p;o3dBQFG5A^0c_R<_9{xhcAR2M_r+UNfIf-o|9t(sClEb5 zUQxT{w+mwnW^XzaYQ;`vD-2$PMJ>D;C(($`{u*j8wsNP?_ozetcUJ26Ae&)j&6{m zAy!24XR%YT7=iSrL$fntB})edh80#xloUpSs6Z5i%4m1x64FoRIc#mxV{Mfdo+OKk zfJGdJ=4&HKvcgqK`bZA2AA!RMQ;y1Ybe@Z^H&~;d(wbWiqkgKK6sK=~uCj4fN1d_7Ru>GBf~(d5XRXBWG|2E{zOafN6MMTH!}186U&v#u ziPqOuhP(zi4$>ybl1Ses2S!nJqsYimih8Qnyv|c6^ZoLy93}_3u0pY$M6}I~gBOcw z9#0#~n>_{;JH!`Jk7HUw7L1)Ar~;=Ha;j9$3zArGOxvG^ZxZ+iS-wFY2*~&hz{Uk# zNp|!g1^qsb;p+esB_T{p+8;@2excC<0GkW=v>}0waKW%xIDV223j!OECd_exreL9F zL!l+qveC(Hy2>opDVl3&6J?^v!Y1(*wqI8T5JQ`8fF7D`*4t!SZS%&WU!j7 z`4)rKyj;sr5+xg^?!bn{K}^s^%w-r+z!fN0luHn*O*A8TVL)hWP<#Xi_(O1%m*Y7p z`j8eP#cCKx_X!ihwgCKAnz_(J+9rw@SAjN?H$D*k=SRBDrWdO@i;YKAt)?)8K?75f$JQbnA z^5|$4NJ43iV6wu~$}|zhPXbyXj_5<)0jP*XjGa;@2z05&f5l?oG>!Zq0P`PMArp_2 zAEemZ^OFx#%3Qq7Vm#7#9QOfDMHd)B{4h#jfbH1JyBzhFB!zSTWX{x{WQBviu?X(! rBn@K@r7*@gnreKW&dHpVmoVo6%u%7^Ll86V7#7HB+uhrV|K0xu@ZdEI literal 0 HcmV?d00001 diff --git a/ddsreplayer/test/blackbox/mcap/resources/helloworld_withtype_file.mcap b/ddsreplayer/test/blackbox/mcap/resources/helloworld_withtype_file.mcap deleted file mode 100644 index 2ae20ee2a245404f1fa6f2d56673e3dffd3af7eb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2809 zcmbVOdvFug8sGHYltNns2DSIb3guB~^JwS`yxpWp(^9HQZ`(8|cC))px83ZfyGh#M z)z%73MXDeb#10@@9WU2=^;Sgjf%ghh0j+GOMA?{%dY<$8X)2)8=N9Jbr+KhNBI?7eBy*y$ z5|Ih$qeZ`;3ob+yQ^e>COa|I(DlnML`9@Q|ms)0|3aKWhz|7LDfuf4c3|jz`NG#7% zG7A%g^|_{8eS#|n(Fl7Vd-7=M)>CtavK!4L>iZ!ogf~`xF#zORIml#V+l4RZ{o2?c zdoGQr`_x;Ow&kN6wOuhCaf{Za&+A+Hm^10{{lfG^7JXdX2mAk?zvX>H{Nc)m6SJB& zba(kiMw?I6)ZenNxH#?L_S0+twq`GT_{y%ARzK0%llj!G|NH7()`3DpOnlfeX3nX9J|$yt-&N-z zbG&8n)Z!J>gIo8P?D=+1!R3*Zxi5Zq;ruZ!Jb3k%Z7rkb&fVJ|n)l`WBXP4&8h32# znQNS1T-EvW1Fm(hquobOUrtY4Ftf7kzUfu5MB;6EbCT`Ht2R|>xOckucD-bpv+;-X zKQaIQtM6~c1@FGry-57HwdO+m?Y|5hbI11g%v)d4x2N>Ix7z;UAR?E)$QZbCbLI@~ zlCtH`R-F4juzcbCSXj${tbD*Cka{%JdoKGKjM z(tR~_Y1$~?x0&g$o@orvKAU{zY_?Q-;^B^#+jN)CCJw!xlF?hSw3t0^ctzawcxT)C zRU5uZNSv({5JAKcX^8sZV(WWQU=CbFiO*uShIkTD(fa!tOFc8TkAQg(Hs3k4=?w6P zF#ms{=OXY|F~4N2^D^*7vFZe&BcXVx;~?f|7X{LRe*yD%dALmAzs0;epI!v~d|da@ zeb9*claGqnp$(PBOE9ctvPK?r0kGMa>WXyBKDw<_K_rcN2QDOkzPby2WvYL*_wH8 zc}KX;SQPP=I}tB}ofVpLXjE88lE!2M>Ma4U-^H^au>wybJ%ZEfEQC2RZ&#(jS3u*f zuUktS?Scon0YID?=qqDn7fXv0!%8(lDj0$VQ1S~nXs0WO^pgggr9D{H?keD;`5izu zKJcaH$0-v|X>5?c&DBa9D)|PKpQpSoQfqQGGmg5oU|Orhx(Y})G%9S6X(iCKqmpO* ze3)@7Hl!WqBW=)FNJn&$stvSI$$JHyltr;s){k^rkcV0@N9*MY!@y|#GbiV5MTapZ zME_UW9I4dX^Tjr)j4G=Oc!T!*=(sItoM$5M7In_atqt^3@^%`Fg5G+2$b(eXO5Vy} zQa>?L$y*VkwHmhty)xf5d0QaWa(l#MQrCspTz$|z1D8394^=G6M1h9TqJE-q;ocDa zK91q-h?0X+hz{x|)Y^NrI)soQb3TD(bi63|bezDj9VLo_Zl)xipOt0G$F4T&?<&#W zTcVAU24!N0qdN{Fmhf{3~)3Y88jo& zr~|T1lwr4_%bTOT9M1(K#X7Y1td_4-gHl5F6++g!TvV GgZDRYu>n>9 diff --git a/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp b/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp index 1b258a97d..a23c2a77a 100644 --- a/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp +++ b/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp @@ -32,11 +32,14 @@ #include #include #include -#include +// #include #include "TypeLookupServicePublisher.h" -#include "types/complete/CompleteTypeObject.h" -#include "types/hello_world/HelloWorldTypeObject.h" + +#include "types/complete/CompletePubSubTypes.h" +#include "types/complete/CompleteTypeObjectSupport.hpp" +#include "types/hello_world/HelloWorldPubSubTypes.h" +#include "types/hello_world/HelloWorldTypeObjectSupport.hpp" using namespace eprosima::fastdds::dds; @@ -58,9 +61,6 @@ TypeLookupServicePublisher::TypeLookupServicePublisher( DomainParticipantQos pqos; pqos.name("TypeLookupService_Participant_Publisher"); - pqos.wire_protocol().builtin.typelookup_config.use_client = false; - pqos.wire_protocol().builtin.typelookup_config.use_server = true; - participant_ = DomainParticipantFactory::get_instance()->create_participant(domain, pqos); if (participant_ == nullptr) @@ -85,11 +85,7 @@ TypeLookupServicePublisher::TypeLookupServicePublisher( break; } - TypeSupport type(new eprosima::fastdds::dds::DynamicPubSubType(dynamic_type_)); - - // Send type information so the type can be discovered - type->auto_fill_type_information(true); - type->auto_fill_type_object(false); + TypeSupport type(new DynamicPubSubType(dynamic_type_)); // Register the type in the Participant participant_->register_type(type); @@ -161,8 +157,8 @@ void TypeLookupServicePublisher::stop() } void TypeLookupServicePublisher::on_publication_matched( - eprosima::fastdds::dds::DataWriter*, - const eprosima::fastdds::dds::PublicationMatchedStatus& info) + DataWriter*, + const PublicationMatchedStatus& info) { if (info.current_count_change == 1) { @@ -229,7 +225,7 @@ void TypeLookupServicePublisher::run( void TypeLookupServicePublisher::publish(unsigned int msg_index) { // Get the dynamic data depending on the data type - eprosima::fastdds::dds::DynamicData::_ref_type dynamic_data_; + DynamicData::_ref_type dynamic_data_; switch (data_type_kind_) { case DataTypeKind::HELLO_WORLD: @@ -249,124 +245,149 @@ void TypeLookupServicePublisher::publish(unsigned int msg_index) // Print the message published std::cout << "Message published: " << std::endl; - eprosima::fastrtps::types::DynamicDataHelper::print(dynamic_data_); + // eprosima::fastrtps::types::DynamicDataHelper::print(dynamic_data_); std::cout << "-----------------------------------------------------" << std::endl; } -eprosima::fastrtps::types::DynamicType_ptr +traits::ref_type TypeLookupServicePublisher::generate_helloworld_type_() const { // Generate HelloWorld type using methods from Fast DDS Gen autogenerated code - registerHelloWorldTypes(); + TypeSupport type(new HelloWorldPubSubType()); + type->register_type_object_representation(); + + xtypes::TypeObjectPair type_object_pair; + if (RETCODE_OK != + DomainParticipantFactory::get_instance()->type_object_registry().get_type_objects( + type_name, type_object_pair)) + + { + std::cout << "Error getting type objects of HelloWorld type." << std::endl; + return nullptr; + } - // Get the complete type object and type identifier of the dynamic type - auto type_object = GetHelloWorldObject(true); - auto type_id = GetHelloWorldIdentifier(true); + // Create DynamicType + auto type_builder = DynamicTypeBuilderFactory::get_instance()->create_type_w_type_object( + type_object_pair.complete_type_object); + const auto dynamic_type = type_builder->build(); - // Use data type name, type identifier and type object to build the dynamic type - return eprosima::fastrtps::types::TypeObjectFactory::get_instance()->build_dynamic_type( - HELLO_WORLD_DATA_TYPE_NAME, - type_id, - type_object); + return dynamic_type; } -eprosima::fastrtps::types::DynamicType_ptr +traits::ref_type TypeLookupServicePublisher::generate_complete_type_() const { // Generate Complete type using methods from Fast DDS Gen autogenerated code - registerCompleteTypes(); + TypeSupport type(new CompletePubSubType()); + type->register_type_object_representation(); + + xtypes::TypeObjectPair type_object_pair; + if (RETCODE_OK != + DomainParticipantFactory::get_instance()->type_object_registry().get_type_objects( + type_name, type_object_pair)) - // For complex types with recursive structures and dependent of another types, - // we need to build the higher level type, as the rest of dependent types will be built recursively + { + std::cout << "Error getting type objects of Complete type." << std::endl; + return nullptr; + } - // Get the complete type object and type identifier of the dynamic type - auto type_object = GetCompleteDataObject(true); - auto type_id = GetCompleteDataIdentifier(true); + // Create DynamicType + auto type_builder = DynamicTypeBuilderFactory::get_instance()->create_type_w_type_object( + type_object_pair.complete_type_object); + const auto dynamic_type = type_builder->build(); - // Use data type name, type identifier and type object to build the dynamic type - return eprosima::fastrtps::types::TypeObjectFactory::get_instance()->build_dynamic_type( - COMPLETE_DATA_TYPE_NAME, - type_id, - type_object); + return dynamic_type; } -eprosima::fastdds::dds::DynamicData::_ref_type +DynamicData::_ref_type TypeLookupServicePublisher::fill_helloworld_data_( const unsigned int& index) { // Create and initialize new dynamic data - eprosima::fastdds::dds::DynamicData::_ref_type new_data; - new_data = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dynamic_type_); + DynamicData::_ref_type new_data; + new_data = DynamicDataFactory::get_instance()->create_data(dynamic_type_); // Set index - new_data->set_uint32_value(index, 0); + new_data->set_uint32_value(new_data->get_member_id_by_name("index"), index); // Set message - new_data->set_string_value("Hello World", 1); + new_data->set_string_value(new_data->get_member_id_by_name("message"), "Hello World"); return new_data; } -eprosima::fastdds::dds::DynamicData::_ref_type +DynamicData::_ref_type TypeLookupServicePublisher::fill_complete_data_( const unsigned int& index) { // Create and initialize new dynamic data - eprosima::fastdds::dds::DynamicData::_ref_type new_data; - new_data = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dynamic_type_); + DynamicData::_ref_type new_data; + new_data = DynamicDataFactory::get_instance()->create_data(dynamic_type_); // Set index - new_data->set_uint32_value(index, 0); + new_data->set_uint32_value(new_data->get_member_id_by_name("index"), index); // Set main_point - eprosima::fastrtps::types::DynamicData* main_point = new_data->loan_value(1); - main_point->set_int32_value(50, 0); - main_point->set_int32_value(100, 1); - main_point->set_int32_value(200, 2); - new_data->return_loaned_value(main_point); + traits::ref_type main_point = new_data->loan_value(new_data->get_member_id_by_name("main_point")); + main_point->set_int32_value(main_point->get_member_id_by_name("x"), 50); + main_point->set_int32_value(main_point->get_member_id_by_name("y"), 100); + main_point->set_int32_value(main_point->get_member_id_by_name("z"), 200); // Set internal_data - eprosima::fastrtps::types::DynamicData* points_sequence = new_data->loan_value(2); - eprosima::fastrtps::types::DynamicType_ptr seq_elem_type = - points_sequence->get_type()->get_descriptor()->get_element_type(); - eprosima::fastdds::dds::DynamicData::_ref_type seq_elem; - eprosima::fastrtps::types::MemberId id; - - // internal_data sequence element 1 - seq_elem = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(seq_elem_type); - seq_elem->set_int32_value(0, 0); - seq_elem->set_int32_value(1, 1); - seq_elem->set_int32_value(2, 2); - points_sequence->insert_complex_value(seq_elem, id); - - // internal_data sequence element 2 - seq_elem = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(seq_elem_type); - seq_elem->set_int32_value(3, 0); - seq_elem->set_int32_value(4, 1); - seq_elem->set_int32_value(5, 2); - points_sequence->insert_complex_value(seq_elem, id); - - // internal_data sequence element 3 - seq_elem = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(seq_elem_type); - seq_elem->set_int32_value(6, 0); - seq_elem->set_int32_value(7, 1); - seq_elem->set_int32_value(8, 2); - points_sequence->insert_complex_value(seq_elem, id); + traits::ref_type points_sequence = new_data->loan_value(new_data->get_member_id_by_name("internal_data")); + points_sequence->set_complex_value(0, main_point); + points_sequence->set_complex_value(1, main_point); + points_sequence->set_complex_value(2, main_point); + new_data->return_loaned_value(main_point); new_data->return_loaned_value(points_sequence); + // // internal_data sequence element 1 + // seq_elem = DynamicDataFactory::get_instance()->create_data(seq_elem_type); + // seq_elem->set_int32_value(0, 0); + // seq_elem->set_int32_value(1, 1); + // seq_elem->set_int32_value(2, 2); + // points_sequence->insert_complex_value(seq_elem, id); + + // // internal_data sequence element 2 + // seq_elem = DynamicDataFactory::get_instance()->create_data(seq_elem_type); + // seq_elem->set_int32_value(3, 0); + // seq_elem->set_int32_value(4, 1); + // seq_elem->set_int32_value(5, 2); + // points_sequence->insert_complex_value(seq_elem, id); + + // // internal_data sequence element 3 + // seq_elem = DynamicDataFactory::get_instance()->create_data(seq_elem_type); + // seq_elem->set_int32_value(6, 0); + // seq_elem->set_int32_value(7, 1); + // seq_elem->set_int32_value(8, 2); + // points_sequence->insert_complex_value(seq_elem, id); + + // Set messages - eprosima::fastrtps::types::DynamicData* messages_array = new_data->loan_value(3); - eprosima::fastrtps::types::DynamicData* array_elem; - eprosima::fastrtps::types::DynamicData* sub_elem; - eprosima::fastrtps::types::DynamicData* timestamp; + traits::ref_type messages_array = new_data->loan_value(new_data->get_member_id_by_name("messages")); + traits::ref_type array_elem; + traits::ref_type descriptor_elem; + traits::ref_type timestamp; for (int i=0; i<2; i++) { array_elem = messages_array->loan_value(i); + // descriptor + descriptor_elem = array_elem->loan_value(array_elem->get_member_id_by_name("descriptor")); + + descriptor_elem->set_uint32_value(descriptor_elem->get_member_id_by_name("id"), static_cast(i)); + descriptor_elem->set_string_value(descriptor_elem->get_member_id_by_name("topic"), "Valuable information"); + + timestamp = descriptor_elem->loan_value(descriptor_elem->get_member_id_by_name("time")); + timestamp->set_int32_value(timestamp->get_member_id_by_name("id"), ) + + + + // descriptor sub_elem = array_elem->loan_value(0); // descriptor id - sub_elem->set_uint32_value(i, 0); + sub_elem->set_uint32_value(sub_elem->get_member_id_by_name("descriptor"), i); // descriptor topic sub_elem->set_string_value("Valuable information", 1); // descriptor timestamp diff --git a/resources/dds/TypeLookupService/TypeLookupServicePublisher.h b/resources/dds/TypeLookupService/TypeLookupServicePublisher.h index de39bacfe..0b2c9483e 100644 --- a/resources/dds/TypeLookupService/TypeLookupServicePublisher.h +++ b/resources/dds/TypeLookupService/TypeLookupServicePublisher.h @@ -105,7 +105,7 @@ class TypeLookupServicePublisher : public eprosima::fastdds::dds::DomainParticip uint32_t sleep); //! Generate the HelloWorld DynamicType - eprosima::fastrtps::types::DynamicType_ptr generate_helloworld_type_() const; + eprosima::fastdds::dds::traits::ref_type generate_helloworld_type_() const; //! Generate the Complete DynamicType eprosima::fastrtps::types::DynamicType_ptr generate_complete_type_() const; @@ -143,7 +143,7 @@ class TypeLookupServicePublisher : public eprosima::fastdds::dds::DomainParticip //! Name of the DDS Topic type according to the DataTypeKind std::string data_type_name_; //! Actual DynamicType generated according to the DataTypeKind - eprosima::fastrtps::types::DynamicType_ptr dynamic_type_; + eprosima::fastdds::dds::traits::ref_type dynamic_type_; //! Indicates if the application is still running diff --git a/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp b/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp index c2f8d838b..ff29bf7a5 100644 --- a/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp +++ b/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp @@ -196,9 +196,9 @@ void TypeLookupServiceSubscriber::on_type_information_received( " > by lookup service. Registering..." << std::endl; // Create the callback to register the remote dynamic type - std::function callback( + std::function::ref_type)> callback( [this] - (const std::string& name, const eprosima::fastrtps::types::DynamicType_ptr type) + (const std::string& name, const eprosima::fastdds::dds::traits::ref_type type) { this->register_remote_type_callback_(name, type); }); @@ -276,7 +276,7 @@ void TypeLookupServiceSubscriber::run( void TypeLookupServiceSubscriber::register_remote_type_callback_( const std::string&, - const eprosima::fastrtps::types::DynamicType_ptr dynamic_type) + const eprosima::fastdds::dds::traits::ref_type dynamic_type) { //////////////////// // Register the type diff --git a/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.h b/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.h index 0158712b0..c96803433 100644 --- a/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.h +++ b/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.h @@ -93,7 +93,7 @@ class TypeLookupServiceSubscriber : public eprosima::fastdds::dds::DomainPartici */ void register_remote_type_callback_( const std::string& name, - const eprosima::fastrtps::types::DynamicType_ptr dynamic_type); + const eprosima::fastdds::dds::traits::ref_type dynamic_type); // Fast DDS entities eprosima::fastdds::dds::DomainParticipant* participant_; @@ -107,7 +107,7 @@ class TypeLookupServiceSubscriber : public eprosima::fastdds::dds::DomainPartici //! Name of the received DDS Topic type std::string type_name_; //! DynamicType generated with the received type information - eprosima::fastrtps::types::DynamicType_ptr dynamic_type_; + eprosima::fastdds::dds::traits::ref_type dynamic_type_; //! Atomic variables to check whether the type has been discovered and registered static std::atomic type_discovered_; diff --git a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx index 13588d163..57dc4017d 100644 --- a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx +++ b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx @@ -27,8 +27,8 @@ #include "CompleteCdrAux.hpp" #include "CompleteTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; TimestampPubSubType::TimestampPubSubType() @@ -57,11 +57,11 @@ TimestampPubSubType::~TimestampPubSubType() } bool TimestampPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - Timestamp* p_type = static_cast(data); + const Timestamp* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool TimestampPubSubType::deserialize( } std::function TimestampPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function TimestampPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void TimestampPubSubType::deleteData( } bool TimestampPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool TimestampPubSubType::getKey( return false; } - Timestamp* p_type = static_cast(data); + const Timestamp* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), @@ -250,11 +250,11 @@ PointPubSubType::~PointPubSubType() } bool PointPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - Point* p_type = static_cast(data); + const Point* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -326,7 +326,7 @@ bool PointPubSubType::deserialize( } std::function PointPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -343,7 +343,7 @@ std::function PointPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -366,7 +366,7 @@ void PointPubSubType::deleteData( } bool PointPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -375,7 +375,7 @@ bool PointPubSubType::getKey( return false; } - Point* p_type = static_cast(data); + const Point* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), @@ -443,11 +443,11 @@ MessageDescriptorPubSubType::~MessageDescriptorPubSubType() } bool MessageDescriptorPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - MessageDescriptor* p_type = static_cast(data); + const MessageDescriptor* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -519,7 +519,7 @@ bool MessageDescriptorPubSubType::deserialize( } std::function MessageDescriptorPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -536,7 +536,7 @@ std::function MessageDescriptorPubSubType::getSerializedSizeProvider eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -559,7 +559,7 @@ void MessageDescriptorPubSubType::deleteData( } bool MessageDescriptorPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -568,7 +568,7 @@ bool MessageDescriptorPubSubType::getKey( return false; } - MessageDescriptor* p_type = static_cast(data); + const MessageDescriptor* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), @@ -636,11 +636,11 @@ MessagePubSubType::~MessagePubSubType() } bool MessagePubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - Message* p_type = static_cast(data); + const Message* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -712,7 +712,7 @@ bool MessagePubSubType::deserialize( } std::function MessagePubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -729,7 +729,7 @@ std::function MessagePubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -752,7 +752,7 @@ void MessagePubSubType::deleteData( } bool MessagePubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -761,7 +761,7 @@ bool MessagePubSubType::getKey( return false; } - Message* p_type = static_cast(data); + const Message* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), @@ -829,11 +829,11 @@ CompleteDataPubSubType::~CompleteDataPubSubType() } bool CompleteDataPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - CompleteData* p_type = static_cast(data); + const CompleteData* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -905,7 +905,7 @@ bool CompleteDataPubSubType::deserialize( } std::function CompleteDataPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -922,7 +922,7 @@ std::function CompleteDataPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -945,7 +945,7 @@ void CompleteDataPubSubType::deleteData( } bool CompleteDataPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -954,7 +954,7 @@ bool CompleteDataPubSubType::getKey( return false; } - CompleteData* p_type = static_cast(data); + const CompleteData* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h index 53524c491..b08770bbc 100644 --- a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h +++ b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h @@ -53,34 +53,34 @@ class TimestampPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~TimestampPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; @@ -144,34 +144,34 @@ class PointPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~PointPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; @@ -235,34 +235,34 @@ class MessageDescriptorPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~MessageDescriptorPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; @@ -326,34 +326,34 @@ class MessagePubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~MessagePubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; @@ -417,34 +417,34 @@ class CompleteDataPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~CompleteDataPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx index aa161b2e1..41da39407 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx @@ -27,8 +27,8 @@ #include "HelloWorldCdrAux.hpp" #include "HelloWorldTypeObjectSupport.hpp" -using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; +using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; +using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; HelloWorldPubSubType::HelloWorldPubSubType() @@ -57,11 +57,11 @@ HelloWorldPubSubType::~HelloWorldPubSubType() } bool HelloWorldPubSubType::serialize( - void* data, + const void* const data, SerializedPayload_t* payload, DataRepresentationId_t data_representation) { - HelloWorld* p_type = static_cast(data); + const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(payload->data), payload->max_size); @@ -133,7 +133,7 @@ bool HelloWorldPubSubType::deserialize( } std::function HelloWorldPubSubType::getSerializedSizeProvider( - void* data, + const void* const data, DataRepresentationId_t data_representation) { return [data, data_representation]() -> uint32_t @@ -150,7 +150,7 @@ std::function HelloWorldPubSubType::getSerializedSizeProvider( eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); size_t current_alignment {0}; return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + + *static_cast(data), current_alignment)) + 4u /*encapsulation*/; } catch (eprosima::fastcdr::exception::Exception& /*exception*/) @@ -173,7 +173,7 @@ void HelloWorldPubSubType::deleteData( } bool HelloWorldPubSubType::getKey( - void* data, + const void* const data, InstanceHandle_t* handle, bool force_md5) { @@ -182,7 +182,7 @@ bool HelloWorldPubSubType::getKey( return false; } - HelloWorld* p_type = static_cast(data); + const HelloWorld* p_type = static_cast(data); // Object that manages the raw buffer. eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h index 7c83d2b30..3db9ca964 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h @@ -53,34 +53,34 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType eProsima_user_DllExport ~HelloWorldPubSubType() override; eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload) override + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override { return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport bool serialize( - void* data, - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool deserialize( - eprosima::fastrtps::rtps::SerializedPayload_t* payload, + eprosima::fastdds::rtps::SerializedPayload_t* payload, void* data) override; eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data) override + const void* const data) override { return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); } eProsima_user_DllExport std::function getSerializedSizeProvider( - void* data, + const void* const data, eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; eProsima_user_DllExport bool getKey( - void* data, - eprosima::fastrtps::rtps::InstanceHandle_t* ihandle, + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, bool force_md5 = false) override; eProsima_user_DllExport void* createData() override; From 0c3f0732909f6f9f3d08a5d79e0157ac735b4210 Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Wed, 3 Jul 2024 12:55:13 +0200 Subject: [PATCH 03/52] Change .h headers to .hpp and regenerate types Signed-off-by: Lucia Echevarria --- .../DdsRecorderCommand/DdsRecorderCommand.hpp | 4 +- .../DdsRecorderCommandCdrAux.hpp | 6 +- .../DdsRecorderCommandCdrAux.ipp | 6 +- .../DdsRecorderCommandPubSubTypes.cxx | 2 +- ...es.h => DdsRecorderCommandPubSubTypes.hpp} | 18 +- .../DdsRecorderCommandTypeObjectSupport.hpp | 6 +- .../DdsRecorderStatus/DdsRecorderStatus.hpp | 4 +- .../DdsRecorderStatusCdrAux.hpp | 6 +- .../DdsRecorderStatusCdrAux.ipp | 6 +- .../DdsRecorderStatusPubSubTypes.cxx | 2 +- ...pes.h => DdsRecorderStatusPubSubTypes.hpp} | 18 +- .../DdsRecorderStatusTypeObjectSupport.hpp | 6 +- .../cpp/command_receiver/CommandReceiver.cpp | 4 +- .../cpp/command_receiver/CommandReceiver.hpp | 4 +- .../DdsRecorderCommand/DdsRecorderCommand.hpp | 4 +- .../DdsRecorderCommandCdrAux.hpp | 6 +- .../DdsRecorderCommandCdrAux.ipp | 6 +- .../DdsRecorderCommandPubSubTypes.cxx | 2 +- ...es.h => DdsRecorderCommandPubSubTypes.hpp} | 18 +- .../DdsRecorderCommandTypeObjectSupport.hpp | 6 +- .../DdsRecorderStatus/DdsRecorderStatus.hpp | 4 +- .../DdsRecorderStatusCdrAux.hpp | 6 +- .../DdsRecorderStatusCdrAux.ipp | 6 +- .../DdsRecorderStatusPubSubTypes.cxx | 2 +- ...pes.h => DdsRecorderStatusPubSubTypes.hpp} | 18 +- .../DdsRecorderStatusTypeObjectSupport.hpp | 6 +- ddsrecorder/test/blackbox/constants.hpp | 2 +- .../blackbox/mcap/McapFileCreationTest.cpp | 2 +- .../resource_limits/ResourceLimitsTest.cpp | 2 +- .../types/hello_world/HelloWorld.hpp | 4 +- .../types/hello_world/HelloWorldCdrAux.hpp | 6 +- .../types/hello_world/HelloWorldCdrAux.ipp | 6 +- .../hello_world/HelloWorldPubSubTypes.cxx | 2 +- ...ubSubTypes.h => HelloWorldPubSubTypes.hpp} | 18 +- .../HelloWorldTypeObjectSupport.hpp | 6 +- .../DynamicTypesCollection.hpp | 4 +- ... => DynamicTypesCollectionPubSubTypes.hpp} | 22 +- ...ynamicTypesCollectionTypeObjectSupport.hpp | 6 +- .../types/logging/DdsRecorderLogEntry.hpp | 4 +- ...s.h => DdsRecorderLogEntryPubSubTypes.hpp} | 14 +- .../DdsRecorderLogEntryTypeObjectSupport.hpp | 6 +- .../DdsRecorderMonitoringStatus.hpp | 4 +- .../DdsRecorderMonitoringStatusCdrAux.hpp | 6 +- .../DdsRecorderMonitoringStatusCdrAux.ipp | 6 +- ...dsRecorderMonitoringStatusPubSubTypes.hpp} | 24 +- ...orderMonitoringStatusTypeObjectSupport.hpp | 6 +- .../recorder/mcap/McapSizeTracker.hpp | 2 +- .../recorder/mcap/McapWriter.hpp | 2 +- .../DdsRecorderStatusMonitorProducer.hpp | 2 +- .../DynamicTypesCollectionCdrAux.hpp | 6 +- .../DynamicTypesCollectionCdrAux.ipp | 6 +- .../DynamicTypesCollectionPubSubTypes.cxx | 2 +- ...DdsRecorderMonitoringStatusPubSubTypes.cxx | 2 +- .../src/cpp/recorder/mcap/McapHandler.cpp | 8 +- .../src/cpp/recorder/mcap/McapMessage.cpp | 2 +- .../monitoring/DdsRecorderMonitor.cpp | 2 +- .../cpp/replayer/McapReaderParticipant.cpp | 2 +- .../test/unittest/monitoring/constants.hpp | 2 +- .../dds/DdsMonitorDdsRecorderStatusTest.cpp | 2 +- ddsreplayer/src/cpp/tool/DdsReplayer.cpp | 6 +- .../dds/ConfigurationDynTypesSubscriber.cpp | 2 +- .../dds/ConfigurationDynTypesSubscriber.h | 4 +- .../mcap/dds/ConfigurationSubscriber.cpp | 10 +- .../mcap/dds/ConfigurationSubscriber.h | 2 +- .../dds/types/configuration/Configuration.hpp | 4 +- .../configuration/ConfigurationCdrAux.hpp | 6 +- .../configuration/ConfigurationCdrAux.ipp | 6 +- .../ConfigurationPubSubTypes.cxx | 2 +- ...ubTypes.h => ConfigurationPubSubTypes.hpp} | 18 +- .../ConfigurationTypeObjectSupport.hpp | 6 +- .../mcap/dds/types/hello_world/HelloWorld.hpp | 227 ----------------- .../mcap/dds/types/hello_world/HelloWorld.idl | 5 - .../types/hello_world/HelloWorldCdrAux.hpp | 46 ---- .../types/hello_world/HelloWorldCdrAux.ipp | 126 ---------- .../hello_world/HelloWorldPubSubTypes.cxx | 229 ------------------ .../HelloWorldTypeObjectSupport.cxx | 138 ----------- .../HelloWorldTypeObjectSupport.hpp | 56 ----- .../types/hello_world_basic/HelloWorld.hpp | 226 ----------------- .../types/hello_world_basic/HelloWorld.idl | 5 - .../hello_world_basic/HelloWorldCdrAux.hpp | 46 ---- .../hello_world_basic/HelloWorldCdrAux.ipp | 126 ---------- .../HelloWorldPubSubTypes.cxx | 229 ------------------ .../hello_world_basic/HelloWorldPubSubTypes.h | 133 ---------- .../HelloWorldTypeObjectSupport.cxx | 164 ------------- .../HelloWorldTypeObjectSupport.hpp | 56 ----- .../TypeLookupServicePublisher.cpp | 4 +- .../types/complete/Complete.hpp | 4 +- .../types/complete/CompleteCdrAux.hpp | 6 +- .../types/complete/CompleteCdrAux.ipp | 6 +- .../types/complete/CompletePubSubTypes.cxx | 2 +- ...ePubSubTypes.h => CompletePubSubTypes.hpp} | 34 +-- .../complete/CompleteTypeObjectSupport.hpp | 6 +- .../types/hello_world/HelloWorld.hpp | 4 +- .../types/hello_world/HelloWorldCdrAux.hpp | 6 +- .../types/hello_world/HelloWorldCdrAux.ipp | 6 +- .../hello_world/HelloWorldPubSubTypes.cxx | 2 +- .../types/hello_world/HelloWorldPubSubTypes.h | 133 ---------- .../hello_world/HelloWorldPubSubTypes.hpp | 18 +- .../HelloWorldTypeObjectSupport.hpp | 6 +- 99 files changed, 268 insertions(+), 2213 deletions(-) rename controller/controller_tool/ddstypes/DdsRecorderCommand/{DdsRecorderCommandPubSubTypes.h => DdsRecorderCommandPubSubTypes.hpp} (88%) rename controller/controller_tool/ddstypes/DdsRecorderStatus/{DdsRecorderStatusPubSubTypes.h => DdsRecorderStatusPubSubTypes.hpp} (88%) rename ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/{DdsRecorderCommandPubSubTypes.h => DdsRecorderCommandPubSubTypes.hpp} (88%) rename ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/{DdsRecorderStatusPubSubTypes.h => DdsRecorderStatusPubSubTypes.hpp} (88%) rename ddsrecorder/test/resources/types/hello_world/{HelloWorldPubSubTypes.h => HelloWorldPubSubTypes.hpp} (89%) rename ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/{DynamicTypesCollectionPubSubTypes.h => DynamicTypesCollectionPubSubTypes.hpp} (91%) rename ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/{DdsRecorderLogEntryPubSubTypes.h => DdsRecorderLogEntryPubSubTypes.hpp} (74%) rename ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/{DdsRecorderMonitoringStatusPubSubTypes.h => DdsRecorderMonitoringStatusPubSubTypes.hpp} (91%) rename ddsreplayer/test/blackbox/mcap/dds/types/configuration/{ConfigurationPubSubTypes.h => ConfigurationPubSubTypes.hpp} (89%) delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.hpp delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.idl delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.cxx delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.hpp delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.hpp delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.idl delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.hpp delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.ipp delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.cxx delete mode 100644 ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.hpp rename resources/dds/TypeLookupService/types/complete/{CompletePubSubTypes.h => CompletePubSubTypes.hpp} (93%) delete mode 100644 resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h rename ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h => resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.hpp (89%) diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.hpp b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.hpp index ca1be197a..da7577a49 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.hpp +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERCOMMAND_HPP +#define FAST_DDS_GENERATED__DDSRECORDERCOMMAND_HPP #include #include diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp index 77005bd95..a2b9833c5 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_HPP +#define FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_HPP #include "DdsRecorderCommand.hpp" @@ -42,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_HPP diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp index f0f7c5c15..70d3e6f90 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_IPP +#define FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_IPP #include "DdsRecorderCommandCdrAux.hpp" @@ -122,5 +122,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_IPP diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx index f39246e75..268668b96 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include "DdsRecorderCommandPubSubTypes.h" +#include "DdsRecorderCommandPubSubTypes.hpp" #include #include diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.hpp similarity index 88% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h rename to controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.hpp index cd9fadaa2..e96550a68 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file DdsRecorderCommandPubSubTypes.h + * @file DdsRecorderCommandPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERCOMMAND_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__DDSRECORDERCOMMAND_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "DdsRecorderCommand.hpp" @@ -106,7 +106,7 @@ class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataTyp } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,10 +124,10 @@ class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__DDSRECORDERCOMMAND_PUBSUBTYPES_HPP diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp index 76fc6f9b1..074b42d8f 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp +++ b/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP #include @@ -53,4 +53,4 @@ eProsima_user_DllExport void register_DdsRecorderCommand_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.hpp b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.hpp index c4cfbe7a1..ae8b202fe 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.hpp +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERSTATUS_HPP +#define FAST_DDS_GENERATED__DDSRECORDERSTATUS_HPP #include #include diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp index 7ad935b53..c87672be8 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_HPP +#define FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_HPP #include "DdsRecorderStatus.hpp" @@ -42,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_HPP diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp index 983ef7b9b..db2f691d8 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_IPP +#define FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_IPP #include "DdsRecorderStatusCdrAux.hpp" @@ -130,5 +130,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_IPP diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx index 6f3b01252..3a491f44d 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include "DdsRecorderStatusPubSubTypes.h" +#include "DdsRecorderStatusPubSubTypes.hpp" #include #include diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.hpp similarity index 88% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h rename to controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.hpp index 1955d866c..879ac6eb3 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file DdsRecorderStatusPubSubTypes.h + * @file DdsRecorderStatusPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERSTATUS_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__DDSRECORDERSTATUS_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "DdsRecorderStatus.hpp" @@ -106,7 +106,7 @@ class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,10 +124,10 @@ class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__DDSRECORDERSTATUS_PUBSUBTYPES_HPP diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp index 1da3c0bd7..3fd63d5f8 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp +++ b/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP #include @@ -53,4 +53,4 @@ eProsima_user_DllExport void register_DdsRecorderStatus_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp index 2f5434d2a..c5c0e9576 100644 --- a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp +++ b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.cpp @@ -23,8 +23,8 @@ #include #include #include -#include -#include +#include +#include #include diff --git a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp index 599b9b03e..22d8188d7 100644 --- a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp +++ b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp @@ -36,9 +36,9 @@ #include -#include "types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h" +#include "types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.hpp" #include "types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp" -#include "types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h" +#include "types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.hpp" #include "types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp" namespace eprosima { diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.hpp index ca1be197a..da7577a49 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.hpp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERCOMMAND_HPP +#define FAST_DDS_GENERATED__DDSRECORDERCOMMAND_HPP #include #include diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp index 77005bd95..a2b9833c5 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_HPP +#define FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_HPP #include "DdsRecorderCommand.hpp" @@ -42,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_HPP diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp index f0f7c5c15..70d3e6f90 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_IPP +#define FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_IPP #include "DdsRecorderCommandCdrAux.hpp" @@ -122,5 +122,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMANDCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERCOMMANDCDRAUX_IPP diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx index f39246e75..268668b96 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include "DdsRecorderCommandPubSubTypes.h" +#include "DdsRecorderCommandPubSubTypes.hpp" #include #include diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.hpp similarity index 88% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.hpp index cd9fadaa2..e96550a68 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file DdsRecorderCommandPubSubTypes.h + * @file DdsRecorderCommandPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERCOMMAND_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__DDSRECORDERCOMMAND_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "DdsRecorderCommand.hpp" @@ -106,7 +106,7 @@ class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataTyp } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,10 +124,10 @@ class DdsRecorderCommandPubSubType : public eprosima::fastdds::dds::TopicDataTyp #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__DDSRECORDERCOMMAND_PUBSUBTYPES_HPP diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp index 76fc6f9b1..074b42d8f 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP #include @@ -53,4 +53,4 @@ eProsima_user_DllExport void register_DdsRecorderCommand_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERCOMMAND_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.hpp index c4cfbe7a1..ae8b202fe 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.hpp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERSTATUS_HPP +#define FAST_DDS_GENERATED__DDSRECORDERSTATUS_HPP #include #include diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp index 7ad935b53..c87672be8 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_HPP +#define FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_HPP #include "DdsRecorderStatus.hpp" @@ -42,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_HPP diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp index 983ef7b9b..db2f691d8 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_IPP +#define FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_IPP #include "DdsRecorderStatusCdrAux.hpp" @@ -130,5 +130,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUSCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERSTATUSCDRAUX_IPP diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx index 6f3b01252..3a491f44d 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include "DdsRecorderStatusPubSubTypes.h" +#include "DdsRecorderStatusPubSubTypes.hpp" #include #include diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.hpp similarity index 88% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h rename to ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.hpp index 1955d866c..879ac6eb3 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file DdsRecorderStatusPubSubTypes.h + * @file DdsRecorderStatusPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERSTATUS_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__DDSRECORDERSTATUS_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "DdsRecorderStatus.hpp" @@ -106,7 +106,7 @@ class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,10 +124,10 @@ class DdsRecorderStatusPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__DDSRECORDERSTATUS_PUBSUBTYPES_HPP diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp index 1da3c0bd7..3fd63d5f8 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp +++ b/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP #include @@ -53,4 +53,4 @@ eProsima_user_DllExport void register_DdsRecorderStatus_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERSTATUS_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddsrecorder/test/blackbox/constants.hpp b/ddsrecorder/test/blackbox/constants.hpp index 37d42e7c0..a04475855 100644 --- a/ddsrecorder/test/blackbox/constants.hpp +++ b/ddsrecorder/test/blackbox/constants.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp index 3cf4a7255..433672b9d 100644 --- a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp @@ -40,7 +40,7 @@ #include #include "../../resources/types/hello_world/HelloWorld.hpp" -#include "../../resources/types/hello_world/HelloWorldPubSubTypes.h" +#include "../../resources/types/hello_world/HelloWorldPubSubTypes.hpp" #include "../../resources/types/hello_world/HelloWorldTypeObjectSupport.hpp" using namespace eprosima::ddspipe; diff --git a/ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp b/ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp index 7ef00b89e..ac070ae51 100644 --- a/ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp +++ b/ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp @@ -36,7 +36,7 @@ #include #include "../../resources/types/hello_world/HelloWorld.hpp" -#include "../../resources/types/hello_world/HelloWorldPubSubTypes.h" +#include "../../resources/types/hello_world/HelloWorldPubSubTypes.hpp" #include "../constants.hpp" diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorld.hpp b/ddsrecorder/test/resources/types/hello_world/HelloWorld.hpp index 971fea8d9..46d0d7b58 100644 --- a/ddsrecorder/test/resources/types/hello_world/HelloWorld.hpp +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorld.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_HPP #include #include diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.hpp b/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.hpp index 6feb8a9da..1164cd5cc 100644 --- a/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.hpp +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP +#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP #include "HelloWorld.hpp" @@ -42,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.ipp b/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.ipp index 97df3fe9d..19316df7d 100644 --- a/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.ipp +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP +#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP #include "HelloWorldCdrAux.hpp" @@ -122,5 +122,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx index 41da39407..38393dbf8 100644 --- a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include "HelloWorldPubSubTypes.h" +#include "HelloWorldPubSubTypes.hpp" #include #include diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.h b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp similarity index 89% rename from ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.h rename to ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp index 3db9ca964..556d4c05e 100644 --- a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.h +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file HelloWorldPubSubTypes.h + * @file HelloWorldPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "HelloWorld.hpp" @@ -106,7 +106,7 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,10 +124,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.hpp b/ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.hpp index 2eba797b0..ec922163d 100644 --- a/ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.hpp +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP #include @@ -53,4 +53,4 @@ eProsima_user_DllExport void register_HelloWorld_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollection.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollection.hpp index 7889fd1fd..f6a33d845 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollection.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollection.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_HPP_ -#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_HPP_ +#ifndef FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_HPP +#define FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_HPP #include #include diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.hpp similarity index 91% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.hpp index 0d1a3c9a3..a267a8a8a 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.h +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file DynamicTypesCollectionPubSubTypes.h + * @file DynamicTypesCollectionPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "DynamicTypesCollection.hpp" @@ -112,7 +112,7 @@ namespace eprosima } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -130,7 +130,7 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; @@ -203,7 +203,7 @@ namespace eprosima } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -221,7 +221,7 @@ namespace eprosima #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; @@ -229,5 +229,5 @@ namespace eprosima } // namespace ddsrecorder } // namespace eprosima -#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_HPP diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.hpp index ac7c82e12..f73c8cf07 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/dynamic_types_collection/DynamicTypesCollectionTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_TYPE_OBJECT_SUPPORT_HPP #include @@ -75,4 +75,4 @@ eProsima_user_DllExport void register_DynamicTypesCollection_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntry.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntry.hpp index 8114c38c2..1492a7eca 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntry.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntry.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERLOGENTRY_HPP +#define FAST_DDS_GENERATED__DDSRECORDERLOGENTRY_HPP #include #include diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryPubSubTypes.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryPubSubTypes.hpp similarity index 74% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryPubSubTypes.h rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryPubSubTypes.hpp index 5e46fa646..aa10c21b5 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryPubSubTypes.h +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file DdsRecorderLogEntryPubSubTypes.h + * @file DdsRecorderLogEntryPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERLOGENTRY_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__DDSRECORDERLOGENTRY_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "DdsRecorderLogEntry.hpp" @@ -38,5 +38,5 @@ #endif // GEN_API_VER -#endif // _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__DDSRECORDERLOGENTRY_PUBSUBTYPES_HPP diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.hpp index 4f7dc76f3..f06d162b3 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/logging/DdsRecorderLogEntryTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERLOGENTRY_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__DDSRECORDERLOGENTRY_TYPE_OBJECT_SUPPORT_HPP #include @@ -40,4 +40,4 @@ #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_DDSRECORDERLOGENTRY_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERLOGENTRY_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatus.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatus.hpp index 35da36d3a..724686a90 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatus.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatus.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUS_HPP +#define FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUS_HPP #include #include diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.hpp index 0e5f11341..09c23c232 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUSCDRAUX_HPP +#define FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUSCDRAUX_HPP #include "DdsRecorderMonitoringStatus.hpp" @@ -50,5 +50,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUSCDRAUX_HPP diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.ipp index c425b4547..5f716670b 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.ipp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUSCDRAUX_IPP +#define FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUSCDRAUX_IPP #include "DdsRecorderMonitoringStatusCdrAux.hpp" @@ -214,5 +214,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUSCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUSCDRAUX_IPP diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.h b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.hpp similarity index 91% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.h rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.hpp index 471170f99..087f9d05b 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.h +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.hpp @@ -13,25 +13,25 @@ // limitations under the License. /*! - * @file DdsRecorderMonitoringStatusPubSubTypes.h + * @file DdsRecorderMonitoringStatusPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUS_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUS_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "DdsRecorderMonitoringStatus.hpp" -#include "ddspipe_core/types/monitoring/status/MonitoringStatusPubSubTypes.h" +#include "ddspipe_core/types/monitoring/status/MonitoringStatusPubSubTypes.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) #error \ @@ -107,7 +107,7 @@ class DdsRecorderMonitoringErrorStatusPubSubType : public eprosima::fastdds::dds } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -125,7 +125,7 @@ class DdsRecorderMonitoringErrorStatusPubSubType : public eprosima::fastdds::dds #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; @@ -198,7 +198,7 @@ class DdsRecorderMonitoringStatusPubSubType : public eprosima::fastdds::dds::Top } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -216,10 +216,10 @@ class DdsRecorderMonitoringStatusPubSubType : public eprosima::fastdds::dds::Top #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUS_PUBSUBTYPES_HPP diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.hpp index 6e74f8589..172892536 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP #include @@ -66,4 +66,4 @@ eProsima_user_DllExport void register_DdsRecorderMonitoringStatus_type_identifie #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__DDSRECORDERMONITORINGSTATUS_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapSizeTracker.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapSizeTracker.hpp index 03d9f1960..c0e02ec50 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapSizeTracker.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapSizeTracker.hpp @@ -23,7 +23,7 @@ #include -#include +#include #include diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp index 7e89da2ad..51972db1b 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp @@ -24,7 +24,7 @@ #include -#include +#include #include #include diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/monitoring/producers/DdsRecorderStatusMonitorProducer.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/monitoring/producers/DdsRecorderStatusMonitorProducer.hpp index 685bf32b6..7678962d8 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/monitoring/producers/DdsRecorderStatusMonitorProducer.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/monitoring/producers/DdsRecorderStatusMonitorProducer.hpp @@ -23,7 +23,7 @@ #include #include -#include +#include #include namespace eprosima { diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.hpp b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.hpp index fc59637d3..5e83bb1b8 100644 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.hpp +++ b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_HPP +#define FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_HPP #include @@ -49,5 +49,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_HPP diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.ipp b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.ipp index 57368df88..e4605677c 100644 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.ipp +++ b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_IPP +#define FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_IPP #include "DynamicTypesCollectionCdrAux.hpp" @@ -222,5 +222,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_IPP diff --git a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx index 56d45e7fc..258a1489b 100644 --- a/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx +++ b/ddsrecorder_participants/src/cpp/common/types/dynamic_types_collection/DynamicTypesCollectionPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include +#include #include #include diff --git a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx index 2d798f5de..5fca2f9c5 100644 --- a/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx +++ b/ddsrecorder_participants/src/cpp/common/types/monitoring/ddsrecorder_status/DdsRecorderMonitoringStatusPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include +#include #include #include diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 8c3a7a5f5..416275655 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -30,10 +30,10 @@ #include #include #include -#include +#include #include -#include -#include +#include +#include #include #include @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include #include diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp index afcf758db..6ae3e091d 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp @@ -16,7 +16,7 @@ * @file McapMessage.cpp */ -#include +#include #include diff --git a/ddsrecorder_participants/src/cpp/recorder/monitoring/DdsRecorderMonitor.cpp b/ddsrecorder_participants/src/cpp/recorder/monitoring/DdsRecorderMonitor.cpp index 02019ddea..449b85cc3 100644 --- a/ddsrecorder_participants/src/cpp/recorder/monitoring/DdsRecorderMonitor.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/monitoring/DdsRecorderMonitor.cpp @@ -20,7 +20,7 @@ #include #include -#include +#include #include diff --git a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp index 94344cf76..a5916c722 100644 --- a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp @@ -18,7 +18,7 @@ #include -#include +#include #include #include diff --git a/ddsrecorder_participants/test/unittest/monitoring/constants.hpp b/ddsrecorder_participants/test/unittest/monitoring/constants.hpp index a7579eb97..f1d3dc942 100644 --- a/ddsrecorder_participants/test/unittest/monitoring/constants.hpp +++ b/ddsrecorder_participants/test/unittest/monitoring/constants.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/DdsMonitorDdsRecorderStatusTest.cpp b/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/DdsMonitorDdsRecorderStatusTest.cpp index da25a2798..164979b45 100644 --- a/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/DdsMonitorDdsRecorderStatusTest.cpp +++ b/ddsrecorder_participants/test/unittest/monitoring/ddsrecorder_status/dds/DdsMonitorDdsRecorderStatusTest.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include "../../constants.hpp" diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index 229308fd3..57076dc4a 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -36,7 +36,7 @@ #include #include -#include +#include #include diff --git a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp index 93b5e25c4..e7e77ac9a 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp +++ b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp @@ -32,7 +32,7 @@ #include #include // #include -#include +#include #include "ConfigurationDynTypesSubscriber.h" diff --git a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.h b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.h index ab04e38fc..385a8ff60 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.h +++ b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.h @@ -30,9 +30,9 @@ #include #include #include -#include +#include -#include "types/configuration/ConfigurationPubSubTypes.h" +#include "types/configuration/ConfigurationPubSubTypes.hpp" struct DataToCheck { diff --git a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp index ca6cb97bb..f109df2af 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp +++ b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp @@ -26,12 +26,12 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include "types/configuration/ConfigurationPubSubTypes.h" +#include "types/configuration/ConfigurationPubSubTypes.hpp" #include "ConfigurationSubscriber.h" using namespace eprosima::fastdds::dds; diff --git a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h index 6c171c083..514cec863 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h +++ b/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h @@ -24,7 +24,7 @@ #include #include -#include "types/configuration/ConfigurationPubSubTypes.h" +#include "types/configuration/ConfigurationPubSubTypes.hpp" struct DataToCheck { diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.hpp index 14df67704..058da2a71 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.hpp +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_CONFIGURATION_HPP_ -#define _FAST_DDS_GENERATED_CONFIGURATION_HPP_ +#ifndef FAST_DDS_GENERATED__CONFIGURATION_HPP +#define FAST_DDS_GENERATED__CONFIGURATION_HPP #include #include diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.hpp index c496adce2..74faadd58 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.hpp +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__CONFIGURATIONCDRAUX_HPP +#define FAST_DDS_GENERATED__CONFIGURATIONCDRAUX_HPP #include "Configuration.hpp" @@ -42,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__CONFIGURATIONCDRAUX_HPP diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.ipp b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.ipp index 15e6a23f8..b52fc41c1 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.ipp +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__CONFIGURATIONCDRAUX_IPP +#define FAST_DDS_GENERATED__CONFIGURATIONCDRAUX_IPP #include "ConfigurationCdrAux.hpp" @@ -130,5 +130,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_CONFIGURATIONCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__CONFIGURATIONCDRAUX_IPP diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx index fbdbb9bf3..2c0854fb8 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include "ConfigurationPubSubTypes.h" +#include "ConfigurationPubSubTypes.hpp" #include #include diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.h b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.hpp similarity index 89% rename from ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.h rename to ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.hpp index a2a5c95ac..f5e4f1ca1 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.h +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file ConfigurationPubSubTypes.h + * @file ConfigurationPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_CONFIGURATION_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_CONFIGURATION_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__CONFIGURATION_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__CONFIGURATION_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "Configuration.hpp" @@ -106,7 +106,7 @@ class ConfigurationPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,10 +124,10 @@ class ConfigurationPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_CONFIGURATION_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__CONFIGURATION_PUBSUBTYPES_HPP diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.hpp index c59a74172..c6c00a501 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.hpp +++ b/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_CONFIGURATION_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_CONFIGURATION_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__CONFIGURATION_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__CONFIGURATION_TYPE_OBJECT_SUPPORT_HPP #include @@ -53,4 +53,4 @@ eProsima_user_DllExport void register_Configuration_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_CONFIGURATION_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__CONFIGURATION_TYPE_OBJECT_SUPPORT_HPP diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.hpp deleted file mode 100644 index 971fea8d9..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.hpp +++ /dev/null @@ -1,227 +0,0 @@ -// 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 HelloWorld.hpp - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ - -#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(HELLOWORLD_SOURCE) -#define HELLOWORLD_DllAPI __declspec( dllexport ) -#else -#define HELLOWORLD_DllAPI __declspec( dllimport ) -#endif // HELLOWORLD_SOURCE -#else -#define HELLOWORLD_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HELLOWORLD_DllAPI -#endif // _WIN32 - -/*! - * @brief This class represents the structure HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorld -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport HelloWorld() - { - } - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~HelloWorld() - { - } - - /*! - * @brief Copy constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - const HelloWorld& x) - { - m_index = x.m_index; - - m_message = x.m_message; - - } - - /*! - * @brief Move constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept - { - m_index = x.m_index; - m_message = std::move(x.m_message); - } - - /*! - * @brief Copy assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x) - { - - m_index = x.m_index; - - m_message = x.m_message; - - return *this; - } - - /*! - * @brief Move assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept - { - - m_index = x.m_index; - m_message = std::move(x.m_message); - return *this; - } - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const - { - return (m_index == x.m_index && - m_message == x.m_message); - } - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const - { - return !(*this == x); - } - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index) - { - m_index = _index; - } - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const - { - return m_index; - } - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index() - { - return m_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) - { - m_message = _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) - { - m_message = std::move(_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 - { - return m_message; - } - - /*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ - eProsima_user_DllExport std::string& message() - { - return m_message; - } - - - -private: - - uint32_t m_index{0}; - std::string m_message; - -}; - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_HPP_ - - diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.idl b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.idl deleted file mode 100644 index 0fd2c355a..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.idl +++ /dev/null @@ -1,5 +0,0 @@ -struct HelloWorld -{ - unsigned long index; - string message; -}; diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp deleted file mode 100644 index 6feb8a9da..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// 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 HelloWorldCdrAux.hpp - * This source file contains some definitions of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ - -#include "HelloWorld.hpp" - -constexpr uint32_t HelloWorld_max_cdr_typesize {268UL}; -constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; - - -namespace eprosima { -namespace fastcdr { - -class Cdr; -class CdrSizeCalculator; - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const HelloWorld& data); - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ - diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp deleted file mode 100644 index 97df3fe9d..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp +++ /dev/null @@ -1,126 +0,0 @@ -// 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 HelloWorldCdrAux.ipp - * This source file contains some declarations of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ - -#include "HelloWorldCdrAux.hpp" - -#include -#include - - -#include -using namespace eprosima::fastcdr::exception; - -namespace eprosima { -namespace fastcdr { - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const HelloWorld& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.index(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.message(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const HelloWorld& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.index() - << eprosima::fastcdr::MemberId(1) << data.message() -; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - HelloWorld& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.index(); - break; - - case 1: - dcdr >> data.message(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const HelloWorld& data) -{ - static_cast(scdr); - static_cast(data); -} - - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ - diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx deleted file mode 100644 index 41da39407..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 HelloWorldPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "HelloWorldPubSubTypes.h" - -#include -#include - -#include "HelloWorldCdrAux.hpp" -#include "HelloWorldTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -HelloWorldPubSubType::HelloWorldPubSubType() -{ - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -HelloWorldPubSubType::~HelloWorldPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool HelloWorldPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - const HelloWorld* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - HelloWorld* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function HelloWorldPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* HelloWorldPubSubType::createData() -{ - return reinterpret_cast(new HelloWorld()); -} - -void HelloWorldPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool HelloWorldPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - const HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - HelloWorld_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void HelloWorldPubSubType::register_type_object_representation() -{ - register_HelloWorld_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.cxx deleted file mode 100644 index 58928b6f0..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// 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 HelloWorldTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "HelloWorldTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_HelloWorld_type_identifier( - TypeIdentifierPair& type_ids_HelloWorld) -{ - - ReturnCode_t return_code_HelloWorld {eprosima::fastdds::dds::RETCODE_OK}; - return_code_HelloWorld = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "HelloWorld", type_ids_HelloWorld); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloWorld) - { - StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, - false, false); - QualifiedTypeName type_name_HelloWorld = "HelloWorld"; - eprosima::fastcdr::optional type_ann_builtin_HelloWorld; - eprosima::fastcdr::optional ann_custom_HelloWorld; - CompleteTypeDetail detail_HelloWorld = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloWorld, ann_custom_HelloWorld, type_name_HelloWorld.to_string()); - CompleteStructHeader header_HelloWorld; - header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld); - CompleteStructMemberSeq member_seq_HelloWorld; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_HelloWorld.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_HelloWorld); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_string_unbounded", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - { - SBound bound = 0; - StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn, - "anonymous_string_unbounded", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_string_unbounded already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, - false, false, false, false); - MemberId member_id_message = 0x00000001; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_HelloWorld.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_HelloWorld); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_message); - } - CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_ids_HelloWorld)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "HelloWorld already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.hpp deleted file mode 100644 index 2eba797b0..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 HelloWorldTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register HelloWorld related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_HelloWorld_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.hpp deleted file mode 100644 index 138a79db5..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.hpp +++ /dev/null @@ -1,226 +0,0 @@ -// 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 HelloWorld.hpp - * This header file contains the declaration of the described types in the IDL file. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ - -#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(HELLOWORLD_SOURCE) -#define HELLOWORLD_DllAPI __declspec( dllexport ) -#else -#define HELLOWORLD_DllAPI __declspec( dllimport ) -#endif // HELLOWORLD_SOURCE -#else -#define HELLOWORLD_DllAPI -#endif // EPROSIMA_USER_DLL_EXPORT -#else -#define HELLOWORLD_DllAPI -#endif // _WIN32 - -/*! - * @brief This class represents the structure HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorld -{ -public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport HelloWorld() - { - } - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~HelloWorld() - { - } - - /*! - * @brief Copy constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - const HelloWorld& x) - { - m_index = x.m_index; - - m_message = x.m_message; - - } - - /*! - * @brief Move constructor. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld( - HelloWorld&& x) noexcept - { - m_index = x.m_index; - m_message = std::move(x.m_message); - } - - /*! - * @brief Copy assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - const HelloWorld& x) - { - - m_index = x.m_index; - - m_message = x.m_message; - - return *this; - } - - /*! - * @brief Move assignment. - * @param x Reference to the object HelloWorld that will be copied. - */ - eProsima_user_DllExport HelloWorld& operator =( - HelloWorld&& x) noexcept - { - - m_index = x.m_index; - m_message = std::move(x.m_message); - return *this; - } - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator ==( - const HelloWorld& x) const - { - return (m_index == x.m_index && - m_message == x.m_message); - } - - /*! - * @brief Comparison operator. - * @param x HelloWorld object to compare. - */ - eProsima_user_DllExport bool operator !=( - const HelloWorld& x) const - { - return !(*this == x); - } - - /*! - * @brief This function sets a value in member index - * @param _index New value for member index - */ - eProsima_user_DllExport void index( - uint32_t _index) - { - m_index = _index; - } - - /*! - * @brief This function returns the value of member index - * @return Value of member index - */ - eProsima_user_DllExport uint32_t index() const - { - return m_index; - } - - /*! - * @brief This function returns a reference to member index - * @return Reference to member index - */ - eProsima_user_DllExport uint32_t& index() - { - return m_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::array& _message) - { - m_message = _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::array&& _message) - { - m_message = std::move(_message); - } - - /*! - * @brief This function returns a constant reference to member message - * @return Constant reference to member message - */ - eProsima_user_DllExport const std::array& message() const - { - return m_message; - } - - /*! - * @brief This function returns a reference to member message - * @return Reference to member message - */ - eProsima_user_DllExport std::array& message() - { - return m_message; - } - - - -private: - - uint32_t m_index{0}; - std::array m_message{0}; - -}; - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_HPP_ - - diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.idl b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.idl deleted file mode 100644 index 9750fbe18..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorld.idl +++ /dev/null @@ -1,5 +0,0 @@ -struct HelloWorld -{ - unsigned long index; - char message[20]; -}; diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.hpp deleted file mode 100644 index de0e84c6e..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.hpp +++ /dev/null @@ -1,46 +0,0 @@ -// 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 HelloWorldCdrAux.hpp - * This source file contains some definitions of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ - -#include "HelloWorld.hpp" - -constexpr uint32_t HelloWorld_max_cdr_typesize {28UL}; -constexpr uint32_t HelloWorld_max_key_cdr_typesize {0UL}; - - -namespace eprosima { -namespace fastcdr { - -class Cdr; -class CdrSizeCalculator; - -eProsima_user_DllExport void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const HelloWorld& data); - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ - diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.ipp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.ipp deleted file mode 100644 index 97df3fe9d..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldCdrAux.ipp +++ /dev/null @@ -1,126 +0,0 @@ -// 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 HelloWorldCdrAux.ipp - * This source file contains some declarations of CDR related functions. - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ - -#include "HelloWorldCdrAux.hpp" - -#include -#include - - -#include -using namespace eprosima::fastcdr::exception; - -namespace eprosima { -namespace fastcdr { - -template<> -eProsima_user_DllExport size_t calculate_serialized_size( - eprosima::fastcdr::CdrSizeCalculator& calculator, - const HelloWorld& data, - size_t& current_alignment) -{ - static_cast(data); - - eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); - size_t calculated_size {calculator.begin_calculate_type_serialized_size( - eprosima::fastcdr::CdrVersion::XCDRv2 == calculator.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - current_alignment)}; - - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(0), - data.index(), current_alignment); - - calculated_size += calculator.calculate_member_serialized_size(eprosima::fastcdr::MemberId(1), - data.message(), current_alignment); - - - calculated_size += calculator.end_calculate_type_serialized_size(previous_encoding, current_alignment); - - return calculated_size; -} - -template<> -eProsima_user_DllExport void serialize( - eprosima::fastcdr::Cdr& scdr, - const HelloWorld& data) -{ - eprosima::fastcdr::Cdr::state current_state(scdr); - scdr.begin_serialize_type(current_state, - eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR); - - scdr - << eprosima::fastcdr::MemberId(0) << data.index() - << eprosima::fastcdr::MemberId(1) << data.message() -; - scdr.end_serialize_type(current_state); -} - -template<> -eProsima_user_DllExport void deserialize( - eprosima::fastcdr::Cdr& cdr, - HelloWorld& data) -{ - cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, - [&data](eprosima::fastcdr::Cdr& dcdr, const eprosima::fastcdr::MemberId& mid) -> bool - { - bool ret_value = true; - switch (mid.id) - { - case 0: - dcdr >> data.index(); - break; - - case 1: - dcdr >> data.message(); - break; - - default: - ret_value = false; - break; - } - return ret_value; - }); -} - -void serialize_key( - eprosima::fastcdr::Cdr& scdr, - const HelloWorld& data) -{ - static_cast(scdr); - static_cast(data); -} - - - -} // namespace fastcdr -} // namespace eprosima - -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ - diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx deleted file mode 100644 index 41da39407..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.cxx +++ /dev/null @@ -1,229 +0,0 @@ -// 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 HelloWorldPubSubTypes.cpp - * This header file contains the implementation of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - -#include "HelloWorldPubSubTypes.h" - -#include -#include - -#include "HelloWorldCdrAux.hpp" -#include "HelloWorldTypeObjectSupport.hpp" - -using SerializedPayload_t = eprosima::fastdds::rtps::SerializedPayload_t; -using InstanceHandle_t = eprosima::fastdds::rtps::InstanceHandle_t; -using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; - -HelloWorldPubSubType::HelloWorldPubSubType() -{ - setName("HelloWorld"); - uint32_t type_size = -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(HelloWorld::getMaxCdrSerializedSize()); -#else - HelloWorld_max_cdr_typesize; -#endif - type_size += static_cast(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ - m_typeSize = type_size + 4; /*encapsulation*/ - m_isGetKeyDefined = false; - uint32_t keyLength = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16; - m_keyBuffer = reinterpret_cast(malloc(keyLength)); - memset(m_keyBuffer, 0, keyLength); -} - -HelloWorldPubSubType::~HelloWorldPubSubType() -{ - if (m_keyBuffer != nullptr) - { - free(m_keyBuffer); - } -} - -bool HelloWorldPubSubType::serialize( - const void* const data, - SerializedPayload_t* payload, - DataRepresentationId_t data_representation) -{ - const HelloWorld* 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, - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); - payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; -#if FASTCDR_VERSION_MAJOR > 1 - ser.set_encoding_flag( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : - eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); -#endif // FASTCDR_VERSION_MAJOR > 1 - - try - { - // Serialize encapsulation - ser.serialize_encapsulation(); - // Serialize the object. - ser << *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - // Get the serialized length -#if FASTCDR_VERSION_MAJOR == 1 - payload->length = static_cast(ser.getSerializedDataLength()); -#else - payload->length = static_cast(ser.get_serialized_data_length()); -#endif // FASTCDR_VERSION_MAJOR == 1 - return true; -} - -bool HelloWorldPubSubType::deserialize( - SerializedPayload_t* payload, - void* data) -{ - try - { - // Convert DATA to pointer of your type - HelloWorld* 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 -#if FASTCDR_VERSION_MAJOR == 1 - , eprosima::fastcdr::Cdr::CdrType::DDS_CDR -#endif // FASTCDR_VERSION_MAJOR == 1 - ); - - // Deserialize encapsulation. - deser.read_encapsulation(); - payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize the object. - deser >> *p_type; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return false; - } - - return true; -} - -std::function HelloWorldPubSubType::getSerializedSizeProvider( - const void* const data, - DataRepresentationId_t data_representation) -{ - return [data, data_representation]() -> uint32_t - { -#if FASTCDR_VERSION_MAJOR == 1 - static_cast(data_representation); - return static_cast(type::getCdrSerializedSize(*static_cast(data))) + - 4u /*encapsulation*/; -#else - try - { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast(calculator.calculate_serialized_size( - *static_cast(data), current_alignment)) + - 4u /*encapsulation*/; - } - catch (eprosima::fastcdr::exception::Exception& /*exception*/) - { - return 0; - } -#endif // FASTCDR_VERSION_MAJOR == 1 - }; -} - -void* HelloWorldPubSubType::createData() -{ - return reinterpret_cast(new HelloWorld()); -} - -void HelloWorldPubSubType::deleteData( - void* data) -{ - delete(reinterpret_cast(data)); -} - -bool HelloWorldPubSubType::getKey( - const void* const data, - InstanceHandle_t* handle, - bool force_md5) -{ - if (!m_isGetKeyDefined) - { - return false; - } - - const HelloWorld* p_type = static_cast(data); - - // Object that manages the raw buffer. - eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast(m_keyBuffer), - HelloWorld_max_key_cdr_typesize); - - // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); -#if FASTCDR_VERSION_MAJOR == 1 - p_type->serializeKey(ser); -#else - eprosima::fastcdr::serialize_key(ser, *p_type); -#endif // FASTCDR_VERSION_MAJOR == 1 - if (force_md5 || HelloWorld_max_key_cdr_typesize > 16) - { - m_md5.init(); -#if FASTCDR_VERSION_MAJOR == 1 - m_md5.update(m_keyBuffer, static_cast(ser.getSerializedDataLength())); -#else - m_md5.update(m_keyBuffer, static_cast(ser.get_serialized_data_length())); -#endif // FASTCDR_VERSION_MAJOR == 1 - 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; -} - -void HelloWorldPubSubType::register_type_object_representation() -{ - register_HelloWorld_type_identifier(type_identifiers_); -} - - -// Include auxiliary functions like for serializing/deserializing. -#include "HelloWorldCdrAux.ipp" diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h deleted file mode 100644 index b161b42f7..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldPubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 HelloWorldPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated HelloWorld 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 HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef HelloWorld type; - - eProsima_user_DllExport HelloWorldPubSubType(); - - eProsima_user_DllExport ~HelloWorldPubSubType() override; - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - 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 - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ - diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.cxx deleted file mode 100644 index 0b3e68810..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.cxx +++ /dev/null @@ -1,164 +0,0 @@ -// 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 HelloWorldTypeObjectSupport.cxx - * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#include "HelloWorldTypeObjectSupport.hpp" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - - -using namespace eprosima::fastdds::dds::xtypes; - -// TypeIdentifier is returned by reference: dependent structures/unions are registered in this same method -void register_HelloWorld_type_identifier( - TypeIdentifierPair& type_ids_HelloWorld) -{ - - ReturnCode_t return_code_HelloWorld {eprosima::fastdds::dds::RETCODE_OK}; - return_code_HelloWorld = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "HelloWorld", type_ids_HelloWorld); - if (eprosima::fastdds::dds::RETCODE_OK != return_code_HelloWorld) - { - StructTypeFlag struct_flags_HelloWorld = TypeObjectUtils::build_struct_type_flag(eprosima::fastdds::dds::xtypes::ExtensibilityKind::APPENDABLE, - false, false); - QualifiedTypeName type_name_HelloWorld = "HelloWorld"; - eprosima::fastcdr::optional type_ann_builtin_HelloWorld; - eprosima::fastcdr::optional ann_custom_HelloWorld; - CompleteTypeDetail detail_HelloWorld = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_HelloWorld, ann_custom_HelloWorld, type_name_HelloWorld.to_string()); - CompleteStructHeader header_HelloWorld; - header_HelloWorld = TypeObjectUtils::build_complete_struct_header(TypeIdentifier(), detail_HelloWorld); - CompleteStructMemberSeq member_seq_HelloWorld; - { - TypeIdentifierPair type_ids_index; - ReturnCode_t return_code_index {eprosima::fastdds::dds::RETCODE_OK}; - return_code_index = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_uint32_t", type_ids_index); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_index) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "index Structure member TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - StructMemberFlag member_flags_index = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, - false, false, false, false); - MemberId member_id_index = 0x00000000; - bool common_index_ec {false}; - CommonStructMember common_index {TypeObjectUtils::build_common_struct_member(member_id_index, member_flags_index, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_index, common_index_ec))}; - if (!common_index_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure index member TypeIdentifier inconsistent."); - return; - } - MemberName name_index = "index"; - eprosima::fastcdr::optional member_ann_builtin_index; - ann_custom_HelloWorld.reset(); - CompleteMemberDetail detail_index = TypeObjectUtils::build_complete_member_detail(name_index, member_ann_builtin_index, ann_custom_HelloWorld); - CompleteStructMember member_index = TypeObjectUtils::build_complete_struct_member(common_index, detail_index); - TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_index); - } - { - TypeIdentifierPair type_ids_message; - ReturnCode_t return_code_message {eprosima::fastdds::dds::RETCODE_OK}; - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "anonymous_array_char_20", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - return_code_message = - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers( - "_char", type_ids_message); - - if (eprosima::fastdds::dds::RETCODE_OK != return_code_message) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "Array element TypeIdentifier unknown to TypeObjectRegistry."); - return; - } - bool element_identifier_anonymous_array_char_20_ec {false}; - TypeIdentifier* element_identifier_anonymous_array_char_20 {new TypeIdentifier(TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, element_identifier_anonymous_array_char_20_ec))}; - if (!element_identifier_anonymous_array_char_20_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Array element TypeIdentifier inconsistent."); - return; - } - EquivalenceKind equiv_kind_anonymous_array_char_20 = EK_COMPLETE; - if (TK_NONE == type_ids_message.type_identifier2()._d()) - { - equiv_kind_anonymous_array_char_20 = EK_BOTH; - } - CollectionElementFlag element_flags_anonymous_array_char_20 = 0; - PlainCollectionHeader header_anonymous_array_char_20 = TypeObjectUtils::build_plain_collection_header(equiv_kind_anonymous_array_char_20, element_flags_anonymous_array_char_20); - { - SBoundSeq array_bound_seq; - TypeObjectUtils::add_array_dimension(array_bound_seq, static_cast(20)); - - PlainArraySElemDefn array_sdefn = TypeObjectUtils::build_plain_array_s_elem_defn(header_anonymous_array_char_20, array_bound_seq, - eprosima::fastcdr::external(element_identifier_anonymous_array_char_20)); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_s_array_type_identifier(array_sdefn, "anonymous_array_char_20", type_ids_message)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "anonymous_array_char_20 already registered in TypeObjectRegistry for a different type."); - } - } - } - StructMemberFlag member_flags_message = TypeObjectUtils::build_struct_member_flag(eprosima::fastdds::dds::xtypes::TryConstructFailAction::DISCARD, - false, false, false, false); - MemberId member_id_message = 0x00000001; - bool common_message_ec {false}; - CommonStructMember common_message {TypeObjectUtils::build_common_struct_member(member_id_message, member_flags_message, TypeObjectUtils::retrieve_complete_type_identifier(type_ids_message, common_message_ec))}; - if (!common_message_ec) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "Structure message member TypeIdentifier inconsistent."); - return; - } - MemberName name_message = "message"; - eprosima::fastcdr::optional member_ann_builtin_message; - ann_custom_HelloWorld.reset(); - CompleteMemberDetail detail_message = TypeObjectUtils::build_complete_member_detail(name_message, member_ann_builtin_message, ann_custom_HelloWorld); - CompleteStructMember member_message = TypeObjectUtils::build_complete_struct_member(common_message, detail_message); - TypeObjectUtils::add_complete_struct_member(member_seq_HelloWorld, member_message); - } - CompleteStructType struct_type_HelloWorld = TypeObjectUtils::build_complete_struct_type(struct_flags_HelloWorld, header_HelloWorld, member_seq_HelloWorld); - if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER == - TypeObjectUtils::build_and_register_struct_type_object(struct_type_HelloWorld, type_name_HelloWorld.to_string(), type_ids_HelloWorld)) - { - EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, - "HelloWorld already registered in TypeObjectRegistry for a different type."); - } - } -} - diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.hpp b/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.hpp deleted file mode 100644 index 2eba797b0..000000000 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world_basic/HelloWorldTypeObjectSupport.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// 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 HelloWorldTypeObjectSupport.hpp - * Header file containing the API required to register the TypeObject representation of the described types in the IDL file - * - * This file was generated by the tool fastddsgen. - */ - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ - -#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 - -#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -/** - * @brief Register HelloWorld related TypeIdentifier. - * Fully-descriptive TypeIdentifiers are directly registered. - * Hash TypeIdentifiers require to fill the TypeObject information and hash it, consequently, the TypeObject is - * indirectly registered as well. - * - * @param[out] TypeIdentifier of the registered type. - * The returned TypeIdentifier corresponds to the complete TypeIdentifier in case of hashed TypeIdentifiers. - * Invalid TypeIdentifier is returned in case of error. - */ -eProsima_user_DllExport void register_HelloWorld_type_identifier( - eprosima::fastdds::dds::xtypes::TypeIdentifierPair& type_ids); - - -#endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ diff --git a/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp b/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp index a23c2a77a..56463ce3c 100644 --- a/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp +++ b/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp @@ -36,9 +36,9 @@ #include "TypeLookupServicePublisher.h" -#include "types/complete/CompletePubSubTypes.h" +#include "types/complete/CompletePubSubTypes.hpp" #include "types/complete/CompleteTypeObjectSupport.hpp" -#include "types/hello_world/HelloWorldPubSubTypes.h" +#include "types/hello_world/HelloWorldPubSubTypes.hpp" #include "types/hello_world/HelloWorldTypeObjectSupport.hpp" using namespace eprosima::fastdds::dds; diff --git a/resources/dds/TypeLookupService/types/complete/Complete.hpp b/resources/dds/TypeLookupService/types/complete/Complete.hpp index 9d1b91cb4..08e68f950 100644 --- a/resources/dds/TypeLookupService/types/complete/Complete.hpp +++ b/resources/dds/TypeLookupService/types/complete/Complete.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_COMPLETE_HPP_ -#define _FAST_DDS_GENERATED_COMPLETE_HPP_ +#ifndef FAST_DDS_GENERATED__COMPLETE_HPP +#define FAST_DDS_GENERATED__COMPLETE_HPP #include #include diff --git a/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp index c896c558e..9faba1b71 100644 --- a/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp +++ b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_COMPLETECDRAUX_HPP_ -#define _FAST_DDS_GENERATED_COMPLETECDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__COMPLETECDRAUX_HPP +#define FAST_DDS_GENERATED__COMPLETECDRAUX_HPP #include "Complete.hpp" @@ -70,5 +70,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_COMPLETECDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__COMPLETECDRAUX_HPP diff --git a/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp index df1837e67..66040d556 100644 --- a/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp +++ b/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_COMPLETECDRAUX_IPP_ -#define _FAST_DDS_GENERATED_COMPLETECDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__COMPLETECDRAUX_IPP +#define FAST_DDS_GENERATED__COMPLETECDRAUX_IPP #include "CompleteCdrAux.hpp" @@ -490,5 +490,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_COMPLETECDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__COMPLETECDRAUX_IPP diff --git a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx index 57dc4017d..b6f94c5a4 100644 --- a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx +++ b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include "CompletePubSubTypes.h" +#include "CompletePubSubTypes.hpp" #include #include diff --git a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.hpp similarity index 93% rename from resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h rename to resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.hpp index b08770bbc..c00dbad4c 100644 --- a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h +++ b/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file CompletePubSubTypes.h + * @file CompletePubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_COMPLETE_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_COMPLETE_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__COMPLETE_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__COMPLETE_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "Complete.hpp" @@ -106,7 +106,7 @@ class TimestampPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,7 +124,7 @@ class TimestampPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; @@ -197,7 +197,7 @@ class PointPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -215,7 +215,7 @@ class PointPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; @@ -288,7 +288,7 @@ class MessageDescriptorPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -306,7 +306,7 @@ class MessageDescriptorPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; @@ -379,7 +379,7 @@ class MessagePubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -397,7 +397,7 @@ class MessagePubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; @@ -470,7 +470,7 @@ class CompleteDataPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -488,10 +488,10 @@ class CompleteDataPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_COMPLETE_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__COMPLETE_PUBSUBTYPES_HPP diff --git a/resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.hpp b/resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.hpp index c2a1ef6ef..137e97627 100644 --- a/resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.hpp +++ b/resources/dds/TypeLookupService/types/complete/CompleteTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_COMPLETE_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_COMPLETE_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__COMPLETE_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__COMPLETE_TYPE_OBJECT_SUPPORT_HPP #include @@ -101,4 +101,4 @@ eProsima_user_DllExport void register_CompleteData_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_COMPLETE_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__COMPLETE_TYPE_OBJECT_SUPPORT_HPP diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorld.hpp b/resources/dds/TypeLookupService/types/hello_world/HelloWorld.hpp index 971fea8d9..46d0d7b58 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorld.hpp +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorld.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_HPP #include #include diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp index 6feb8a9da..1164cd5cc 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP +#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP #include "HelloWorld.hpp" @@ -42,5 +42,5 @@ eProsima_user_DllExport void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_HPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp index 97df3fe9d..19316df7d 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ -#define _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP +#define FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP #include "HelloWorldCdrAux.hpp" @@ -122,5 +122,5 @@ void serialize_key( } // namespace fastcdr } // namespace eprosima -#endif // _FAST_DDS_GENERATED_HELLOWORLDCDRAUX_IPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx index 41da39407..38393dbf8 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx @@ -19,7 +19,7 @@ * This file was generated by the tool fastddsgen. */ -#include "HelloWorldPubSubTypes.h" +#include "HelloWorldPubSubTypes.hpp" #include #include diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h deleted file mode 100644 index 3db9ca964..000000000 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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 HelloWorldPubSubTypes.h - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ - -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated HelloWorld 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 HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef HelloWorld type; - - eProsima_user_DllExport HelloWorldPubSubType(); - - eProsima_user_DllExport ~HelloWorldPubSubType() override; - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - 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 - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ - diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.hpp similarity index 89% rename from ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h rename to resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.hpp index 3db9ca964..556d4c05e 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.hpp @@ -13,21 +13,21 @@ // limitations under the License. /*! - * @file HelloWorldPubSubTypes.h + * @file HelloWorldPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ -#define _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP #include #include -#include -#include -#include +#include +#include +#include #include "HelloWorld.hpp" @@ -106,7 +106,7 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType } eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override { static_cast(data_representation); return false; @@ -124,10 +124,10 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType #endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - MD5 m_md5; + eprosima::fastdds::MD5 m_md5; unsigned char* m_keyBuffer; }; -#endif // _FAST_DDS_GENERATED_HELLOWORLD_PUBSUBTYPES_H_ +#endif // FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.hpp b/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.hpp index 2eba797b0..ec922163d 100644 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.hpp +++ b/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObjectSupport.hpp @@ -19,8 +19,8 @@ * This file was generated by the tool fastddsgen. */ -#ifndef _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ -#define _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#ifndef FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP #include @@ -53,4 +53,4 @@ eProsima_user_DllExport void register_HelloWorld_type_identifier( #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC -#endif // _FAST_DDS_GENERATED_HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP_ +#endif // FAST_DDS_GENERATED__HELLOWORLD_TYPE_OBJECT_SUPPORT_HPP From fc30c833d5371bbb10ffc45db1e681ee2c457f90 Mon Sep 17 00:00:00 2001 From: Lucia Echevarria Date: Tue, 16 Jul 2024 10:49:08 +0200 Subject: [PATCH 04/52] Change to FastDDS idl_serialize implementation Signed-off-by: Lucia Echevarria --- .../src/cpp/recorder/mcap/McapHandler.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 416275655..0b2f6a87a 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -124,6 +125,7 @@ void McapHandler::add_schema( if (configuration_.ros2_types) { + // NOTE: Currently ROS2 types are not supported, change when supported name = utils::demangle_if_ros_type(type_name); encoding = "ros2msg"; data = msg::generate_ros2_schema(dynamic_type); @@ -132,7 +134,15 @@ void McapHandler::add_schema( { name = type_name; encoding = "omgidl"; - data = idl::generate_idl_schema(dynamic_type); + + std::stringstream idl; + auto ret = idl_serialize(dynamic_type, idl); + if (ret != fastdds::dds::RETCODE_OK) + { + logError(DDSRECORDER_MCAP_HANDLER, "MCAP_WRITE | Failed to serialize DynamicType to idl for type wth name: " << dynamic_type->get_name().to_string()); + return; + } + data = idl.str(); } mcap::Schema new_schema(name, encoding, data); From 5c921588d8e77621c1cea7b8ac382546c597a921 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 7 May 2024 11:08:51 +0200 Subject: [PATCH 05/52] Move exceptions to a folder Signed-off-by: tempate --- .../recorder/{output => exceptions}/FullDiskException.hpp | 0 .../recorder/{output => exceptions}/FullFileException.hpp | 0 .../ddsrecorder_participants/recorder/mcap/McapWriter.hpp | 2 +- .../recorder/mcap/impl/McapWriter.ipp | 4 ++-- .../cpp/recorder/{output => exceptions}/FullDiskException.cpp | 2 +- .../cpp/recorder/{output => exceptions}/FullFileException.cpp | 2 +- .../src/cpp/recorder/mcap/McapSizeTracker.cpp | 2 +- ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp | 4 ++-- .../src/cpp/recorder/output/FileTracker.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) rename ddsrecorder_participants/include/ddsrecorder_participants/recorder/{output => exceptions}/FullDiskException.hpp (100%) rename ddsrecorder_participants/include/ddsrecorder_participants/recorder/{output => exceptions}/FullFileException.hpp (100%) rename ddsrecorder_participants/src/cpp/recorder/{output => exceptions}/FullDiskException.cpp (92%) rename ddsrecorder_participants/src/cpp/recorder/{output => exceptions}/FullFileException.cpp (93%) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/FullDiskException.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/exceptions/FullDiskException.hpp similarity index 100% rename from ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/FullDiskException.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/recorder/exceptions/FullDiskException.hpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/FullFileException.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/exceptions/FullFileException.hpp similarity index 100% rename from ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/FullFileException.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/recorder/exceptions/FullFileException.hpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp index 51972db1b..c9524328a 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp @@ -28,10 +28,10 @@ #include #include +#include #include #include #include -#include namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/impl/McapWriter.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/impl/McapWriter.ipp index e38564ca9..4b8e2e5f7 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/impl/McapWriter.ipp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/impl/McapWriter.ipp @@ -18,9 +18,9 @@ #include +#include +#include #include -#include -#include namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder_participants/src/cpp/recorder/output/FullDiskException.cpp b/ddsrecorder_participants/src/cpp/recorder/exceptions/FullDiskException.cpp similarity index 92% rename from ddsrecorder_participants/src/cpp/recorder/output/FullDiskException.cpp rename to ddsrecorder_participants/src/cpp/recorder/exceptions/FullDiskException.cpp index f85495502..93db86d0e 100644 --- a/ddsrecorder_participants/src/cpp/recorder/output/FullDiskException.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/exceptions/FullDiskException.cpp @@ -16,7 +16,7 @@ * @file FullDiskException.cpp */ -#include +#include namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder_participants/src/cpp/recorder/output/FullFileException.cpp b/ddsrecorder_participants/src/cpp/recorder/exceptions/FullFileException.cpp similarity index 93% rename from ddsrecorder_participants/src/cpp/recorder/output/FullFileException.cpp rename to ddsrecorder_participants/src/cpp/recorder/exceptions/FullFileException.cpp index 191ab37a4..659806a45 100644 --- a/ddsrecorder_participants/src/cpp/recorder/output/FullFileException.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/exceptions/FullFileException.cpp @@ -16,7 +16,7 @@ * @file FullFileException.cpp */ -#include +#include namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapSizeTracker.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapSizeTracker.cpp index 226a9d509..c42febba1 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapSizeTracker.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapSizeTracker.cpp @@ -25,8 +25,8 @@ #include #include +#include #include -#include namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp index d9ad8144e..00fb04795 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp @@ -28,11 +28,11 @@ #include #include +#include +#include #include #include #include -#include -#include namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder_participants/src/cpp/recorder/output/FileTracker.cpp b/ddsrecorder_participants/src/cpp/recorder/output/FileTracker.cpp index 69fa881a5..43edaca01 100644 --- a/ddsrecorder_participants/src/cpp/recorder/output/FileTracker.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/output/FileTracker.cpp @@ -25,8 +25,8 @@ #include #include +#include #include -#include namespace eprosima { namespace ddsrecorder { From 04fa0d18e8e383dcb9bf8c45a5ca54fcb4ccfa5c Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 7 May 2024 15:05:20 +0200 Subject: [PATCH 06/52] Strip serializing methods from the McapHandler Signed-off-by: tempate --- .../recorder/mcap/McapHandler.hpp | 44 +--- .../recorder/output/Serializer.hpp | 102 ++++++++ .../recorder/output/impl/Serializer.ipp | 112 +++++++++ .../src/cpp/recorder/mcap/McapHandler.cpp | 231 +----------------- .../src/cpp/recorder/output/Serializer.cpp | 73 ++++++ 5 files changed, 295 insertions(+), 267 deletions(-) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/Serializer.hpp create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/impl/Serializer.ipp create mode 100644 ddsrecorder_participants/src/cpp/recorder/output/Serializer.cpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index 11d89f360..ec7d540bc 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -19,21 +19,19 @@ #pragma once #include -#include #include #include #include -#include #include #include -#include -#include - #include #include +#include +#include + #include #include #include @@ -410,42 +408,6 @@ class McapHandler : public ddspipe::participants::ISchemaHandler const std::string& type_name, DynamicTypesCollection& dynamic_types) const; - /** - * @brief Serialize given \c DynamicTypesCollection into a \c SerializedPayload . - * - * @param [in] dynamic_types Dynamic types collection to be serialized. - * @return Serialized payload for the given dynamic types collection. - */ - fastdds::rtps::SerializedPayload_t* serialize_dynamic_types_( - DynamicTypesCollection& dynamic_types) const; - - /** - * @brief Serialize a \c TopicQoS struct into a string. - * - * @param [in] qos TopicQoS to be serialized - * @return Serialized TopicQoS string - */ - static std::string serialize_qos_( - const ddspipe::core::types::TopicQoS& qos); - - /** - * @brief Serialize a \c TypeIdentifier into a string. - * - * @param [in] type_identifier TypeIdentifier to be serialized - * @return Serialized TypeIdentifier string - */ - static std::string serialize_type_identifier_( - const fastdds::dds::xtypes::TypeIdentifier& type_identifier); - - /** - * @brief Serialize a \c TypeObject into a string. - * - * @param [in] type_object TypeObject to be serialized - * @return Serialized TypeObject string - */ - static std::string serialize_type_object_( - const fastdds::dds::xtypes::TypeObject& type_object); - //! Handler configuration McapHandlerConfiguration configuration_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/Serializer.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/Serializer.hpp new file mode 100644 index 000000000..824a5f2ba --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/Serializer.hpp @@ -0,0 +1,102 @@ +// Copyright 2023 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 Serializer.hpp + */ + +#pragma once + +#include +#include + +#include + +#include +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +/** + * Class to serialize different types of data. + */ +class Serializer +{ +public: + + /** + * @brief Serialize a \c TopicQoS struct into a string. + * + * @param [in] qos TopicQoS to be serialized + * @return Serialized TopicQoS string + */ + DDSRECORDER_PARTICIPANTS_DllAPI + static std::string serialize( + const ddspipe::core::types::TopicQoS& qos); + + /** + * @brief Serialize a \c TypeIdentifier into a string. + * + * Calculates the size of the serialized TypeIdentifier. + * Calls \c data_to_str_ to serialize \c type_identifier + * + * @param [in] type_identifier TypeIdentifier to be serialized + * @return Serialized TypeIdentifier string + */ + DDSRECORDER_PARTICIPANTS_DllAPI + static std::string serialize( + const fastdds::dds::xtypes::TypeIdentifier& type_identifier); + + /** + * @brief Serialize a \c TypeObject into a string. + * + * @param [in] type_object TypeObject to be serialized + * @return Serialized TypeObject string + */ + DDSRECORDER_PARTICIPANTS_DllAPI + static std::string serialize( + const fastdds::dds::xtypes::TypeObject& type_object); + + /** + * @brief Serialize given \c DynamicTypesCollection into a \c SerializedPayload . + * + * @param [in] dynamic_types Dynamic types collection to be serialized. + * @return Serialized payload for the given dynamic types collection. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + static fastdds::rtps::SerializedPayload_t* serialize( + DynamicTypesCollection* dynamic_types); + +protected: + + /** + * @brief Serialize a \c TypeObject or a \c TypeIdentifier into a string. + * + * @param [in] type_data \c TypeObject or \c TypeIdentifier to serialize + * @return string with the serialization + */ + DDSRECORDER_PARTICIPANTS_DllAPI + template + static std::string type_data_to_str_( + const T& type_data); +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ + +#include diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/impl/Serializer.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/impl/Serializer.ipp new file mode 100644 index 000000000..1f543555c --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/impl/Serializer.ipp @@ -0,0 +1,112 @@ +// Copyright 2023 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 Serializer.cpp + */ + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +template +std::string Serializer::type_data_to_str_( + const T& type_data) +{ + // Reserve payload and create buffer + fastcdr::CdrSizeCalculator calculator(fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + size_t type_data_size = calculator.calculate_serialized_size(type_data, current_alignment) + + fastdds::rtps::SerializedPayload_t::representation_header_size; + + fastdds::rtps::SerializedPayload_t payload(static_cast(type_data_size)); + fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); + + // Create CDR serializer + fastcdr::Cdr ser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, + fastcdr::CdrVersion::XCDRv2); + + payload.encapsulation = ser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Serialize + fastcdr::serialize(ser, type_data); + payload.length = (std::uint32_t)ser.get_serialized_data_length(); + type_data_size = (ser.get_serialized_data_length() + 3) & ~3; + + // Create CDR message with payload + auto cdr_message = std::make_unique(payload); + + // Add data + if (!(cdr_message && (cdr_message->pos + payload.length <= cdr_message->max_size))|| (payload.length > 0 && !payload.data)) + { + // TODO Warning + } + else + { + memcpy(&cdr_message->buffer[cdr_message->pos], payload.data, payload.length); + cdr_message->pos += payload.length; + cdr_message->length += payload.length; + } + + fastdds::rtps::octet value = 0; + + for (std::uint32_t count = payload.length; count < type_data_size; ++count) + { + const std::uint32_t size_octet = sizeof(value); + if (!(cdr_message && (cdr_message->pos + size_octet <= cdr_message->max_size))) + { + // TODO Warning + continue; + } + + for (std::uint32_t i = 0; i < size_octet; i++) + { + cdr_message->buffer[cdr_message->pos + i] = *((fastdds::rtps::octet*)&value + size_octet - 1 - i); + } + + cdr_message->pos += size_octet; + cdr_message->length += size_octet; + } + + // Copy buffer to string + std::string type_data_str(reinterpret_cast(cdr_message->buffer), type_data_size); + + // Delete CDR message + // NOTE: set wraps attribute to avoid double free (buffer released by payload on destruction) + cdr_message->wraps = true; + + return type_data_str; +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 0b2f6a87a..c5c5966ec 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -19,24 +19,10 @@ #define MCAP_IMPLEMENTATION // Define this in exactly one .cpp file #include -#include -#include -#include #include - #include -#include -#include -#include -#include -#include -#include -#include -#include - -#include #include #include #include @@ -49,6 +35,7 @@ #include #include #include +#include namespace eprosima { namespace ddsrecorder { @@ -167,14 +154,7 @@ void McapHandler::add_schema( if (configuration_.record_types) { - // Store dynamic type in dynamic_types collection - store_dynamic_type_(type_name, type_id, dynamic_types_); - - // Serialize dynamic types collection - const auto serialized_dynamic_types = serialize_dynamic_types_(dynamic_types_); - - // Recalculate the attachment - mcap_writer_.update_dynamic_types(*serialized_dynamic_types); + mcap_writer_.update_dynamic_types(*Serializer::serialize(&dynamic_types_)); } // Check if there are any pending samples for this new schema. If so, add them. @@ -800,7 +780,7 @@ mcap::ChannelId McapHandler::create_channel_id_nts_( // Create new channel mcap::KeyValueMap metadata = {}; - metadata[QOS_SERIALIZATION_QOS] = serialize_qos_(topic.topic_qos); + metadata[QOS_SERIALIZATION_QOS] = Serializer::serialize(topic.topic_qos); std::string topic_name = configuration_.ros2_types ? utils::demangle_if_ros_topic(topic.m_topic_name) : topic.m_topic_name; // Set ROS2_TYPES to "false" if the given topic_name is equal to topic.m_topic_name, otherwise set it to "true". @@ -921,212 +901,11 @@ void McapHandler::store_dynamic_type_( { DynamicType dynamic_type; dynamic_type.type_name(type_name); - dynamic_type.type_information(utils::base64_encode(serialize_type_identifier_(type_identifier))); - dynamic_type.type_object(utils::base64_encode(serialize_type_object_(type_object))); - + dynamic_type.type_information(utils::base64_encode(Serializer::serialize(type_identifier))); + dynamic_type.type_object(utils::base64_encode(Serializer::serialize(type_object))); dynamic_types.dynamic_types().push_back(dynamic_type); } -fastdds::rtps::SerializedPayload_t* McapHandler::serialize_dynamic_types_( - DynamicTypesCollection& dynamic_types) const -{ - // Serialize dynamic types collection using CDR - fastdds::dds::TypeSupport type_support(new DynamicTypesCollectionPubSubType()); - fastdds::rtps::SerializedPayload_t* serialized_payload = new fastdds::rtps::SerializedPayload_t( - type_support.get_serialized_size_provider(&dynamic_types)()); - type_support.serialize(&dynamic_types, serialized_payload); - - return serialized_payload; -} - -std::string McapHandler::serialize_qos_( - const TopicQoS& qos) -{ - // TODO: Reuse code from ddspipe_yaml - - YAML::Node qos_yaml; - - // Reliability tag - YAML::Node reliability_tag = qos_yaml[QOS_SERIALIZATION_RELIABILITY]; - if (qos.is_reliable()) - { - reliability_tag = true; - } - else - { - reliability_tag = false; - } - - // Durability tag - YAML::Node durability_tag = qos_yaml[QOS_SERIALIZATION_DURABILITY]; - if (qos.is_transient_local()) - { - durability_tag = true; - } - else - { - durability_tag = false; - } - - // Ownership tag - YAML::Node ownership_tag = qos_yaml[QOS_SERIALIZATION_OWNERSHIP]; - if (qos.has_ownership()) - { - ownership_tag = true; - } - else - { - ownership_tag = false; - } - - // Keyed tag - YAML::Node keyed_tag = qos_yaml[QOS_SERIALIZATION_KEYED]; - if (qos.keyed) - { - keyed_tag = true; - } - else - { - keyed_tag = false; - } - - return YAML::Dump(qos_yaml); -} - -std::string McapHandler::serialize_type_identifier_( - const fastdds::dds::xtypes::TypeIdentifier& type_identifier) -{ - // Reserve payload and create buffer - fastcdr::CdrSizeCalculator calculator(fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - size_t size = calculator.calculate_serialized_size(type_identifier, current_alignment) + - fastdds::rtps::SerializedPayload_t::representation_header_size; - - fastdds::rtps::SerializedPayload_t payload(static_cast(size)); - fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - - // Create CDR serializer - fastcdr::Cdr ser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, - fastcdr::CdrVersion::XCDRv2); - - payload.encapsulation = ser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Serialize - fastcdr::serialize(ser, type_identifier); - payload.length = (uint32_t)ser.get_serialized_data_length(); - size = (ser.get_serialized_data_length() + 3) & ~3; - - // Create CDR message with payload - fastdds::rtps::CDRMessage_t* cdr_message = new fastdds::rtps::CDRMessage_t(payload); - - // Add data - if (!(cdr_message && (cdr_message->pos + payload.length <= cdr_message->max_size))|| (payload.length > 0 && !payload.data)) - { - // TODO Warning - } - else - { - memcpy(&cdr_message->buffer[cdr_message->pos], payload.data, payload.length); - cdr_message->pos += payload.length; - cdr_message->length += payload.length; - } - - fastdds::rtps::octet value = 0; - for (uint32_t count = payload.length; count < size; ++count) - { - const uint32_t size_octet = sizeof(value); - if (!(cdr_message && (cdr_message->pos + size_octet <= cdr_message->max_size))) - { - // TODO Warning - } - else - { - for (uint32_t i = 0; i < size_octet; i++) - { - cdr_message->buffer[cdr_message->pos + i] = *((fastdds::rtps::octet*)&value + size_octet - 1 - i); - } - cdr_message->pos += size_octet; - cdr_message->length += size_octet; - } - } - - // Copy buffer to string - std::string typeid_str(reinterpret_cast(cdr_message->buffer), size); - - // Delete CDR message - // NOTE: set wraps attribute to avoid double free (buffer released by payload on destruction) - cdr_message->wraps = true; - delete cdr_message; - - return typeid_str; -} - -std::string McapHandler::serialize_type_object_( - const fastdds::dds::xtypes::TypeObject& type_object) -{ - // Reserve payload and create buffer - fastcdr::CdrSizeCalculator calculator(fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - size_t size = calculator.calculate_serialized_size(type_object, current_alignment) + - fastdds::rtps::SerializedPayload_t::representation_header_size; - fastdds::rtps::SerializedPayload_t payload(static_cast(size)); - fastcdr::FastBuffer fastbuffer((char*) payload.data, payload.max_size); - - // Create CDR serializer - fastcdr::Cdr ser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, - fastcdr::CdrVersion::XCDRv2); - payload.encapsulation = ser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Serialize - fastcdr::serialize(ser, type_object); - payload.length = (uint32_t)ser.get_serialized_data_length(); - size = (ser.get_serialized_data_length() + 3) & ~3; - - // Create CDR message with payload - fastdds::rtps::CDRMessage_t* cdr_message = new fastdds::rtps::CDRMessage_t(payload); - - // Add data - if (!(cdr_message && (cdr_message->pos + payload.length <= cdr_message->max_size))|| (payload.length > 0 && !payload.data)) - { - // TODO Warning - } - else - { - memcpy(&cdr_message->buffer[cdr_message->pos], payload.data, payload.length); - cdr_message->pos += payload.length; - cdr_message->length += payload.length; - } - - fastdds::rtps::octet value = 0; - for (uint32_t count = payload.length; count < size; ++count) - { - const uint32_t size_octet = sizeof(value); - if (!(cdr_message && (cdr_message->pos + size_octet <= cdr_message->max_size))) - { - // TODO Warning - } - else - { - for (uint32_t i = 0; i < size_octet; i++) - { - cdr_message->buffer[cdr_message->pos + i] = *((fastdds::rtps::octet*)&value + size_octet - 1 - i); - } - cdr_message->pos += size_octet; - cdr_message->length += size_octet; - } - } - - // Copy buffer to string - std::string typeobj_str(reinterpret_cast(cdr_message->buffer), size); - - // Delete CDR message - // NOTE: set wraps attribute to avoid double free (buffer released by payload on destruction) - cdr_message->wraps = true; - delete cdr_message; - - return typeobj_str; -} - } /* namespace participants */ } /* namespace ddsrecorder */ } /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/output/Serializer.cpp b/ddsrecorder_participants/src/cpp/recorder/output/Serializer.cpp new file mode 100644 index 000000000..b03c84be8 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/recorder/output/Serializer.cpp @@ -0,0 +1,73 @@ +// Copyright 2023 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 Serializer.cpp + */ + +#include + +#include +#include +#include + +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + + +std::string Serializer::serialize( + const ddspipe::core::types::TopicQoS& qos) +{ + // TODO: Reuse code from ddspipe_yaml + + YAML::Node qos_yaml; + + qos_yaml[QOS_SERIALIZATION_RELIABILITY] = qos.is_reliable(); + qos_yaml[QOS_SERIALIZATION_DURABILITY] = qos.is_transient_local(); + qos_yaml[QOS_SERIALIZATION_OWNERSHIP] = qos.has_ownership(); + qos_yaml[QOS_SERIALIZATION_KEYED] = qos.keyed.get_value(); + + return YAML::Dump(qos_yaml); +} + +std::string Serializer::serialize( + const fastdds::dds::xtypes::TypeIdentifier& type_identifier) +{ + return type_data_to_str_(type_identifier); +} + +std::string Serializer::serialize( + const fastdds::dds::xtypes::TypeObject& type_object) +{ + return type_data_to_str_(type_object); +} + +fastdds::rtps::SerializedPayload_t* Serializer::serialize( + DynamicTypesCollection* dynamic_types) +{ + // Serialize dynamic types collection using CDR + fastdds::dds::TypeSupport type_support(new DynamicTypesCollectionPubSubType()); + auto serialized_payload = new fastdds::rtps::SerializedPayload_t(type_support.get_serialized_size_provider(dynamic_types)()); + type_support.serialize(dynamic_types, serialized_payload); + + return serialized_payload; +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ From 82ceb00c80db17e1681aba97a83f263efa404e58 Mon Sep 17 00:00:00 2001 From: tempate Date: Wed, 8 May 2024 08:45:56 +0200 Subject: [PATCH 07/52] Strip time utils from the McapHandler Signed-off-by: tempate --- .../recorder/mcap/McapHandler.hpp | 29 ---------- .../recorder/mcap/utils.hpp | 58 +++++++++++++++++++ .../src/cpp/recorder/mcap/McapHandler.cpp | 27 ++------- .../src/cpp/recorder/mcap/McapWriter.cpp | 5 +- .../src/cpp/recorder/mcap/utils.cpp | 44 ++++++++++++++ 5 files changed, 109 insertions(+), 54 deletions(-) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp create mode 100644 ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index ec7d540bc..cdc921301 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -30,7 +30,6 @@ #include #include -#include #include #include @@ -198,34 +197,6 @@ class McapHandler : public ddspipe::participants::ISchemaHandler DDSRECORDER_PARTICIPANTS_DllAPI void trigger_event(); - /** - * @brief This method converts a timestamp in Fast DDS format to its mcap equivalent. - * - * @param [in] time Timestamp to be converted - * @return Timestamp in mcap format - */ - DDSRECORDER_PARTICIPANTS_DllAPI - static mcap::Timestamp fastdds_timestamp_to_mcap_timestamp( - const ddspipe::core::types::DataTime& time); - - /** - * @brief This method converts a timestamp in standard format to its mcap equivalent. - * - * @param [in] time Timestamp to be converted - * @return Timestamp in mcap format - */ - DDSRECORDER_PARTICIPANTS_DllAPI - static mcap::Timestamp std_timepoint_to_mcap_timestamp( - const utils::Timestamp& time); - - /** - * @brief Get current time point in mcap format. - * - * @return Current time in mcap format - */ - DDSRECORDER_PARTICIPANTS_DllAPI - static mcap::Timestamp now(); - protected: //! Flag code controlling the event thread routine diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp new file mode 100644 index 000000000..25c7ea511 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp @@ -0,0 +1,58 @@ +// Copyright 2024 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 utils.hpp + */ + +#pragma once + +#include + +#include + +#include + +#include + + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + + +/** + * @brief This method converts a timestamp in Fast DDS format to its mcap equivalent. + * + * @param [in] time Timestamp to be converted + * @return Timestamp in mcap format + */ +DDSRECORDER_PARTICIPANTS_DllAPI +mcap::Timestamp to_mcap_timestamp( + const fastrtps::rtps::Time_t& time); + +/** + * @brief This method converts a timestamp in standard format to its mcap equivalent. + * + * @param [in] time Timestamp to be converted + * @return Timestamp in mcap format + */ +DDSRECORDER_PARTICIPANTS_DllAPI +mcap::Timestamp to_mcap_timestamp( + const utils::Timestamp& time); + + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index c5c5966ec..8c147c2a1 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include namespace eprosima { @@ -186,14 +187,14 @@ void McapHandler::add_data( // Add data to channel McapMessage msg; msg.sequence = unique_sequence_number_++; - msg.publishTime = fastdds_timestamp_to_mcap_timestamp(data.source_timestamp); + msg.publishTime = to_mcap_timestamp(data.source_timestamp); if (configuration_.log_publishTime) { msg.logTime = msg.publishTime; } else { - msg.logTime = now(); + msg.logTime = to_mcap_timestamp(utils::now()); } msg.dataSize = data.payload.length; @@ -443,25 +444,6 @@ void McapHandler::trigger_event() } } -mcap::Timestamp McapHandler::fastdds_timestamp_to_mcap_timestamp( - const DataTime& time) -{ - std::uint64_t mcap_time = time.seconds(); - mcap_time *= 1000000000; - return mcap_time + time.nanosec(); -} - -mcap::Timestamp McapHandler::std_timepoint_to_mcap_timestamp( - const utils::Timestamp& time) -{ - return mcap::Timestamp(std::chrono::duration_cast(time.time_since_epoch()).count()); -} - -mcap::Timestamp McapHandler::now() -{ - return std_timepoint_to_mcap_timestamp(utils::now()); -} - void McapHandler::add_data_nts_( const McapMessage& msg, bool direct_write /* false */) @@ -691,7 +673,8 @@ void McapHandler::remove_outdated_samples_nts_() logInfo(DDSRECORDER_MCAP_HANDLER, "MCAP_STATE | Removing outdated samples."); - auto threshold = std_timepoint_to_mcap_timestamp(utils::now() - std::chrono::seconds(configuration_.event_window)); + const auto threshold = to_mcap_timestamp(utils::now() - std::chrono::seconds(configuration_.event_window)); + samples_buffer_.remove_if([&](auto& sample) { return sample.logTime < threshold; diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp index 00fb04795..32e3e2907 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include namespace eprosima { @@ -333,9 +334,7 @@ void McapWriter::write_attachment_nts_() attachment.name = DYNAMIC_TYPES_ATTACHMENT_NAME; attachment.data = reinterpret_cast(dynamic_types_payload_->data); attachment.dataSize = dynamic_types_payload_->length; - attachment.createTime = - mcap::Timestamp(std::chrono::duration_cast( - utils::now().time_since_epoch()).count()); + attachment.createTime = to_mcap_timestamp(utils::now()); write_nts_(attachment); } diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp new file mode 100644 index 000000000..88a0aa98c --- /dev/null +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp @@ -0,0 +1,44 @@ +// Copyright 2024 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 utils.cpp + */ + +#include +#include + +#include + + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +mcap::Timestamp to_mcap_timestamp( + const fastrtps::rtps::Time_t& time) +{ + static constexpr std::uint64_t NS_PER_SEC = 1000000000; + return time.seconds() * NS_PER_SEC + time.nanosec(); +} + +mcap::Timestamp to_mcap_timestamp( + const utils::Timestamp& time) +{ + return mcap::Timestamp(std::chrono::duration_cast(time.time_since_epoch()).count()); +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ From c80db8f17487b6cbc6a378fd3ca8d1865052fc44 Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 9 May 2024 16:02:41 +0200 Subject: [PATCH 08/52] Strip state transitions and buffer management from the McapHandler Signed-off-by: tempate --- ddsrecorder/src/cpp/tool/DdsRecorder.cpp | 10 +- ddsrecorder/src/cpp/tool/DdsRecorder.hpp | 3 +- .../test/blackbox/mcap/McapLogErrorTests.cpp | 4 +- .../recorder/mcap/McapHandler.hpp | 256 +------- .../mcap/McapHandlerConfiguration.hpp | 2 +- .../recorder/mcap/utils.hpp | 2 +- .../BaseMessage.hpp} | 62 +- .../recorder/message/McapMessage.hpp | 61 ++ .../recorder/output/BaseHandler.hpp | 317 +++++++++ .../src/cpp/recorder/mcap/McapHandler.cpp | 605 +++--------------- .../src/cpp/recorder/mcap/McapWriter.cpp | 2 +- .../src/cpp/recorder/mcap/utils.cpp | 2 +- .../src/cpp/recorder/message/BaseMessage.cpp | 98 +++ .../{mcap => message}/McapMessage.cpp | 35 +- .../src/cpp/recorder/output/BaseHandler.cpp | 498 ++++++++++++++ 15 files changed, 1160 insertions(+), 797 deletions(-) rename ddsrecorder_participants/include/ddsrecorder_participants/recorder/{mcap/McapMessage.hpp => message/BaseMessage.hpp} (55%) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/McapMessage.hpp create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp create mode 100644 ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp rename ddsrecorder_participants/src/cpp/recorder/{mcap => message}/McapMessage.cpp (53%) create mode 100644 ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp diff --git a/ddsrecorder/src/cpp/tool/DdsRecorder.cpp b/ddsrecorder/src/cpp/tool/DdsRecorder.cpp index f09ba8609..269c4ab33 100644 --- a/ddsrecorder/src/cpp/tool/DdsRecorder.cpp +++ b/ddsrecorder/src/cpp/tool/DdsRecorder.cpp @@ -239,26 +239,26 @@ void DdsRecorder::load_internal_topics_( } } -participants::McapHandlerStateCode DdsRecorder::recorder_to_handler_state_( +participants::BaseHandlerStateCode DdsRecorder::recorder_to_handler_state_( const DdsRecorderStateCode& recorder_state) { switch (recorder_state) { case DdsRecorderStateCode::RUNNING: - return participants::McapHandlerStateCode::RUNNING; + return participants::BaseHandlerStateCode::RUNNING; case DdsRecorderStateCode::PAUSED: - return participants::McapHandlerStateCode::PAUSED; + return participants::BaseHandlerStateCode::PAUSED; case DdsRecorderStateCode::STOPPED: case DdsRecorderStateCode::SUSPENDED: - return participants::McapHandlerStateCode::STOPPED; + return participants::BaseHandlerStateCode::STOPPED; default: // Unreachable utils::tsnh( utils::Formatter() << "Trying to convert to McapHandler state an invalid DdsRecorder state."); - return participants::McapHandlerStateCode::STOPPED; + return participants::BaseHandlerStateCode::STOPPED; } } diff --git a/ddsrecorder/src/cpp/tool/DdsRecorder.hpp b/ddsrecorder/src/cpp/tool/DdsRecorder.hpp index 4ec602171..b9df8ee84 100644 --- a/ddsrecorder/src/cpp/tool/DdsRecorder.hpp +++ b/ddsrecorder/src/cpp/tool/DdsRecorder.hpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -131,7 +132,7 @@ class DdsRecorder void load_internal_topics_( yaml::RecorderConfiguration& configuration); - static participants::McapHandlerStateCode recorder_to_handler_state_( + static participants::BaseHandlerStateCode recorder_to_handler_state_( const DdsRecorderStateCode& recorder_state); //! Configuration of the DDS Recorder diff --git a/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp b/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp index 8a1cc545b..cb902d39f 100644 --- a/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp @@ -68,8 +68,8 @@ TEST(McapLogErrorTests, fail_to_open_file) { ); std::shared_ptr payload_pool; - eprosima::ddsrecorder::participants::McapHandlerStateCode init_state = - eprosima::ddsrecorder::participants::McapHandlerStateCode::RUNNING; + eprosima::ddsrecorder::participants::BaseHandlerStateCode init_state = + eprosima::ddsrecorder::participants::BaseHandlerStateCode::RUNNING; // Create the McapWriter auto file_tracker = std::make_shared(config.output_settings); diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index cdc921301..4033c511f 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -18,11 +18,9 @@ #pragma once -#include #include #include #include -#include #include @@ -36,12 +34,12 @@ #include #include -#include - #include #include -#include #include +#include +#include +#include #include #include @@ -50,26 +48,16 @@ namespace eprosima { namespace ddsrecorder { namespace participants { -//! State of the handler instance -ENUMERATION_BUILDER( - McapHandlerStateCode, - STOPPED, //! Received messages are not processed. - RUNNING, //! Messages are stored in buffer and dumped to disk when full. - PAUSED //! Messages are stored in buffer and dumped to disk when event triggered. - ); - /** * Class that manages the interaction between DDS Pipe (\c SchemaParticipant) and MCAP files through mcap library. * Payloads are efficiently passed from DDS Pipe to mcap without copying data (only references). * - * @implements ISchemaHandler + * @implements BaseHandler */ -class McapHandler : public ddspipe::participants::ISchemaHandler +class McapHandler : public BaseHandler { public: - using pending_list = std::list>; - /** * McapHandler constructor by required values. * @@ -92,7 +80,7 @@ class McapHandler : public ddspipe::participants::ISchemaHandler const McapHandlerConfiguration& config, const std::shared_ptr& payload_pool, std::shared_ptr file_tracker, - const McapHandlerStateCode& init_state = McapHandlerStateCode::RUNNING, + const BaseHandlerStateCode& init_state = BaseHandlerStateCode::RUNNING, const std::function& on_disk_full_lambda = nullptr); /** @@ -103,7 +91,21 @@ class McapHandler : public ddspipe::participants::ISchemaHandler * */ DDSRECORDER_PARTICIPANTS_DllAPI - ~McapHandler(); + virtual ~McapHandler(); + + /** + * @brief Enable handler instance + * + * Enables the \c mcap_writer_ instance. + */ + void enable() override; + + /** + * @brief Disable handler instance + * + * Disables the \c mcap_writer_ instance. + */ + void disable() override; /** * @brief Create and store in \c schemas_ an OMG IDL (.idl format) or ROS 2 (.msg format) schema. @@ -139,176 +141,19 @@ class McapHandler : public ddspipe::participants::ISchemaHandler const ddspipe::core::types::DdsTopic& topic, ddspipe::core::types::RtpsPayloadData& data) override; - /** - * @brief Start handler instance - * - * If previous state was PAUSED, the event thread is stopped (and buffers are cleared). - * - * @warning Not thread safe with respect to other command methods ( \c start , \c pause , \c stop , - * and \c trigger_event). This is, they are expected to be executed sequentially and all in the same thread. - * - */ - DDSRECORDER_PARTICIPANTS_DllAPI - void start(); - - /** - * @brief Stop handler instance - * - * If previous state was RUNNING, data stored in buffer is dumped to disk. - * If previous state was PAUSED, the event thread is stopped (and buffers are cleared). - * In both cases, pending samples are stored without schema if allowed (only_with_schema not true). - * - * @param [in] on_destruction Whether this command is executed on object's destruction. - * - * @warning Not thread safe with respect to other command methods ( \c start , \c pause , \c stop , - * and \c trigger_event). This is, they are expected to be executed sequentially and all in the same thread. - * - */ - DDSRECORDER_PARTICIPANTS_DllAPI - void stop( - bool on_destruction = false); - - /** - * @brief Pause handler instance - * - * Creates event thread waiting for an event to dump samples in buffer. - * - * If previous state was RUNNING, data stored in buffer is dumped to disk. - * - * @warning Not thread safe with respect to other command methods ( \c start , \c pause , \c stop , - * and \c trigger_event). This is, they are expected to be executed sequentially and all in the same thread. - * - */ - DDSRECORDER_PARTICIPANTS_DllAPI - void pause(); - - /** - * @brief Trigger event. - * - * When an event is triggered, data stored in buffer (containing samples received during the last event_window - * seconds) is written to disk. - * - * This method is ineffective if instance state is different than PAUSED. - * - * @warning Not thread safe with respect to other command methods ( \c start , \c pause , \c stop , - * and \c trigger_event). This is, they are expected to be executed sequentially and all in the same thread. - * - */ - DDSRECORDER_PARTICIPANTS_DllAPI - void trigger_event(); - protected: - //! Flag code controlling the event thread routine - enum class EventCode - { - untriggered = 0, //! Waiting for an event to be received. - triggered, //! Indicates that an event has been triggered. - stopped, //! Signals event thread to exit. - }; - /** - * @brief Add message to \c buffer_ structure, or directly write to MCAP file. + * @brief Writes \c samples to disk. * - * If after adding the new sample (when not directly writing to file) the buffer reaches its maximum size, the - * content is dumped to disk. + * For each sample in \c samples, it downcasts it to \c McapMessage, writes it to disk, and removes it from + * \c samples. + * The method ends when \c samples is empty. * - * @param [in] msg McapMessage to be added - * @param [in] direct_write Whether to directly store in MCAP file + * @param [in] samples List of samples to be written. */ - void add_data_nts_( - const McapMessage& msg, - bool direct_write = false); - - /** - * @brief Add message with given topic. - * - * First, it is attempted to get a channel given \c topic to be associated with the message. - * If this fails, the sample is not added. - * - * @param [in] msg McapMessage to be added - * @param [in] topic Topic of message to be added - * @param [in] direct_write Whether to directly store in MCAP file - */ - void add_data_nts_( - McapMessage& msg, - const ddspipe::core::types::DdsTopic& topic, - bool direct_write = false); - - /** - * @brief Add to pending samples collection. - * - * If pending samples collection is full, the oldest message is popped and written (if only_with_schema not true). - * - * @param [in] msg McapMessage to be added - * @param [in] topic Topic of message to be added - */ - void add_to_pending_nts_( - McapMessage& msg, - const ddspipe::core::types::DdsTopic& topic); - - /** - * @brief Add any pending samples associated to \c schema_name - * - * If in PAUSED state, samples in \c pending_samples_paused_ structure for this schema are moved to the buffer, - * so they will be written to file later on if event triggered. - * - * Samples in \c pending_samples_ structure for this schema are to be written irrespectively of the current state. - * However, in RUNNING/STOPPED states these are moved to buffer (to be written together with the next batch), - * while in PAUSED state they are directly written to the file (to avoid being deleted by event thread). - * Note that in the last case, pending samples correspond to messages that were previously received in RUNNING - * state, and hence should be stored regardless of whether or not an event is triggered. - * - * @param [in] schema_name Name of the schema for which pending samples using it are added. - */ - void add_pending_samples_nts_( - const std::string& schema_name); - - /** - * @brief Add pending samples. - * - * Add/write and pop all pending samples from the given list. - * - * @param [in] pending_samples List of pending samples to be added - * @param [in] direct_write Whether to directly store in MCAP file - */ - void add_pending_samples_nts_( - pending_list& pending_samples, - bool direct_write = false); - - /** - * @brief Add all samples stored in \c pending_samples_ structure, associating each of them to a blank schema. - * - */ - void add_pending_samples_nts_(); - - /** - * @brief Wait for an event trigger to write in disk samples from buffer. - * - * Every \c cleanup_period seconds, and before dumping data to disk, samples older than [now - event_window] are - * removed. This way, when an event is triggered, only the samples received in the last \c event_window seconds - * are kept. - * - * The loop is exited when \c event_flag_ is set to \c stopped. - * - */ - void event_thread_routine_(); - - //! Remove buffered samples older than [now - event_window] - void remove_outdated_samples_nts_(); - - /** - * @brief Stop event thread, and clear \c samples_buffer_ and \c pending_samples_paused_ structures - * - * A (locked) lock wrapping \c event_cv_mutex_ is passed so it can be released just before joining the thread. - * - * @param [in] event_lock Lock in locked state wrapping \c event_cv_mutex_ - */ - void stop_event_thread_nts_( - std::unique_lock& event_lock); - - //! Write in disk samples stored in buffer - void dump_data_nts_(); + void write_samples_( + std::list& samples) override; /** * @brief Create and add to \c mcap_writer_ channel associated to given \c topic @@ -379,56 +224,17 @@ class McapHandler : public ddspipe::participants::ISchemaHandler const std::string& type_name, DynamicTypesCollection& dynamic_types) const; - //! Handler configuration - McapHandlerConfiguration configuration_; - - //! Payload pool - std::shared_ptr payload_pool_; - - //! Handler instance state - McapHandlerStateCode state_; - //! MCAP writer McapWriter mcap_writer_; - //! Schemas map - std::map schemas_; - //! Received types set std::set received_types_; + //! Schemas map + std::map schemas_; + //! Channels map std::map channels_; - - //! Samples buffer - std::list samples_buffer_; - - //! Dynamic types collection - DynamicTypesCollection dynamic_types_; - - //! Structure where messages (received in RUNNING state) with unknown type are kept - std::map pending_samples_; - - //! Structure where messages (received in PAUSED state) with unknown type are kept - std::map pending_samples_paused_; - - //! Mutex synchronizing state transitions and access to object's data structures - std::mutex mtx_; - - //! Event thread - std::thread event_thread_; - - //! Event flag - EventCode event_flag_ = EventCode::stopped; - - //! Event condition variable - std::condition_variable event_cv_; - - //! Event condition variable mutex - std::mutex event_cv_mutex_; - - //! Unique sequence number assigned to received messages. It is incremented with every sample added. - unsigned int unique_sequence_number_{0}; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp index c8de43fcb..87956cb5c 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp @@ -63,7 +63,7 @@ struct McapHandlerConfiguration OutputSettings output_settings; //! Max number of messages to store in memory when schema not yet available - int max_pending_samples; + unsigned int max_pending_samples; //! Max number of elements to keep in memory prior to writing in disk (applies to started state) unsigned int buffer_size; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp index 25c7ea511..79f9e5163 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp @@ -40,7 +40,7 @@ namespace participants { */ DDSRECORDER_PARTICIPANTS_DllAPI mcap::Timestamp to_mcap_timestamp( - const fastrtps::rtps::Time_t& time); + const fastdds::rtps::Time_t& time); /** * @brief This method converts a timestamp in standard format to its mcap equivalent. diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp similarity index 55% rename from ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapMessage.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp index 726f890fc..01f2af213 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapMessage.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp @@ -13,55 +13,93 @@ // limitations under the License. /** - * @file McapMessage.hpp + * @file BaseMessage.hpp */ #pragma once -#include +#include +#include +#include +#include #include +#include #include + namespace eprosima { namespace ddsrecorder { namespace participants { /** - * Structure extending \c mcap::Message with Fast DDS payload and its owner (a \c PayloadPool). + * Structure implementing a DDS Message with a Fast-DDS payload and its owner (a \c PayloadPool). */ -struct McapMessage : public mcap::Message +struct BaseMessage { - McapMessage() = default; + BaseMessage() = default; /** - * Message copy constructor + * @brief TODO + */ + BaseMessage( + const ddspipe::core::types::Payload& payload, + ddspipe::core::PayloadPool* payload_owner); + + /** + * @brief TODO + */ + BaseMessage( + const ddspipe::core::types::RtpsPayloadData& data, + std::shared_ptr payload_pool, + const ddspipe::core::types::DdsTopic& topic, + const bool log_publish_time); + + /** + * @brief Message copy constructor * * Copy message without copying payload through PayloadPool API (copy reference and increment counter). * * @note If using instead the default destructor and copy constructor, the destruction of the copied message would * free the newly constructed sample (payload's data attribute), thus rendering the latter useless. - * */ - McapMessage( - const McapMessage& msg); + BaseMessage( + const BaseMessage& msg); /** - * Message destructor + * @brief Message destructor * * Releases internal payload, decrementing its reference count and freeing only when no longer referenced. * * @note Releasing the payload correctly sets payload's internal data attribute to \c nullptr , which eludes * the situation described in copy constructor's note. - * */ - ~McapMessage(); + virtual ~BaseMessage(); + + /** + * @brief Get the message's payload data + */ + std::byte* get_data() const; + + /** + * @brief Get the message's payload size + */ + std::uint32_t get_data_size() const; //! Serialized payload fastdds::rtps::SerializedPayload_t payload{}; //! Payload owner (reference to \c PayloadPool which created/reserved it) ddspipe::core::PayloadPool* payload_owner{nullptr}; + + //! Topic in which the payload was published + ddspipe::core::types::DdsTopic topic; + + //! When the message was recorded or received for recording + ddspipe::core::types::DataTime log_time; + + //! When the message was initially published + ddspipe::core::types::DataTime publish_time; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/McapMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/McapMessage.hpp new file mode 100644 index 000000000..84a7e8a75 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/McapMessage.hpp @@ -0,0 +1,61 @@ +// Copyright 2024 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 McapMessage.hpp + */ + +#pragma once + +#include +#include +#include + +#include + +#include +#include +#include + +#include + + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +/** + * Structure extending a \c BaseMessage for the \c mcap library. + */ +struct McapMessage : public BaseMessage, public mcap::Message +{ + McapMessage() = default; + + /** + * @brief Construct a \c McapMessage. + */ + McapMessage( + const ddspipe::core::types::RtpsPayloadData& data, + std::shared_ptr payload_pool, + const ddspipe::core::types::DdsTopic& topic, + const mcap::ChannelId channel_id, + const bool log_publish_time); + + // Number of McapMessages created + static std::atomic number_of_msgs; +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp new file mode 100644 index 000000000..441109e91 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp @@ -0,0 +1,317 @@ +// Copyright 2023 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 BaseHandler.hpp + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +//! State of the handler instance +ENUMERATION_BUILDER( + BaseHandlerStateCode, + STOPPED, //! Received messages are not processed. + RUNNING, //! Messages are stored in buffer and dumped to disk when full. + PAUSED //! Messages are stored in buffer and dumped to disk when event triggered. + ); + +/** + * Class that manages the interaction between DDS Pipe (\c SchemaParticipant) and MCAP files through mcap library. + * Payloads are efficiently passed from DDS Pipe to mcap without copying data (only references). + * + * @implements ISchemaHandler + */ +class BaseHandler : public ddspipe::participants::ISchemaHandler +{ +public: + + /** + * BaseHandler constructor by required values. + * + * Creates BaseHandler instance with given configuration, payload pool and initial state. + * Opens temporal MCAP file where data is to be written. + * + * @throw InitializationException if creation fails (fail to open MCAP file). + * + * @warning Command methods ( \c start , \c pause , \c stop , and \c trigger_event ) are not thread safe + * among themselves. This is, they are expected to be executed sequentially and all in the same thread. + * + * @param config: Structure encapsulating all configuration options. + * @param payload_pool: Pool of payloads to be used by the handler. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + BaseHandler( + const McapHandlerConfiguration& config, + const std::shared_ptr& payload_pool); + + /** + * @brief Destructor + * + * Closes temporal MCAP file, and renames it with filename given in configuration. + * Before closing file, received dynamic types are serialized and stored as an attachment. + * + */ + DDSRECORDER_PARTICIPANTS_DllAPI + virtual ~BaseHandler(); + + /** + * @brief Initialize handler instance + * + * @param [in] init_state Initial state of the handler instance. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + void init( + const BaseHandlerStateCode& init_state = BaseHandlerStateCode::RUNNING); + + /** + * @brief Enable handler instance + */ + DDSRECORDER_PARTICIPANTS_DllAPI + virtual void enable() = 0; + + /** + * @brief Disable handler instance + */ + DDSRECORDER_PARTICIPANTS_DllAPI + virtual void disable() = 0; + + /** + * @brief Start handler instance + * + * If previous state was PAUSED, the event thread is stopped (and buffers are cleared). + * + * @warning Not thread safe with respect to other command methods ( \c start , \c pause , \c stop , + * and \c trigger_event). This is, they are expected to be executed sequentially and all in the same thread. + * + */ + DDSRECORDER_PARTICIPANTS_DllAPI + void start(); + + /** + * @brief Stop handler instance + * + * If previous state was RUNNING, data stored in buffer is dumped to disk. + * If previous state was PAUSED, the event thread is stopped (and buffers are cleared). + * In both cases, pending samples are stored without schema if allowed (only_with_schema not true). + * + * @param [in] on_destruction Whether this command is executed on object's destruction. + * + * @warning Not thread safe with respect to other command methods ( \c start , \c pause , \c stop , + * and \c trigger_event). This is, they are expected to be executed sequentially and all in the same thread. + * + */ + DDSRECORDER_PARTICIPANTS_DllAPI + void stop( + bool on_destruction = false); + + /** + * @brief Pause handler instance + * + * Creates event thread waiting for an event to dump samples in buffer. + * + * If previous state was RUNNING, data stored in buffer is dumped to disk. + * + * @warning Not thread safe with respect to other command methods ( \c start , \c pause , \c stop , + * and \c trigger_event). This is, they are expected to be executed sequentially and all in the same thread. + * + */ + DDSRECORDER_PARTICIPANTS_DllAPI + void pause(); + + /** + * @brief Trigger event. + * + * When an event is triggered, data stored in buffer (containing samples received during the last event_window + * seconds) is written to disk. + * + * This method is ineffective if instance state is different than PAUSED. + * + * @warning Not thread safe with respect to other command methods ( \c start , \c pause , \c stop , + * and \c trigger_event). This is, they are expected to be executed sequentially and all in the same thread. + * + */ + DDSRECORDER_PARTICIPANTS_DllAPI + void trigger_event(); + +protected: + + //! Flag code controlling the event thread routine + enum class EventCode + { + untriggered = 0, //! Waiting for an event to be received. + triggered, //! Indicates that an event has been triggered. + stopped, //! Signals event thread to exit. + }; + + /** + * @brief Wait for an event trigger to write in disk samples from buffer. + * + * Every \c cleanup_period seconds, and before dumping data to disk, samples older than [now - event_window] are + * removed. This way, when an event is triggered, only the samples received in the last \c event_window seconds + * are kept. + * + * The loop is exited when \c event_flag_ is set to \c stopped. + * + */ + void event_thread_routine_(); + + /** + * @brief Stop event thread, and clear \c samples_buffer_ and \c pending_samples_paused_ structures + * + * A (locked) lock wrapping \c event_cv_mutex_ is passed so it can be released just before joining the thread. + * + * @param [in] event_lock Lock in locked state wrapping \c event_cv_mutex_ + */ + void stop_event_thread_nts_( + std::unique_lock& event_lock); + + /** + * @brief Writes \c samples to disk. + * + * For each sample in \c samples, it writes it to disk and removes it from \c samples. + * The method ends when \c samples is empty. + * + * @param [in] samples List of samples to be written. + */ + virtual void write_samples_( + std::list& samples) = 0; + + /** + * @brief Adds a sample to \c samples_buffer. + * + * @param sample Sample to be added. + */ + void add_sample_to_buffer_nts_( + const BaseMessage* sample); + + /** + * @brief Adds samples to \c samples_buffer. + * + * For each sample in \c samples, it writes it to disk and removes it from \c samples. + * The method ends when \c samples is empty. + * + * @param [in] samples List of samples to be added. + */ + void add_samples_to_buffer_nts_( + std::list& samples); + + /** + * @brief Adds a sample to \c pending_samples_. + * + * If \c pending_samples_ is full, it adds the oldest sample to the buffer until there space for \c sample. + * + * @param sample Sample to be added. + */ + void add_sample_to_pending_nts_( + const BaseMessage* sample); + + /** + * @brief Dumps the pending samples corresponding to \c type_name. + * + * The function is called when the handler discovers a new type. + * + * If in PAUSED state, samples in \c pending_samples_paused_ structure for \c type_name are moved to the buffer, + * so they will be written later on if an event is triggered. + * + * Samples in \c pending_samples_ structure for \c type_name are to be written irrespectively of the current state. + * However, in RUNNING/STOPPED states these are moved to buffer (to be written together with the next batch), + * while in PAUSED state they are directly written to the file (to avoid being deleted by event thread). + * Note that in the last case, pending samples correspond to messages that were previously received in RUNNING + * state, and hence should be stored regardless of whether or not an event is triggered. + * + * @param type_name Type name of the samples to be dumped. + */ + void dump_pending_samples_nts_( + const std::string& type_name); + + /** + * @brief Remove samples older than [now - event_window]. + * + * This method removes samples older than [now - event_window] from: + * - \c samples_buffer_ + * - \c pending_samples_ + * - \c pending_samples_paused_ + */ + void remove_outdated_samples_nts_(); + + //! Handler configuration + McapHandlerConfiguration configuration_; + + //! Payload pool + std::shared_ptr payload_pool_; + + //! Handler instance state + BaseHandlerStateCode state_; + + //! Mutex synchronizing state transitions and access to object's data structures + std::mutex mtx_; + + ////////////////////// + // EVENT MANAGEMENT // + ////////////////////// + + //! Event thread + std::thread event_thread_; + + //! Event flag + EventCode event_flag_ = EventCode::stopped; + + //! Event condition variable + std::condition_variable event_cv_; + + //! Event condition variable mutex + std::mutex event_cv_mutex_; + + /////////////////////// + // BUFFER MANAGEMENT // + /////////////////////// + + //! Samples buffer + std::list samples_buffer_; + + //! Structure where messages (received in RUNNING state) with unknown type are kept + std::map> pending_samples_; + + //! Structure where messages (received in PAUSED state) with unknown type are kept + std::map> pending_samples_paused_; +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 8c147c2a1..2cdc38c7d 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include @@ -48,11 +48,9 @@ McapHandler::McapHandler( const McapHandlerConfiguration& config, const std::shared_ptr& payload_pool, std::shared_ptr file_tracker, - const McapHandlerStateCode& init_state /* = McapHandlerStateCode::RUNNING */, + const BaseHandlerStateCode& init_state /* = BaseHandlerStateCode::RUNNING */, const std::function& on_disk_full_lambda /* = nullptr */) - : configuration_(config) - , payload_pool_(payload_pool) - , state_(McapHandlerStateCode::STOPPED) + : BaseHandler(config, payload_pool) , mcap_writer_(config.output_settings, config.mcap_writer_options, file_tracker, config.record_types) { logInfo(DDSRECORDER_MCAP_HANDLER, @@ -63,30 +61,40 @@ McapHandler::McapHandler( mcap_writer_.set_on_disk_full_callback(on_disk_full_lambda); } - switch (init_state) - { - case McapHandlerStateCode::RUNNING: - start(); - break; - - case McapHandlerStateCode::PAUSED: - pause(); - break; - - default: - break; - } + init(init_state); } McapHandler::~McapHandler() { logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Destroying handler."); + "MCAP_STATE | Destroying MCAP handler."); // Stop handler prior to destruction stop(true); } +void McapHandler::enable() +{ + logInfo(DDSRECORDER_MCAP_HANDLER, "Enabling MCAP handler."); + + mcap_writer_.enable(); +} + +void McapHandler::disable() +{ + logInfo(DDSRECORDER_MCAP_HANDLER, "Disabling MCAP handler."); + + // Ideally, the channels and schemas should be shared between the McapHandler and McapWriter. + // Right now, the data is duplicated in both classes, which uses more memory and can lead to inconsistencies. + // TODO: Share the channels and schemas between the McapHandler and McapWriter. + + // NOTE: disabling the McapWriter clears its channels + mcap_writer_.disable(); + + // Clear the channels after a disable so the old channels are not rewritten in every new file + channels_.clear(); +} + void McapHandler::add_schema( const fastdds::dds::DynamicType::_ref_type& dynamic_type, const std::string& type_name, @@ -158,12 +166,12 @@ void McapHandler::add_schema( mcap_writer_.update_dynamic_types(*Serializer::serialize(&dynamic_types_)); } - // Check if there are any pending samples for this new schema. If so, add them. + // Check if there are any pending samples for this new schema. If so, dump them. if ((pending_samples_.find(type_name) != pending_samples_.end()) || - (state_ == McapHandlerStateCode::PAUSED && + (state_ == BaseHandlerStateCode::PAUSED && (pending_samples_paused_.find(type_name) != pending_samples_paused_.end()))) { - add_pending_samples_nts_(type_name); + dump_pending_samples_nts_(type_name); } } @@ -173,7 +181,7 @@ void McapHandler::add_data( { std::unique_lock lock(mtx_); - if (state_ == McapHandlerStateCode::STOPPED) + if (state_ == BaseHandlerStateCode::STOPPED) { logInfo(DDSRECORDER_MCAP_HANDLER, "FAIL_MCAP_WRITE | Attempting to add sample through a stopped handler, dropping..."); @@ -184,548 +192,83 @@ void McapHandler::add_data( DDSRECORDER_MCAP_HANDLER, "MCAP_WRITE | Adding data in topic " << topic); - // Add data to channel - McapMessage msg; - msg.sequence = unique_sequence_number_++; - msg.publishTime = to_mcap_timestamp(data.source_timestamp); - if (configuration_.log_publishTime) - { - msg.logTime = msg.publishTime; - } - else - { - msg.logTime = to_mcap_timestamp(utils::now()); - } - msg.dataSize = data.payload.length; - - if (data.payload.length > 0) - { - if (data.payload_owner != nullptr) - { - payload_pool_->get_payload( - data.payload, - msg.payload); - - msg.payload_owner = payload_pool_.get(); - msg.data = reinterpret_cast(msg.payload.data); - } - else - { - throw utils::InconsistencyException( - STR_ENTRY << "Payload owner not found in data received." - ); - } - } - else - { - throw utils::InconsistencyException( - STR_ENTRY << "Received sample with no payload." - ); - } - - if (received_types_.count(topic.type_name) != 0) - { - // Schema available -> add to buffer - add_data_nts_(msg, topic); - } - else - { - if (state_ == McapHandlerStateCode::RUNNING) - { - if (configuration_.max_pending_samples == 0) - { - if (configuration_.only_with_schema) - { - // No schema available + no pending samples + only_with_schema -> Discard message - return; - } - else - { - // No schema available + no pending samples -> Add to buffer with blank schema - add_data_nts_(msg, topic); - } - } - else - { - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Schema for topic " << topic << " not yet available. " - "Inserting to pending samples queue."); - - add_to_pending_nts_(msg, topic); - } - } - else if (state_ == McapHandlerStateCode::PAUSED) - { - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Schema for topic " << topic << " not yet available. " - "Inserting to (paused) pending samples queue."); - - pending_samples_paused_[topic.type_name].push_back({topic, msg}); - } - else - { - // Should not happen, protected with mutex and state verified at beginning - utils::tsnh( - utils::Formatter() << "Trying to add sample from a stopped instance."); - } - } -} - -void McapHandler::start() -{ - // Wait for completion of event routine in case event was triggered - std::unique_lock event_lock(event_cv_mutex_); - event_cv_.wait( - event_lock, - [&] - { - return event_flag_ != EventCode::triggered; - }); - - // Protect access to state and data structures (cleared in stop_event_thread_nts) - std::lock_guard lock(mtx_); - - // Store previous state to act differently depending on its value - McapHandlerStateCode prev_state = state_; - state_ = McapHandlerStateCode::RUNNING; - - if (prev_state == McapHandlerStateCode::RUNNING) - { - logWarning(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Ignoring start command, instance already started."); - } - else - { - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Starting handler."); - - if (prev_state == McapHandlerStateCode::STOPPED) - { - mcap_writer_.enable(); - } - else if (prev_state == McapHandlerStateCode::PAUSED) - { - // Stop event routine (cleans buffers) - stop_event_thread_nts_(event_lock); - } - } -} - -void McapHandler::stop( - bool on_destruction /* false */) -{ - // Wait for completion of event routine in case event was triggered - std::unique_lock event_lock(event_cv_mutex_); - event_cv_.wait( - event_lock, - [&] - { - return event_flag_ != EventCode::triggered; - }); - - // Protect access to state and data structures - std::lock_guard lock(mtx_); - - // Store previous state to act differently depending on its value - McapHandlerStateCode prev_state = state_; - state_ = McapHandlerStateCode::STOPPED; - if (prev_state == McapHandlerStateCode::STOPPED) - { - if (!on_destruction) - { - logWarning(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Ignoring stop command, instance already stopped."); - } - - return; - } - - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Stopping handler."); - - if (prev_state == McapHandlerStateCode::PAUSED) - { - // Stop event routine (cleans buffers) - stop_event_thread_nts_(event_lock); - } - - if (!configuration_.only_with_schema) - { - // Adds to buffer samples whose schema was not received while running - add_pending_samples_nts_(); - } - else - { - // Free memory resources - pending_samples_.clear(); - } - dump_data_nts_(); // if prev_state == RUNNING -> writes buffer + added pending samples (if !only_with_schema) - // if prev_state == PAUSED -> writes added pending samples (if !only_with_schema) - - // Ideally, the channels and schemas should be shared between the McapHandler and McapWriter. - // Right now, the data is duplicated in both classes, which uses more memory and can lead to inconsistencies. - // TODO: Share the channels and schemas between the McapHandler and McapWriter. - - // NOTE: disabling the McapWriter clears its channels - mcap_writer_.disable(); - - // Clear the channels after a stop so the old channels are not rewritten in every new file - channels_.clear(); -} - -void McapHandler::pause() -{ - // Protect access to state and data structures - std::lock_guard lock(mtx_); - - // NOTE: no need to take event mutex as event thread does not exist at this point - - // Store previous state to act differently depending on its value - McapHandlerStateCode prev_state = state_; - state_ = McapHandlerStateCode::PAUSED; - - if (prev_state == McapHandlerStateCode::PAUSED) - { - logWarning(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Ignoring pause command, instance already paused."); - } - else - { - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Pausing handler."); - - if (prev_state == McapHandlerStateCode::STOPPED) - { - mcap_writer_.enable(); - } - else if (prev_state == McapHandlerStateCode::RUNNING) - { - // Write data stored in buffer - dump_data_nts_(); - // Clear buffer - // NOTE: not really needed, dump_data_nts_ already writes and pops all samples - samples_buffer_.clear(); - } - - // Launch event thread routine - event_flag_ = EventCode::untriggered; // No need to take event mutex (protected by mtx_) - event_thread_ = std::thread(&McapHandler::event_thread_routine_, this); - } -} - -void McapHandler::trigger_event() -{ - // Wait for completion of event routine in case event was triggered - std::unique_lock event_lock(event_cv_mutex_); - event_cv_.wait( - event_lock, - [&] - { - return event_flag_ != EventCode::triggered; - }); - - // Protect access to state - std::lock_guard lock(mtx_); - - if (state_ != McapHandlerStateCode::PAUSED) - { - logWarning(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Ignoring trigger event command, instance is not paused."); - } - else - { - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Triggering event."); - - // Notify event routine thread an event has been triggered - event_flag_ = EventCode::triggered; - event_lock.unlock(); // Unlock before notifying for efficiency purposes - event_cv_.notify_all(); // Need to notify all as not possible to notify a specific thread - } -} - -void McapHandler::add_data_nts_( - const McapMessage& msg, - bool direct_write /* false */) -{ - if (direct_write) - { - // Write to MCAP file - mcap_writer_.write(msg); - } - else - { - samples_buffer_.push_back(msg); - - if (state_ == McapHandlerStateCode::RUNNING && samples_buffer_.size() == configuration_.buffer_size) - { - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Full buffer, writing to disk..."); - dump_data_nts_(); - } - } -} + // Add channel to data + mcap::ChannelId channel_id; -void McapHandler::add_data_nts_( - McapMessage& msg, - const DdsTopic& topic, - bool direct_write /* false */) -{ try { - auto channel_id = get_channel_id_nts_(topic); - msg.channelId = channel_id; + channel_id = get_channel_id_nts_(topic); } catch (const utils::InconsistencyException& e) { logWarning(DDSRECORDER_MCAP_HANDLER, "MCAP_WRITE | Error adding message in topic " << topic << ". Error message:\n " << e.what()); - return; - } - - add_data_nts_(msg, direct_write); -} - -void McapHandler::add_to_pending_nts_( - McapMessage& msg, - const DdsTopic& topic) -{ - assert(configuration_.max_pending_samples != 0); - - if (configuration_.max_pending_samples > 0 && - pending_samples_[topic.type_name].size() == static_cast(configuration_.max_pending_samples)) - { - if (configuration_.only_with_schema) - { - // Discard oldest message in pending samples - logWarning(DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Dropping pending sample in type " << topic.type_name << ": buffer limit (" << - configuration_.max_pending_samples << ") reached."); - } - else - { - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Buffer limit (" << configuration_.max_pending_samples << ") reached for type " << - topic.type_name << ": writing oldest sample without schema."); - - // Write oldest message without schema - auto& oldest_sample = pending_samples_[topic.type_name].front(); - add_data_nts_(oldest_sample.second, oldest_sample.first); - } - - pending_samples_[topic.type_name].pop_front(); - } - - pending_samples_[topic.type_name].push_back({topic, msg}); -} - -void McapHandler::add_pending_samples_nts_( - const std::string& schema_name) -{ - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Adding pending samples for type: " << schema_name << "."); - if (pending_samples_.find(schema_name) != pending_samples_.end()) - { - // Move samples from pending_samples to buffer - // NOTE: directly write to MCAP when PAUSED, as these correspond to samples that were previously received in - // RUNNING state (hence to avoid being cleaned by event thread) - add_pending_samples_nts_(pending_samples_[schema_name], state_ == McapHandlerStateCode::PAUSED); - pending_samples_.erase(schema_name); - } - if (state_ == McapHandlerStateCode::PAUSED && - (pending_samples_paused_.find(schema_name) != pending_samples_paused_.end())) - { - // Move samples from pending_samples_paused to buffer, from where they will be written if event received - add_pending_samples_nts_(pending_samples_paused_[schema_name]); - pending_samples_paused_.erase(schema_name); - } -} - -void McapHandler::add_pending_samples_nts_( - pending_list& pending_samples, - bool direct_write /* false */) -{ - while (!pending_samples.empty()) - { - // Move samples from pending list to buffer, or write them directly to MCAP file - auto& sample = pending_samples.front(); - add_data_nts_(sample.second, sample.first, direct_write); - - pending_samples.pop_front(); } -} -void McapHandler::add_pending_samples_nts_() -{ - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Adding pending samples for all types."); + const auto sample = new McapMessage(data, payload_pool_, topic, channel_id, configuration_.log_publishTime); - auto pending_types = utils::get_keys(pending_samples_); - for (auto& pending_type: pending_types) + if (received_types_.find(topic.type_name) != received_types_.end()) { - add_pending_samples_nts_(pending_type); + add_sample_to_buffer_nts_(sample); + return; } -} -void McapHandler::event_thread_routine_() -{ - bool keep_going = true; - while (keep_going) + switch (state_) { - bool timeout; - auto exit_time = std::chrono::time_point::max(); - auto cleanup_period_ = std::chrono::seconds(configuration_.cleanup_period); - if (cleanup_period_ < std::chrono::seconds::max()) - { - auto now = std::chrono::system_clock::now(); - exit_time = now + cleanup_period_; - } - - std::unique_lock event_lock(event_cv_mutex_); - - if (event_flag_ != EventCode::untriggered) - { - // Flag set before taking mutex, no need to wait - timeout = false; - } - else - { - timeout = !event_cv_.wait_until( - event_lock, - exit_time, - [&] - { - return event_flag_ != EventCode::untriggered; - }); - } - - if (event_flag_ == EventCode::stopped) - { - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Finishing event thread routine."); - keep_going = false; - } - else - { - // Protect access to state and data structures - std::lock_guard lock(mtx_); - - // NOTE: event mutex not released until routine completed to avoid other commands (start/stop/trigger) to interfere. + case BaseHandlerStateCode::RUNNING: - // Delete outdated samples if timeout, and also before dumping (event triggered case) - remove_outdated_samples_nts_(); - - if (timeout) + if (configuration_.max_pending_samples != 0) { - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Event thread timeout."); + logInfo( + DDSRECORDER_MCAP_HANDLER, + "MCAP_WRITE | Schema for topic " << topic << + " not yet available, inserting to pending samples queue."); + + add_sample_to_pending_nts_(sample); } - else + else if (!configuration_.only_with_schema) { - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Event triggered: dumping buffered data."); - - if (!(configuration_.max_pending_samples == 0 && configuration_.only_with_schema)) - { - // Move (paused) pending samples to buffer (or pending samples) prior to dumping - for (auto& pending_type : pending_samples_paused_) - { - auto type_name = pending_type.first; - auto& pending_list = pending_type.second; - while (!pending_list.empty()) - { - auto& sample = pending_list.front(); - if (configuration_.max_pending_samples == 0) - { - if (configuration_.only_with_schema) - { - // Cannot happen (outter if) - } - else - { - // Add to buffer with blank schema - add_data_nts_(sample.second, sample.first); - } - } - else - { - add_to_pending_nts_(sample.second, sample.first); - } - pending_list.pop_front(); - } - } - } - dump_data_nts_(); + // No schema available + no pending samples -> Add to buffer with blank schema + add_sample_to_buffer_nts_(sample); } + break; - // Event routine iteration completed: reset and wait for next event - event_flag_ = EventCode::untriggered; - } - - // Notify threads waiting for this resource - event_lock.unlock(); - event_cv_.notify_all(); - } -} + case BaseHandlerStateCode::PAUSED: -void McapHandler::remove_outdated_samples_nts_() -{ - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Removing outdated samples."); + logInfo( + DDSRECORDER_MCAP_HANDLER, + "MCAP_WRITE | Schema for topic " << topic << + " not yet available, inserting to (paused) pending samples queue."); - const auto threshold = to_mcap_timestamp(utils::now() - std::chrono::seconds(configuration_.event_window)); + pending_samples_paused_[topic.type_name].push_back(sample); + break; - samples_buffer_.remove_if([&](auto& sample) - { - return sample.logTime < threshold; - }); + default: - for (auto& pending_type : pending_samples_paused_) - { - pending_type.second.remove_if([&](auto& sample) - { - return sample.second.logTime < threshold; - }); + // Should not happen, protected with mutex and state verified at beginning + utils::tsnh(utils::Formatter() << "Trying to add sample to a stopped instance."); + break; } } -void McapHandler::stop_event_thread_nts_( - std::unique_lock& event_lock) +void McapHandler::write_samples_( + std::list& samples) { - // NOTE: this method assumes both mtx_ and event_cv_mutex_ (within event_lock) are locked - - // WARNING: state must have been set different to PAUSED before calling this method - assert(state_ != McapHandlerStateCode::PAUSED); + logInfo(DDSRECORDER_MCAP_HANDLER, "Writing samples to MCAP file."); - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_STATE | Stopping event thread."); - - if (event_thread_.joinable()) + while (!samples.empty()) { - event_flag_ = EventCode::stopped; - event_lock.unlock(); // Unlock prior to notification (for efficiency) and join (to avoid deadlock) - event_cv_.notify_all(); // Need to notify all as not possible to notify a specific thread - event_thread_.join(); - } + const auto mcap_sample = static_cast(samples.front()); - samples_buffer_.clear(); - pending_samples_paused_.clear(); -} - -void McapHandler::dump_data_nts_() -{ - logInfo(DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Writing data stored in buffer."); - - while (!samples_buffer_.empty()) - { - auto& sample = samples_buffer_.front(); + if (mcap_sample == nullptr) + { + logWarning(DDSRECORDER_MCAP_HANDLER, "Error downcasting sample to McapMessage. Skipping..."); + continue; + } - // Write to MCAP file - mcap_writer_.write(sample); + mcap_writer_.write(*mcap_sample); - // Pop written sample - samples_buffer_.pop_front(); + samples.pop_front(); } } diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp index 32e3e2907..19614d0ec 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp index 88a0aa98c..3f8102bde 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp @@ -27,7 +27,7 @@ namespace ddsrecorder { namespace participants { mcap::Timestamp to_mcap_timestamp( - const fastrtps::rtps::Time_t& time) + const fastdds::rtps::Time_t& time) { static constexpr std::uint64_t NS_PER_SEC = 1000000000; return time.seconds() * NS_PER_SEC + time.nanosec(); diff --git a/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp new file mode 100644 index 000000000..c7cbc7fea --- /dev/null +++ b/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp @@ -0,0 +1,98 @@ +// Copyright 2024 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 BaseMessage.cpp + */ + +#include + +#include +#include + +#include + + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +BaseMessage::BaseMessage( + const ddspipe::core::types::Payload& payload, + ddspipe::core::PayloadPool* payload_owner) + : payload_owner(payload_owner) +{ + if (payload.length == 0) + { + throw utils::InconsistencyException( + STR_ENTRY << "Received sample with no payload." + ); + } + + payload_owner->get_payload( + payload, + this->payload); +} + +BaseMessage::BaseMessage( + const ddspipe::core::types::RtpsPayloadData& data, + std::shared_ptr payload_pool, + const ddspipe::core::types::DdsTopic& topic, + const bool log_publish_time) + : BaseMessage(data.payload, payload_pool.get()) +{ + this->topic = topic; + publish_time = data.source_timestamp; + + if (log_publish_time) + { + log_time = publish_time; + } + else + { + ddspipe::core::types::DataTime::now(log_time); + } +} + +BaseMessage::BaseMessage( + const BaseMessage& msg) + : BaseMessage(msg.payload, msg.payload_owner) +{ + topic = msg.topic; + log_time = msg.log_time; + publish_time = msg.publish_time; +} + +BaseMessage::~BaseMessage() +{ + // If payload owner exists and payload has size, release it correctly in pool + if (payload_owner && payload.length > 0) + { + payload_owner->release_payload(payload); + } +} + +std::byte* BaseMessage::get_data() const +{ + return reinterpret_cast(payload.data); +} + +std::uint32_t BaseMessage::get_data_size() const +{ + return payload.length; +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp similarity index 53% rename from ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp rename to ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp index 6ae3e091d..d0393a07d 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp @@ -16,32 +16,33 @@ * @file McapMessage.cpp */ -#include - -#include +#include +#include namespace eprosima { namespace ddsrecorder { namespace participants { +std::atomic McapMessage::number_of_msgs = 0; + McapMessage::McapMessage( - const McapMessage& msg) - : mcap::Message(msg) + const ddspipe::core::types::RtpsPayloadData& data, + std::shared_ptr payload_pool, + const ddspipe::core::types::DdsTopic& topic, + const mcap::ChannelId channel_id, + const bool log_publish_time) + : BaseMessage(data, payload_pool, topic, log_publish_time) + , mcap::Message() { - payload_owner = msg.payload_owner; - payload_owner->get_payload( - msg.payload, - this->payload); -} + sequence = number_of_msgs.fetch_add(1); + channelId = channel_id; -McapMessage::~McapMessage() -{ - // If payload owner exists and payload has size, release it correctly in pool - if (payload_owner && payload.length > 0) - { - payload_owner->release_payload(payload); - } + this->data = get_data(); + dataSize = get_data_size(); + + publishTime = to_mcap_timestamp(publish_time); + logTime = to_mcap_timestamp(log_time); } } /* namespace participants */ diff --git a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp new file mode 100644 index 000000000..6987344e9 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp @@ -0,0 +1,498 @@ +// Copyright 2024 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 BaseHandler.cpp + */ + +#include +#include + +#include + +#include + +#include +#include + +#include +#include +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +using namespace eprosima::ddspipe::core::types; + +BaseHandler::BaseHandler( + const McapHandlerConfiguration& config, + const std::shared_ptr& payload_pool) + : configuration_(config) + , payload_pool_(payload_pool) + , state_(BaseHandlerStateCode::STOPPED) +{ + logInfo(DDSRECORDER_DATA_HANDLER, "Creating handler instance."); +} + +BaseHandler::~BaseHandler() +{ + logInfo(DDSRECORDER_DATA_HANDLER, "Destroying handler."); +} + +void BaseHandler::init( + const BaseHandlerStateCode& init_state /* = BaseHandlerStateCode::RUNNING */) +{ + switch (init_state) + { + case BaseHandlerStateCode::RUNNING: + start(); + break; + + case BaseHandlerStateCode::PAUSED: + pause(); + break; + + default: + break; + } +} + +void BaseHandler::start() +{ + // Wait for completion of event routine in case event was triggered + std::unique_lock event_lock(event_cv_mutex_); + event_cv_.wait( + event_lock, + [&] + { + return event_flag_ != EventCode::triggered; + }); + + // Protect access to state and data structures (cleared in stop_event_thread_nts) + std::lock_guard lock(mtx_); + + // Store previous state to act differently depending on its value + BaseHandlerStateCode prev_state = state_; + state_ = BaseHandlerStateCode::RUNNING; + + if (prev_state == BaseHandlerStateCode::RUNNING) + { + logWarning( + DDSRECORDER_DATA_HANDLER, + "Ignoring start command, instance already started."); + } + else + { + logInfo( + DDSRECORDER_DATA_HANDLER, + "Starting handler."); + + if (prev_state == BaseHandlerStateCode::STOPPED) + { + enable(); + } + else if (prev_state == BaseHandlerStateCode::PAUSED) + { + // Stop event routine (cleans buffers) + stop_event_thread_nts_(event_lock); + } + } +} + +void BaseHandler::stop( + bool on_destruction /* false */) +{ + // Wait for completion of event routine in case event was triggered + std::unique_lock event_lock(event_cv_mutex_); + event_cv_.wait( + event_lock, + [&] + { + return event_flag_ != EventCode::triggered; + }); + + // Protect access to state and data structures + std::lock_guard lock(mtx_); + + // Store previous state to act differently depending on its value + BaseHandlerStateCode prev_state = state_; + state_ = BaseHandlerStateCode::STOPPED; + + switch (prev_state) + { + case BaseHandlerStateCode::STOPPED: + + if (!on_destruction) + { + logWarning( + DDSRECORDER_DATA_HANDLER, + "Ignoring stop command, instance already stopped."); + } + + break; + + case BaseHandlerStateCode::PAUSED: + + // Stop event routine (cleans buffers) + stop_event_thread_nts_(event_lock); + + [[fallthrough]]; + + default: + + logInfo( + DDSRECORDER_DATA_HANDLER, + "Stopping handler."); + + if (!configuration_.only_with_schema) + { + // Adds to buffer samples whose schema was not received while running + // NOTE: Loop this way since dump_pending_samples_nts_ removes the entry from the map + while (!pending_samples_.empty()) + { + const auto type_name = pending_samples_.begin()->first; + dump_pending_samples_nts_(type_name); + } + } + else + { + // Free memory resources + pending_samples_.clear(); + } + + // if prev_state == RUNNING -> writes buffer + added pending samples (if !only_with_schema) + // if prev_state == PAUSED -> writes added pending samples (if !only_with_schema) + write_samples_(samples_buffer_); + + disable(); + break; + } +} + +void BaseHandler::pause() +{ + // Protect access to state and data structures + std::lock_guard lock(mtx_); + + // NOTE: no need to take event mutex as event thread does not exist at this point + + // Store previous state to act differently depending on its value + BaseHandlerStateCode prev_state = state_; + state_ = BaseHandlerStateCode::PAUSED; + + if (prev_state == BaseHandlerStateCode::PAUSED) + { + logWarning( + DDSRECORDER_DATA_HANDLER, + "Ignoring pause command, instance already paused."); + } + else + { + logInfo( + DDSRECORDER_DATA_HANDLER, + "Pausing handler."); + + if (prev_state == BaseHandlerStateCode::STOPPED) + { + enable(); + } + else if (prev_state == BaseHandlerStateCode::RUNNING) + { + // Write data stored in buffer + write_samples_(samples_buffer_); + } + + // Launch event thread routine + event_flag_ = EventCode::untriggered; // No need to take event mutex (protected by mtx_) + event_thread_ = std::thread(&BaseHandler::event_thread_routine_, this); + } +} + +void BaseHandler::trigger_event() +{ + // Wait for completion of event routine in case event was triggered + std::unique_lock event_lock(event_cv_mutex_); + event_cv_.wait( + event_lock, + [&] + { + return event_flag_ != EventCode::triggered; + }); + + // Protect access to state + std::lock_guard lock(mtx_); + + if (state_ != BaseHandlerStateCode::PAUSED) + { + logWarning( + DDSRECORDER_DATA_HANDLER, + "Ignoring trigger event command, instance is not paused."); + } + else + { + logInfo( + DDSRECORDER_DATA_HANDLER, + "Triggering event."); + + // Notify event routine thread an event has been triggered + event_flag_ = EventCode::triggered; + event_lock.unlock(); // Unlock before notifying for efficiency purposes + event_cv_.notify_all(); // Need to notify all as not possible to notify a specific thread + } +} + +void BaseHandler::event_thread_routine_() +{ + bool keep_going = true; + while (keep_going) + { + bool timeout; + auto exit_time = std::chrono::time_point::max(); + auto cleanup_period_ = std::chrono::seconds(configuration_.cleanup_period); + if (cleanup_period_ < std::chrono::seconds::max()) + { + auto now = std::chrono::system_clock::now(); + exit_time = now + cleanup_period_; + } + + std::unique_lock event_lock(event_cv_mutex_); + + if (event_flag_ != EventCode::untriggered) + { + // Flag set before taking mutex, no need to wait + timeout = false; + } + else + { + timeout = !event_cv_.wait_until( + event_lock, + exit_time, + [&] + { + return event_flag_ != EventCode::untriggered; + }); + } + + if (event_flag_ == EventCode::stopped) + { + logInfo(DDSRECORDER_DATA_HANDLER, "Finishing event thread routine."); + keep_going = false; + } + else + { + // Protect access to state and data structures + std::lock_guard lock(mtx_); + + // NOTE: event mutex not released until routine completed to avoid other commands (start/stop/trigger) to interfere. + + // Delete outdated samples if timeout, and also before writing the buffer (event triggered case) + remove_outdated_samples_nts_(); + + if (timeout) + { + logInfo(DDSRECORDER_DATA_HANDLER, "Event thread timeout."); + } + else + { + logInfo(DDSRECORDER_DATA_HANDLER, "Event triggered: writing buffered data."); + + if (!(configuration_.max_pending_samples == 0 && configuration_.only_with_schema)) + { + // Move (paused) pending samples to buffer (or pending samples) before writing the buffer + for (auto& [_, pending] : pending_samples_paused_) + { + while (!pending.empty()) + { + const auto& sample = pending.front(); + + if (configuration_.max_pending_samples != 0) + { + add_sample_to_pending_nts_(sample); + } + else if (!configuration_.only_with_schema) + { + // Add to buffer with blank schema + add_sample_to_buffer_nts_(sample); + } + + pending.pop_front(); + } + } + } + + write_samples_(samples_buffer_); + } + + // Event routine iteration completed: reset and wait for next event + event_flag_ = EventCode::untriggered; + } + + // Notify threads waiting for this resource + event_lock.unlock(); + event_cv_.notify_all(); + } +} + +void BaseHandler::stop_event_thread_nts_( + std::unique_lock& event_lock) +{ + // NOTE: this method assumes both mtx_ and event_cv_mutex_ (within event_lock) are locked + + // WARNING: state must have been set different to PAUSED before calling this method + assert(state_ != BaseHandlerStateCode::PAUSED); + + logInfo(DDSRECORDER_DATA_HANDLER, "Stopping event thread."); + + if (event_thread_.joinable()) + { + event_flag_ = EventCode::stopped; + event_lock.unlock(); // Unlock prior to notification (for efficiency) and join (to avoid deadlock) + event_cv_.notify_all(); // Need to notify all as not possible to notify a specific thread + event_thread_.join(); + } + + samples_buffer_.clear(); + pending_samples_paused_.clear(); +} + +void BaseHandler::add_sample_to_buffer_nts_( + const BaseMessage* sample) +{ + samples_buffer_.push_back(sample); + + if (state_ != BaseHandlerStateCode::RUNNING || samples_buffer_.size() < configuration_.buffer_size) + { + // Don't write samples to disk + return; + } + + if (samples_buffer_.size() == configuration_.buffer_size) + { + logInfo(DDSRECORDER_BASE_HANDLER, + "The buffer is full. Writing to disk..."); + } + else + { + logWarning(DDSRECORDER_BASE_HANDLER, + "The buffer's size (" << samples_buffer_.size() << ") exceeds its limit (" << + configuration_.buffer_size << "). Writing to disk..."); + } + + write_samples_(samples_buffer_); +} + +void BaseHandler::add_samples_to_buffer_nts_( + std::list& samples) +{ + while (!samples.empty()) + { + add_sample_to_buffer_nts_(samples.front()); + samples.pop_front(); + } +} + +void BaseHandler::add_sample_to_pending_nts_( + const BaseMessage* sample) +{ + assert(configuration_.max_pending_samples != 0); + + auto& pending_samples = pending_samples_[sample->topic.type_name]; + + while (pending_samples.size() >= configuration_.max_pending_samples) + { + // The pending samples buffer is full. Discard the oldest sample. + const auto oldest_sample = pending_samples.front(); + pending_samples.pop_front(); + + if (configuration_.only_with_schema) + { + logWarning(DDSRECORDER_BASE_HANDLER, + "Dropping pending sample in type " << sample->topic.type_name << ": buffer limit (" << + configuration_.max_pending_samples << ") reached."); + } + else + { + logInfo(DDSRECORDER_BASE_HANDLER, + "Buffer limit (" << configuration_.max_pending_samples << ") reached for type " << + sample->topic.type_name << ": writing oldest sample without schema."); + + add_sample_to_buffer_nts_(oldest_sample); + } + } + + pending_samples.push_back(sample); +} + +void BaseHandler::dump_pending_samples_nts_( + const std::string& type_name) +{ + logInfo(DDSRECORDER_BASE_HANDLER, "Adding pending samples for type: " << type_name << "."); + + if (pending_samples_.find(type_name) != pending_samples_.end()) + { + if (state_ == BaseHandlerStateCode::PAUSED) + { + // The samples were received previously in the RUNNING state. + // To avoid them being cleaned by the event thread, we write them directly. + write_samples_(pending_samples_[type_name]); + } + else + { + // Move samples from pending_samples to buffer + add_samples_to_buffer_nts_(pending_samples_[type_name]); + } + + pending_samples_.erase(type_name); + } + + if (state_ == BaseHandlerStateCode::PAUSED && + (pending_samples_paused_.find(type_name) != pending_samples_paused_.end())) + { + // Move samples from pending_samples_paused to buffer + add_samples_to_buffer_nts_(pending_samples_paused_[type_name]); + pending_samples_paused_.erase(type_name); + } +} + +void BaseHandler::remove_outdated_samples_nts_() +{ + logInfo(DDSRECORDER_BASE_HANDLER, "Removing outdated samples."); + + ddspipe::core::types::DataTime threshold; + ddspipe::core::types::DataTime::now(threshold); + threshold = threshold - ddspipe::core::types::DataTime(configuration_.event_window); + + // NOTE: the outdated pending samples are not removed since they must be written as soon as they receive their type. + + // Buffer + samples_buffer_.remove_if([&](const auto sample) + { + return sample->log_time < threshold; + }); + + // Pending samples paused + for (auto& [_, pending] : pending_samples_paused_) + { + pending.remove_if([&](const auto sample) + { + return sample->log_time < threshold; + }); + } +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ From 1904c671b64ad36c6bb5bafd088968f0c6d2ec28 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 10 May 2024 08:48:49 +0200 Subject: [PATCH 09/52] Strip dynamic types management from the McapHandler Signed-off-by: tempate --- .../recorder/mcap/McapHandler.hpp | 27 ------- .../recorder/output/BaseHandler.hpp | 40 ++++++++++- .../src/cpp/recorder/mcap/McapHandler.cpp | 62 ---------------- .../src/cpp/recorder/output/BaseHandler.cpp | 71 +++++++++++++++++++ 4 files changed, 109 insertions(+), 91 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index 4033c511f..b0205bc6a 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -200,36 +200,9 @@ class McapHandler : public BaseHandler mcap::SchemaId get_schema_id_nts_( const std::string& schema_name); - /** - * @brief Serialize type identifier and object, and insert the result into a \c DynamicTypesCollection . - * - * @param [in] type_name Name of the type to be stored, used as key in \c dynamic_types map. - */ - void store_dynamic_type_( - const std::string& type_name, - const fastdds::dds::xtypes::TypeIdentifier& type_id, - DynamicTypesCollection& dynamic_types) const; - - /** - * @brief Serialize type identifier and object, and insert the result into a \c DynamicTypesCollection . - * - * @param [in] type_identifier Type identifier to be serialized and stored. - * @param [in] type_object Type object to be serialized and stored. - * @param [in] type_name Name of the type to be stored, used as key in \c dynamic_types map. - * @param [in,out] dynamic_types Collection where to store serialized dynamic type. - */ - void store_dynamic_type_( - const fastdds::dds::xtypes::TypeIdentifier& type_identifier, - const fastdds::dds::xtypes::TypeObject& type_object, - const std::string& type_name, - DynamicTypesCollection& dynamic_types) const; - //! MCAP writer McapWriter mcap_writer_; - //! Received types set - std::set received_types_; - //! Schemas map std::map schemas_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp index 441109e91..85737cd9a 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp @@ -22,9 +22,14 @@ #include #include #include +#include +#include #include #include +#include +#include + #include #include @@ -32,13 +37,12 @@ #include +#include #include #include #include #include -#include - namespace eprosima { namespace ddsrecorder { namespace participants { @@ -270,6 +274,28 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler */ void remove_outdated_samples_nts_(); + /** + * @brief Create a \c DynamicType and insert it into \c dynamic_types_ . + * + * @param [in] type_name Name of the type to be stored, used as key in \c dynamic_types map. + * @param [in] type_identifier Type identifier to be serialized and stored. + */ + void store_dynamic_type_( + const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_identifier); + + /** + * @brief Serialize type identifier and object, and insert the result into a \c DynamicTypesCollection . + * + * @param [in] type_name Name of the type to be stored, used as key in \c dynamic_types map. + * @param [in] type_identifier Type identifier to be serialized and stored. + * @param [in] type_object Type object to be serialized and stored. + */ + void store_dynamic_type_( + const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_identifier, + const fastdds::dds::xtypes::TypeObject& type_object); + //! Handler configuration McapHandlerConfiguration configuration_; @@ -310,6 +336,16 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler //! Structure where messages (received in PAUSED state) with unknown type are kept std::map> pending_samples_paused_; + + ////////////////////////////// + // DYNAMIC TYPES COLLECTION // + ////////////////////////////// + + //! Received types set + std::set received_types_; + + //! Dynamic types collection + DynamicTypesCollection dynamic_types_; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 2cdc38c7d..8f6ad9fcf 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -30,8 +30,6 @@ #include -#include -#include #include #include #include @@ -372,66 +370,6 @@ mcap::SchemaId McapHandler::get_schema_id_nts_( } } -void McapHandler::store_dynamic_type_( - const std::string& type_name, - const fastdds::dds::xtypes::TypeIdentifier& type_id, - DynamicTypesCollection& dynamic_types) const -{ - fastdds::dds::xtypes::TypeIdentifierPair type_ids_pair; - type_ids_pair.type_identifier1(type_id); - - fastdds::dds::xtypes::TypeInformation type_info; - if (fastdds::dds::RETCODE_OK == fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_information( - type_ids_pair, - type_info, - true)) - { - std::string dependency_name; - unsigned int dependency_index = 0; - auto type_dependencies = type_info.complete().dependent_typeids(); - for (auto dependency : type_dependencies) - { - fastdds::dds::xtypes::TypeIdentifier type_identifier; - type_identifier = dependency.type_id(); - - fastdds::dds::xtypes::TypeObject type_object; - const auto ret = fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_object( - type_identifier, - type_object); - - dependency_name = type_name + "_" + std::to_string(dependency_index); - - // Store dependency in dynamic_types collection - store_dynamic_type_(type_identifier, type_object, dependency_name, dynamic_types); - - // Increment suffix counter - dependency_index++; - } - - fastdds::dds::xtypes::TypeObject type_obj; - if (fastdds::dds::RETCODE_OK == fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_object( - type_id, - type_obj)) - { - // Store dynamic type in dynamic_types collection - store_dynamic_type_(type_id, type_obj, type_name, dynamic_types); - } - } -} - -void McapHandler::store_dynamic_type_( - const fastdds::dds::xtypes::TypeIdentifier& type_identifier, - const fastdds::dds::xtypes::TypeObject& type_object, - const std::string& type_name, - DynamicTypesCollection& dynamic_types) const -{ - DynamicType dynamic_type; - dynamic_type.type_name(type_name); - dynamic_type.type_information(utils::base64_encode(Serializer::serialize(type_identifier))); - dynamic_type.type_object(utils::base64_encode(Serializer::serialize(type_object))); - dynamic_types.dynamic_types().push_back(dynamic_type); -} - } /* namespace participants */ } /* namespace ddsrecorder */ } /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp index 6987344e9..a3f2ffa52 100644 --- a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp @@ -19,6 +19,11 @@ #include #include +#include +#include +#include +#include + #include #include @@ -30,6 +35,7 @@ #include #include #include +#include namespace eprosima { namespace ddsrecorder { @@ -493,6 +499,71 @@ void BaseHandler::remove_outdated_samples_nts_() } } +void BaseHandler::store_dynamic_type_( + const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_identifier) +{ + fastdds::dds::xtypes::TypeIdentifierPair type_identifiers; + type_identifiers.type_identifier1(type_identifier); + + auto factory = fastdds::dds::DomainParticipantFactory::get_instance(); + + fastdds::dds::xtypes::TypeInformation type_information; + if (fastdds::dds::RETCODE_OK != factory->type_object_registry().get_type_information( + type_identifiers, type_information, true)) + { + return; + } + + // Store dependencies as dynamic types + auto dependencies = type_information.complete().dependent_typeids(); + unsigned int dependency_index = 0; + + for (auto dependency : dependencies) + { + const auto dep_type_identifier = dependency.type_id(); + + fastdds::dds::xtypes::TypeObject dep_type_object; + + if (fastdds::dds::RETCODE_OK != factory->type_object_registry().get_type_object( + dep_type_identifier, dep_type_object)) + { + continue; + } + + const auto dep_type_name = type_name + "_" + std::to_string(dependency_index); + + // Store dependency in dynamic_types collection + store_dynamic_type_(dep_type_name, dep_type_identifier, dep_type_object); + + // Increment suffix counter + dependency_index++; + } + + fastdds::dds::xtypes::TypeObject type_object; + + if (fastdds::dds::RETCODE_OK != factory->type_object_registry().get_type_object( + type_identifier, type_object)) + { + return; + } + + // Store dynamic type in dynamic_types collection + store_dynamic_type_(type_name, type_identifier, type_object); +} + +void BaseHandler::store_dynamic_type_( + const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_identifier, + const fastdds::dds::xtypes::TypeObject& type_object) +{ + DynamicType dynamic_type; + dynamic_type.type_name(type_name); + dynamic_type.type_information(utils::base64_encode(Serializer::serialize(type_identifier))); + dynamic_type.type_object(utils::base64_encode(Serializer::serialize(type_object))); + dynamic_types_.dynamic_types().push_back(dynamic_type); +} + } /* namespace participants */ } /* namespace ddsrecorder */ } /* namespace eprosima */ From 29afbb55e1b6b27c32f901e7a6519de36f9c3c60 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 10 May 2024 11:14:18 +0200 Subject: [PATCH 10/52] Strip new sample generic processing from the McapHandler Signed-off-by: tempate --- .../recorder/mcap/McapHandler.hpp | 2 +- .../recorder/output/BaseHandler.hpp | 42 ++++++--- .../src/cpp/recorder/mcap/McapHandler.cpp | 87 +++++-------------- .../src/cpp/recorder/output/BaseHandler.cpp | 60 ++++++++++++- 4 files changed, 107 insertions(+), 84 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index b0205bc6a..240b97029 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -153,7 +153,7 @@ class McapHandler : public BaseHandler * @param [in] samples List of samples to be written. */ void write_samples_( - std::list& samples) override; + std::list>& samples) override; /** * @brief Create and add to \c mcap_writer_ channel associated to given \c topic diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp index 85737cd9a..cf18acbd0 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp @@ -206,15 +206,15 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler std::unique_lock& event_lock); /** - * @brief Writes \c samples to disk. + * @brief Processes a received sample. * - * For each sample in \c samples, it writes it to disk and removes it from \c samples. - * The method ends when \c samples is empty. + * The method is called when a new sample is received. + * It either writes the sample directly to disk, adds it to \c samples_buffer or to a pending list, or discards it. * - * @param [in] samples List of samples to be written. + * @param [in] sample Sample to be processed. */ - virtual void write_samples_( - std::list& samples) = 0; + void process_new_sample_nts_( + std::shared_ptr sample); /** * @brief Adds a sample to \c samples_buffer. @@ -222,7 +222,7 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler * @param sample Sample to be added. */ void add_sample_to_buffer_nts_( - const BaseMessage* sample); + std::shared_ptr sample); /** * @brief Adds samples to \c samples_buffer. @@ -233,7 +233,7 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler * @param [in] samples List of samples to be added. */ void add_samples_to_buffer_nts_( - std::list& samples); + std::list>& samples); /** * @brief Adds a sample to \c pending_samples_. @@ -243,7 +243,7 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler * @param sample Sample to be added. */ void add_sample_to_pending_nts_( - const BaseMessage* sample); + std::shared_ptr sample); /** * @brief Dumps the pending samples corresponding to \c type_name. @@ -264,6 +264,17 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler void dump_pending_samples_nts_( const std::string& type_name); + /** + * @brief Writes \c samples to disk. + * + * For each sample in \c samples, it writes it to disk and removes it from \c samples. + * The method ends when \c samples is empty. + * + * @param [in] samples List of samples to be written. + */ + virtual void write_samples_( + std::list>& samples) = 0; + /** * @brief Remove samples older than [now - event_window]. * @@ -275,7 +286,10 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler void remove_outdated_samples_nts_(); /** - * @brief Create a \c DynamicType and insert it into \c dynamic_types_ . + * @brief Store a \c DynamicType and its dependencies in \c dynamic_types_. + * + * It calls \c store_dynamic_type_ with the type identifier and type object of each dependency of \c dynamic_type. + * It calls \c store_dynamic_type_ with the type identifier and type object of \c type_name. * * @param [in] type_name Name of the type to be stored, used as key in \c dynamic_types map. * @param [in] type_identifier Type identifier to be serialized and stored. @@ -285,7 +299,7 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler const fastdds::dds::xtypes::TypeIdentifier& type_identifier); /** - * @brief Serialize type identifier and object, and insert the result into a \c DynamicTypesCollection . + * @brief Create a \c DynamicType and insert it into \c dynamic_types_. * * @param [in] type_name Name of the type to be stored, used as key in \c dynamic_types map. * @param [in] type_identifier Type identifier to be serialized and stored. @@ -329,13 +343,13 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler /////////////////////// //! Samples buffer - std::list samples_buffer_; + std::list> samples_buffer_; //! Structure where messages (received in RUNNING state) with unknown type are kept - std::map> pending_samples_; + std::map>> pending_samples_; //! Structure where messages (received in PAUSED state) with unknown type are kept - std::map> pending_samples_paused_; + std::map>> pending_samples_paused_; ////////////////////////////// // DYNAMIC TYPES COLLECTION // diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 8f6ad9fcf..7dae39e57 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -98,11 +98,14 @@ void McapHandler::add_schema( const std::string& type_name, const fastdds::dds::xtypes::TypeIdentifier& type_id) { - std::lock_guard lock(mtx_); - // NOTE: Process schemas even if in STOPPED state to avoid losing them (only sent/received once in discovery) + std::lock_guard lock(mtx_); - assert(nullptr != dynamic_type); + if (dynamic_type == nullptr) + { + logWarning(DDSRECORDER_MCAP_HANDLER, "Received nullptr dynamic type. Skipping..."); + return; + } // const std::string type_name = dynamic_type->get_name(); @@ -140,8 +143,9 @@ void McapHandler::add_schema( } mcap::Schema new_schema(name, encoding, data); + logInfo(DDSRECORDER_MCAP_HANDLER, "Schema created: " << new_schema.name << "."); - // Add schema to writer and to schemas map + // Add schema to writer logInfo(DDSRECORDER_MCAP_HANDLER, "MCAP_WRITE | Adding schema with name " << dynamic_type->get_name().to_string() << " :\n" << data << "\n"); @@ -150,13 +154,17 @@ void McapHandler::add_schema( logInfo(DDSRECORDER_MCAP_HANDLER, "MCAP_WRITE | Schema created: " << new_schema.name << "."); - auto it = schemas_.find(type_name); + // Update channels previously created with blank schema + const auto it = schemas_.find(type_name); if (it != schemas_.end()) { - // Update channels previously created with blank schema update_channels_nts_(it->second.id, new_schema.id); } + + // Store schema schemas_[type_name] = std::move(new_schema); + + // Add type to the list of received types received_types_.insert(type_name); if (configuration_.record_types) @@ -164,10 +172,10 @@ void McapHandler::add_schema( mcap_writer_.update_dynamic_types(*Serializer::serialize(&dynamic_types_)); } - // Check if there are any pending samples for this new schema. If so, dump them. - if ((pending_samples_.find(type_name) != pending_samples_.end()) || + // Check if there are any pending samples for this new type. If so, dump them. + if (pending_samples_.find(type_name) != pending_samples_.end() || (state_ == BaseHandlerStateCode::PAUSED && - (pending_samples_paused_.find(type_name) != pending_samples_paused_.end()))) + pending_samples_paused_.find(type_name) != pending_samples_paused_.end())) { dump_pending_samples_nts_(type_name); } @@ -179,17 +187,6 @@ void McapHandler::add_data( { std::unique_lock lock(mtx_); - if (state_ == BaseHandlerStateCode::STOPPED) - { - logInfo(DDSRECORDER_MCAP_HANDLER, - "FAIL_MCAP_WRITE | Attempting to add sample through a stopped handler, dropping..."); - return; - } - - logInfo( - DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Adding data in topic " << topic); - // Add channel to data mcap::ChannelId channel_id; @@ -203,60 +200,18 @@ void McapHandler::add_data( "MCAP_WRITE | Error adding message in topic " << topic << ". Error message:\n " << e.what()); } - const auto sample = new McapMessage(data, payload_pool_, topic, channel_id, configuration_.log_publishTime); - - if (received_types_.find(topic.type_name) != received_types_.end()) - { - add_sample_to_buffer_nts_(sample); - return; - } - - switch (state_) - { - case BaseHandlerStateCode::RUNNING: - - if (configuration_.max_pending_samples != 0) - { - logInfo( - DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Schema for topic " << topic << - " not yet available, inserting to pending samples queue."); - - add_sample_to_pending_nts_(sample); - } - else if (!configuration_.only_with_schema) - { - // No schema available + no pending samples -> Add to buffer with blank schema - add_sample_to_buffer_nts_(sample); - } - break; - - case BaseHandlerStateCode::PAUSED: - - logInfo( - DDSRECORDER_MCAP_HANDLER, - "MCAP_WRITE | Schema for topic " << topic << - " not yet available, inserting to (paused) pending samples queue."); - - pending_samples_paused_[topic.type_name].push_back(sample); - break; - - default: - - // Should not happen, protected with mutex and state verified at beginning - utils::tsnh(utils::Formatter() << "Trying to add sample to a stopped instance."); - break; - } + process_new_sample_nts_(std::make_shared( + data, payload_pool_, topic, channel_id, configuration_.log_publishTime)); } void McapHandler::write_samples_( - std::list& samples) + std::list>& samples) { logInfo(DDSRECORDER_MCAP_HANDLER, "Writing samples to MCAP file."); while (!samples.empty()) { - const auto mcap_sample = static_cast(samples.front()); + const auto mcap_sample = static_cast(samples.front().get()); if (mcap_sample == nullptr) { diff --git a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp index a3f2ffa52..41ee1cf79 100644 --- a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp @@ -374,8 +374,62 @@ void BaseHandler::stop_event_thread_nts_( pending_samples_paused_.clear(); } +void BaseHandler::process_new_sample_nts_( + std::shared_ptr sample) +{ + if (state_ == BaseHandlerStateCode::STOPPED) + { + logInfo(DDSRECORDER_BASE_HANDLER, "Attempting to add sample through a stopped handler, dropping..."); + return; + } + + logInfo(DDSRECORDER_BASE_HANDLER, "Adding data in topic " << sample->topic); + + if (received_types_.find(sample->topic.type_name) != received_types_.end()) + { + add_sample_to_buffer_nts_(sample); + return; + } + + switch (state_) + { + case BaseHandlerStateCode::RUNNING: + + if (configuration_.max_pending_samples != 0) + { + logInfo(DDSRECORDER_BASE_HANDLER, + "Dynamic type for topic " << sample->topic << " not yet available, inserting to pending " + "samples queue."); + + add_sample_to_pending_nts_(sample); + } + else if (!configuration_.only_with_schema) + { + // No schema available + no pending samples -> Add to buffer with blank schema + add_sample_to_buffer_nts_(sample); + } + break; + + case BaseHandlerStateCode::PAUSED: + + logInfo( + DDSRECORDER_BASE_HANDLER, + "Dynamic type for topic " << sample->topic << " not yet available, inserting to (paused) pending " + "samples queue."); + + pending_samples_paused_[sample->topic.type_name].push_back(sample); + break; + + default: + + // Should not happen, protected with mutex and state verified at beginning + utils::tsnh(utils::Formatter() << "Trying to add sample to a stopped instance."); + break; + } +} + void BaseHandler::add_sample_to_buffer_nts_( - const BaseMessage* sample) + std::shared_ptr sample) { samples_buffer_.push_back(sample); @@ -401,7 +455,7 @@ void BaseHandler::add_sample_to_buffer_nts_( } void BaseHandler::add_samples_to_buffer_nts_( - std::list& samples) + std::list>& samples) { while (!samples.empty()) { @@ -411,7 +465,7 @@ void BaseHandler::add_samples_to_buffer_nts_( } void BaseHandler::add_sample_to_pending_nts_( - const BaseMessage* sample) + std::shared_ptr sample) { assert(configuration_.max_pending_samples != 0); From 10d30685d91185632b13576b3d34af3c25a2bee3 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 10 May 2024 12:24:59 +0200 Subject: [PATCH 11/52] Update includes in McapHandler and BaseHandler Signed-off-by: tempate --- .../recorder/mcap/McapHandler.hpp | 7 ++----- .../recorder/output/BaseHandler.hpp | 2 -- .../src/cpp/recorder/mcap/McapHandler.cpp | 6 +----- .../src/cpp/recorder/output/BaseHandler.cpp | 12 ++---------- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index 240b97029..e3e1d7879 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -21,14 +21,14 @@ #include #include #include +#include +#include #include #include #include -#include - #include #include #include @@ -38,12 +38,9 @@ #include #include #include -#include #include #include -#include - namespace eprosima { namespace ddsrecorder { namespace participants { diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp index cf18acbd0..3efe03dd1 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp @@ -33,7 +33,6 @@ #include #include -#include #include @@ -41,7 +40,6 @@ #include #include #include -#include namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 7dae39e57..2ed64d841 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -18,14 +18,11 @@ #define MCAP_IMPLEMENTATION // Define this in exactly one .cpp file -#include +#include #include -#include #include -#include -#include #include #include @@ -33,7 +30,6 @@ #include #include #include -#include #include namespace eprosima { diff --git a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp index 41ee1cf79..58afced61 100644 --- a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp @@ -16,7 +16,6 @@ * @file BaseHandler.cpp */ -#include #include #include @@ -24,16 +23,9 @@ #include #include -#include +#include +#include -#include - -#include -#include - -#include -#include -#include #include #include From 597295c2dea5eb8854419b61edbf60fa3a19efaa Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 10 May 2024 14:55:25 +0200 Subject: [PATCH 12/52] Strip non-mcap-related from the McapHandlerConfiguration Signed-off-by: tempate --- .../mcap/McapHandlerConfiguration.hpp | 69 +++++---------- .../recorder/output/BaseHandler.hpp | 39 ++++----- .../output/BaseHandlerConfiguration.hpp | 84 +++++++++++++++++++ .../src/cpp/recorder/output/BaseHandler.cpp | 2 +- 4 files changed, 125 insertions(+), 69 deletions(-) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandlerConfiguration.hpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp index 87956cb5c..903a54e6f 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp @@ -18,12 +18,9 @@ #pragma once -#include -#include -#include - #include +#include #include namespace eprosima { @@ -33,61 +30,35 @@ namespace participants { /** * Structure encapsulating all of \c McapHandler configuration options. */ -struct McapHandlerConfiguration +struct McapHandlerConfiguration : public BaseHandlerConfiguration { McapHandlerConfiguration( const OutputSettings& output_settings, - const int& max_pending_samples, - const unsigned int& buffer_size, - const unsigned int& event_window, - const unsigned int& cleanup_period, - const bool& log_publishTime, - const bool& only_with_schema, + const int max_pending_samples, + const unsigned int buffer_size, + const unsigned int event_window, + const unsigned int cleanup_period, + const bool log_publishTime, + const bool only_with_schema, const mcap::McapWriterOptions& mcap_writer_options, - const bool& record_types, - const bool& ros2_types) - : output_settings(output_settings) - , max_pending_samples(max_pending_samples) - , buffer_size(buffer_size) - , event_window(event_window) - , cleanup_period(cleanup_period) - , log_publishTime(log_publishTime) - , only_with_schema(only_with_schema) + const bool record_types, + const bool ros2_types) + : BaseHandlerConfiguration( + output_settings, + max_pending_samples, + buffer_size, + event_window, + cleanup_period, + log_publishTime, + only_with_schema, + record_types, + ros2_types) , mcap_writer_options(mcap_writer_options) - , record_types(record_types) - , ros2_types(ros2_types) { } - //! Configuration settings for MCAP file where data is to be written - OutputSettings output_settings; - - //! Max number of messages to store in memory when schema not yet available - unsigned int max_pending_samples; - - //! Max number of elements to keep in memory prior to writing in disk (applies to started state) - unsigned int buffer_size; - - //! Keep in memory samples received in time frame [s], to be stored when event triggered (applies to paused state) - unsigned int event_window; - - //! Remove from buffer samples older than *now - event_window* with this period [s] (applies to paused state) - unsigned int cleanup_period; - - //! Store messages with logTime set to sample publication timestamp - bool log_publishTime; - - //! Only write messages whose schema is registered (i.e. discard pending samples when leaving RUNNING state) - bool only_with_schema; - //! Mcap writer configuration options mcap::McapWriterOptions mcap_writer_options; - - //! Whether to store received dynamic types in output MCAP file - bool record_types; - - //! Whether to generate schemas as OMG IDL or ROS2 msg - bool ros2_types; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp index 3efe03dd1..41a6ecd6b 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp @@ -38,8 +38,8 @@ #include #include -#include #include +#include namespace eprosima { namespace ddsrecorder { @@ -54,8 +54,15 @@ ENUMERATION_BUILDER( ); /** - * Class that manages the interaction between DDS Pipe (\c SchemaParticipant) and MCAP files through mcap library. - * Payloads are efficiently passed from DDS Pipe to mcap without copying data (only references). + * @brief Base class with generic methods to interact with the \c DdsPipe ( \c SchemaParticipant ). + * + * More concretely, the \c BaseHandler manages: + * - state transitions (start, stop, pause, trigger_event), + * - buffer management (storing, discarding and dumping samples), + * - pending samples management (samples received before the type is known), + * - dynamic types collection (storing and serializing types). + * + * Payloads are efficiently passed from DDS Pipe to the output file without copying data (only references). * * @implements ISchemaHandler */ @@ -64,30 +71,18 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler public: /** - * BaseHandler constructor by required values. - * - * Creates BaseHandler instance with given configuration, payload pool and initial state. - * Opens temporal MCAP file where data is to be written. - * - * @throw InitializationException if creation fails (fail to open MCAP file). - * - * @warning Command methods ( \c start , \c pause , \c stop , and \c trigger_event ) are not thread safe - * among themselves. This is, they are expected to be executed sequentially and all in the same thread. + * @brief Creates the \c BaseHandler instance with the given configuration. * * @param config: Structure encapsulating all configuration options. * @param payload_pool: Pool of payloads to be used by the handler. */ DDSRECORDER_PARTICIPANTS_DllAPI BaseHandler( - const McapHandlerConfiguration& config, + const BaseHandlerConfiguration& config, const std::shared_ptr& payload_pool); /** - * @brief Destructor - * - * Closes temporal MCAP file, and renames it with filename given in configuration. - * Before closing file, received dynamic types are serialized and stored as an attachment. - * + * @brief Destructor the \c BaseHandler instance. */ DDSRECORDER_PARTICIPANTS_DllAPI virtual ~BaseHandler(); @@ -95,6 +90,12 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler /** * @brief Initialize handler instance * + * @warning Command methods ( \c start , \c pause , \c stop , and \c trigger_event ) are not thread safe + * among themselves. This is, they are expected to be executed sequentially and all in the same thread. + * + * @note This method should be called by a derived class constructor to ensure the purely virtual methods have been + * implemented. + * * @param [in] init_state Initial state of the handler instance. */ DDSRECORDER_PARTICIPANTS_DllAPI @@ -309,7 +310,7 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler const fastdds::dds::xtypes::TypeObject& type_object); //! Handler configuration - McapHandlerConfiguration configuration_; + const BaseHandlerConfiguration configuration_; //! Payload pool std::shared_ptr payload_pool_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandlerConfiguration.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandlerConfiguration.hpp new file mode 100644 index 000000000..cb457dc6b --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandlerConfiguration.hpp @@ -0,0 +1,84 @@ +// Copyright 2024 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 BaseHandlerConfiguration.hpp + */ + +#pragma once + +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +/** + * Structure encapsulating all the \c BaseHandler configuration options. + */ +struct BaseHandlerConfiguration +{ + BaseHandlerConfiguration( + const OutputSettings& output_settings, + const unsigned int max_pending_samples, + const unsigned int buffer_size, + const unsigned int event_window, + const unsigned int cleanup_period, + const bool log_publishTime, + const bool only_with_schema, + const bool record_types, + const bool ros2_types) + : output_settings(output_settings) + , max_pending_samples(max_pending_samples) + , buffer_size(buffer_size) + , event_window(event_window) + , cleanup_period(cleanup_period) + , log_publishTime(log_publishTime) + , only_with_schema(only_with_schema) + , record_types(record_types) + , ros2_types(ros2_types) + { + } + + //! Configuration settings for the output file where data is to be written + OutputSettings output_settings; + + //! Max number of messages to store in memory when schema not yet available + unsigned int max_pending_samples; + + //! Max number of elements to keep in memory prior to writing in disk (applies to started state) + unsigned int buffer_size; + + //! Keep in memory samples received in time frame [s], to be stored when event triggered (applies to paused state) + unsigned int event_window; + + //! Remove from buffer samples older than *now - event_window* with this period [s] (applies to paused state) + unsigned int cleanup_period; + + //! Store messages with logTime set to sample publication timestamp + bool log_publishTime; + + //! Only write messages whose schema is registered (i.e. discard pending samples when leaving RUNNING state) + bool only_with_schema; + + //! Whether to store received dynamic types in the output file + bool record_types; + + //! Whether to generate schemas as OMG IDL or ROS2 msg + bool ros2_types; +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp index 58afced61..028b0ec2d 100644 --- a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp @@ -36,7 +36,7 @@ namespace participants { using namespace eprosima::ddspipe::core::types; BaseHandler::BaseHandler( - const McapHandlerConfiguration& config, + const BaseHandlerConfiguration& config, const std::shared_ptr& payload_pool) : configuration_(config) , payload_pool_(payload_pool) From bf2a0d80603727c617b6b648d831c75d380051db Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 13 May 2024 09:39:38 +0200 Subject: [PATCH 13/52] Strip generic file processing methods from the McapWriter Signed-off-by: tempate --- .../recorder/mcap/McapWriter.hpp | 83 ++--------- .../recorder/mcap/impl/McapWriter.ipp | 2 +- .../recorder/output/BaseWriter.hpp | 137 ++++++++++++++++++ .../src/cpp/recorder/mcap/McapWriter.cpp | 96 +----------- .../src/cpp/recorder/output/BaseWriter.cpp | 136 +++++++++++++++++ 5 files changed, 286 insertions(+), 168 deletions(-) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseWriter.hpp create mode 100644 ddsrecorder_participants/src/cpp/recorder/output/BaseWriter.cpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp index c9524328a..3483957a4 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp @@ -19,25 +19,20 @@ #pragma once #include -#include -#include #include #include -#include #include -#include -#include #include -#include +#include namespace eprosima { namespace ddsrecorder { namespace participants { -class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter +class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter : public BaseWriter { public: @@ -47,36 +42,20 @@ class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter std::shared_ptr& file_tracker, const bool record_types = true); - ~McapWriter(); - - /** - * @brief Enable the writer. - * - * After a \c FullFileException : - * - @throws \c InconsistencyException if the allocated space is not enough to close the current file or to open a - * new one. - * - @throws \c InitializationException if the MCAP library fails to open a new file. - */ - void enable(); - /** * @brief Disable the writer. - * - * After a \c FullFileException : - * - @throws \c InconsistencyException if the allocated space is not enough to close the current file or to open a - * new one. */ - void disable(); + void disable() override; /** - * @brief Writes data to the MCAP file. + * @brief Writes data to the output file. * * @param data Pointer to the data to be written. * * After a \c FullFileException : * - @throws \c InconsistencyException if the allocated space is not enough to close the current file or to open a * new one. - * - @throws \c InitializationException if the MCAP library fails to open a new file. + * - @throws \c InitializationException if the output library fails to open a new file. */ template void write( @@ -97,14 +76,6 @@ class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter void update_dynamic_types( const fastdds::rtps::SerializedPayload_t& dynamic_types_payload); - /** - * @brief Sets the callback to be called when the disk is full. - * - * Sets \c on_disk_full_lambda_ to \c on_disk_full_lambda. - */ - void set_on_disk_full_callback( - std::function on_disk_full_lambda) noexcept; - protected: /** @@ -117,14 +88,14 @@ class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter * @throws \c InitializationException if the MCAP library fails to open the new file. */ void open_new_file_nts_( - const std::uint64_t min_file_size); + const std::uint64_t min_file_size) override; /** * @brief Closes the current file. * * @throws \c InconsistencyException if there is not enough space to write the attachment. */ - void close_current_file_nts_(); + void close_current_file_nts_() override; /** * @brief Writes data to the MCAP file. @@ -167,42 +138,9 @@ class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter */ void write_schemas_nts_(); - /** - * @brief Function called when the MCAP file is full. - * - * The function closes the current file and opens a new one. - * - * @throws \c FullDiskException if the MCAP file is full. - * @throws \c InconsistencyException if \c min_file_size is not enough to write the: metadata, schemas, channels, - * and attachment. - * @throws \c InitializationException if the MCAP library fails to open the new file. - */ - void on_mcap_full_nts_( - const FullFileException& e); - - /** - * @brief Function called when the disk is full. - */ - void on_disk_full_() const noexcept; - - // The configuration for the class - const OutputSettings configuration_; - // The configuration for the MCAP library const mcap::McapWriterOptions mcap_configuration_; - // Track the files written by the MCAP library - std::shared_ptr file_tracker_; - - // Whether to record the types - const bool record_types_{false}; - - // The mutex to protect the calls to write - std::mutex mutex_; - - // Whether the writer can write to the MCAP library - bool enabled_{false}; - // Track the size of the current MCAP file McapSizeTracker size_tracker_; @@ -218,11 +156,8 @@ class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter // The schemas that have been written std::map schemas_; - //! Lambda to call when the disk is full - std::function on_disk_full_lambda_; - - // The size of an MCAP file only with metadata and an empty attachment - static constexpr std::uint64_t MIN_MCAP_SIZE = 2056; + // The size of an empty MCAP file + static constexpr std::uint64_t MIN_MCAP_SIZE{2056}; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/impl/McapWriter.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/impl/McapWriter.ipp index 4b8e2e5f7..27c4c7585 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/impl/McapWriter.ipp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/impl/McapWriter.ipp @@ -40,7 +40,7 @@ void McapWriter::write( { try { - on_mcap_full_nts_(e); + on_file_full_nts_(e, size_tracker_.get_min_mcap_size()); write_nts_(data); } catch (const FullDiskException& e) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseWriter.hpp new file mode 100644 index 000000000..1c0cf4a1b --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseWriter.hpp @@ -0,0 +1,137 @@ +// Copyright 2024 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 BaseWriter.hpp + */ + +#pragma once + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +class DDSRECORDER_PARTICIPANTS_DllAPI BaseWriter +{ +public: + + BaseWriter( + const OutputSettings& configuration, + std::shared_ptr& file_tracker, + const bool record_types = true, + const std::uint64_t min_file_size = 0); + + virtual ~BaseWriter(); + + /** + * @brief Enable the writer. + * + * After a \c FullFileException : + * - @throws \c InconsistencyException if the allocated space is not enough to close the current file or to open a + * new one. + * - @throws \c InitializationException if the output library fails to open a new file. + */ + virtual void enable(); + + /** + * @brief Disable the writer. + * + * After a \c FullFileException : + * - @throws \c InconsistencyException if the allocated space is not enough to close the current file or to open a + * new one. + */ + virtual void disable(); + + /** + * @brief Sets the callback to be called when the disk is full. + * + * Sets \c on_disk_full_lambda_ to \c on_disk_full_lambda. + */ + void set_on_disk_full_callback( + std::function on_disk_full_lambda) noexcept; + +protected: + + /** + * @brief Opens a new file. + * + * @param min_file_size The minimum size of the file. + */ + virtual void open_new_file_nts_( + const std::uint64_t min_file_size) = 0; + + /** + * @brief Closes the current file. + */ + virtual void close_current_file_nts_() = 0; + + /** + * @brief Function called when the output file is full. + * + * The function closes the current file and tries to open a new one if allowed. + * + * @throws \c FullDiskException if the disk is full and the \c BaseWriter can't open any more files. + * @throws \c InconsistencyException if \c min_file_size is not enough to write the file's minimum information. + * @throws \c InitializationException if the output library fails to open the new file. + * + * @param e The exception thrown. + * @param min_file_size The minimum size of an empty file. + */ + void on_file_full_nts_( + const FullFileException& e, + const std::uint64_t min_file_size); + + /** + * @brief Function called when the disk is full. + */ + void on_disk_full_() const noexcept; + + // The configuration for the class + const OutputSettings configuration_; + + // Track the files written by the output library + std::shared_ptr file_tracker_; + + // Whether to record the types + const bool record_types_{false}; + + // The mutex to protect the calls to the public methods + std::mutex mutex_; + + // Whether the writer can write to the output library + bool enabled_{false}; + + //! Lambda to call when the disk is full + std::function on_disk_full_lambda_; + + // The size of an empty output file + const std::uint64_t MIN_FILE_SIZE{0}; +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp index 19614d0ec..5e1465c0b 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp @@ -16,14 +16,9 @@ * @file McapWriter.cpp */ -#include -#include - #include -#include #include -#include #include #include #include @@ -33,7 +28,6 @@ #include #include #include -#include namespace eprosima { namespace ddsrecorder { @@ -44,62 +38,17 @@ McapWriter::McapWriter( const mcap::McapWriterOptions& mcap_configuration, std::shared_ptr& file_tracker, const bool record_types) - : configuration_(configuration) + : BaseWriter(configuration, file_tracker, record_types, MIN_MCAP_SIZE) , mcap_configuration_(mcap_configuration) - , file_tracker_(file_tracker) - , record_types_(record_types) -{ -} - -McapWriter::~McapWriter() { - disable(); -} - -void McapWriter::enable() -{ - std::lock_guard lock(mutex_); - - if (enabled_) - { - return; - } - - logInfo(DDSRECORDER_MCAP_WRITER, - "MCAP_WRITE | Enabling MCAP writer.") - - try - { - open_new_file_nts_(MIN_MCAP_SIZE); - } - catch (const FullDiskException& e) - { - logError(DDSRECORDER_MCAP_WRITER, - "MCAP_WRITE | Error opening a new MCAP file: " << e.what()); - on_disk_full_(); - } - - enabled_ = true; } void McapWriter::disable() { - std::lock_guard lock(mutex_); - - if (!enabled_) - { - return; - } - - logInfo(DDSRECORDER_MCAP_WRITER, - "MCAP_WRITE | Disabling MCAP writer.") - - close_current_file_nts_(); + BaseWriter::disable(); // Clear the channels when disabling the writer so the old channels are not rewritten in every new file channels_.clear(); - - enabled_ = false; } void McapWriter::update_dynamic_types( @@ -136,7 +85,7 @@ void McapWriter::update_dynamic_types( { try { - on_mcap_full_nts_(e); + on_file_full_nts_(e, size_tracker_.get_min_mcap_size()); update_dynamic_types_payload(); } catch (const FullDiskException& e) @@ -151,12 +100,6 @@ void McapWriter::update_dynamic_types( file_tracker_->set_current_file_size(size_tracker_.get_potential_mcap_size()); } -void McapWriter::set_on_disk_full_callback( - std::function on_disk_full_lambda) noexcept -{ - on_disk_full_lambda_ = on_disk_full_lambda; -} - void McapWriter::open_new_file_nts_( const std::uint64_t min_file_size) { @@ -385,39 +328,6 @@ void McapWriter::write_schemas_nts_() } } -void McapWriter::on_mcap_full_nts_( - const FullFileException& e) -{ - close_current_file_nts_(); - - // Disable the writer in case opening a new file fails - enabled_ = false; - - if (configuration_.max_file_size == configuration_.max_size) - { - // There can only be one file and it's full - throw FullDiskException(e.what()); - } - - // Open a new file to write the remaining data. - // Throw an exception if a file with the minimum size cannot be opened. - const auto min_file_size = size_tracker_.get_min_mcap_size() + e.data_size_to_write(); - open_new_file_nts_(min_file_size); - - // The file has been opened correctly. Enable the writer. - enabled_ = true; -} - -void McapWriter::on_disk_full_() const noexcept -{ - monitor_error("DISK_FULL"); - - if (on_disk_full_lambda_ != nullptr) - { - on_disk_full_lambda_(); - } -} - } /* namespace participants */ } /* namespace ddsrecorder */ } /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/output/BaseWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/output/BaseWriter.cpp new file mode 100644 index 000000000..eb25f93ff --- /dev/null +++ b/ddsrecorder_participants/src/cpp/recorder/output/BaseWriter.cpp @@ -0,0 +1,136 @@ +// Copyright 2024 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 BaseWriter.cpp + */ + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +BaseWriter::BaseWriter( + const OutputSettings& configuration, + std::shared_ptr& file_tracker, + const bool record_types /* = true */, + const std::uint64_t min_file_size /* = 0 */) + : configuration_(configuration) + , file_tracker_(file_tracker) + , record_types_(record_types) + , MIN_FILE_SIZE(min_file_size) +{ +} + +BaseWriter::~BaseWriter() +{ + disable(); +} + +void BaseWriter::enable() +{ + std::lock_guard lock(mutex_); + + if (enabled_) + { + return; + } + + logInfo(DDSRECORDER_BASE_WRITER, + "WRITE | Enabling writer."); + + try + { + open_new_file_nts_(MIN_FILE_SIZE); + } + catch (const FullDiskException& e) + { + logError(DDSRECORDER_BASE_WRITER, + "WRITE | Error opening a new output file: " << e.what()); + on_disk_full_(); + } + + enabled_ = true; +} + +void BaseWriter::disable() +{ + std::lock_guard lock(mutex_); + + if (!enabled_) + { + return; + } + + logInfo(DDSRECORDER_BASE_WRITER, + "WRITE | Disabling writer."); + + close_current_file_nts_(); + + enabled_ = false; +} + +void BaseWriter::set_on_disk_full_callback( + std::function on_disk_full_lambda) noexcept +{ + on_disk_full_lambda_ = on_disk_full_lambda; +} + +void BaseWriter::on_file_full_nts_( + const FullFileException& e, + const std::uint64_t min_file_size) +{ + close_current_file_nts_(); + + // Disable the writer in case opening a new file fails + enabled_ = false; + + if (configuration_.max_file_size == configuration_.max_size) + { + // There can only be one file and it's full + throw FullDiskException(e.what()); + } + + // Open a new file to write the remaining data. + // Throw an exception if the file cannot be opened. + open_new_file_nts_(min_file_size + e.data_size_to_write()); + + // The file has been opened correctly. Enable the writer. + enabled_ = true; +} + +void BaseWriter::on_disk_full_() const noexcept +{ + monitor_error("DISK_FULL"); + + if (on_disk_full_lambda_ != nullptr) + { + on_disk_full_lambda_(); + } +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ From 2f61526ce71dae4fc31549e2af3796e5ce6fb7b2 Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 13 May 2024 10:38:30 +0200 Subject: [PATCH 14/52] Use the BaseWriter in the McapHandler Signed-off-by: tempate --- .../recorder/mcap/McapHandler.hpp | 12 ++-------- .../recorder/output/BaseHandler.hpp | 17 +++++++++++--- .../src/cpp/recorder/mcap/McapHandler.cpp | 22 +++++-------------- .../src/cpp/recorder/output/BaseHandler.cpp | 22 ++++++++++++++++++- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index e3e1d7879..7c7a14599 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -91,17 +91,9 @@ class McapHandler : public BaseHandler virtual ~McapHandler(); /** - * @brief Enable handler instance - * - * Enables the \c mcap_writer_ instance. - */ - void enable() override; - - /** - * @brief Disable handler instance - * - * Disables the \c mcap_writer_ instance. + * @brief Disable MCAP handler instance */ + DDSRECORDER_PARTICIPANTS_DllAPI void disable() override; /** diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp index 41a6ecd6b..60675b3ce 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include #include @@ -40,6 +41,7 @@ #include #include #include +#include namespace eprosima { namespace ddsrecorder { @@ -97,22 +99,28 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler * implemented. * * @param [in] init_state Initial state of the handler instance. + * @param [in] on_disk_full_lambda Lambda to be executed when disk is full. */ DDSRECORDER_PARTICIPANTS_DllAPI void init( - const BaseHandlerStateCode& init_state = BaseHandlerStateCode::RUNNING); + const BaseHandlerStateCode& init_state = BaseHandlerStateCode::RUNNING, + const std::function& on_disk_full_lambda = nullptr); /** * @brief Enable handler instance + * + * Enables the writer. */ DDSRECORDER_PARTICIPANTS_DllAPI - virtual void enable() = 0; + virtual void enable(); /** * @brief Disable handler instance + * + * Disables the writer. */ DDSRECORDER_PARTICIPANTS_DllAPI - virtual void disable() = 0; + virtual void disable(); /** * @brief Start handler instance @@ -341,6 +349,9 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler // BUFFER MANAGEMENT // /////////////////////// + //! MCAP writer + BaseWriter* writer_; + //! Samples buffer std::list> samples_buffer_; diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 2ed64d841..24f1ac85b 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -50,12 +50,11 @@ McapHandler::McapHandler( logInfo(DDSRECORDER_MCAP_HANDLER, "MCAP_STATE | Creating MCAP handler instance."); - if (on_disk_full_lambda != nullptr) - { - mcap_writer_.set_on_disk_full_callback(on_disk_full_lambda); - } + // Set the BaseHandler's writer + writer_ = &mcap_writer_; - init(init_state); + // Initialize the BaseHandler + init(init_state, on_disk_full_lambda); } McapHandler::~McapHandler() @@ -67,23 +66,14 @@ McapHandler::~McapHandler() stop(true); } -void McapHandler::enable() -{ - logInfo(DDSRECORDER_MCAP_HANDLER, "Enabling MCAP handler."); - - mcap_writer_.enable(); -} - void McapHandler::disable() { - logInfo(DDSRECORDER_MCAP_HANDLER, "Disabling MCAP handler."); - // Ideally, the channels and schemas should be shared between the McapHandler and McapWriter. // Right now, the data is duplicated in both classes, which uses more memory and can lead to inconsistencies. // TODO: Share the channels and schemas between the McapHandler and McapWriter. - // NOTE: disabling the McapWriter clears its channels - mcap_writer_.disable(); + // NOTE: disabling the BaseHandler disables the McapWriter which clears its channels + BaseHandler::disable(); // Clear the channels after a disable so the old channels are not rewritten in every new file channels_.clear(); diff --git a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp index 028b0ec2d..c74084777 100644 --- a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp @@ -51,8 +51,14 @@ BaseHandler::~BaseHandler() } void BaseHandler::init( - const BaseHandlerStateCode& init_state /* = BaseHandlerStateCode::RUNNING */) + const BaseHandlerStateCode& init_state /* = BaseHandlerStateCode::RUNNING */, + const std::function& on_disk_full_lambda /* = nullptr */) { + if (on_disk_full_lambda != nullptr) + { + writer_->set_on_disk_full_callback(on_disk_full_lambda); + } + switch (init_state) { case BaseHandlerStateCode::RUNNING: @@ -68,6 +74,20 @@ void BaseHandler::init( } } +void BaseHandler::enable() +{ + logInfo(DDSRECORDER_BASE_HANDLER, "Enabling handler."); + + writer_->enable(); +} + +void BaseHandler::disable() +{ + logInfo(DDSRECORDER_BASE_HANDLER, "Disabling handler."); + + writer_->disable(); +} + void BaseHandler::start() { // Wait for completion of event routine in case event was triggered From e3a23a5b55c347fc317dd23c0cdca3cbb1c1c874 Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 13 May 2024 11:57:48 +0200 Subject: [PATCH 15/52] Use the BaseHandler in the DdsRecorder Signed-off-by: tempate --- ddsrecorder/src/cpp/tool/DdsRecorder.cpp | 18 +++++++++++------- ddsrecorder/src/cpp/tool/DdsRecorder.hpp | 12 +++++------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/ddsrecorder/src/cpp/tool/DdsRecorder.cpp b/ddsrecorder/src/cpp/tool/DdsRecorder.cpp index 269c4ab33..1e9b87d9f 100644 --- a/ddsrecorder/src/cpp/tool/DdsRecorder.cpp +++ b/ddsrecorder/src/cpp/tool/DdsRecorder.cpp @@ -22,6 +22,10 @@ #include #include +#include +#include +#include + #include "DdsRecorder.hpp" namespace eprosima { @@ -119,7 +123,7 @@ DdsRecorder::DdsRecorder( } // Create MCAP Handler - mcap_handler_ = std::make_shared( + handler_ = std::make_shared( handler_config, payload_pool_, file_tracker, @@ -138,7 +142,7 @@ DdsRecorder::DdsRecorder( configuration_.recorder_configuration, payload_pool_, discovery_database_, - mcap_handler_); + handler_); // Create Participant Database participants_database_ = std::make_shared(); @@ -189,27 +193,27 @@ utils::ReturnCode DdsRecorder::reload_configuration( void DdsRecorder::start() { - mcap_handler_->start(); + handler_->start(); } void DdsRecorder::pause() { - mcap_handler_->pause(); + handler_->pause(); } void DdsRecorder::suspend() { - mcap_handler_->stop(); + handler_->stop(); } void DdsRecorder::stop() { - mcap_handler_->stop(); + handler_->stop(); } void DdsRecorder::trigger_event() { - mcap_handler_->trigger_event(); + handler_->trigger_event(); } void DdsRecorder::on_disk_full() diff --git a/ddsrecorder/src/cpp/tool/DdsRecorder.hpp b/ddsrecorder/src/cpp/tool/DdsRecorder.hpp index b9df8ee84..9357d967d 100644 --- a/ddsrecorder/src/cpp/tool/DdsRecorder.hpp +++ b/ddsrecorder/src/cpp/tool/DdsRecorder.hpp @@ -31,8 +31,6 @@ #include #include -#include -#include #include #include #include @@ -89,7 +87,7 @@ class DdsRecorder DdsRecorder( const yaml::RecorderConfiguration& configuration, const DdsRecorderStateCode& init_state, - std::shared_ptr event_handler, + std::shared_ptr event_handler, std::shared_ptr& file_tracker, const std::string& file_name = ""); @@ -151,13 +149,13 @@ class DdsRecorder std::shared_ptr participants_database_; //! MCAP Handler - std::shared_ptr mcap_handler_; + std::shared_ptr handler_; //! Dynamic Types Participant - std::shared_ptr dyn_participant_; + std::shared_ptr dyn_participant_; //! Schema Participant - std::shared_ptr recorder_participant_; + std::shared_ptr recorder_participant_; //! DDS Pipe std::unique_ptr pipe_; @@ -166,7 +164,7 @@ class DdsRecorder std::unique_ptr monitor_; //! Reference to event handler used for thread synchronization in main application - std::shared_ptr event_handler_; + std::shared_ptr event_handler_; }; } /* namespace recorder */ From b900671b5988a79d7c750373eb39e9109f75e5b0 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 14 May 2024 10:45:24 +0200 Subject: [PATCH 16/52] PoC: record data in SQLite Signed-off-by: tempate --- ddsrecorder/src/cpp/tool/DdsRecorder.cpp | 98 +++++-- .../recorder/message/SqlMessage.hpp | 53 ++++ .../recorder/output/OutputSettings.hpp | 8 + .../recorder/sql/SqlHandler.hpp | 137 ++++++++++ .../recorder/sql/SqlHandlerConfiguration.hpp | 59 +++++ .../recorder/sql/SqlWriter.hpp | 95 +++++++ .../recorder/sql/impl/SqlWriter.ipp | 53 ++++ .../recorder/sql/utils.hpp | 58 +++++ .../project_settings.cmake | 3 +- .../src/cpp/recorder/message/SqlMessage.cpp | 37 +++ .../src/cpp/recorder/sql/SqlHandler.cpp | 131 ++++++++++ .../src/cpp/recorder/sql/SqlWriter.cpp | 242 ++++++++++++++++++ .../src/cpp/recorder/sql/utils.cpp | 51 ++++ .../recorder/YamlReaderConfiguration.hpp | 3 + .../recorder/yaml_configuration_tags.hpp | 3 + .../cpp/recorder/YamlReaderConfiguration.cpp | 14 + 16 files changed, 1023 insertions(+), 22 deletions(-) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/impl/SqlWriter.ipp create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/utils.hpp create mode 100644 ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp create mode 100644 ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp create mode 100644 ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp create mode 100644 ddsrecorder_participants/src/cpp/recorder/sql/utils.cpp diff --git a/ddsrecorder/src/cpp/tool/DdsRecorder.cpp b/ddsrecorder/src/cpp/tool/DdsRecorder.cpp index 1e9b87d9f..b57fa24a6 100644 --- a/ddsrecorder/src/cpp/tool/DdsRecorder.cpp +++ b/ddsrecorder/src/cpp/tool/DdsRecorder.cpp @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include "DdsRecorder.hpp" @@ -86,7 +89,19 @@ DdsRecorder::DdsRecorder( output_settings.prepend_timestamp = false; } - output_settings.extension = ".mcap"; + switch (configuration_.output_library) + { + case participants::OutputLibrary::mcap: + output_settings.extension = ".mcap"; + break; + case participants::OutputLibrary::sql: + output_settings.extension = ".db"; + break; + default: + utils::tsnh(utils::Formatter() << "The library " << configuration_.output_library << " is not valid."); + break; + } + output_settings.safety_margin = configuration_.safety_margin; output_settings.file_rotation = configuration_.output_resource_limits_file_rotation; output_settings.max_file_size = configuration_.output_resource_limits_max_file_size; @@ -103,32 +118,73 @@ DdsRecorder::DdsRecorder( output_settings.max_size = output_settings.max_file_size; } - // Create MCAP Handler configuration - participants::McapHandlerConfiguration handler_config( - output_settings, - configuration_.max_pending_samples, - configuration_.buffer_size, - configuration_.event_window, - configuration_.cleanup_period, - configuration_.log_publish_time, - configuration_.only_with_type, - configuration_.mcap_writer_options, - configuration_.record_types, - configuration_.ros2_types); - if (file_tracker == nullptr) { // Create the File Tracker file_tracker.reset(new participants::FileTracker(output_settings)); } - // Create MCAP Handler - handler_ = std::make_shared( - handler_config, - payload_pool_, - file_tracker, - recorder_to_handler_state_(init_state), - std::bind(&DdsRecorder::on_disk_full, this)); + const auto handler_state = recorder_to_handler_state_(init_state); + const auto on_disk_full_lambda = std::bind(&DdsRecorder::on_disk_full, this); + + switch (configuration_.output_library) + { + case participants::OutputLibrary::mcap: + { + // Create MCAP Handler configuration + participants::McapHandlerConfiguration handler_config( + output_settings, + configuration_.max_pending_samples, + configuration_.buffer_size, + configuration_.event_window, + configuration_.cleanup_period, + configuration_.log_publish_time, + configuration_.only_with_type, + configuration_.mcap_writer_options, + configuration_.record_types, + configuration_.ros2_types); + + // Create MCAP Handler + handler_ = std::make_shared( + handler_config, + payload_pool_, + file_tracker, + handler_state, + on_disk_full_lambda); + + break; + } + case participants::OutputLibrary::sql: + { + // Create SQL Handler configuration + participants::SqlHandlerConfiguration handler_config( + output_settings, + configuration_.max_pending_samples, + configuration_.buffer_size, + configuration_.event_window, + configuration_.cleanup_period, + configuration_.log_publish_time, + configuration_.only_with_type, + configuration_.record_types, + configuration_.ros2_types); + + // Create MCAP Handler + handler_ = std::make_shared( + handler_config, + payload_pool_, + file_tracker, + handler_state, + on_disk_full_lambda); + + break; + } + default: + { + utils::tsnh(utils::Formatter() << "The library " << configuration_.output_library << " is not valid."); + break; + } + } + // Create DynTypes Participant dyn_participant_ = std::make_shared( diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp new file mode 100644 index 000000000..d8dda68af --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp @@ -0,0 +1,53 @@ +// Copyright 2024 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 SqlMessage.hpp + */ + +#pragma once + +#include + +#include +#include +#include + +#include + + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +/** + * Structure extending a \c BaseMessage for SQLite. + */ +struct SqlMessage : public BaseMessage +{ + SqlMessage() = default; + + /** + * @brief Construct a \c SqlMessage. + */ + SqlMessage( + const ddspipe::core::types::RtpsPayloadData& payload, + std::shared_ptr payload_pool, + const ddspipe::core::types::DdsTopic& topic, + const bool log_publish_time); +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/OutputSettings.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/OutputSettings.hpp index 3011767e7..c297e03a5 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/OutputSettings.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/OutputSettings.hpp @@ -21,11 +21,19 @@ #include #include +#include namespace eprosima { namespace ddsrecorder { namespace participants { +//! Supported output libraries +ENUMERATION_BUILDER( + OutputLibrary, + mcap, //! MCAP library. + sql //! SQL library. + ); + /** * Structure encapsulating all output configuration options. */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp new file mode 100644 index 000000000..addee837d --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp @@ -0,0 +1,137 @@ +// Copyright 2024 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 SqlHandler.hpp + */ + +#pragma once + +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +/** + * Class that manages the interaction between DDS Pipe (\c SchemaParticipant) and MCAP files through sql library. + * Payloads are efficiently passed from DDS Pipe to sql without copying data (only references). + * + * @implements BaseHandler + */ +class SqlHandler : public BaseHandler +{ +public: + + /** + * SqlHandler constructor by required values. + * + * Creates SqlHandler instance with given configuration, payload pool and initial state. + * Opens temporal MCAP file where data is to be written. + * + * @throw InitializationException if creation fails (fail to open MCAP file). + * + * @warning Command methods (\c start , \c pause , \c stop , and \c trigger_event) are not thread safe + * among themselves. This is, they are expected to be executed sequentially and all in the same thread. + * + * @param config: Structure encapsulating all configuration options. + * @param payload_pool: Owner of every payload contained in received messages. + * @param init_state: Initial instance state (RUNNING/PAUSED/STOPPED). + */ + DDSRECORDER_PARTICIPANTS_DllAPI + SqlHandler( + const SqlHandlerConfiguration& config, + const std::shared_ptr& payload_pool, + std::shared_ptr file_tracker, + const BaseHandlerStateCode& init_state = BaseHandlerStateCode::RUNNING, + const std::function& on_disk_full_lambda = nullptr); + + /** + * @brief Destructor + * + * Closes temporal MCAP file, and renames it with filename given in configuration. + * Before closing file, received dynamic types are serialized and stored as an attachment. + * + */ + DDSRECORDER_PARTICIPANTS_DllAPI + virtual ~SqlHandler(); + + /** + * @brief Create and store in \c schemas_ an OMG IDL (.idl format) or ROS 2 (.msg format) schema. + * Any samples following this schema that were received before the schema itself are moved to the memory buffer + * to be written with the next batch. + * Previously created channels (for this type) associated with a blank schema are updated to use the new one. + * + * @param [in] dynamic_type DynamicType containing the type information required to generate the schema. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + void add_schema( + const fastrtps::types::DynamicType_ptr& dynamic_type) override; + + /** + * @brief Add a data sample to the given \c topic. + * + * If a channel with (non-blank) schema exists, the sample is saved in memory \c buffer_ . + * Otherwise: + * if RUNNING -> the sample is inserted into \c pending_samples_ queue if max pending samples is not 0. + * If 0, the sample is added to buffer without schema if allowed (only_with_schema not true), + * and discarded otherwise. + * if PAUSED -> the sample is inserted into \c pending_samples_paused_ queue. + * + * If instance is STOPPED, received data is not processed. + * + * @param [in] topic DDS topic associated to this sample. + * @param [in] data SqlMessage to be added. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + void add_data( + const ddspipe::core::types::DdsTopic& topic, + ddspipe::core::types::RtpsPayloadData& data) override; + +protected: + + /** + * @brief Writes \c samples to disk. + * + * For each sample in \c samples, it downcasts it to \c SqlMessage, writes it to disk, and removes it from + * \c samples. + * The method ends when \c samples is empty. + * + * @param [in] samples List of samples to be written. + */ + void write_samples_( + std::list>& samples) override; + + //! SQL writer + SqlWriter sql_writer_; +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp new file mode 100644 index 000000000..1d9b4f58b --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp @@ -0,0 +1,59 @@ +// Copyright 2024 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 SqlHandlerConfiguration.hpp + */ + +#pragma once + +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +/** + * Structure encapsulating the \c SqlHandler configuration options. + */ +struct SqlHandlerConfiguration : public BaseHandlerConfiguration +{ + SqlHandlerConfiguration( + const OutputSettings& output_settings, + const int max_pending_samples, + const unsigned int buffer_size, + const unsigned int event_window, + const unsigned int cleanup_period, + const bool log_publishTime, + const bool only_with_schema, + const bool record_types, + const bool ros2_types) + : BaseHandlerConfiguration( + output_settings, + max_pending_samples, + buffer_size, + event_window, + cleanup_period, + log_publishTime, + only_with_schema, + record_types, + ros2_types) + { + } +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp new file mode 100644 index 000000000..4fdd8f765 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp @@ -0,0 +1,95 @@ +// Copyright 2024 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 SqlWriter.hpp + */ + +#pragma once + +#include + +#include +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +class DDSRECORDER_PARTICIPANTS_DllAPI SqlWriter : public BaseWriter +{ +public: + + SqlWriter( + const OutputSettings& configuration, + std::shared_ptr& file_tracker, + const bool record_types = true); + + /** + * @brief Writes data to the output file. + * + * @param data Pointer to the data to be written. + * + * After a \c FullFileException : + * - @throws \c InconsistencyException if the allocated space is not enough to close the current file or to open a + * new one. + * - @throws \c InitializationException if the output library fails to open a new file. + */ + template + void write( + const T& data); + +protected: + + /** + * @brief Opens a new file. + * + * @param min_file_size The minimum size of the file. + * @throws \c FullDiskException if the disk is full. + * @throws \c InconsistencyException if \c min_file_size is not enough to open a new empty file. + * @throws \c InitializationException if the SQL library fails to open the new file. + */ + void open_new_file_nts_( + const std::uint64_t min_file_size) override; + + /** + * @brief Closes the current file. + * + * @throws \c InconsistencyException if closing the current file fails. + */ + void close_current_file_nts_() override; + + /** + * @brief Writes data to the SQL file. + * + * @param data The data to be written. + * @throws \c FullFileException if the SQL file is full. + */ + template + void write_nts_( + const T& data); + + // The SQLite database + sqlite3* database_; + + // The size of an empty SQL file + static constexpr std::uint64_t MIN_SQL_SIZE{20480}; +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ + +#include diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/impl/SqlWriter.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/impl/SqlWriter.ipp new file mode 100644 index 000000000..31ca40499 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/impl/SqlWriter.ipp @@ -0,0 +1,53 @@ +// Copyright 2024 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 SqlWriter.cpp + */ + +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +template +void SqlWriter::write( + const T& data) +{ + std::lock_guard lock(mutex_); + + try + { + write_nts_(data); + } + catch (const FullFileException& e) + { + try + { + on_file_full_nts_(e, MIN_SQL_SIZE); + write_nts_(data); + } + catch(const FullDiskException& e) + { + logError(DDSRECORDER_SQL_HANDLER, "FAIL_SQL_WRITE | Disk is full. Error message:\n " << e.what()); + on_disk_full_(); + } + } +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/utils.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/utils.hpp new file mode 100644 index 000000000..2a3abbaae --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/utils.hpp @@ -0,0 +1,58 @@ +// Copyright 2024 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 utils.hpp + */ + +#pragma once + +#include + +#include + +#include + +#include + + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + + +/** + * @brief This method converts a timestamp in Fast DDS format to a SQL-friendly format. + * + * @param [in] time Timestamp to convert + * @return String formatted as "YYYY-MM-DD HH:MM:SS" + */ +DDSRECORDER_PARTICIPANTS_DllAPI +std::string to_sql_timestamp( + const fastrtps::rtps::Time_t& time); + +/** + * @brief This method converts a timestamp in standard format to a SQL-friendly format. + * + * @param [in] time Timestamp to convert + * @return String formatted as "YYYY-MM-DD HH:MM:SS" + */ +DDSRECORDER_PARTICIPANTS_DllAPI +std::string to_sql_timestamp( + const utils::Timestamp& time); + + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/project_settings.cmake b/ddsrecorder_participants/project_settings.cmake index 619eb30df..fe82d42e3 100644 --- a/ddsrecorder_participants/project_settings.cmake +++ b/ddsrecorder_participants/project_settings.cmake @@ -51,7 +51,8 @@ set(MODULE_DEPENDENCIES ddspipe_core ddspipe_participants $,lz4::lz4,lz4> - $,$,zstd::libzstd_shared,zstd::libzstd_static>,zstd>) + $,$,zstd::libzstd_shared,zstd::libzstd_static>,zstd> + sqlite3) set(MODULE_CPP_VERSION C++17) diff --git a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp new file mode 100644 index 000000000..8971a46a8 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp @@ -0,0 +1,37 @@ +// Copyright 2024 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 SqlMessage.cpp + */ + +#include + + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +SqlMessage::SqlMessage( + const ddspipe::core::types::RtpsPayloadData& data, + std::shared_ptr payload_pool, + const ddspipe::core::types::DdsTopic& topic, + const bool log_publish_time) + : BaseMessage(data, payload_pool, topic, log_publish_time) +{ +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp new file mode 100644 index 000000000..646b45d74 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp @@ -0,0 +1,131 @@ +// Copyright 2024 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 SqlHandler.cpp + */ + +#define SQL_IMPLEMENTATION // Define this in exactly one .cpp file + +#include +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +using namespace eprosima::ddspipe::core::types; + +SqlHandler::SqlHandler( + const SqlHandlerConfiguration& config, + const std::shared_ptr& payload_pool, + std::shared_ptr file_tracker, + const BaseHandlerStateCode& init_state /* = BaseHandlerStateCode::RUNNING */, + const std::function& on_disk_full_lambda /* = nullptr */) + : BaseHandler(config, payload_pool) + , sql_writer_(config.output_settings, file_tracker, config.record_types) +{ + logInfo(DDSRECORDER_SQL_HANDLER, "Creating SQL handler instance."); + + // Set the BaseHandler's writer + writer_ = &sql_writer_; + + // Initialize the BaseHandler + init(init_state, on_disk_full_lambda); +} + +SqlHandler::~SqlHandler() +{ + logInfo(DDSRECORDER_SQL_HANDLER, "Destroying SQL handler."); + + // Stop handler prior to destruction + stop(true); +} + +void SqlHandler::add_schema( + const fastrtps::types::DynamicType_ptr& dynamic_type) +{ + // NOTE: Process schemas even if in STOPPED state to avoid losing them (only sent/received once in discovery) + std::lock_guard lock(mtx_); + + if (dynamic_type == nullptr) + { + logWarning(DDSRECORDER_SQL_HANDLER, "Received nullptr dynamic type. Skipping..."); + return; + } + + const auto type_name = dynamic_type->get_name(); + + // Check if it exists already + if (received_types_.find(type_name) != received_types_.end()) + { + return; + } + + // Add type to the list of received types + received_types_.insert(type_name); + + // Add type to the collection of dynamic types + store_dynamic_type_(type_name); + + if (configuration_.record_types) + { + const auto dynamic_type = dynamic_types_.dynamic_types().back(); + sql_writer_.write(dynamic_type); + } + + // Check if there are any pending samples for this new type. If so, dump them. + if (pending_samples_.find(type_name) != pending_samples_.end() || + (state_ == BaseHandlerStateCode::PAUSED && + pending_samples_paused_.find(type_name) != pending_samples_paused_.end())) + { + dump_pending_samples_nts_(type_name); + } +} + +void SqlHandler::add_data( + const DdsTopic& topic, + RtpsPayloadData& data) +{ + std::unique_lock lock(mtx_); + + process_new_sample_nts_(std::make_shared( + data, payload_pool_, topic, configuration_.log_publishTime)); +} + +void SqlHandler::write_samples_( + std::list>& samples) +{ + logInfo(DDSRECORDER_SQL_HANDLER, "Writing samples to SQL file."); + + while (!samples.empty()) + { + const auto sql_sample = static_cast(samples.front().get()); + + if (sql_sample == nullptr) + { + logWarning(DDSRECORDER_SQL_HANDLER, "Error downcasting sample to SqlMessage. Skipping..."); + continue; + } + + sql_writer_.write(*sql_sample); + + samples.pop_front(); + } +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp new file mode 100644 index 000000000..067f49743 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -0,0 +1,242 @@ +// Copyright 2024 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 SqlWriter.cpp + */ + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include +#else + #include +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +SqlWriter::SqlWriter( + const OutputSettings& configuration, + std::shared_ptr& file_tracker, + const bool record_types) + : BaseWriter(configuration, file_tracker, record_types, MIN_SQL_SIZE) +{ +} + +void SqlWriter::open_new_file_nts_( + const std::uint64_t min_file_size) +{ + try + { + file_tracker_->new_file(min_file_size); + } + catch (const std::invalid_argument& e) + { + throw FullDiskException( + "The minimum SQL size (" + utils::from_bytes(min_file_size) + ") is greater than the maximum SQL " + "size (" + utils::from_bytes(configuration_.max_file_size) + ")."); + } + + const auto filename = file_tracker_->get_current_filename(); + + // Create SQLite database + const auto ret = sqlite3_open(filename.c_str(), &database_); + + if (ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to open SQL file " << filename + << " for writing: " << sqlite3_errmsg(database_); + sqlite3_close(database_); + + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_OPEN | " << error_msg); + throw utils::InitializationException(error_msg); + } + + // Create Messages table + { + const auto create_table = R"( + CREATE TABLE IF NOT EXISTS Messages ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + data BLOB NOT NULL, + data_size INTEGER NOT NULL, + topic TEXT NOT NULL, + log_time DATETIME NOT NULL, + publish_time DATETIME NOT NULL + ); + )"; + + const auto ret = sqlite3_exec(database_, create_table, nullptr, nullptr, nullptr); + + if (ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to create SQL table to write DDS messages: " + << sqlite3_errmsg(database_); + sqlite3_close(database_); + + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_OPEN | " << error_msg); + throw utils::InitializationException(error_msg); + } + } + + // Create DynamicTypes table + { + const auto create_table = R"( + CREATE TABLE IF NOT EXISTS DynamicTypes ( + type_name TEXT PRIMARY KEY NOT NULL, + type_information TEXT NOT NULL, + type_object TEXT NOT NULL + ); + )"; + + const auto ret = sqlite3_exec(database_, create_table, nullptr, nullptr, nullptr); + + if (ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to open SQL table to write dynamic types: " + << sqlite3_errmsg(database_); + sqlite3_close(database_); + + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_OPEN | " << error_msg); + throw utils::InitializationException(error_msg); + } + } +} + +void SqlWriter::close_current_file_nts_() +{ + sqlite3_close(database_); + file_tracker_->close_file(); +} + +template <> +void SqlWriter::write_nts_( + const DynamicType& dynamic_type) +{ + logInfo(DDSRECORDER_SQL_WRITER, "Writing dynamic type " << dynamic_type.type_name() << "."); + + // Define the SQL statement + const char* insert_statement = R"( + INSERT INTO DynamicTypes (type_name, type_information, type_object) + VALUES (?, ?, ?); + )"; + + // Prepare the SQL statement + sqlite3_stmt* statement; + const auto prep_ret = sqlite3_prepare_v2(database_, insert_statement, -1, &statement, nullptr); + + if (prep_ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement to write dynamic type: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); + + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_WRITE | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + + // Bind the DynamicType to the SQL statement + sqlite3_bind_text(statement, 1, dynamic_type.type_name().c_str(), -1, SQLITE_STATIC); + sqlite3_bind_text(statement, 2, dynamic_type.type_information().c_str(), -1, SQLITE_STATIC); + sqlite3_bind_text(statement, 3, dynamic_type.type_object().c_str(), -1, SQLITE_STATIC); + + // Execute the SQL statement + const auto step_ret = sqlite3_step(statement); + + if (step_ret != SQLITE_DONE) + { + const std::string error_msg = utils::Formatter() << "Failed to write dynamic type to SQL database: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); + + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_WRITE | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + + // Finalize the SQL statement + sqlite3_finalize(statement); +} + +template <> +void SqlWriter::write_nts_( + const SqlMessage& msg) +{ + if (!enabled_) + { + logWarning(DDSRECORDER_SQL_WRITER, "Attempting to write a message in a disabled writer."); + return; + } + + logInfo(DDSRECORDER_SQL_WRITER, "Writing message: " << utils::from_bytes(msg.get_data_size()) << "."); + + // Define the SQL statement + const char* insert_message = R"( + INSERT INTO Messages (data, data_size, topic, log_time, publish_time) + VALUES (?, ?, ?, ?, ?); + )"; + + // Prepare the SQL statement + sqlite3_stmt* statement = nullptr; + const auto prep_ret = sqlite3_prepare_v2(database_, insert_message, -1, &statement, nullptr); + + if (prep_ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement to write DDS message: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); + + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_WRITE | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + + // Bind the SqlMessage to the SQL statement + sqlite3_bind_blob(statement, 1, msg.get_data(), msg.get_data_size(), SQLITE_TRANSIENT); + sqlite3_bind_int64(statement, 2, msg.get_data_size()); + sqlite3_bind_text(statement, 3, msg.topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 4, to_sql_timestamp(msg.log_time).c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 5, to_sql_timestamp(msg.publish_time).c_str(), -1, SQLITE_TRANSIENT); + + // Execute the SQL statement + const auto step_ret = sqlite3_step(statement); + + if (step_ret != SQLITE_DONE) + { + const std::string error_msg = utils::Formatter() << "Failed to write DDS message to SQL database: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); + + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_WRITE | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + + // Finalize the SQL statement + sqlite3_finalize(statement); +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/utils.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/utils.cpp new file mode 100644 index 000000000..43a6c7a2d --- /dev/null +++ b/ddsrecorder_participants/src/cpp/recorder/sql/utils.cpp @@ -0,0 +1,51 @@ +// Copyright 2024 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 utils.cpp + */ + +#include + +#include + +#include + + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +const auto SQL_TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S"; + +std::string to_sql_timestamp( + const fastrtps::rtps::Time_t& time) +{ + char datetime_str[20]; + + const std::time_t time_seconds = time.seconds(); + std::strftime(datetime_str, sizeof(datetime_str), SQL_TIMESTAMP_FORMAT, std::localtime(&time_seconds)); + + return std::string(datetime_str); +} + +std::string to_sql_timestamp( + const utils::Timestamp& time) +{ + return utils::timestamp_to_string(time, SQL_TIMESTAMP_FORMAT, true); +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp index 40b33d38b..a1b97f87a 100644 --- a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp +++ b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp @@ -35,6 +35,8 @@ #include #include +#include + #include #include @@ -70,6 +72,7 @@ class DDSRECORDER_YAML_DllAPI RecorderConfiguration std::shared_ptr recorder_configuration; // Output file params + participants::OutputLibrary output_library = participants::OutputLibrary::mcap; std::string output_filepath = "."; std::string output_filename = "output"; std::string output_timestamp_format = "%Y-%m-%d_%H-%M-%S_%Z"; diff --git a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp index 43aedb092..d821e60ba 100644 --- a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp +++ b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp @@ -37,6 +37,9 @@ constexpr const char* RECORDER_RECORDER_TAG("recorder"); // Output related tags constexpr const char* RECORDER_OUTPUT_TAG("output"); +constexpr const char* RECORDER_OUTPUT_LIBRARY_TAG("library"); +constexpr const char* RECORDER_OUTPUT_LIBRARY_MCAP_TAG("mcap"); +constexpr const char* RECORDER_OUTPUT_LIBRARY_SQL_TAG("sql"); constexpr const char* RECORDER_OUTPUT_PATH_FILE_TAG("path"); constexpr const char* RECORDER_OUTPUT_FILE_NAME_TAG("filename"); constexpr const char* RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG("timestamp-format"); diff --git a/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp b/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp index ed5d4fe1e..ec5b7f604 100644 --- a/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp +++ b/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp @@ -30,6 +30,8 @@ #include #include +#include + #include #include @@ -214,6 +216,18 @@ void RecorderConfiguration::load_recorder_configuration_( { auto output_yml = YamlReader::get_value_in_tag(yml, RECORDER_OUTPUT_TAG); + ///// + // Get optional library + if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_LIBRARY_TAG)) + { + output_library = YamlReader::get_enumeration( + YamlReader::get_value_in_tag(output_yml, RECORDER_OUTPUT_LIBRARY_TAG), + { + {RECORDER_OUTPUT_LIBRARY_MCAP_TAG, participants::OutputLibrary::mcap}, + {RECORDER_OUTPUT_LIBRARY_SQL_TAG, participants::OutputLibrary::sql} + }); + } + ///// // Get optional file path if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_PATH_FILE_TAG)) From b25f882dba8a388874a2b042a041f631cdcabd6d Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 17 May 2024 13:45:54 +0200 Subject: [PATCH 17/52] Store DdsTopics in a table Signed-off-by: tempate --- .../recorder/sql/SqlHandler.hpp | 4 + .../recorder/sql/SqlWriter.hpp | 13 ++ .../src/cpp/recorder/sql/SqlHandler.cpp | 10 + .../src/cpp/recorder/sql/SqlWriter.cpp | 176 ++++++++++++------ 4 files changed, 148 insertions(+), 55 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp index addee837d..39fc6aa13 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -130,6 +131,9 @@ class SqlHandler : public BaseHandler //! SQL writer SqlWriter sql_writer_; + + //! Topics that the SQL writer has written + std::set written_topics_; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp index 4fdd8f765..3e30805ab 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp @@ -19,6 +19,7 @@ #pragma once #include +#include #include #include @@ -81,6 +82,18 @@ class DDSRECORDER_PARTICIPANTS_DllAPI SqlWriter : public BaseWriter void write_nts_( const T& data); + /** + * @brief Creates a new SQL table. + * + * @param table_name The name of the table. + * @param table_definition The definition of the table. + * + * @throws \c InitializationException if the table creation fails. + */ + void create_sql_table_( + const std::string& table_name, + const std::string& table_definition); + // The SQLite database sqlite3* database_; diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp index 646b45d74..5133214fc 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp @@ -120,6 +120,16 @@ void SqlHandler::write_samples_( continue; } + // Write the topic if it hasn't been written before + const auto topic = sql_sample->topic; + + if (written_topics_.find(topic) == written_topics_.end()) + { + sql_writer_.write(topic); + written_topics_.insert(topic); + } + + // Write the sample sql_writer_.write(*sql_sample); samples.pop_front(); diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index 067f49743..97af7eb9e 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -25,8 +25,11 @@ #include #include +#include + #include #include +#include #include #include @@ -77,54 +80,46 @@ void SqlWriter::open_new_file_nts_( throw utils::InitializationException(error_msg); } - // Create Messages table - { - const auto create_table = R"( - CREATE TABLE IF NOT EXISTS Messages ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - data BLOB NOT NULL, - data_size INTEGER NOT NULL, - topic TEXT NOT NULL, - log_time DATETIME NOT NULL, - publish_time DATETIME NOT NULL - ); - )"; - - const auto ret = sqlite3_exec(database_, create_table, nullptr, nullptr, nullptr); - - if (ret != SQLITE_OK) - { - const std::string error_msg = utils::Formatter() << "Failed to create SQL table to write DDS messages: " - << sqlite3_errmsg(database_); - sqlite3_close(database_); - - logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_OPEN | " << error_msg); - throw utils::InitializationException(error_msg); - } - } - // Create DynamicTypes table - { - const auto create_table = R"( - CREATE TABLE IF NOT EXISTS DynamicTypes ( - type_name TEXT PRIMARY KEY NOT NULL, - type_information TEXT NOT NULL, - type_object TEXT NOT NULL - ); - )"; - - const auto ret = sqlite3_exec(database_, create_table, nullptr, nullptr, nullptr); - - if (ret != SQLITE_OK) - { - const std::string error_msg = utils::Formatter() << "Failed to open SQL table to write dynamic types: " - << sqlite3_errmsg(database_); - sqlite3_close(database_); - - logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_OPEN | " << error_msg); - throw utils::InitializationException(error_msg); - } - } + const std::string create_dynamic_types_table{ + R"( + CREATE TABLE IF NOT EXISTS DynamicTypes ( + type_name TEXT PRIMARY KEY NOT NULL, + type_information TEXT NOT NULL, + type_object TEXT NOT NULL + ); + )"}; + + create_sql_table_("DynamicTypes", create_dynamic_types_table); + + // Create Topics table + const std::string create_topics_table{ + R"( + CREATE TABLE IF NOT EXISTS Topics ( + name TEXT PRIMARY KEY NOT NULL, + type TEXT NOT NULL, + qos TEXT NOT NULL, + FOREIGN KEY(type) REFERENCES DynamicTypes(type_name) + ); + )"}; + + create_sql_table_("Topics", create_topics_table); + + // Create Messages table + const std::string create_messages_table{ + R"( + CREATE TABLE IF NOT EXISTS Messages ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + data BLOB NOT NULL, + data_size INTEGER NOT NULL, + topic TEXT NOT NULL, + log_time DATETIME NOT NULL, + publish_time DATETIME NOT NULL, + FOREIGN KEY(topic) REFERENCES Topics(name) + ); + )"}; + + create_sql_table_("Messages", create_messages_table); } void SqlWriter::close_current_file_nts_() @@ -160,9 +155,9 @@ void SqlWriter::write_nts_( } // Bind the DynamicType to the SQL statement - sqlite3_bind_text(statement, 1, dynamic_type.type_name().c_str(), -1, SQLITE_STATIC); - sqlite3_bind_text(statement, 2, dynamic_type.type_information().c_str(), -1, SQLITE_STATIC); - sqlite3_bind_text(statement, 3, dynamic_type.type_object().c_str(), -1, SQLITE_STATIC); + sqlite3_bind_text(statement, 1, dynamic_type.type_name().c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 2, dynamic_type.type_information().c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 3, dynamic_type.type_object().c_str(), -1, SQLITE_TRANSIENT); // Execute the SQL statement const auto step_ret = sqlite3_step(statement); @@ -194,18 +189,18 @@ void SqlWriter::write_nts_( logInfo(DDSRECORDER_SQL_WRITER, "Writing message: " << utils::from_bytes(msg.get_data_size()) << "."); // Define the SQL statement - const char* insert_message = R"( + const char* insert_statement = R"( INSERT INTO Messages (data, data_size, topic, log_time, publish_time) VALUES (?, ?, ?, ?, ?); )"; // Prepare the SQL statement - sqlite3_stmt* statement = nullptr; - const auto prep_ret = sqlite3_prepare_v2(database_, insert_message, -1, &statement, nullptr); + sqlite3_stmt* statement; + const auto prep_ret = sqlite3_prepare_v2(database_, insert_statement, -1, &statement, nullptr); if (prep_ret != SQLITE_OK) { - const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement to write DDS message: " + const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement to write message: " << sqlite3_errmsg(database_); sqlite3_finalize(statement); @@ -225,7 +220,7 @@ void SqlWriter::write_nts_( if (step_ret != SQLITE_DONE) { - const std::string error_msg = utils::Formatter() << "Failed to write DDS message to SQL database: " + const std::string error_msg = utils::Formatter() << "Failed to write message to SQL database: " << sqlite3_errmsg(database_); sqlite3_finalize(statement); @@ -237,6 +232,77 @@ void SqlWriter::write_nts_( sqlite3_finalize(statement); } +template <> +void SqlWriter::write_nts_( + const ddspipe::core::types::DdsTopic& topic) +{ + if (!enabled_) + { + logWarning(DDSRECORDER_SQL_WRITER, "Attempting to write a topic in a disabled writer."); + return; + } + + logInfo(DDSRECORDER_SQL_WRITER, "Writing topic " << topic.topic_name() << "."); + + // Define the SQL statement + const char* insert_statement = R"( + INSERT INTO Topics (name, type, qos) + VALUES (?, ?, ?); + )"; + + // Prepare the SQL statement + sqlite3_stmt* statement; + const auto prep_ret = sqlite3_prepare_v2(database_, insert_statement, -1, &statement, nullptr); + + if (prep_ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement to write topic: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); + + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_WRITE | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + + // Bind the Topic to the SQL statement + sqlite3_bind_text(statement, 1, topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 2, topic.type_name.c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 3, Serializer::serialize(topic.topic_qos).c_str(), -1, SQLITE_TRANSIENT); + + // Execute the SQL statement + const auto step_ret = sqlite3_step(statement); + + if (step_ret != SQLITE_DONE) + { + const std::string error_msg = utils::Formatter() << "Failed to write topic to SQL database: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); + + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_WRITE | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + + // Finalize the SQL statement + sqlite3_finalize(statement); +} + +void SqlWriter::create_sql_table_( + const std::string& table_name, + const std::string& table_definition) +{ + const auto ret = sqlite3_exec(database_, table_definition.c_str(), nullptr, nullptr, nullptr); + + if (ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to create " << table_name << " table: " + << sqlite3_errmsg(database_); + close_current_file_nts_(); + + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_OPEN | " << error_msg); + throw utils::InitializationException(error_msg); + } +} + } /* namespace participants */ } /* namespace ddsrecorder */ } /* namespace eprosima */ From 404e7ad844b238cba5dd857b2f4ae276a3ccff1b Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 20 May 2024 12:28:09 +0200 Subject: [PATCH 18/52] Strip state transitions and IParticipant methods from the McapReaderParticipant Signed-off-by: tempate --- .../replayer/BaseReaderParticipant.hpp | 125 ++++++++++++++++++ .../replayer/McapReaderParticipant.hpp | 69 +--------- .../cpp/replayer/BaseReaderParticipant.cpp | 105 +++++++++++++++ .../cpp/replayer/McapReaderParticipant.cpp | 64 +-------- ddsreplayer/src/cpp/main.cpp | 6 +- ddsreplayer/src/cpp/tool/DdsReplayer.cpp | 4 +- ddsreplayer/src/cpp/tool/DdsReplayer.hpp | 2 +- .../test/blackbox/mcap/McapFileReadTest.cpp | 4 +- .../mcap/McapFileReadWithTypeTest.cpp | 2 +- 9 files changed, 245 insertions(+), 136 deletions(-) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp create mode 100644 ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp new file mode 100644 index 000000000..4a3ac179f --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp @@ -0,0 +1,125 @@ +// Copyright 2024 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. + +#pragma once + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +/** + * Participant that reads files and passes its messages to other DDS Pipe participants. + * + * @implements IParticipant + */ +class BaseReaderParticipant : public ddspipe::core::IParticipant +{ +public: + + /** + * BaseReaderParticipant constructor by required values. + * + * Creates BaseReaderParticipant instance with given configuration, payload pool and input file path. + * + * @param config: Structure encapsulating all configuration options. + * @param payload_pool: Owner of every payload contained in sent messages. + * @param file_path: Path to the file with the messages to be read and sent. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + BaseReaderParticipant( + std::shared_ptr configuration, + std::shared_ptr payload_pool, + std::string& file_path); + + //! Override id() IParticipant method + DDSRECORDER_PARTICIPANTS_DllAPI + ddspipe::core::types::ParticipantId id() const noexcept override; + + //! Override is_repeater() IParticipant method + DDSRECORDER_PARTICIPANTS_DllAPI + bool is_repeater() const noexcept override; + + //! Override is_rtps_kind() IParticipant method + DDSRECORDER_PARTICIPANTS_DllAPI + bool is_rtps_kind() const noexcept override; + + //! Override topic_qos() IParticipant method + DDSRECORDER_PARTICIPANTS_DllAPI + ddspipe::core::types::TopicQoS topic_qos() const noexcept override; + + //! Override create_writer_() IParticipant method + DDSRECORDER_PARTICIPANTS_DllAPI + std::shared_ptr create_writer( + const ddspipe::core::ITopic& topic) override; + + //! Override create_reader_() IParticipant method + DDSRECORDER_PARTICIPANTS_DllAPI + std::shared_ptr create_reader( + const ddspipe::core::ITopic& topic) override; + + /** + * @brief Read and send messages sequentially (according to timestamp). + * + * @throw utils::InconsistencyException if failed to read file. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + virtual void process_file() = 0; + + //! Stop participant (abort processing file) + DDSRECORDER_PARTICIPANTS_DllAPI + void stop() noexcept; + +protected: + + //! Participant Configuration + std::shared_ptr configuration_; + + //! DDS Pipe shared Payload Pool + std::shared_ptr payload_pool_; + + //! Input file path + std::string file_path_; + + //! Internal readers map + std::map> readers_; + + //! Stop flag + bool stop_; + + //! Scheduling condition variable + std::condition_variable scheduling_cv_; + + //! Scheduling condition variable mutex + std::mutex scheduling_cv_mtx_; +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp index bae6e5c46..478eb322e 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp @@ -14,21 +14,13 @@ #pragma once -#include -#include - #include -#include - #include -#include -#include - -#include #include #include +#include namespace eprosima { namespace ddsrecorder { @@ -37,9 +29,9 @@ namespace participants { /** * Participant that reads MCAP files and passes its messages to other DDS Pipe participants. * - * @implements IParticipant + * @implements BaseReaderParticipant */ -class McapReaderParticipant : public ddspipe::core::IParticipant +class McapReaderParticipant : public BaseReaderParticipant { public: @@ -58,43 +50,13 @@ class McapReaderParticipant : public ddspipe::core::IParticipant std::shared_ptr payload_pool, std::string& file_path); - //! Override id() IParticipant method - DDSRECORDER_PARTICIPANTS_DllAPI - ddspipe::core::types::ParticipantId id() const noexcept override; - - //! Override is_repeater() IParticipant method - DDSRECORDER_PARTICIPANTS_DllAPI - bool is_repeater() const noexcept override; - - //! Override is_rtps_kind() IParticipant method - DDSRECORDER_PARTICIPANTS_DllAPI - bool is_rtps_kind() const noexcept override; - - //! Override topic_qos() IParticipant method - DDSRECORDER_PARTICIPANTS_DllAPI - ddspipe::core::types::TopicQoS topic_qos() const noexcept override; - - //! Override create_writer_() IParticipant method - DDSRECORDER_PARTICIPANTS_DllAPI - std::shared_ptr create_writer( - const ddspipe::core::ITopic& topic) override; - - //! Override create_reader_() IParticipant method - DDSRECORDER_PARTICIPANTS_DllAPI - std::shared_ptr create_reader( - const ddspipe::core::ITopic& topic) override; - /** * @brief Read and send messages sequentially (according to timestamp). * * @throw utils::InconsistencyException if failed to read mcap file. */ DDSRECORDER_PARTICIPANTS_DllAPI - void process_mcap(); - - //! Stop participant (abort processing mcap) - DDSRECORDER_PARTICIPANTS_DllAPI - void stop() noexcept; + void process_file() override; /** * @brief This method converts a mcap timestamp to standard format. @@ -115,29 +77,6 @@ class McapReaderParticipant : public ddspipe::core::IParticipant DDSRECORDER_PARTICIPANTS_DllAPI static mcap::Timestamp std_timepoint_to_mcap_timestamp( const utils::Timestamp& time); - -protected: - - //! Participant Configuration - std::shared_ptr configuration_; - - //! DDS Pipe shared Payload Pool - std::shared_ptr payload_pool_; - - //! Input file path - std::string file_path_; - - //! Internal readers map - std::map> readers_; - - //! Stop flag - bool stop_; - - //! Scheduling condition variable - std::condition_variable scheduling_cv_; - - //! Scheduling condition variable mutex - std::mutex scheduling_cv_mtx_; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp new file mode 100644 index 000000000..47b2fd7e1 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp @@ -0,0 +1,105 @@ +// Copyright 2023 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 BaseReaderParticipant.cpp + */ + + +#include +#include + +#include +#include +#include + +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +using namespace eprosima::ddspipe::core; +using namespace eprosima::ddspipe::core::types; +using namespace eprosima::ddspipe::participants; +using namespace eprosima::utils; + +BaseReaderParticipant::BaseReaderParticipant( + std::shared_ptr configuration, + std::shared_ptr payload_pool, + std::string& file_path) + : configuration_(configuration) + , payload_pool_(payload_pool) + , file_path_(file_path) + , stop_(false) +{ + // Do nothing +} + +ParticipantId BaseReaderParticipant::id() const noexcept +{ + return configuration_->id; +} + +bool BaseReaderParticipant::is_repeater() const noexcept +{ + return false; +} + +bool BaseReaderParticipant::is_rtps_kind() const noexcept +{ + return false; +} + +TopicQoS BaseReaderParticipant::topic_qos() const noexcept +{ + return configuration_->topic_qos; +} + +std::shared_ptr BaseReaderParticipant::create_writer( + const ITopic& /* topic */) +{ + return std::make_shared(); +} + +std::shared_ptr BaseReaderParticipant::create_reader( + const ITopic& topic) +{ + if (!utils::can_cast(topic)) + { + logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, "Not creating Writer for topic " << topic.topic_name()); + return std::make_shared(); + } + + auto reader = std::make_shared(id()); + + auto dds_topic = dynamic_cast(topic); + + readers_[dds_topic] = reader; + + return reader; +} + +void BaseReaderParticipant::stop() noexcept +{ + { + std::lock_guard lock(scheduling_cv_mtx_); + stop_ = true; + } + scheduling_cv_.notify_one(); +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp index a5916c722..8b2adf142 100644 --- a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp @@ -24,15 +24,11 @@ #include #include #include -#include #include #include #include -#include -#include - #include #include @@ -49,59 +45,12 @@ McapReaderParticipant::McapReaderParticipant( std::shared_ptr configuration, std::shared_ptr payload_pool, std::string& file_path) - : configuration_(configuration) - , payload_pool_(payload_pool) - , file_path_(file_path) - , stop_(false) + : BaseReaderParticipant(configuration, payload_pool, file_path) { // Do nothing } -ParticipantId McapReaderParticipant::id() const noexcept -{ - return configuration_->id; -} - -bool McapReaderParticipant::is_repeater() const noexcept -{ - return false; -} - -bool McapReaderParticipant::is_rtps_kind() const noexcept -{ - return false; -} - -TopicQoS McapReaderParticipant::topic_qos() const noexcept -{ - return configuration_->topic_qos; -} - -std::shared_ptr McapReaderParticipant::create_writer( - const ITopic& /* topic */) -{ - return std::make_shared(); -} - -std::shared_ptr McapReaderParticipant::create_reader( - const ITopic& topic) -{ - if (!utils::can_cast(topic)) - { - logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, "Not creating Writer for topic " << topic.topic_name()); - return std::make_shared(); - } - - auto reader = std::make_shared(id()); - - auto dds_topic = dynamic_cast(topic); - - readers_[dds_topic] = reader; - - return reader; -} - -void McapReaderParticipant::process_mcap() +void McapReaderParticipant::process_file() { // Read MCAP file mcap::McapReader mcap_reader; @@ -245,15 +194,6 @@ void McapReaderParticipant::process_mcap() mcap_reader.close(); } -void McapReaderParticipant::stop() noexcept -{ - { - std::lock_guard lock(scheduling_cv_mtx_); - stop_ = true; - } - scheduling_cv_.notify_one(); -} - utils::Timestamp McapReaderParticipant::mcap_timestamp_to_std_timepoint( const mcap::Timestamp& time) { diff --git a/ddsreplayer/src/cpp/main.cpp b/ddsreplayer/src/cpp/main.cpp index f2f5515e6..f8ea61338 100644 --- a/ddsreplayer/src/cpp/main.cpp +++ b/ddsreplayer/src/cpp/main.cpp @@ -255,11 +255,11 @@ int main( // Start replaying data bool read_success; - std::thread process_mcap_thread([&] + std::thread process_file_thread([&] { try { - replayer->process_mcap(); + replayer->process_file(); read_success = true; } catch (const eprosima::utils::InconsistencyException& e) @@ -278,7 +278,7 @@ int main( // Disable inner pipe, which would abort replaying messages in case execution stopped by signal replayer->stop(); - process_mcap_thread.join(); + process_file_thread.join(); if (!read_success) { diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index 57076dc4a..9895682a4 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -134,9 +134,9 @@ utils::ReturnCode DdsReplayer::reload_configuration( return pipe_->reload_configuration(new_configuration.ddspipe_configuration); } -void DdsReplayer::process_mcap() +void DdsReplayer::process_file() { - mcap_reader_participant_->process_mcap(); + mcap_reader_participant_->process_file(); // Wait until all tasks have been consumed thread_pool_->wait_all_consumed(); diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp index 49e45d929..d0fac549b 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp @@ -84,7 +84,7 @@ class DdsReplayer const yaml::ReplayerConfiguration& new_configuration); //! Process input MCAP file - void process_mcap(); + void process_file(); //! Stop replayer instance void stop(); diff --git a/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp b/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp index 6afc2b390..251fcd071 100644 --- a/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp +++ b/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp @@ -78,9 +78,9 @@ void create_subscriber_replayer( std::this_thread::sleep_for(std::chrono::seconds(1)); // Start replaying data - replayer->process_mcap(); + replayer->process_file(); - std::cout << "finish process_mcap!!!!" << std::endl; + std::cout << "finish process_file!!!!" << std::endl; replayer->stop(); diff --git a/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp b/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp index 932a0121c..141beedb7 100644 --- a/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp +++ b/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp @@ -93,7 +93,7 @@ void create_subscriber_replayer( std::this_thread::sleep_for(std::chrono::seconds(1)); // Start replaying data - replayer->process_mcap(); + replayer->process_file(); replayer->stop(); From 61e51643f5d5093d7c8025a813bc2d34f4a0b36d Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 21 May 2024 09:21:25 +0200 Subject: [PATCH 19/52] Rename DynamicTypes to Types Signed-off-by: tempate --- .../src/cpp/recorder/sql/SqlWriter.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index 97af7eb9e..1214721cb 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -80,17 +80,17 @@ void SqlWriter::open_new_file_nts_( throw utils::InitializationException(error_msg); } - // Create DynamicTypes table - const std::string create_dynamic_types_table{ + // Create Types table + const std::string create_types_table{ R"( - CREATE TABLE IF NOT EXISTS DynamicTypes ( - type_name TEXT PRIMARY KEY NOT NULL, - type_information TEXT NOT NULL, - type_object TEXT NOT NULL + CREATE TABLE IF NOT EXISTS Types ( + name TEXT PRIMARY KEY NOT NULL, + information TEXT NOT NULL, + object TEXT NOT NULL ); )"}; - create_sql_table_("DynamicTypes", create_dynamic_types_table); + create_sql_table_("Types", create_types_table); // Create Topics table const std::string create_topics_table{ @@ -99,7 +99,7 @@ void SqlWriter::open_new_file_nts_( name TEXT PRIMARY KEY NOT NULL, type TEXT NOT NULL, qos TEXT NOT NULL, - FOREIGN KEY(type) REFERENCES DynamicTypes(type_name) + FOREIGN KEY(type) REFERENCES Types(name) ); )"}; @@ -136,7 +136,7 @@ void SqlWriter::write_nts_( // Define the SQL statement const char* insert_statement = R"( - INSERT INTO DynamicTypes (type_name, type_information, type_object) + INSERT INTO Types (name, information, object) VALUES (?, ?, ?); )"; From 3c5fbcd5a4e492430cbcb969664aee80d2a1513f Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 21 May 2024 12:11:38 +0200 Subject: [PATCH 20/52] Store a message's key in SQL Signed-off-by: tempate --- .../recorder/message/SqlMessage.hpp | 27 ++- .../recorder/output/BaseHandler.hpp | 6 +- .../recorder/sql/SqlHandler.hpp | 18 ++ .../src/cpp/recorder/mcap/McapHandler.cpp | 2 +- .../src/cpp/recorder/message/SqlMessage.cpp | 181 +++++++++++++++++- .../src/cpp/recorder/sql/SqlHandler.cpp | 30 ++- .../src/cpp/recorder/sql/SqlWriter.cpp | 10 +- 7 files changed, 263 insertions(+), 11 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp index d8dda68af..9d2ae82fd 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp @@ -19,9 +19,13 @@ #pragma once #include +#include + +#include #include #include +#include #include #include @@ -45,7 +49,28 @@ struct SqlMessage : public BaseMessage const ddspipe::core::types::RtpsPayloadData& payload, std::shared_ptr payload_pool, const ddspipe::core::types::DdsTopic& topic, - const bool log_publish_time); + const bool log_publish_time, + const std::string& key = ""); + + /** + * @brief Set the key of the message. + * + * The following steps are performed: + * - Deserialize the payload into a DynamicData. + * - Find the key fields in the DynamicData. + * - Find the values of the key fields. + * - Serialize the values into a JSON string. + * + * @param dynamic_type DynamicType of the message. + */ + void set_key( + fastrtps::types::DynamicType_ptr dynamic_type); + + // Hashed value identifying the instance + ddspipe::core::types::InstanceHandle instance_handle; + + // String containing the JSON-serialized instance key + std::string key; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp index 60675b3ce..01b599818 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -33,8 +32,9 @@ #include -#include +#include +#include #include #include @@ -366,7 +366,7 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler ////////////////////////////// //! Received types set - std::set received_types_; + std::map received_types_; //! Dynamic types collection DynamicTypesCollection dynamic_types_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp index 39fc6aa13..a920128b2 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp @@ -22,15 +22,18 @@ #include #include #include +#include #include #include #include +#include #include #include #include +#include #include #include #include @@ -129,11 +132,26 @@ class SqlHandler : public BaseHandler void write_samples_( std::list>& samples) override; + /** + * @brief Sets the key of a sample. + * + * If the key was previously stored in \c keys_, it sets it. + * If not, it is set from the payload of the \c sql_sample. + * The key is stored in \c keys. + * + * @param [in] sql_sample SqlMessage to set the key. + */ + void set_key_( + SqlMessage& sql_sample); + //! SQL writer SqlWriter sql_writer_; //! Topics that the SQL writer has written std::set written_topics_; + + //! Map instance handles (hashed/serialized keys) to JSON-serialized keys + std::map keys_; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 24f1ac85b..5a197d602 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -151,7 +151,7 @@ void McapHandler::add_schema( schemas_[type_name] = std::move(new_schema); // Add type to the list of received types - received_types_.insert(type_name); + received_types_[type_name] = dynamic_type; if (configuration_.record_types) { diff --git a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp index 8971a46a8..9fff3bda9 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp @@ -16,6 +16,18 @@ * @file SqlMessage.cpp */ + +#include + +#include + +#include +#include +#include +#include +#include +#include + #include @@ -27,11 +39,178 @@ SqlMessage::SqlMessage( const ddspipe::core::types::RtpsPayloadData& data, std::shared_ptr payload_pool, const ddspipe::core::types::DdsTopic& topic, - const bool log_publish_time) + const bool log_publish_time, + const std::string& key /* = "" */) : BaseMessage(data, payload_pool, topic, log_publish_time) + , instance_handle(data.instanceHandle) + , key(key) { } +void SqlMessage::set_key( + fastrtps::types::DynamicType_ptr dynamic_type) +{ + // Deserialize the payload + fastrtps::types::DynamicPubSubType pub_sub_type(dynamic_type); + fastrtps::types::DynamicData_ptr dynamic_data; + dynamic_data = fastrtps::types::DynamicDataFactory::get_instance()->create_data(dynamic_type); + + pub_sub_type.deserialize(&payload, dynamic_data.get()); + + // Clear non-key values to free-up unnecessary space + // dynamic_data->clear_nonkey_values(); + + // Serialize the key members into a JSON + nlohmann::json key_json; + + std::map members_map; + dynamic_type->get_all_members(members_map); + + for (const auto& member : members_map) + { + if (!member.second->key_annotation()) + { + // The member is not a key + continue; + } + + const auto descriptor = member.second->get_descriptor(); + + if (descriptor == nullptr) + { + // The member has no descriptor + continue; + } + + switch (descriptor->get_kind()) + { + case fastrtps::types::TK_BOOLEAN: + { + key_json[descriptor->get_name()] = dynamic_data->get_bool_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_BYTE: + { + key_json[descriptor->get_name()] = dynamic_data->get_byte_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_INT16: + { + key_json[descriptor->get_name()] = dynamic_data->get_int16_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_INT32: + { + key_json[descriptor->get_name()] = dynamic_data->get_int32_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_INT64: + { + key_json[descriptor->get_name()] = dynamic_data->get_int64_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_UINT16: + { + key_json[descriptor->get_name()] = dynamic_data->get_uint16_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_UINT32: + { + key_json[descriptor->get_name()] = dynamic_data->get_uint32_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_UINT64: + { + key_json[descriptor->get_name()] = dynamic_data->get_uint64_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_FLOAT32: + { + key_json[descriptor->get_name()] = dynamic_data->get_float32_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_FLOAT64: + { + key_json[descriptor->get_name()] = dynamic_data->get_float64_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_FLOAT128: + { + key_json[descriptor->get_name()] = dynamic_data->get_float128_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_CHAR8: + { + key_json[descriptor->get_name()] = dynamic_data->get_char8_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_CHAR16: + { + key_json[descriptor->get_name()] = dynamic_data->get_char16_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_STRING8: + { + key_json[descriptor->get_name()] = dynamic_data->get_string_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_STRING16: + { + key_json[descriptor->get_name()] = dynamic_data->get_wstring_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_ALIAS: + { + // TODO + break; + } + case fastrtps::types::TK_ENUM: + { + key_json[descriptor->get_name()] = dynamic_data->get_enum_value(descriptor->get_id()); + break; + } + case fastrtps::types::TK_BITMASK: + { + // TODO + break; + } + case fastrtps::types::TK_ANNOTATION: + { + // TODO + break; + } + case fastrtps::types::TK_STRUCTURE: + { + // TODO + break; + } + case fastrtps::types::TK_UNION: + { + // TODO + break; + } + case fastrtps::types::TK_BITSET: + { + // TODO + break; + } + case fastrtps::types::TK_SEQUENCE: + { + // TODO + break; + } + case fastrtps::types::TK_ARRAY: + { + // TODO + break; + } + } + } + + // Dump the JSON into a string + key = key_json.dump(); +} + } /* namespace participants */ } /* namespace ddsrecorder */ } /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp index 5133214fc..af45d52b7 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp @@ -75,7 +75,7 @@ void SqlHandler::add_schema( } // Add type to the list of received types - received_types_.insert(type_name); + received_types_[type_name] = dynamic_type; // Add type to the collection of dynamic types store_dynamic_type_(type_name); @@ -130,12 +130,40 @@ void SqlHandler::write_samples_( } // Write the sample + if (sql_sample->key.empty()) + { + set_key_(*const_cast(sql_sample)); + } + sql_writer_.write(*sql_sample); samples.pop_front(); } } +void SqlHandler::set_key_( + SqlMessage& sql_sample) +{ + if (keys_.find(sql_sample.instance_handle) != keys_.end()) + { + // The key has already been calculated + sql_sample.key = keys_[sql_sample.instance_handle]; + return; + } + + if (received_types_.find(sql_sample.topic.type_name) == received_types_.end()) + { + // The type is not known. The key can't be calculated + return; + } + + // Calculate the key + sql_sample.set_key(received_types_[sql_sample.topic.type_name]); + + // Store the key + keys_[sql_sample.instance_handle] = sql_sample.key; +} + } /* namespace participants */ } /* namespace ddsrecorder */ } /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index 1214721cb..7aaa7fb49 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -113,6 +113,7 @@ void SqlWriter::open_new_file_nts_( data BLOB NOT NULL, data_size INTEGER NOT NULL, topic TEXT NOT NULL, + key TEXT NOT NULL, log_time DATETIME NOT NULL, publish_time DATETIME NOT NULL, FOREIGN KEY(topic) REFERENCES Topics(name) @@ -190,8 +191,8 @@ void SqlWriter::write_nts_( // Define the SQL statement const char* insert_statement = R"( - INSERT INTO Messages (data, data_size, topic, log_time, publish_time) - VALUES (?, ?, ?, ?, ?); + INSERT INTO Messages (data, data_size, topic, key, log_time, publish_time) + VALUES (?, ?, ?, ?, ?, ?); )"; // Prepare the SQL statement @@ -212,8 +213,9 @@ void SqlWriter::write_nts_( sqlite3_bind_blob(statement, 1, msg.get_data(), msg.get_data_size(), SQLITE_TRANSIENT); sqlite3_bind_int64(statement, 2, msg.get_data_size()); sqlite3_bind_text(statement, 3, msg.topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 4, to_sql_timestamp(msg.log_time).c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 5, to_sql_timestamp(msg.publish_time).c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 4, msg.key.c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 5, to_sql_timestamp(msg.log_time).c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 6, to_sql_timestamp(msg.publish_time).c_str(), -1, SQLITE_TRANSIENT); // Execute the SQL statement const auto step_ret = sqlite3_step(statement); From 41548fde5ac716e591a1ae16b54d772a914b520c Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 23 May 2024 10:02:55 +0200 Subject: [PATCH 21/52] Strip deserializing methods from the DdsReplayer Signed-off-by: tempate --- .../replayer/Deserializer.hpp | 63 +++++++ .../replayer/impl/Deserializer.ipp | 74 ++++++++ .../src/cpp/replayer/Deserializer.cpp | 128 +++++++++++++ ddsreplayer/src/cpp/tool/DdsReplayer.cpp | 172 +----------------- ddsreplayer/src/cpp/tool/DdsReplayer.hpp | 27 --- 5 files changed, 273 insertions(+), 191 deletions(-) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/replayer/Deserializer.hpp create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/replayer/impl/Deserializer.ipp create mode 100644 ddsrecorder_participants/src/cpp/replayer/Deserializer.cpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/Deserializer.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/Deserializer.hpp new file mode 100644 index 000000000..0e4af50b2 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/Deserializer.hpp @@ -0,0 +1,63 @@ +// Copyright 2024 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 Deserializer.hpp + */ + +#pragma once + +#include + +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +/** + * Class to deserialize different types of data. + */ +class DDSRECORDER_PARTICIPANTS_DllAPI Deserializer +{ +public: + + /** + * @brief Deserialize \c serialized_str into \c T. + * + * @param [in] serialized_str String to deserialize + * @return Deserialized \c T + */ + template + static T deserialize( + const std::string& serialized_str); + +protected: + + /** + * @brief Deserialize \c type_str into a \c TypeObject or a \c TypeIdentifier. + * + * @param [in] type_str String to deserialize + * @return Deserialized \c TypeObject or \c TypeIdentifier + */ + template + static T type_str_to_type_data_( + const std::string& type_str); +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ + +#include diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/impl/Deserializer.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/impl/Deserializer.ipp new file mode 100644 index 000000000..76b5c94fc --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/impl/Deserializer.ipp @@ -0,0 +1,74 @@ +// Copyright 2024 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 Deserializer.cpp + */ + +#include + +#include +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +template +T Deserializer::type_str_to_type_data_( + const std::string& type_str) +{ + // Create CDR message from string + // NOTE: Use 0 length to avoid allocation + auto cdr_message = std::make_unique(0); + + cdr_message->buffer = (unsigned char*)reinterpret_cast(type_str.c_str()); + cdr_message->length = type_str.length(); +#if __BIG_ENDIAN__ + cdr_message->msg_endian = fastdds::rtps::BIGEND; +#else + cdr_message->msg_endian = fastdds::rtps::LITTLEEND; +#endif // if __BIG_ENDIAN__ + + // Reserve payload and create buffer + const auto parameter_length = cdr_message->length; + fastdds::rtps::SerializedPayload_t payload(parameter_length); + fastcdr::FastBuffer fastbuffer((char*)payload.data, parameter_length); + + // Read data + if (cdr_message != nullptr && cdr_message->length >= cdr_message->pos + parameter_length && parameter_length > 0 && payload.data != nullptr) + { + memcpy(payload.data, &cdr_message->buffer[cdr_message->pos], parameter_length); + cdr_message->pos += parameter_length; + } + + // Create CDR deserializer + fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = deser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize + T type_data; + fastcdr::deserialize(deser, type_data); + + // Delete CDR message + // NOTE: set wraps attribute to avoid double free (buffer released by string on destruction) + cdr_message->wraps = true; + + return type_data; +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/replayer/Deserializer.cpp b/ddsrecorder_participants/src/cpp/replayer/Deserializer.cpp new file mode 100644 index 000000000..0935d3b8d --- /dev/null +++ b/ddsrecorder_participants/src/cpp/replayer/Deserializer.cpp @@ -0,0 +1,128 @@ +// Copyright 2024 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 Deserializer.cpp + */ + +#include + +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +template <> +ddspipe::core::types::TopicQoS Deserializer::deserialize( + const std::string& topic_qos_str) +{ + // TODO: Reuse code from ddspipe_yaml + + ddspipe::core::types::TopicQoS qos{}; + + auto qos_yaml = YAML::Load(topic_qos_str); + bool reliable = qos_yaml[QOS_SERIALIZATION_RELIABILITY].as(); + bool transient_local = qos_yaml[QOS_SERIALIZATION_DURABILITY].as(); + bool exclusive_ownership = qos_yaml[QOS_SERIALIZATION_OWNERSHIP].as(); + bool keyed = qos_yaml[QOS_SERIALIZATION_KEYED].as(); + + // Parse reliability + if (reliable) + { + qos.reliability_qos = ddspipe::core::types::ReliabilityKind::RELIABLE; + } + else + { + qos.reliability_qos = ddspipe::core::types::ReliabilityKind::BEST_EFFORT; + } + + // Parse durability + if (transient_local) + { + qos.durability_qos = ddspipe::core::types::DurabilityKind::TRANSIENT_LOCAL; + } + else + { + qos.durability_qos = ddspipe::core::types::DurabilityKind::VOLATILE; + } + + // Parse ownership + if (exclusive_ownership) + { + qos.ownership_qos = ddspipe::core::types::OwnershipQosPolicyKind::EXCLUSIVE_OWNERSHIP_QOS; + } + else + { + qos.ownership_qos = ddspipe::core::types::OwnershipQosPolicyKind::SHARED_OWNERSHIP_QOS; + } + + // Parse keyed + qos.keyed = keyed; + + return qos; +} + +template <> +fastdds::dds::xtypes::TypeIdentifier Deserializer::deserialize( + const std::string& type_identifier_str) +{ + return type_str_to_type_data_(type_identifier_str); +} + +template <> +fastdds::dds::xtypes::TypeObject Deserializer::deserialize( + const std::string& type_object_str) +{ + return type_str_to_type_data_(type_object_str); +} + +template <> +DynamicTypesCollection Deserializer::deserialize( + const std::string& raw_data_str) +{ + // Copy raw data into a payload + fastdds::rtps::SerializedPayload_t serialized_payload{(std::uint32_t) raw_data_str.size()}; + serialized_payload.length = raw_data_str.size(); + + std::memcpy( + serialized_payload.data, + reinterpret_cast(raw_data_str.c_str()), + raw_data_str.size()); + + // Deserialize the payload into a DynamicTypesCollection + DynamicTypesCollection dynamic_types; + fastdds::dds::TypeSupport type_support(new DynamicTypesCollectionPubSubType()); + + type_support.deserialize(&serialized_payload, &dynamic_types); + + return dynamic_types; +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index 9895682a4..1c45642e0 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -39,6 +39,7 @@ #include #include +#include #include @@ -208,16 +209,8 @@ std::set> DdsReplayer::generate_builtin_topic mcap::Attachment dynamic_attachment = attachments[DYNAMIC_TYPES_ATTACHMENT_NAME]; // Deserialize dynamic types collection using CDR - DynamicTypesCollection dynamic_types; - eprosima::fastdds::dds::TypeSupport type_support(new DynamicTypesCollectionPubSubType()); - eprosima::fastdds::rtps::SerializedPayload_t serialized_payload = - eprosima::fastdds::rtps::SerializedPayload_t(dynamic_attachment.dataSize); - serialized_payload.length = dynamic_attachment.dataSize; - std::memcpy( - serialized_payload.data, - reinterpret_cast(dynamic_attachment.data), - dynamic_attachment.dataSize); - type_support.deserialize(&serialized_payload, &dynamic_types); + const std::string dynamic_types_str(reinterpret_cast(dynamic_attachment.data), dynamic_attachment.dataSize); + const auto dynamic_types = Deserializer::deserialize(dynamic_types_str); if (configuration.replay_types) { @@ -245,7 +238,7 @@ std::set> DdsReplayer::generate_builtin_topic // Apply the QoS stored in the MCAP file as if they were the discovered QoS. channel_topic->topic_qos.set_qos( - deserialize_qos_(it->second->metadata[QOS_SERIALIZATION_QOS]), + Deserializer::deserialize(it->second->metadata[QOS_SERIALIZATION_QOS]), utils::FuzzyLevelValues::fuzzy_level_fuzzy); // Insert channel topic in builtin topics list @@ -277,8 +270,10 @@ void DdsReplayer::register_dynamic_type_( std::string typeobj_str = utils::base64_decode(dynamic_type.type_object()); // Deserialize type identifer and object strings - fastdds::dds::xtypes::TypeIdentifier type_identifier = deserialize_type_identifier_(typeid_str); - fastdds::dds::xtypes::TypeObject type_object = deserialize_type_object_(typeobj_str); + fastdds::dds::xtypes::TypeIdentifier type_identifier = + Deserializer::deserialize(typeid_str); + fastdds::dds::xtypes::TypeObject type_object = + Deserializer::deserialize(typeobj_str); // Create a TypeIdentifierPair to use in register_type_identifier fastdds::dds::xtypes::TypeIdentifierPair type_identifiers; @@ -297,157 +292,6 @@ void DdsReplayer::register_dynamic_type_( } } -TopicQoS DdsReplayer::deserialize_qos_( - const std::string& qos_str) -{ - // TODO: Reuse code from ddspipe_yaml - - TopicQoS qos{}; - - YAML::Node qos_yaml = YAML::Load(qos_str); - bool reliable = qos_yaml[QOS_SERIALIZATION_RELIABILITY].as(); - bool transient_local = qos_yaml[QOS_SERIALIZATION_DURABILITY].as(); - bool exclusive_ownership = qos_yaml[QOS_SERIALIZATION_OWNERSHIP].as(); - bool keyed = qos_yaml[QOS_SERIALIZATION_KEYED].as(); - - // Parse reliability - if (reliable) - { - qos.reliability_qos = ddspipe::core::types::ReliabilityKind::RELIABLE; - } - else - { - qos.reliability_qos = ddspipe::core::types::ReliabilityKind::BEST_EFFORT; - } - - // Parse durability - if (transient_local) - { - qos.durability_qos = ddspipe::core::types::DurabilityKind::TRANSIENT_LOCAL; - } - else - { - qos.durability_qos = ddspipe::core::types::DurabilityKind::VOLATILE; - } - - // Parse ownership - if (exclusive_ownership) - { - qos.ownership_qos = ddspipe::core::types::OwnershipQosPolicyKind::EXCLUSIVE_OWNERSHIP_QOS; - } - else - { - qos.ownership_qos = ddspipe::core::types::OwnershipQosPolicyKind::SHARED_OWNERSHIP_QOS; - } - - // Parse keyed - qos.keyed = keyed; - - return qos; -} - -fastdds::dds::xtypes::TypeIdentifier DdsReplayer::deserialize_type_identifier_( - const std::string& typeid_str) -{ - // Create CDR message from string - // NOTE: Use 0 length to avoid allocation - fastdds::rtps::CDRMessage_t* cdr_message = new fastdds::rtps::CDRMessage_t(0); - cdr_message->buffer = (unsigned char*)reinterpret_cast(typeid_str.c_str()); - cdr_message->length = typeid_str.length(); -#if __BIG_ENDIAN__ - cdr_message->msg_endian = fastdds::rtps::BIGEND; -#else - cdr_message->msg_endian = fastdds::rtps::LITTLEEND; -#endif // if __BIG_ENDIAN__ - - // Reserve payload and create buffer - const auto parameter_length = cdr_message->length; - fastdds::rtps::SerializedPayload_t payload(parameter_length); - fastcdr::FastBuffer fastbuffer((char*)payload.data, parameter_length); - - // Read data - if (cdr_message != nullptr) - { - if (cdr_message->length >= cdr_message->pos + parameter_length) - { - if (parameter_length > 0) - { - if (payload.data != nullptr) - { - memcpy(payload.data, &cdr_message->buffer[cdr_message->pos], parameter_length); - cdr_message->pos += parameter_length; - } - } - } - } - - // Create CDR deserializer - fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::CdrVersion::XCDRv2); - payload.encapsulation = deser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize - fastdds::dds::xtypes::TypeIdentifier type_identifier; - fastcdr::deserialize(deser, type_identifier); - - // Delete CDR message - // NOTE: set wraps attribute to avoid double free (buffer released by string on destruction) - cdr_message->wraps = true; - delete cdr_message; - - return type_identifier; -} - -fastdds::dds::xtypes::TypeObject DdsReplayer::deserialize_type_object_( - const std::string& typeobj_str) -{ - // Create CDR message from string - // NOTE: Use 0 length to avoid allocation - fastdds::rtps::CDRMessage_t* cdr_message = new fastdds::rtps::CDRMessage_t(0); - cdr_message->buffer = (unsigned char*)reinterpret_cast(typeobj_str.c_str()); - cdr_message->length = typeobj_str.length(); -#if __BIG_ENDIAN__ - cdr_message->msg_endian = fastdds::rtps::BIGEND; -#else - cdr_message->msg_endian = fastdds::rtps::LITTLEEND; -#endif // if __BIG_ENDIAN__ - - // Reserve payload and create buffer - const auto parameter_length = cdr_message->length; - fastdds::rtps::SerializedPayload_t payload(parameter_length); - fastcdr::FastBuffer fastbuffer((char*)payload.data, parameter_length); - - // Read data - if (cdr_message != nullptr) - { - if (cdr_message->length >= cdr_message->pos + parameter_length) - { - if (parameter_length > 0) - { - if (payload.data != nullptr) - { - memcpy(payload.data, &cdr_message->buffer[cdr_message->pos], parameter_length); - cdr_message->pos += parameter_length; - } - } - } - } - - // Create CDR deserializer - fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::CdrVersion::XCDRv2); - payload.encapsulation = deser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize - fastdds::dds::xtypes::TypeObject type_object; - fastcdr::deserialize(deser, type_object); - - // Delete CDR message - // NOTE: set wraps attribute to avoid double free (buffer released by string on destruction) - cdr_message->wraps = true; - delete cdr_message; - - return type_object; -} - } /* namespace replayer */ } /* namespace ddsrecorder */ } /* namespace eprosima */ diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp index d0fac549b..031223625 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp @@ -123,33 +123,6 @@ class DdsReplayer void create_dynamic_writer_( utils::Heritable topic); - /** - * @brief Deserialize a serialized \c TopicQoS string. - * - * @param [in] qos_str Serialized \c TopicQoS string - * @return Deserialized TopicQoS - */ - static ddspipe::core::types::TopicQoS deserialize_qos_( - const std::string& qos_str); - - /** - * @brief Deserialize a serialized \c TypeIdentifier string. - * - * @param [in] typeid_str Serialized \c TypeIdentifier string - * @return Deserialized TypeIdentifier - */ - static fastdds::dds::xtypes::TypeIdentifier deserialize_type_identifier_( - const std::string& typeid_str); - - /** - * @brief Deserialize a serialized \c TypeObject string. - * - * @param [in] typeobj_str Serialized \c TypeObject string - * @return Deserialized TypeObject - */ - static fastdds::dds::xtypes::TypeObject deserialize_type_object_( - const std::string& typeobj_str); - //! Payload Pool std::shared_ptr payload_pool_; From ebdd61a8442f77a08aa8a989fd7cfb4e5263b9c4 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 24 May 2024 11:01:37 +0200 Subject: [PATCH 22/52] Generalize time_utils between the DDS Recorder and Replayer Signed-off-by: tempate --- .../mcap/utils.hpp => common/time_utils.hpp} | 53 +++++++- .../recorder/sql/utils.hpp | 58 --------- .../replayer/McapReaderParticipant.hpp | 20 --- .../src/cpp/common/time_utils.cpp | 120 ++++++++++++++++++ .../src/cpp/recorder/mcap/McapWriter.cpp | 2 +- .../src/cpp/recorder/mcap/utils.cpp | 44 ------- .../src/cpp/recorder/message/McapMessage.cpp | 2 +- .../src/cpp/recorder/sql/SqlWriter.cpp | 2 +- .../src/cpp/recorder/sql/utils.cpp | 51 -------- .../cpp/replayer/McapReaderParticipant.cpp | 22 +--- 10 files changed, 180 insertions(+), 194 deletions(-) rename ddsrecorder_participants/include/ddsrecorder_participants/{recorder/mcap/utils.hpp => common/time_utils.hpp} (50%) delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/utils.hpp create mode 100644 ddsrecorder_participants/src/cpp/common/time_utils.cpp delete mode 100644 ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp delete mode 100644 ddsrecorder_participants/src/cpp/recorder/sql/utils.cpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp similarity index 50% rename from ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp index 79f9e5163..603b47d40 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/utils.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp @@ -18,6 +18,9 @@ #pragma once +#include +#include + #include #include @@ -26,11 +29,28 @@ #include - namespace eprosima { namespace ddsrecorder { namespace participants { +/** + * @brief This method converts a mcap timestamp to standard format. + * + * @param [in] time Timestamp to be converted + * @return Timestamp in standard format + */ +DDSRECORDER_PARTICIPANTS_DllAPI +utils::Timestamp to_std_timestamp( + const mcap::Timestamp& time); + +/** + * @brief This method converts a string timestamp to standard format. + * + * @param [in] time Timestamp to be converted + * @param [in] format Format of the timestamp + */ +utils::Timestamp to_std_timestamp( + const std::string& time); /** * @brief This method converts a timestamp in Fast DDS format to its mcap equivalent. @@ -52,6 +72,37 @@ DDSRECORDER_PARTICIPANTS_DllAPI mcap::Timestamp to_mcap_timestamp( const utils::Timestamp& time); +/** + * @brief This method converts a timestamp in Fast DDS format to a SQL-friendly format. + * + * @param [in] time Timestamp to convert + * @param [in] local_time Flag to indicate if the timestamp is in local time + * @return String formatted as "YYYY-MM-DD HH:MM:SS" + */ +DDSRECORDER_PARTICIPANTS_DllAPI +std::string to_sql_timestamp( + const fastrtps::rtps::Time_t& time, + const bool local_time = false); + +/** + * @brief This method converts a timestamp in standard format to a SQL-friendly format. + * + * @param [in] time Timestamp to convert + * @return String formatted as "YYYY-MM-DD HH:MM:SS" + */ +DDSRECORDER_PARTICIPANTS_DllAPI +std::string to_sql_timestamp( + const utils::Timestamp& time); + +/** + * @brief This method converts a timestamp in standard format to nanoseconds. + * + * @param [in] time Timestamp to convert + * @return Timestamp in nanoseconds + */ +DDSRECORDER_PARTICIPANTS_DllAPI +std::uint64_t to_ticks( + const utils::Timestamp& time); } /* namespace participants */ } /* namespace ddsrecorder */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/utils.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/utils.hpp deleted file mode 100644 index 2a3abbaae..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/utils.hpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2024 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 utils.hpp - */ - -#pragma once - -#include - -#include - -#include - -#include - - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - - -/** - * @brief This method converts a timestamp in Fast DDS format to a SQL-friendly format. - * - * @param [in] time Timestamp to convert - * @return String formatted as "YYYY-MM-DD HH:MM:SS" - */ -DDSRECORDER_PARTICIPANTS_DllAPI -std::string to_sql_timestamp( - const fastrtps::rtps::Time_t& time); - -/** - * @brief This method converts a timestamp in standard format to a SQL-friendly format. - * - * @param [in] time Timestamp to convert - * @return String formatted as "YYYY-MM-DD HH:MM:SS" - */ -DDSRECORDER_PARTICIPANTS_DllAPI -std::string to_sql_timestamp( - const utils::Timestamp& time); - - -} /* namespace participants */ -} /* namespace ddsrecorder */ -} /* namespace eprosima */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp index 478eb322e..c90523191 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp @@ -57,26 +57,6 @@ class McapReaderParticipant : public BaseReaderParticipant */ DDSRECORDER_PARTICIPANTS_DllAPI void process_file() override; - - /** - * @brief This method converts a mcap timestamp to standard format. - * - * @param [in] time Timestamp to be converted - * @return Timestamp in standard format - */ - DDSRECORDER_PARTICIPANTS_DllAPI - static utils::Timestamp mcap_timestamp_to_std_timepoint( - const mcap::Timestamp& time); - - /** - * @brief This method converts a timestamp in standard format to its mcap equivalent. - * - * @param [in] time Timestamp to be converted - * @return Timestamp in mcap format - */ - DDSRECORDER_PARTICIPANTS_DllAPI - static mcap::Timestamp std_timepoint_to_mcap_timestamp( - const utils::Timestamp& time); }; } /* namespace participants */ diff --git a/ddsrecorder_participants/src/cpp/common/time_utils.cpp b/ddsrecorder_participants/src/cpp/common/time_utils.cpp new file mode 100644 index 000000000..6132925bc --- /dev/null +++ b/ddsrecorder_participants/src/cpp/common/time_utils.cpp @@ -0,0 +1,120 @@ +// Copyright 2024 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 time_utils.cpp + */ + +#include +#include +#include +#include +#include + +#include + +#include + + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +const auto SQL_TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S"; +constexpr std::uint64_t NS_PER_SEC = 1000000000; + +utils::Timestamp to_std_timestamp( + const mcap::Timestamp& time) +{ + const auto timestamp = utils::Timestamp() + std::chrono::nanoseconds(time); + return std::chrono::time_point_cast(timestamp); +} + +utils::Timestamp to_std_timestamp( + const std::string& time) +{ + // Parse the nanoseconds from the fractional part of the timestamp + const auto dot_pos = time.find('.'); + + if (dot_pos == std::string::npos) + { + throw std::runtime_error("No dot found in the timestamp"); + } + + auto time_point = utils::string_to_timestamp(time.substr(0, dot_pos), SQL_TIMESTAMP_FORMAT); + + const auto decimals = time.substr(dot_pos + 1); + std::uint32_t nanoseconds; + std::istringstream(decimals) >> nanoseconds; + + if (decimals.empty() || std::istringstream(decimals).fail()) + { + throw std::runtime_error("Failed to parse fractional part as an integer"); + } + + time_point += std::chrono::nanoseconds(nanoseconds); + + return time_point; +} + +mcap::Timestamp to_mcap_timestamp( + const fastrtps::rtps::Time_t& time) +{ + return time.seconds() * NS_PER_SEC + time.nanosec(); +} + +mcap::Timestamp to_mcap_timestamp( + const utils::Timestamp& time) +{ + return mcap::Timestamp(to_ticks(time)); +} + +std::string to_sql_timestamp( + const fastrtps::rtps::Time_t& time, + const bool local_time /* = false */) +{ + char datetime_str[30]; + + const std::time_t time_seconds = time.seconds(); + const auto time_seconds_zone = local_time ? std::localtime(&time_seconds) : std::gmtime(&time_seconds); + std::strftime(datetime_str, sizeof(datetime_str), SQL_TIMESTAMP_FORMAT, time_seconds_zone); + + // Combine the date-time string with nanoseconds to form the full timestamp + std::ostringstream oss; + oss << datetime_str << '.' << std::setw(9) << std::setfill('0') << time.nanosec(); + + return oss.str(); +} + +std::string to_sql_timestamp( + const utils::Timestamp& time) +{ + std::ostringstream time_str; + time_str << utils::timestamp_to_string(time, SQL_TIMESTAMP_FORMAT); + + auto nanoseconds = to_ticks(time) % NS_PER_SEC; + time_str << '.' << std::setw(9) << std::setfill('0') << nanoseconds; + + return time_str.str(); +} + +std::uint64_t to_ticks( + const utils::Timestamp& time) +{ + return std::chrono::duration_cast(time.time_since_epoch()).count(); +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp index 5e1465c0b..bd1d1eb6f 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp @@ -23,11 +23,11 @@ #include #include +#include #include #include #include #include -#include namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp deleted file mode 100644 index 3f8102bde..000000000 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/utils.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2024 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 utils.cpp - */ - -#include -#include - -#include - - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - -mcap::Timestamp to_mcap_timestamp( - const fastdds::rtps::Time_t& time) -{ - static constexpr std::uint64_t NS_PER_SEC = 1000000000; - return time.seconds() * NS_PER_SEC + time.nanosec(); -} - -mcap::Timestamp to_mcap_timestamp( - const utils::Timestamp& time) -{ - return mcap::Timestamp(std::chrono::duration_cast(time.time_since_epoch()).count()); -} - -} /* namespace participants */ -} /* namespace ddsrecorder */ -} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp index d0393a07d..52fe280d9 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp @@ -16,7 +16,7 @@ * @file McapMessage.cpp */ -#include +#include #include diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index 7aaa7fb49..19172e9f6 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 #include diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/utils.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/utils.cpp deleted file mode 100644 index 43a6c7a2d..000000000 --- a/ddsrecorder_participants/src/cpp/recorder/sql/utils.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2024 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 utils.cpp - */ - -#include - -#include - -#include - - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - -const auto SQL_TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S"; - -std::string to_sql_timestamp( - const fastrtps::rtps::Time_t& time) -{ - char datetime_str[20]; - - const std::time_t time_seconds = time.seconds(); - std::strftime(datetime_str, sizeof(datetime_str), SQL_TIMESTAMP_FORMAT, std::localtime(&time_seconds)); - - return std::string(datetime_str); -} - -std::string to_sql_timestamp( - const utils::Timestamp& time) -{ - return utils::timestamp_to_string(time, SQL_TIMESTAMP_FORMAT, true); -} - -} /* namespace participants */ -} /* namespace ddsrecorder */ -} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp index 8b2adf142..e48ebbf73 100644 --- a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp @@ -31,6 +31,7 @@ #include #include +#include namespace eprosima { namespace ddsrecorder { @@ -67,11 +68,11 @@ void McapReaderParticipant::process_file() mcap::Timestamp end_time = mcap::MaxTime; if (configuration_->begin_time.is_set()) { - begin_time = std_timepoint_to_mcap_timestamp(configuration_->begin_time.get_reference()); + begin_time = to_mcap_timestamp(configuration_->begin_time.get_reference()); } if (configuration_->end_time.is_set()) { - end_time = std_timepoint_to_mcap_timestamp(configuration_->end_time.get_reference()); + end_time = to_mcap_timestamp(configuration_->end_time.get_reference()); } mcap::ReadMessageOptions read_options(begin_time, end_time); @@ -93,7 +94,7 @@ void McapReaderParticipant::process_file() auto messages_end = messages.end(); if (messages_it != messages_end) { - initial_ts_origin = mcap_timestamp_to_std_timepoint(messages_it->message.logTime); + initial_ts_origin = to_std_timestamp(messages_it->message.logTime); } else { @@ -138,7 +139,7 @@ void McapReaderParticipant::process_file() mcap_payload.data = nullptr; // Set to nullptr after copy to avoid free on destruction // Set publication delay from original log time and configured playback rate - auto delay = mcap_timestamp_to_std_timepoint(it->message.logTime) - initial_ts_origin; + auto delay = to_std_timestamp(it->message.logTime) - initial_ts_origin; scheduled_write_ts = std::chrono::time_point_cast(initial_ts + std::chrono::duration_cast( delay / configuration_->rate)); @@ -194,19 +195,6 @@ void McapReaderParticipant::process_file() mcap_reader.close(); } -utils::Timestamp McapReaderParticipant::mcap_timestamp_to_std_timepoint( - const mcap::Timestamp& time) -{ - return std::chrono::time_point_cast(utils::Timestamp() + - std::chrono::nanoseconds(time)); -} - -mcap::Timestamp McapReaderParticipant::std_timepoint_to_mcap_timestamp( - const utils::Timestamp& time) -{ - return mcap::Timestamp(std::chrono::duration_cast(time.time_since_epoch()).count()); -} - } /* namespace participants */ } /* namespace ddsrecorder */ } /* namespace eprosima */ From 78de7fccecb4b4520c6dba43a1861d2b6195e8bb Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 24 May 2024 11:02:17 +0200 Subject: [PATCH 23/52] Strip MCAP summary processing from the DdsReplayer Signed-off-by: tempate --- .../replayer/BaseReaderParticipant.hpp | 76 ++++- .../replayer/McapReaderParticipant.hpp | 71 ++++- .../cpp/replayer/BaseReaderParticipant.cpp | 102 +++++-- .../cpp/replayer/McapReaderParticipant.cpp | 275 +++++++++++------- ddsreplayer/src/cpp/tool/DdsReplayer.cpp | 263 +++++++---------- ddsreplayer/src/cpp/tool/DdsReplayer.hpp | 86 +++--- 6 files changed, 530 insertions(+), 343 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp index 4a3ac179f..c49bce2e0 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp @@ -15,14 +15,24 @@ #pragma once #include +#include #include #include #include +#include #include +#include +#include + +#include + #include #include #include +#include +#include +#include #include #include @@ -30,6 +40,12 @@ #include #include +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include +#else + #include +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + namespace eprosima { namespace ddsrecorder { namespace participants { @@ -54,9 +70,9 @@ class BaseReaderParticipant : public ddspipe::core::IParticipant */ DDSRECORDER_PARTICIPANTS_DllAPI BaseReaderParticipant( - std::shared_ptr configuration, - std::shared_ptr payload_pool, - std::string& file_path); + const std::shared_ptr& configuration, + const std::shared_ptr& payload_pool, + const std::string& file_path); //! Override id() IParticipant method DDSRECORDER_PARTICIPANTS_DllAPI @@ -85,12 +101,25 @@ class BaseReaderParticipant : public ddspipe::core::IParticipant const ddspipe::core::ITopic& topic) override; /** - * @brief Read and send messages sequentially (according to timestamp). + * @brief Process the input file's summary. * - * @throw utils::InconsistencyException if failed to read file. + * @param topics: Set of topics to be filled with the information from the input file. + * @param types: DynamicTypesCollection instance to be filled with the types information from the input file. */ DDSRECORDER_PARTICIPANTS_DllAPI - virtual void process_file() = 0; + virtual void process_summary( + std::set>& topics, + DynamicTypesCollection& types) = 0; + + /** + * @brief Process the input file's messages + * + * Reads and sends messages sequentially (according to timestamp). + * + * @throw \c InconsistencyException if failed to read the input file. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + virtual void process_messages() = 0; //! Stop participant (abort processing file) DDSRECORDER_PARTICIPANTS_DllAPI @@ -98,14 +127,45 @@ class BaseReaderParticipant : public ddspipe::core::IParticipant protected: + /** + * @brief Create a payload from raw data. + * + * @param raw_data: Raw data to be encapsulated in the payload. + * @param raw_data_size: Size of the raw data. + */ + std::unique_ptr create_payload_( + const void* raw_data, + const std::uint32_t raw_data_size); + + /** + * @brief Create a new \c DdsTopic instance. + * + * @param topic_name: Name of the topic. + * @param type_name: Name of the type. + * @param is_ros2_type: Whether the type is a ROS2 type. + * @return A new \c DdsTopic instance. + */ + ddspipe::core::types::DdsTopic create_topic_( + const std::string& topic_name, + const std::string& type_name, + const bool is_ros2_type); + + /** + * @brief Wait until timestamp is reached. + * + * @param timestamp: Timestamp to wait until. + */ + void wait_until_timestamp_( + const utils::Timestamp& timestamp); + //! Participant Configuration - std::shared_ptr configuration_; + const std::shared_ptr configuration_; //! DDS Pipe shared Payload Pool std::shared_ptr payload_pool_; //! Input file path - std::string file_path_; + const std::string file_path_; //! Internal readers map std::map> readers_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp index c90523191..30e0f79f3 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp @@ -14,13 +14,24 @@ #pragma once -#include +#include +#include + +#include + +#include #include #include -#include #include +#include + +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include +#else + #include +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 namespace eprosima { namespace ddsrecorder { @@ -46,17 +57,63 @@ class McapReaderParticipant : public BaseReaderParticipant */ DDSRECORDER_PARTICIPANTS_DllAPI McapReaderParticipant( - std::shared_ptr configuration, - std::shared_ptr payload_pool, - std::string& file_path); + const std::shared_ptr& configuration, + const std::shared_ptr& payload_pool, + const std::string& file_path); + + /** + * @brief Process the MCAP file summary. + * + * Fills the topics with the MCAP file's channels and schemas. + * Fills the types with the MCAP file's attachment. + * + * @param topics: Set of topics to be filled with the information from the MCAP file. + * @param types: DynamicTypesCollection instance to be filled with the types' information from the MCAP file. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + void process_summary( + std::set>& topics, + DynamicTypesCollection& types) override; /** * @brief Read and send messages sequentially (according to timestamp). * - * @throw utils::InconsistencyException if failed to read mcap file. + * Reads the MCAP file messages and sends them to the participants. */ DDSRECORDER_PARTICIPANTS_DllAPI - void process_file() override; + void process_messages() override; + +protected: + + /** + * @brief Open the MCAP file. + * + * @throws \c InitializationException if failed to open MCAP file. + */ + void open_file_(); + + /** + * @brief Close the MCAP file. + */ + void close_file_(); + + /** + * @brief Read the MCAP file summary. + * + * Reads the MCAP file summary. + * Checks if the version of the MCAP file is supported. + */ + void read_mcap_summary_(); + + /** + * @brief Read the MCAP file messages. + * + * @return A \c LinearMessageView instance with the messages read. + */ + mcap::LinearMessageView read_mcap_messages_(); + + //! MCAP reader instance. + mcap::McapReader mcap_reader_; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp index 47b2fd7e1..6af1d0062 100644 --- a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp @@ -1,4 +1,4 @@ -// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2024 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. @@ -16,10 +16,17 @@ * @file BaseReaderParticipant.cpp */ +#include + +#include #include +#include #include +#include +#include +#include #include #include #include @@ -30,15 +37,10 @@ namespace eprosima { namespace ddsrecorder { namespace participants { -using namespace eprosima::ddspipe::core; -using namespace eprosima::ddspipe::core::types; -using namespace eprosima::ddspipe::participants; -using namespace eprosima::utils; - BaseReaderParticipant::BaseReaderParticipant( - std::shared_ptr configuration, - std::shared_ptr payload_pool, - std::string& file_path) + const std::shared_ptr& configuration, + const std::shared_ptr& payload_pool, + const std::string& file_path) : configuration_(configuration) , payload_pool_(payload_pool) , file_path_(file_path) @@ -47,7 +49,7 @@ BaseReaderParticipant::BaseReaderParticipant( // Do nothing } -ParticipantId BaseReaderParticipant::id() const noexcept +ddspipe::core::types::ParticipantId BaseReaderParticipant::id() const noexcept { return configuration_->id; } @@ -62,29 +64,29 @@ bool BaseReaderParticipant::is_rtps_kind() const noexcept return false; } -TopicQoS BaseReaderParticipant::topic_qos() const noexcept +ddspipe::core::types::TopicQoS BaseReaderParticipant::topic_qos() const noexcept { return configuration_->topic_qos; } -std::shared_ptr BaseReaderParticipant::create_writer( - const ITopic& /* topic */) +std::shared_ptr BaseReaderParticipant::create_writer( + const ddspipe::core::ITopic& /* topic */) { - return std::make_shared(); + return std::make_shared(); } -std::shared_ptr BaseReaderParticipant::create_reader( - const ITopic& topic) +std::shared_ptr BaseReaderParticipant::create_reader( + const ddspipe::core::ITopic& topic) { - if (!utils::can_cast(topic)) + if (!utils::can_cast(topic)) { logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, "Not creating Writer for topic " << topic.topic_name()); - return std::make_shared(); + return std::make_shared(); } - auto reader = std::make_shared(id()); + auto reader = std::make_shared(id()); - auto dds_topic = dynamic_cast(topic); + auto dds_topic = dynamic_cast(topic); readers_[dds_topic] = reader; @@ -100,6 +102,66 @@ void BaseReaderParticipant::stop() noexcept scheduling_cv_.notify_one(); } +std::unique_ptr BaseReaderParticipant::create_payload_( + const void* raw_data, + const std::uint32_t raw_data_size) +{ + auto data = std::make_unique(); + + // Store the raw data in a payload + ddspipe::core::types::Payload payload(raw_data_size); + payload.max_size = raw_data_size; + payload.length = raw_data_size; + payload.data = (unsigned char*) reinterpret_cast(raw_data); + + // Reserve and copy the payload into the payload pool + fastrtps::rtps::IPayloadPool* null_payload_pool = nullptr; + + payload_pool_->get_payload(payload, null_payload_pool, data->payload); + data->payload_owner = payload_pool_.get(); + + // Remove the raw data pointer to avoid freeing it on destruction + payload.data = nullptr; + + return data; +} + +ddspipe::core::types::DdsTopic BaseReaderParticipant::create_topic_( + const std::string& topic_name, + const std::string& type_name, + const bool is_ros2_type) +{ + ddspipe::core::types::DdsTopic topic; + + if (is_ros2_type) + { + topic.m_topic_name = utils::mangle_if_ros_topic(topic_name); + topic.type_name = utils::mangle_if_ros_type(type_name); + } + else + { + topic.m_topic_name = topic_name; + topic.type_name = type_name; + } + + return topic; +} + +void BaseReaderParticipant::wait_until_timestamp_( + const utils::Timestamp& timestamp) +{ + const auto timepoint = std::chrono::time_point_cast(timestamp); + + std::unique_lock lock(scheduling_cv_mtx_); + scheduling_cv_.wait_until( + lock, + timepoint, + [&] + { + return stop_ || (utils::now() >= timepoint); + }); +} + } /* namespace participants */ } /* namespace ddsrecorder */ } /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp index e48ebbf73..1c42006a3 100644 --- a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp @@ -16,183 +16,248 @@ * @file McapReaderParticipant.cpp */ +#include +#include + +#include #include +#include #include -#include +#include #include -#include +#include #include -#include +#include -#include -#include +#include +#include +#include #include +#include #include -#include + +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include +#else + #include +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 namespace eprosima { namespace ddsrecorder { namespace participants { -using namespace eprosima::ddspipe::core; -using namespace eprosima::ddspipe::core::types; -using namespace eprosima::ddspipe::participants; -using namespace eprosima::utils; - McapReaderParticipant::McapReaderParticipant( - std::shared_ptr configuration, - std::shared_ptr payload_pool, - std::string& file_path) + const std::shared_ptr& configuration, + const std::shared_ptr& payload_pool, + const std::string& file_path) : BaseReaderParticipant(configuration, payload_pool, file_path) { - // Do nothing } -void McapReaderParticipant::process_file() +void McapReaderParticipant::process_summary( + std::set>& topics, + DynamicTypesCollection& types) { - // Read MCAP file - mcap::McapReader mcap_reader; - auto status = mcap_reader.open(file_path_); - if (status.code != mcap::StatusCode::Success) - { - throw utils::InconsistencyException( - STR_ENTRY << "Failed MCAP read." - ); - } + open_file_(); - // NOTE: begin_time < end_time assertion already done in YAML module - mcap::Timestamp begin_time = 0; - mcap::Timestamp end_time = mcap::MaxTime; - if (configuration_->begin_time.is_set()) + read_mcap_summary_(); + + // Get the topics from the channels and schemas + const auto channels = mcap_reader_.channels(); + const auto schemas = mcap_reader_.schemas(); + + for (const auto& [_, channel]: channels) { - begin_time = to_mcap_timestamp(configuration_->begin_time.get_reference()); + const auto topic_name = channel->topic; + const auto type_name = schemas.at(channel->schemaId)->name; + + const bool is_topic_ros2_type = channel->metadata[ROS2_TYPES] == "true"; + const auto topic = utils::Heritable::make_heritable( + create_topic_(topic_name, type_name, is_topic_ros2_type)); + + // Apply the QoS stored in the MCAP file as if they were the discovered QoS. + const auto topic_qos_str = channel->metadata[QOS_SERIALIZATION_QOS]; + const auto topic_qos = Deserializer::deserialize(topic_qos_str); + + topic->topic_qos.set_qos(topic_qos, utils::FuzzyLevelValues::fuzzy_level_fuzzy); + + topics.insert(topic); } - if (configuration_->end_time.is_set()) + + // Get the dynamic types from the attachment + const auto attachments = mcap_reader_.attachments(); + + if (attachments.find(DYNAMIC_TYPES_ATTACHMENT_NAME) != attachments.end()) { - end_time = to_mcap_timestamp(configuration_->end_time.get_reference()); + const auto dynamic_types_attachment = attachments.at(DYNAMIC_TYPES_ATTACHMENT_NAME); + + const std::string dynamic_types_str( + reinterpret_cast(dynamic_types_attachment.data), dynamic_types_attachment.dataSize); + + types = Deserializer::deserialize(dynamic_types_str); } - mcap::ReadMessageOptions read_options(begin_time, end_time); - // Iterate over messages ordered by incremental log_time - // NOTE: this corresponds to recording time (not publication) unless recorder configured with `log-publish-time: true` - read_options.readOrder = mcap::ReadMessageOptions::ReadOrder::LogTimeOrder; + close_file_(); +} - // Read messages - const auto onProblem = [](const mcap::Status& status) - { - logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, - "An error occurred while reading messages: " << status.message << "."); - }; - auto messages = mcap_reader.readMessages(onProblem, read_options); +void McapReaderParticipant::process_messages() +{ + open_file_(); - // Obtain timestamp of first recorded message - utils::Timestamp initial_ts_origin; - auto messages_it = messages.begin(); - auto messages_end = messages.end(); - if (messages_it != messages_end) - { - initial_ts_origin = to_std_timestamp(messages_it->message.logTime); - } - else + auto messages = read_mcap_messages_(); + + if (messages.begin() == messages.end()) { logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, "Provided input file contains no messages in the given range."); + close_file_(); return; } + // Obtain timestamp of first recorded message + const auto first_message_timestamp = to_std_timestamp(messages.begin()->message.logTime); + // Define the time to start replaying messages - utils::Timestamp initial_ts; - utils::Timestamp now = utils::now(); + const auto now = utils::now(); + utils::Timestamp initial_timestamp; + if (configuration_->start_replay_time.is_set()) { - initial_ts = configuration_->start_replay_time.get_reference(); + initial_timestamp = configuration_->start_replay_time.get_reference(); - if (initial_ts < now) + if (initial_timestamp < now) { logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, "Provided start-replay-time already expired, starting immediately..."); - initial_ts = now; + initial_timestamp = now; } } else { - initial_ts = now; + initial_timestamp = now; } - // Schedule messages to be replayed - utils::Timestamp scheduled_write_ts; - for (auto it = messages.begin(); it != messages_end; it++) + // Replay messages + for (const auto& it : messages) { // Create RTPS data - auto data = std::make_unique(); - - // Create data payload - Payload mcap_payload; - mcap_payload.length = it->message.dataSize; - mcap_payload.max_size = it->message.dataSize; - mcap_payload.data = (unsigned char*)reinterpret_cast(it->message.data); - - // Copy payload from MCAP file to RTPS data through payload pool - payload_pool_->get_payload(mcap_payload, data->payload); // this reserves and copies payload - mcap_payload.data = nullptr; // Set to nullptr after copy to avoid free on destruction + auto data = create_payload_(it.message.data, it.message.dataSize); // Set publication delay from original log time and configured playback rate - auto delay = to_std_timestamp(it->message.logTime) - initial_ts_origin; - scheduled_write_ts = std::chrono::time_point_cast(initial_ts + std::chrono::duration_cast( - delay / configuration_->rate)); + auto delay = to_std_timestamp(it.message.logTime) - first_message_timestamp; + auto scheduled_write_ts = + std::chrono::time_point_cast(initial_timestamp + + std::chrono::duration_cast(delay / configuration_->rate)); // Set source timestamp // NOTE: this is important for QoS such as LifespanQosPolicy - data->source_timestamp = - fastdds::rtps::Time_t(std::chrono::duration_cast(scheduled_write_ts - .time_since_epoch()).count() / 1e9); + data->source_timestamp = fastrtps::rtps::Time_t(to_ticks(scheduled_write_ts) / 1e9); // Create topic on which this message should be published - DdsTopic channel_topic; - channel_topic.m_topic_name = it->channel->metadata[ROS2_TYPES] == "true" ? utils::mangle_if_ros_topic( - it->channel->topic) : it->channel->topic; - channel_topic.type_name = it->channel->metadata[ROS2_TYPES] == "true" ? utils::mangle_if_ros_type( - it->schema->name) : it->schema->name; + const bool is_topic_ros2_type = it.channel->metadata[ROS2_TYPES] == "true"; + const auto topic = create_topic_(it.channel->topic, it.schema->name, is_topic_ros2_type); + + const auto readers_it = readers_.find(topic); - auto readers_it = readers_.find(channel_topic); if (readers_it == readers_.end()) { logError(DDSREPLAYER_MCAP_READER_PARTICIPANT, - "Failed to replay message in topic " << channel_topic << ": topic not found, skipping..."); + "Failed to replay message in topic " << topic << ": topic not found, skipping..."); continue; } logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, - "Scheduling message to be replayed in topic " << readers_it->first << "."); + "Scheduling message to be replayed in topic " << topic << "."); - { - std::unique_lock lock(scheduling_cv_mtx_); - scheduling_cv_.wait_until( - lock, - scheduled_write_ts, - [&] - { - return stop_ || (utils::now() >= scheduled_write_ts); - }); - - if (stop_) - { - logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, - "Participant stopped while processing MCAP file."); - break; - } - } + // Wait until it's time to write the message + wait_until_timestamp_(scheduled_write_ts); logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, - "Replaying message in topic " << readers_it->first << "."); + "Replaying message in topic " << topic << "."); // Insert new data in internal reader queue readers_it->second->simulate_data_reception(std::move(data)); } - mcap_reader.close(); + close_file_(); +} + +void McapReaderParticipant::open_file_() +{ + const auto status = mcap_reader_.open(file_path_); + + if (status.code != mcap::StatusCode::Success) + { + throw utils::InitializationException(STR_ENTRY << "Failed to open MCAP."); + } +} + +void McapReaderParticipant::close_file_() +{ + mcap_reader_.close(); +} + +void McapReaderParticipant::read_mcap_summary_() +{ + // Read mcap summary: ForceScan method required for parsing metadata and attachments + const auto status = mcap_reader_.readSummary(mcap::ReadSummaryMethod::ForceScan, [](const mcap::Status& status) + { + logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, + "An error occurred while reading MCAP summary: " << status.message << "."); + }); + + if (status.code != mcap::StatusCode::Success) + { + throw utils::InitializationException(STR_ENTRY << "Failed to read summary."); + } + + // Check the recording version is correct + const auto metadata = mcap_reader_.metadata(); + std::string recording_version; + + if (metadata.find(VERSION_METADATA_NAME) != metadata.end()) + { + const auto version_metadata = metadata.at(VERSION_METADATA_NAME).metadata; + recording_version = version_metadata.at(VERSION_METADATA_RELEASE); + } + + if (recording_version != DDSRECORDER_PARTICIPANTS_VERSION_STRING) + { + logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, + "MCAP file generated with a different DDS Record & Replay version (" << recording_version << + ", current is " << DDSRECORDER_PARTICIPANTS_VERSION_STRING << "), incompatibilities might arise..."); + } +} + +mcap::LinearMessageView McapReaderParticipant::read_mcap_messages_() +{ + // NOTE: begin_time < end_time assertion already done in YAML module + const mcap::Timestamp begin_time = + configuration_->begin_time.is_set() ? + to_mcap_timestamp(configuration_->begin_time.get_reference()) : + 0; + + const mcap::Timestamp end_time = + configuration_->end_time.is_set() ? + to_mcap_timestamp(configuration_->end_time.get_reference()) : + mcap::MaxTime; + + mcap::ReadMessageOptions read_options(begin_time, end_time); + + // Iterate over messages ordered by incremental log_time + // NOTE: this corresponds to recording time (not publication) unless recorder configured with `log-publish-time: true` + read_options.readOrder = mcap::ReadMessageOptions::ReadOrder::LogTimeOrder; + + // Read messages + auto messages = mcap_reader_.readMessages([](const mcap::Status& status) + { + logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, + "An error occurred while reading MCAP messages: " << status.message << "."); + }, read_options); + + return messages; } } /* namespace participants */ diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index 1c45642e0..e682d71e1 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -12,36 +12,36 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include - -#include -#include -#include - -#include -#include +#include +#include +#include +#include #include +#include #include -#include #include #include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include +#include +#include +#include #include #include - -#include +#include +#include #include "DdsReplayer.hpp" @@ -49,53 +49,48 @@ namespace eprosima { namespace ddsrecorder { namespace replayer { -using namespace eprosima::ddspipe::core; -using namespace eprosima::ddspipe::core::types; -using namespace eprosima::ddspipe::participants; -using namespace eprosima::ddspipe::participants::rtps; -using namespace eprosima::ddsrecorder::participants; -using namespace eprosima::utils; - DdsReplayer::DdsReplayer( yaml::ReplayerConfiguration& configuration, std::string& input_file) + : configuration_(configuration) { - // Create Discovery Database - discovery_database_ = std::make_shared(); - // Create Payload Pool - payload_pool_ = std::make_shared(); + auto payload_pool = std::make_shared(); - // Create Thread Pool - thread_pool_ = std::make_shared(configuration.n_threads); - - // Create MCAP Reader Participant - mcap_reader_participant_ = std::make_shared( + // Create Reader Participant + reader_participant_ = std::make_shared( configuration.mcap_reader_configuration, - payload_pool_, + payload_pool, input_file); + // Create Discovery Database + auto discovery_database = std::make_shared(); + // Create Replayer Participant - replayer_participant_ = std::make_shared( + auto replayer_participant = std::make_shared( configuration.replayer_configuration, - payload_pool_, - discovery_database_); - replayer_participant_->init(); + payload_pool, + discovery_database); + + replayer_participant->init(); // Create and populate Participants Database - participants_database_ = - std::make_shared(); + auto participants_database = std::make_shared(); // Populate Participants Database - participants_database_->add_participant( - mcap_reader_participant_->id(), - mcap_reader_participant_ + participants_database->add_participant( + reader_participant_->id(), + reader_participant_ ); - participants_database_->add_participant( - replayer_participant_->id(), - replayer_participant_ + + participants_database->add_participant( + replayer_participant->id(), + replayer_participant ); + // Create Thread Pool + thread_pool_ = std::make_shared(configuration.n_threads); + if (configuration.replay_types) { // Create participant sending dynamic types @@ -113,15 +108,30 @@ DdsReplayer::DdsReplayer( "true"); } - // Generate builtin-topics from the topics in the MCAP file - configuration.ddspipe_configuration.builtin_topics = generate_builtin_topics_(configuration, input_file); + // Process the input file's summary + std::set> topics; + participants::DynamicTypesCollection types; + + reader_participant_->process_summary(topics, types); + + // Store the topics as built-in topics + for (const auto& topic : topics) + { + configuration.ddspipe_configuration.builtin_topics.insert(topic); + } + + // Register the dynamic types + const auto& registered_types = register_dynamic_types_(types); + + // Create writers to publish the dynamic types + create_dynamic_types_writers_(topics, registered_types); // Create DDS Pipe - pipe_ = std::make_unique( + pipe_ = std::make_unique( configuration.ddspipe_configuration, - discovery_database_, - payload_pool_, - participants_database_, + discovery_database, + payload_pool, + participants_database, thread_pool_); } @@ -137,7 +147,7 @@ utils::ReturnCode DdsReplayer::reload_configuration( void DdsReplayer::process_file() { - mcap_reader_participant_->process_file(); + reader_participant_->process_messages(); // Wait until all tasks have been consumed thread_pool_->wait_all_consumed(); @@ -149,139 +159,82 @@ void DdsReplayer::process_file() void DdsReplayer::stop() { - mcap_reader_participant_->stop(); + reader_participant_->stop(); pipe_->disable(); } -std::set> DdsReplayer::generate_builtin_topics_( - const yaml::ReplayerConfiguration& configuration, - std::string& input_file) +std::set DdsReplayer::register_dynamic_types_( + const participants::DynamicTypesCollection& dynamic_types) { - std::set> builtin_topics; + std::set registered_types{}; - mcap::McapReader mcap_reader; - - auto status = mcap_reader.open(input_file); - if (status.code != mcap::StatusCode::Success) + for (const auto& dynamic_type : dynamic_types.dynamic_types()) { - throw utils::InitializationException( - STR_ENTRY << "Failed MCAP read." - ); - } + // Deserialize type identifier + const auto type_identifier_str = utils::base64_decode(dynamic_type.type_information()); + const auto type_identifier = participants::Deserializer::deserialize(type_identifier_str); - // Scan and parse channels and schemas - const auto onProblem = [](const mcap::Status& status) - { - logWarning(DDSREPLAYER_REPLAYER, - "An error occurred while reading summary: " << status.message << "."); - }; - // Read mcap summary: ForceScan method required for parsing metadata and attachments - status = mcap_reader.readSummary(mcap::ReadSummaryMethod::ForceScan, onProblem); - if (status.code != mcap::StatusCode::Success) - { - throw utils::InitializationException( - STR_ENTRY << "Failed to read summary." - ); - } + // Deserialize type object + const auto type_object_str = utils::base64_decode(dynamic_type.type_object()); + const auto type_object = participants::Deserializer::deserialize(type_object_str); - // Fetch version metadata - auto metadatas = mcap_reader.metadata(); - std::string recording_version; - if (metadatas.count(VERSION_METADATA_NAME) != 0) - { - mcap::KeyValueMap version_metadata = metadatas[VERSION_METADATA_NAME].metadata; - recording_version = version_metadata[VERSION_METADATA_RELEASE]; - } - else - { - recording_version = "UNKNOWN"; - } + // Register in factory + fastrtps::types::TypeObjectFactory::get_instance()->add_type_object( + dynamic_type.type_name(), &type_identifier, &type_object); - if (recording_version != DDSRECORDER_PARTICIPANTS_VERSION_STRING) - { - logWarning(DDSREPLAYER_REPLAYER, - "MCAP file generated with a different DDS Record & Replay version (" << recording_version << - ", current is " << DDSRECORDER_PARTICIPANTS_VERSION_STRING << "), incompatibilities might arise..."); + registered_types.insert(dynamic_type.type_name()); } - // Fetch dynamic types attachment - auto attachments = mcap_reader.attachments(); - mcap::Attachment dynamic_attachment = attachments[DYNAMIC_TYPES_ATTACHMENT_NAME]; - - // Deserialize dynamic types collection using CDR - const std::string dynamic_types_str(reinterpret_cast(dynamic_attachment.data), dynamic_attachment.dataSize); - const auto dynamic_types = Deserializer::deserialize(dynamic_types_str); + return registered_types; +} - if (configuration.replay_types) +void DdsReplayer::create_dynamic_types_writers_( + const std::set>& topics, + const std::set& registered_types) +{ + for (const auto& topic : topics) { - // Register in factory dynamic types from attachment - for (auto& dynamic_type : dynamic_types.dynamic_types()) + if (registered_types.find(topic->type_name) == registered_types.end()) { - register_dynamic_type_(dynamic_type); + continue; } - } - - auto channels = mcap_reader.channels(); - auto schemas = mcap_reader.schemas(); - - for (auto it = channels.begin(); it != channels.end(); it++) - { - std::string topic_name = it->second->metadata[ROS2_TYPES] == "true" ? utils::mangle_if_ros_topic( - it->second->topic) : it->second->topic; - std::string type_name = it->second->metadata[ROS2_TYPES] == "true" ? utils::mangle_if_ros_type( - schemas[it->second->schemaId]->name) : schemas[it->second->schemaId]->name; // TODO: assert exists beforehand - auto channel_topic = utils::Heritable::make_heritable(); - channel_topic->m_topic_name = topic_name; - channel_topic->type_name = type_name; - channel_topic->type_ids = registered_types_[type_name]; + // Make a copy of the Topic to customize it according to the Participant's configured QoS. + utils::Heritable topic_copy = topic->copy(); - // Apply the QoS stored in the MCAP file as if they were the discovered QoS. - channel_topic->topic_qos.set_qos( - Deserializer::deserialize(it->second->metadata[QOS_SERIALIZATION_QOS]), - utils::FuzzyLevelValues::fuzzy_level_fuzzy); - - // Insert channel topic in builtin topics list - builtin_topics.insert(channel_topic); - - if (configuration.replay_types && registered_types_.count(type_name) != 0) + // Apply the Manual Topics for this participant. + for (const auto& [manual_topic, _] : configuration_.ddspipe_configuration.get_manual_topics(*topic)) { - // Make a copy of the Topic to customize it according to the Participant's configured QoS. - utils::Heritable topic = channel_topic->copy(); - - // Apply the Manual Topics for this participant. - for (const auto& manual_topic : configuration.ddspipe_configuration.get_manual_topics(*channel_topic)) - { - topic->topic_qos.set_qos(manual_topic.first->topic_qos, utils::FuzzyLevelValues::fuzzy_level_hard); - } + topic_copy->topic_qos.set_qos(manual_topic->topic_qos, utils::FuzzyLevelValues::fuzzy_level_hard); } - } - mcap_reader.close(); - - return builtin_topics; + // Create Datawriter in this topic so dynamic type can be shared in EDP + // TODO: Avoid creating the dynamic writer when the topic is not allowed. + create_dynamic_type_writer_(topic_copy); + } } -void DdsReplayer::register_dynamic_type_( - const ddsrecorder::participants::DynamicType& dynamic_type) +void DdsReplayer::create_dynamic_type_writer_( + utils::Heritable topic) { // Decode type identifer and object strings - std::string typeid_str = utils::base64_decode(dynamic_type.type_information()); - std::string typeobj_str = utils::base64_decode(dynamic_type.type_object()); + const auto type_identifier_str = utils::base64_decode(dynamic_type.type_information()); + const auto type_object_str = utils::base64_decode(dynamic_type.type_object()); // Deserialize type identifer and object strings fastdds::dds::xtypes::TypeIdentifier type_identifier = - Deserializer::deserialize(typeid_str); + Deserializer::deserialize(type_identifier_str); fastdds::dds::xtypes::TypeObject type_object = - Deserializer::deserialize(typeobj_str); + Deserializer::deserialize(type_object_str); // Create a TypeIdentifierPair to use in register_type_identifier fastdds::dds::xtypes::TypeIdentifierPair type_identifiers; type_identifiers.type_identifier1(type_identifier); - // // Register in factory - if (fastdds::dds::RETCODE_OK != fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().register_type_object( - type_object, type_identifiers)) + // Register in factory + auto& factory = fastdds::dds::DomainParticipantFactory::get_instance(); + + if (fastdds::dds::RETCODE_OK != factory->type_object_registry().register_type_object(type_object, type_identifiers)) { logWarning(DDSREPLAYER_REPLAYER, "Failed to register " << dynamic_type.type_name() << " DynamicType."); diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp index 031223625..bd2f3d133 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp @@ -14,8 +14,10 @@ #pragma once +#include #include #include +#include #include #include @@ -27,11 +29,8 @@ #include #include -#include -#include -#include -#include -#include +#include +#include #include #include @@ -52,12 +51,12 @@ class DdsReplayer public: /** - * DdsRecorder constructor by required values. + * @brief DdsRecorder constructor by required values. * - * Creates DdsRecorder instance with given configuration, initial state and mcap file name. + * Creates a DdsRecorder instance with a configuration, an initial state, and input file name. * * @param configuration: Structure encapsulating all replayer configuration options. - * @param input_file: MCAP file containing the messages to be played back. + * @param input_file: File containing the DDS data to be played back. * * @throw utils::InitializationException if failed to create dynamic participant/publisher. */ @@ -66,14 +65,22 @@ class DdsReplayer std::string& input_file); /** - * @brief Destructor - * - * Removes all DDS resources created via the \c fastdds::DomainParticipantFactory + * @brief DdsReplayer destructor. */ ~DdsReplayer(); /** - * Reconfigure the Replayer with the new configuration. + * @brief Process the input file. + */ + void process_file(); + + /** + * @brief Stop the Replayer. + */ + void stop(); + + /** + * @brief Reconfigure the Replayer with the new configuration. * * @param new_configuration: The configuration to replace the previous configuration with. * @@ -83,63 +90,46 @@ class DdsReplayer utils::ReturnCode reload_configuration( const yaml::ReplayerConfiguration& new_configuration); - //! Process input MCAP file - void process_file(); - - //! Stop replayer instance - void stop(); - protected: /** - * @brief Generate a builtin-topics list by combining the channels information within the MCAP file and the - * optional builtin-topics list provided via YAML configuration file. + * @brief Register the dynamic types in the \c dyn_participant_. * - * @param configuration: replayer config containing, among other specs, the YAML-provided builtin-topics list. - * @param input_file: path to the input MCAP file. - * - * @return generated builtin-topics list (set). - * @throw utils::InitializationException if failed to read mcap file. + * @param dynamic_types: The dynamic types to be registered. + * @return The set of registered types. */ - std::set> generate_builtin_topics_( - const yaml::ReplayerConfiguration& configuration, - std::string& input_file); + std::set register_dynamic_types_( + const participants::DynamicTypesCollection& dynamic_types); /** - * @brief Deserialize and register \c dynamic_type into \c TypeObjectFactory . + * @brief Create the dynamic types' writers for \c topics. * - * @param dynamic_type: serialized dynamic type to be registered. + * @param topics: The topics to create the writers for. + * @param registered_types: The types to create the writers for. */ - void register_dynamic_type_( - const ddsrecorder::participants::DynamicType& dynamic_type); + void create_dynamic_types_writers_( + const std::set>& topics, + const std::set& registered_types); /** - * @brief Create DDS DataWriter in given topic to send associated dynamic type information to applications relying - * on dynamic types (e.g. applications which dynamically create DataReaders every time a participant receives a - * dynamic type via on_type_discovery/on_type_information_received callbacks). + * @brief Create the dynamic types' writer for \c topic. * - * @param topic: topic on which DataWriter is created. + * @param topic: The topic to create the writer for. */ - void create_dynamic_writer_( + void create_dynamic_type_writer_( utils::Heritable topic); + //! Replayer Configuration + const yaml::ReplayerConfiguration configuration_; + //! Payload Pool std::shared_ptr payload_pool_; //! Thread Pool std::shared_ptr thread_pool_; - //! Discovery Database - std::shared_ptr discovery_database_; - - //! Participants Database - std::shared_ptr participants_database_; - - //! Replayer Participant - std::shared_ptr replayer_participant_; - - //! MCAP Reader Participant - std::shared_ptr mcap_reader_participant_; + //! Reader Participant + std::shared_ptr reader_participant_; //! DDS Pipe std::unique_ptr pipe_; From 9ebbdfd851c1938e9142d3385220968d254b7a45 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 24 May 2024 14:06:12 +0200 Subject: [PATCH 24/52] PoC: replay data from SQLite Signed-off-by: tempate --- .../replayer/SqlReaderParticipant.hpp | 144 +++++++++ .../src/cpp/replayer/SqlReaderParticipant.cpp | 282 ++++++++++++++++++ ddsreplayer/src/cpp/tool/DdsReplayer.cpp | 19 +- 3 files changed, 441 insertions(+), 4 deletions(-) create mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp create mode 100644 ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp new file mode 100644 index 000000000..4cccb6bd1 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp @@ -0,0 +1,144 @@ +// Copyright 2024 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. + +#pragma once + +#include +#include +#include + +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include +#else + #include +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +/** + * Participant that reads MCAP files and passes its messages to other DDS Pipe participants. + * + * @implements BaseReaderParticipant + */ +class SqlReaderParticipant : public BaseReaderParticipant +{ +public: + + /** + * SqlReaderParticipant constructor by required values. + * + * Creates SqlReaderParticipant instance with given configuration, payload pool and input file path. + * + * @param config: Structure encapsulating all configuration options. + * @param payload_pool: Owner of every payload contained in sent messages. + * @param file_path: Path to the MCAP file with the messages to be read and sent. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + SqlReaderParticipant( + const std::shared_ptr& configuration, + const std::shared_ptr& payload_pool, + const std::string& file_path); + + /** + * @brief SqlReaderParticipant destructor. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + ~SqlReaderParticipant(); + + /** + * @brief Process the topics and the types stored in the SQLite database. + * + * @param topics: Set of topics to be filled with the information from the SQLite database. + * @param types: DynamicTypesCollection instance to be filled with the types information from the SQLite database. + */ + DDSRECORDER_PARTICIPANTS_DllAPI + void process_summary( + std::set>& topics, + DynamicTypesCollection& types) override; + + /** + * @brief Process the messages stored in the SQLite database. + * + * Reads and sends messages sequentially (according to timestamp). + */ + DDSRECORDER_PARTICIPANTS_DllAPI + void process_messages() override; + +protected: + + /** + * @brief Open the SQLite file. + */ + void open_file_(); + + /** + * @brief Close the SQLite file. + */ + void close_file_(); + + /** + * @brief Execute a SQL statement. + * + * @param statement: SQL statement to be executed. + * @param process_row: Function to be called for each row of the result. + */ + void exec_sql_statement_( + const std::string& statement, + const std::function& process_row); + + /** + * @brief Get the \c DdsTopic for \c topic_name. + * + * If the topic is in the cache, return it. + * If not, find the topic's type in the database, create a topic, and store it in the cache. + * + * @param topic_name: Name of the topic to be found. + * @return \c DdsTopic instance for \c topic_name. + */ + ddspipe::core::types::DdsTopic find_topic_( + const std::string& topic_name); + + /** + * @brief Find the type of the topic with name \c topic_name. + * + * @param topic_name: Name of the topic to find its type. + * @return Type of the topic with name \c topic_name. + */ + std::string find_type_of_topic_( + const std::string& topic_name); + + // Database + sqlite3* database_; + + // Topics cache + std::map topics_; +}; + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp new file mode 100644 index 000000000..82cc81682 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp @@ -0,0 +1,282 @@ +// Copyright 2024 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 SqlReaderParticipant.cpp + */ + +#include +#include + +#include + +#include +#include +#include +#include + +#include + +#include + +namespace eprosima { +namespace ddsrecorder { +namespace participants { + +SqlReaderParticipant::SqlReaderParticipant( + const std::shared_ptr& configuration, + const std::shared_ptr& payload_pool, + const std::string& file_path) + : BaseReaderParticipant(configuration, payload_pool, file_path) +{ +} + +SqlReaderParticipant::~SqlReaderParticipant() +{ +} + +void SqlReaderParticipant::process_summary( + std::set>& topics, + DynamicTypesCollection& types) +{ + open_file_(); + + exec_sql_statement_("SELECT * FROM Topics;", [&](sqlite3_stmt* stmt) + { + // Create a DdsTopic to publish the message + const std::string topic_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); + const std::string type_name = reinterpret_cast(sqlite3_column_text(stmt, 1)); + const auto topic = utils::Heritable::make_heritable( + create_topic_(topic_name, type_name, true)); + + // Apply the QoS stored in the MCAP file as if they were the discovered QoS. + const auto topic_qos_str = reinterpret_cast(sqlite3_column_text(stmt, 2)); + const auto topic_qos = Serializer::deserialize(topic_qos_str); + + topic->topic_qos.set_qos(topic_qos, utils::FuzzyLevelValues::fuzzy_level_fuzzy); + + // Store the topic in the cache + topics_[topic_name] = *topic; + + // Store the topic in the set + topics.insert(utils::Heritable::make_heritable(topic)); + }); + + exec_sql_statement_("SELECT * FROM Types;", [&](sqlite3_stmt* stmt) + { + // Read the type data from the database + const std::string type_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); + const std::string type_information = reinterpret_cast(sqlite3_column_text(stmt, 1)); + const std::string type_object = reinterpret_cast(sqlite3_column_text(stmt, 2)); + + // Create a DynamicType to store the type data + DynamicType type; + + type.type_name(type_name); + type.type_information(type_information); + type.type_object(type_object); + + // Store the DynamicType in the DynamicTypesCollection + types.dynamic_types().push_back(type); + }); + + close_file_(); +} + +void SqlReaderParticipant::process_messages() +{ + open_file_(); + + exec_sql_statement_("SELECT * FROM Messages ORDER BY publish_time;", [&](sqlite3_stmt* stmt) + { + // Create a DdsTopic to publish the message + const std::string topic_name = reinterpret_cast(sqlite3_column_text(stmt, 3)); + const auto topic = find_topic_(topic_name); + + // Find the reader for the topic + if (readers_.find(topic) == readers_.end()) + { + logError(DDSREPLAYER_MCAP_READER_PARTICIPANT, + "Failed to replay message in topic " << topic << ": topic not found, skipping..."); + return; + } + + const auto reader = readers_[topic]; + + // Create a RtpsPayloadData from the raw data + const auto raw_data = sqlite3_column_blob(stmt, 1); + const auto raw_data_size = sqlite3_column_int(stmt, 2); + auto data = create_payload_(raw_data, raw_data_size); + + logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, + "Scheduling message to be replayed in topic " << topic << "."); + + // Wait until it's time to write the message + wait_until_timestamp_(utils::now()); + + logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, "Replaying message in topic " << topic << "."); + + // Insert new data in internal reader queue + reader->simulate_data_reception(std::move(data)); + }); + + close_file_(); +} + +void SqlReaderParticipant::open_file_() +{ + const auto ret = sqlite3_open(file_path_.c_str(), &database_); + + if (ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to open SQL file " << file_path_ + << " for reading: " << sqlite3_errmsg(database_); + sqlite3_close(database_); + + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_OPEN | " << error_msg); + throw utils::InitializationException(error_msg); + } +} + +void SqlReaderParticipant::close_file_() +{ + sqlite3_close(database_); +} + +ddspipe::core::types::DdsTopic SqlReaderParticipant::find_topic_( + const std::string& topic_name) +{ + // Check if the topic is in the cache + if (topics_.find(topic_name) != topics_.end()) + { + return topics_[topic_name]; + } + + const auto type_name = find_type_of_topic_(topic_name); + + // Create the DdsTopic + const auto topic = create_topic_(topic_name, type_name, false); + + // Store the topic in the cache + topics_[topic_name] = topic; + + return topic; +} + +std::string SqlReaderParticipant::find_type_of_topic_( + const std::string& topic_name) +{ + // Find the type of the Topic with name topic_name + const char* select_statement = R"( + SELECT type FROM Topics + WHERE name = ?; + )"; + + sqlite3_stmt* statement; + const auto prep_ret = sqlite3_prepare_v2(database_, select_statement, -1, &statement, nullptr); + + if (prep_ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement to read messages: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); + + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + + const auto bind_ret = sqlite3_bind_text(statement, 1, topic_name.c_str(), -1, SQLITE_STATIC); + + if (bind_ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to bind SQL statement to read messages: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); + + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + + std::string type_name; + + switch (sqlite3_step(statement)) + { + case SQLITE_ROW: + { + // Store the type in the topic + type_name = reinterpret_cast(sqlite3_column_text(statement, 0)); + break; + } + case SQLITE_DONE: + { + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, + "FAIL_SQL_READ | No type found for topic '" << topic_name << "'."); + break; + } + default: + { + const std::string error_msg = utils::Formatter() << "Failed to execute query: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); + + // Maybe we should finalize statements on top? + + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + } + + return type_name; +} + +void SqlReaderParticipant::exec_sql_statement_( + const std::string& statement, + const std::function& process_row) +{ + sqlite3_stmt* stmt; + + const auto ret = sqlite3_prepare_v2(database_, statement.c_str(), -1, &stmt, nullptr); + + if (ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement: " + << sqlite3_errmsg(database_); + sqlite3_finalize(stmt); + + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); + throw std::runtime_error(error_msg); + } + + std::unique_ptr stmt_guard(stmt, sqlite3_finalize); + + int step_ret; + + while ((step_ret = sqlite3_step(stmt)) == SQLITE_ROW) + { + process_row(stmt); + } + + if (step_ret != SQLITE_DONE) + { + const std::string error_msg = utils::Formatter() << "Failed to fetch data: " + << sqlite3_errmsg(database_); + + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); + throw std::runtime_error(error_msg); + } +} + +} /* namespace participants */ +} /* namespace ddsrecorder */ +} /* namespace eprosima */ diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index e682d71e1..df57ca575 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include "DdsReplayer.hpp" @@ -58,10 +59,20 @@ DdsReplayer::DdsReplayer( auto payload_pool = std::make_shared(); // Create Reader Participant - reader_participant_ = std::make_shared( - configuration.mcap_reader_configuration, - payload_pool, - input_file); + if (input_file.size() >= 3 && input_file.substr(input_file.size() - 3) == ".db") + { + reader_participant_ = std::make_shared( + configuration.mcap_reader_configuration, + payload_pool, + input_file); + } + else + { + reader_participant_ = std::make_shared( + configuration.mcap_reader_configuration, + payload_pool, + input_file); + } // Create Discovery Database auto discovery_database = std::make_shared(); From 155cbb6ed7a0fa82aba997158d16076bd368d866 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 24 May 2024 14:08:41 +0200 Subject: [PATCH 25/52] Avoid creating a payload when replaying a message in a topic without a reader Signed-off-by: tempate --- .../cpp/replayer/McapReaderParticipant.cpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp index 1c42006a3..78afaede9 100644 --- a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp @@ -142,19 +142,6 @@ void McapReaderParticipant::process_messages() // Replay messages for (const auto& it : messages) { - // Create RTPS data - auto data = create_payload_(it.message.data, it.message.dataSize); - - // Set publication delay from original log time and configured playback rate - auto delay = to_std_timestamp(it.message.logTime) - first_message_timestamp; - auto scheduled_write_ts = - std::chrono::time_point_cast(initial_timestamp + - std::chrono::duration_cast(delay / configuration_->rate)); - - // Set source timestamp - // NOTE: this is important for QoS such as LifespanQosPolicy - data->source_timestamp = fastrtps::rtps::Time_t(to_ticks(scheduled_write_ts) / 1e9); - // Create topic on which this message should be published const bool is_topic_ros2_type = it.channel->metadata[ROS2_TYPES] == "true"; const auto topic = create_topic_(it.channel->topic, it.schema->name, is_topic_ros2_type); @@ -171,6 +158,19 @@ void McapReaderParticipant::process_messages() logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, "Scheduling message to be replayed in topic " << topic << "."); + // Set publication delay from original log time and configured playback rate + auto delay = to_std_timestamp(it.message.logTime) - first_message_timestamp; + auto scheduled_write_ts = + std::chrono::time_point_cast(initial_timestamp + + std::chrono::duration_cast(delay / configuration_->rate)); + + // Create RTPS data + auto data = create_payload_(it.message.data, it.message.dataSize); + + // Set source timestamp + // NOTE: this is important for QoS such as LifespanQosPolicy + data->source_timestamp = fastrtps::rtps::Time_t(to_ticks(scheduled_write_ts) / 1e9); + // Wait until it's time to write the message wait_until_timestamp_(scheduled_write_ts); From 1e275c38fb51acc4b94199329bcfbbd0d8681502 Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 27 May 2024 15:25:03 +0200 Subject: [PATCH 26/52] Strip MCAP message processing from the DdsReplayer Signed-off-by: tempate --- .../replayer/BaseReaderParticipant.hpp | 13 +++++++++++ .../cpp/replayer/BaseReaderParticipant.cpp | 23 +++++++++++++++++++ .../cpp/replayer/McapReaderParticipant.cpp | 19 +-------------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp index c49bce2e0..b082ef714 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -150,6 +151,18 @@ class BaseReaderParticipant : public ddspipe::core::IParticipant const std::string& type_name, const bool is_ros2_type); + /** + * @brief Given a fuzzy timestamp, return the timestamp to start replaying. + * + * It returns the current timestamp if \c start_replay_time is not set or if it is in the past. + * Otherwise, it returns \c start_replay_time. + *] + * @param start_replay_time: Fuzzy timestamp to start replaying. + * @return The timestamp to start replaying. + */ + static utils::Timestamp when_to_start_replay_( + const utils::Fuzzy& start_replay_time); + /** * @brief Wait until timestamp is reached. * diff --git a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp index 6af1d0062..ffcede2c7 100644 --- a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -147,6 +148,28 @@ ddspipe::core::types::DdsTopic BaseReaderParticipant::create_topic_( return topic; } +utils::Timestamp BaseReaderParticipant::when_to_start_replay_( + const utils::Fuzzy& start_replay_time) +{ + const auto now = utils::now(); + + if (!start_replay_time.is_set()) + { + return now; + } + + const auto time = start_replay_time.get_reference(); + + if (time < now) + { + logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, + "Provided start-replay-time already expired, starting immediately..."); + return now; + } + + return time; +} + void BaseReaderParticipant::wait_until_timestamp_( const utils::Timestamp& timestamp) { diff --git a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp index 78afaede9..7889b070e 100644 --- a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp @@ -120,24 +120,7 @@ void McapReaderParticipant::process_messages() const auto first_message_timestamp = to_std_timestamp(messages.begin()->message.logTime); // Define the time to start replaying messages - const auto now = utils::now(); - utils::Timestamp initial_timestamp; - - if (configuration_->start_replay_time.is_set()) - { - initial_timestamp = configuration_->start_replay_time.get_reference(); - - if (initial_timestamp < now) - { - logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, - "Provided start-replay-time already expired, starting immediately..."); - initial_timestamp = now; - } - } - else - { - initial_timestamp = now; - } + const auto initial_timestamp = when_to_start_replay_(configuration_->start_replay_time); // Replay messages for (const auto& it : messages) From 25bb91fe47f03215ec9fb6e61bbbf66ac4cabead Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 27 May 2024 15:27:01 +0200 Subject: [PATCH 27/52] Replay messages according to their log_time Signed-off-by: tempate --- .../replayer/SqlReaderParticipant.hpp | 2 + .../src/cpp/replayer/SqlReaderParticipant.cpp | 140 +++++++++--------- 2 files changed, 76 insertions(+), 66 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp index 4cccb6bd1..c1bbc3bf1 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp @@ -105,10 +105,12 @@ class SqlReaderParticipant : public BaseReaderParticipant * @brief Execute a SQL statement. * * @param statement: SQL statement to be executed. + * @param bind_values: Values to be bound to the statement. * @param process_row: Function to be called for each row of the result. */ void exec_sql_statement_( const std::string& statement, + const std::vector& bind_values, const std::function& process_row); /** diff --git a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp index 82cc81682..ae270f090 100644 --- a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp @@ -28,8 +28,10 @@ #include +#include +#include +#include #include - namespace eprosima { namespace ddsrecorder { namespace participants { @@ -52,7 +54,7 @@ void SqlReaderParticipant::process_summary( { open_file_(); - exec_sql_statement_("SELECT * FROM Topics;", [&](sqlite3_stmt* stmt) + exec_sql_statement_("SELECT name, type, qos FROM Topics;", {}, [&](sqlite3_stmt* stmt) { // Create a DdsTopic to publish the message const std::string topic_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); @@ -70,10 +72,10 @@ void SqlReaderParticipant::process_summary( topics_[topic_name] = *topic; // Store the topic in the set - topics.insert(utils::Heritable::make_heritable(topic)); + topics.insert(topic); }); - exec_sql_statement_("SELECT * FROM Types;", [&](sqlite3_stmt* stmt) + exec_sql_statement_("SELECT name, information, object FROM Types;", {}, [&](sqlite3_stmt* stmt) { // Read the type data from the database const std::string type_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); @@ -98,10 +100,33 @@ void SqlReaderParticipant::process_messages() { open_file_(); - exec_sql_statement_("SELECT * FROM Messages ORDER BY publish_time;", [&](sqlite3_stmt* stmt) + // Define the time to start replaying messages + const auto initial_timestamp = when_to_start_replay_(configuration_->start_replay_time); + + const auto begin_time = to_sql_timestamp( + configuration_->begin_time.is_set() ? + configuration_->begin_time.get_reference() : + utils::the_beginning_of_time()); + + const auto end_time = to_sql_timestamp( + configuration_->end_time.is_set() ? + configuration_->end_time.get_reference() : + utils::the_end_of_time()); + + exec_sql_statement_( + "SELECT log_time, topic, data, data_size FROM Messages " + "WHERE log_time >= ? AND log_time <= ? " + "ORDER BY log_time;", + {begin_time, end_time}, + [&](sqlite3_stmt* stmt) { + const auto log_time = to_std_timestamp(reinterpret_cast(sqlite3_column_text(stmt, 0))); + + // Store the timestamp of the first recorded message + static utils::Timestamp first_message_timestamp = log_time; + // Create a DdsTopic to publish the message - const std::string topic_name = reinterpret_cast(sqlite3_column_text(stmt, 3)); + const std::string topic_name = reinterpret_cast(sqlite3_column_text(stmt, 1)); const auto topic = find_topic_(topic_name); // Find the reader for the topic @@ -112,23 +137,32 @@ void SqlReaderParticipant::process_messages() return; } - const auto reader = readers_[topic]; + logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, + "Scheduling message to be replayed in topic " << topic << "."); + + // Set publication delay from original log time and configured playback rate + const auto delay = (log_time - first_message_timestamp) / configuration_->rate; + const auto delay_ns = std::chrono::duration_cast(delay); + const auto time_to_write = + std::chrono::time_point_cast(initial_timestamp + delay_ns); // Create a RtpsPayloadData from the raw data - const auto raw_data = sqlite3_column_blob(stmt, 1); - const auto raw_data_size = sqlite3_column_int(stmt, 2); + const auto raw_data = sqlite3_column_blob(stmt, 2); + const auto raw_data_size = sqlite3_column_int(stmt, 3); auto data = create_payload_(raw_data, raw_data_size); - logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, - "Scheduling message to be replayed in topic " << topic << "."); + // Set source timestamp + // NOTE: this is important for QoS such as LifespanQosPolicy + data->source_timestamp = fastrtps::rtps::Time_t(to_ticks(time_to_write) / 1e9); // Wait until it's time to write the message - wait_until_timestamp_(utils::now()); + wait_until_timestamp_(time_to_write); - logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, "Replaying message in topic " << topic << "."); + logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, + "Replaying message in topic " << topic << "."); // Insert new data in internal reader queue - reader->simulate_data_reception(std::move(data)); + readers_[topic]->simulate_data_reception(std::move(data)); }); close_file_(); @@ -177,75 +211,32 @@ ddspipe::core::types::DdsTopic SqlReaderParticipant::find_topic_( std::string SqlReaderParticipant::find_type_of_topic_( const std::string& topic_name) { - // Find the type of the Topic with name topic_name - const char* select_statement = R"( - SELECT type FROM Topics - WHERE name = ?; - )"; - - sqlite3_stmt* statement; - const auto prep_ret = sqlite3_prepare_v2(database_, select_statement, -1, &statement, nullptr); - - if (prep_ret != SQLITE_OK) - { - const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement to read messages: " - << sqlite3_errmsg(database_); - sqlite3_finalize(statement); - - logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); - throw utils::InconsistencyException(error_msg); - } - - const auto bind_ret = sqlite3_bind_text(statement, 1, topic_name.c_str(), -1, SQLITE_STATIC); - - if (bind_ret != SQLITE_OK) - { - const std::string error_msg = utils::Formatter() << "Failed to bind SQL statement to read messages: " - << sqlite3_errmsg(database_); - sqlite3_finalize(statement); - - logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); - throw utils::InconsistencyException(error_msg); - } - std::string type_name; - switch (sqlite3_step(statement)) + exec_sql_statement_("SELECT type FROM Topics WHERE name = ?;", {topic_name}, [&](sqlite3_stmt* stmt) { - case SQLITE_ROW: - { - // Store the type in the topic - type_name = reinterpret_cast(sqlite3_column_text(statement, 0)); - break; - } - case SQLITE_DONE: + if (!type_name.empty()) { - logError(DDSREPLAYER_SQL_READER_PARTICIPANT, - "FAIL_SQL_READ | No type found for topic '" << topic_name << "'."); - break; - } - default: - { - const std::string error_msg = utils::Formatter() << "Failed to execute query: " - << sqlite3_errmsg(database_); - sqlite3_finalize(statement); - - // Maybe we should finalize statements on top? + const std::string error_msg = utils::Formatter() << "Multiple types found for topic " << topic_name; logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); - throw utils::InconsistencyException(error_msg); + throw std::runtime_error(error_msg); } - } + + type_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); + }); return type_name; } void SqlReaderParticipant::exec_sql_statement_( const std::string& statement, + const std::vector& bind_values, const std::function& process_row) { sqlite3_stmt* stmt; + // Prepare the SQL statement const auto ret = sqlite3_prepare_v2(database_, statement.c_str(), -1, &stmt, nullptr); if (ret != SQLITE_OK) @@ -258,8 +249,25 @@ void SqlReaderParticipant::exec_sql_statement_( throw std::runtime_error(error_msg); } + // Guard the statement to ensure it's always finalized std::unique_ptr stmt_guard(stmt, sqlite3_finalize); + // Bind the values to the statement + for (int i = 0; i < (int) bind_values.size(); i++) + { + const auto bind_ret = sqlite3_bind_text(stmt, i+1, bind_values[i].c_str(), -1, SQLITE_STATIC); + + if (bind_ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to bind SQL statement to read messages: " + << sqlite3_errmsg(database_); + + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + } + + // Step through the statement and process the rows int step_ret; while ((step_ret = sqlite3_step(stmt)) == SQLITE_ROW) From cfecd23519ee0222ea5572ae3b0b73f4aa450987 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 28 May 2024 14:52:24 +0200 Subject: [PATCH 28/52] Merge Serializer and Deserializer into a single class Signed-off-by: tempate --- .../serialize/Serializer.hpp} | 29 ++++- .../serialize}/impl/Serializer.ipp | 58 ++++++++-- .../recorder/mcap/McapWriter.hpp | 4 +- .../recorder/output/Serializer.hpp | 102 ------------------ .../replayer/impl/Deserializer.ipp | 74 ------------- .../serialize/Serializer.cpp} | 64 ++++++++--- .../src/cpp/recorder/mcap/McapHandler.cpp | 4 +- .../src/cpp/recorder/mcap/McapWriter.cpp | 32 +++--- .../src/cpp/recorder/output/BaseHandler.cpp | 2 +- .../src/cpp/recorder/output/Serializer.cpp | 73 ------------- .../src/cpp/recorder/sql/SqlHandler.cpp | 2 +- .../src/cpp/recorder/sql/SqlWriter.cpp | 2 +- .../cpp/replayer/McapReaderParticipant.cpp | 6 +- .../src/cpp/replayer/SqlReaderParticipant.cpp | 2 +- ddsreplayer/src/cpp/tool/DdsReplayer.cpp | 6 +- 15 files changed, 155 insertions(+), 305 deletions(-) rename ddsrecorder_participants/include/ddsrecorder_participants/{replayer/Deserializer.hpp => common/serialize/Serializer.hpp} (64%) rename ddsrecorder_participants/include/ddsrecorder_participants/{recorder/output => common/serialize}/impl/Serializer.ipp (65%) delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/Serializer.hpp delete mode 100644 ddsrecorder_participants/include/ddsrecorder_participants/replayer/impl/Deserializer.ipp rename ddsrecorder_participants/src/cpp/{replayer/Deserializer.cpp => common/serialize/Serializer.cpp} (66%) delete mode 100644 ddsrecorder_participants/src/cpp/recorder/output/Serializer.cpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/Deserializer.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/Serializer.hpp similarity index 64% rename from ddsrecorder_participants/include/ddsrecorder_participants/replayer/Deserializer.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/Serializer.hpp index 0e4af50b2..5770f4bb1 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/Deserializer.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/Serializer.hpp @@ -13,7 +13,7 @@ // limitations under the License. /** - * @file Deserializer.hpp + * @file Serializer.hpp */ #pragma once @@ -27,12 +27,22 @@ namespace ddsrecorder { namespace participants { /** - * Class to deserialize different types of data. + * Class to serialize and deserialize different types of data. */ -class DDSRECORDER_PARTICIPANTS_DllAPI Deserializer +class DDSRECORDER_PARTICIPANTS_DllAPI Serializer { public: + /** + * @brief Serialize \c object into a string. + * + * @param [in] object Object to serialize + * @return Serialized object string + */ + template + static std::string serialize( + const T& object); + /** * @brief Deserialize \c serialized_str into \c T. * @@ -45,6 +55,17 @@ class DDSRECORDER_PARTICIPANTS_DllAPI Deserializer protected: + /** + * @brief Serialize a \c TypeObject or a \c TypeIdentifier into a \c SerializedPayload_t. + * + * @param [in] object \c TypeObject or \c TypeIdentifier to serialize + * @return \c SerializedPayload_t with the serialization + */ + template + static std::string type_data_to_type_str_( + const T& data, + const size_t size); + /** * @brief Deserialize \c type_str into a \c TypeObject or a \c TypeIdentifier. * @@ -60,4 +81,4 @@ class DDSRECORDER_PARTICIPANTS_DllAPI Deserializer } /* namespace ddsrecorder */ } /* namespace eprosima */ -#include +#include diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/impl/Serializer.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/impl/Serializer.ipp similarity index 65% rename from ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/impl/Serializer.ipp rename to ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/impl/Serializer.ipp index 1f543555c..4f4e264c8 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/impl/Serializer.ipp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/impl/Serializer.ipp @@ -1,4 +1,4 @@ -// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2024 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. @@ -13,33 +13,28 @@ // limitations under the License. /** - * @file Serializer.cpp + * @file Serializer.ipp */ -#include +#include #include #include #include -#include -#include #include #include #include #include -#include - -#include -#include namespace eprosima { namespace ddsrecorder { namespace participants { + template -std::string Serializer::type_data_to_str_( +std::string Serializer::type_data_to_type_str_( const T& type_data) { // Reserve payload and create buffer @@ -107,6 +102,49 @@ std::string Serializer::type_data_to_str_( return type_data_str; } +template +T Serializer::type_str_to_type_data_( + const std::string& type_str) +{ + // Create CDR message from string + // NOTE: Use 0 length to avoid allocation + auto cdr_message = std::make_unique(0); + + cdr_message->buffer = (unsigned char*)reinterpret_cast(type_str.c_str()); + cdr_message->length = type_str.length(); +#if __BIG_ENDIAN__ + cdr_message->msg_endian = fastdds::rtps::BIGEND; +#else + cdr_message->msg_endian = fastdds::rtps::LITTLEEND; +#endif // if __BIG_ENDIAN__ + + // Reserve payload and create buffer + const auto parameter_length = cdr_message->length; + fastdds::rtps::SerializedPayload_t payload(parameter_length); + fastcdr::FastBuffer fastbuffer((char*)payload.data, parameter_length); + + // Read data + if (cdr_message != nullptr && cdr_message->length >= cdr_message->pos + parameter_length && parameter_length > 0 && payload.data != nullptr) + { + memcpy(payload.data, &cdr_message->buffer[cdr_message->pos], parameter_length); + cdr_message->pos += parameter_length; + } + + // Create CDR deserializer + fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::CdrVersion::XCDRv2); + payload.encapsulation = deser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + + // Deserialize + T type_data; + fastcdr::deserialize(deser, type_data); + + // Delete CDR message + // NOTE: set wraps attribute to avoid double free (buffer released by string on destruction) + cdr_message->wraps = true; + + return type_data; +} + } /* namespace participants */ } /* namespace ddsrecorder */ } /* namespace eprosima */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp index 3483957a4..fded4183a 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapWriter.hpp @@ -74,7 +74,7 @@ class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter : public BaseWriter * - @throws \c InitializationException if the MCAP library fails to open a new file. */ void update_dynamic_types( - const fastdds::rtps::SerializedPayload_t& dynamic_types_payload); + const std::string& dynamic_types_payload); protected: @@ -148,7 +148,7 @@ class DDSRECORDER_PARTICIPANTS_DllAPI McapWriter : public BaseWriter mcap::McapWriter writer_; // The dynamic types payload to be written as an attachment - std::unique_ptr dynamic_types_payload_; + std::string dynamic_types_; // The channels that have been written std::map channels_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/Serializer.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/Serializer.hpp deleted file mode 100644 index 824a5f2ba..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/Serializer.hpp +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2023 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 Serializer.hpp - */ - -#pragma once - -#include -#include - -#include - -#include -#include -#include - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - -/** - * Class to serialize different types of data. - */ -class Serializer -{ -public: - - /** - * @brief Serialize a \c TopicQoS struct into a string. - * - * @param [in] qos TopicQoS to be serialized - * @return Serialized TopicQoS string - */ - DDSRECORDER_PARTICIPANTS_DllAPI - static std::string serialize( - const ddspipe::core::types::TopicQoS& qos); - - /** - * @brief Serialize a \c TypeIdentifier into a string. - * - * Calculates the size of the serialized TypeIdentifier. - * Calls \c data_to_str_ to serialize \c type_identifier - * - * @param [in] type_identifier TypeIdentifier to be serialized - * @return Serialized TypeIdentifier string - */ - DDSRECORDER_PARTICIPANTS_DllAPI - static std::string serialize( - const fastdds::dds::xtypes::TypeIdentifier& type_identifier); - - /** - * @brief Serialize a \c TypeObject into a string. - * - * @param [in] type_object TypeObject to be serialized - * @return Serialized TypeObject string - */ - DDSRECORDER_PARTICIPANTS_DllAPI - static std::string serialize( - const fastdds::dds::xtypes::TypeObject& type_object); - - /** - * @brief Serialize given \c DynamicTypesCollection into a \c SerializedPayload . - * - * @param [in] dynamic_types Dynamic types collection to be serialized. - * @return Serialized payload for the given dynamic types collection. - */ - DDSRECORDER_PARTICIPANTS_DllAPI - static fastdds::rtps::SerializedPayload_t* serialize( - DynamicTypesCollection* dynamic_types); - -protected: - - /** - * @brief Serialize a \c TypeObject or a \c TypeIdentifier into a string. - * - * @param [in] type_data \c TypeObject or \c TypeIdentifier to serialize - * @return string with the serialization - */ - DDSRECORDER_PARTICIPANTS_DllAPI - template - static std::string type_data_to_str_( - const T& type_data); -}; - -} /* namespace participants */ -} /* namespace ddsrecorder */ -} /* namespace eprosima */ - -#include diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/impl/Deserializer.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/impl/Deserializer.ipp deleted file mode 100644 index 76b5c94fc..000000000 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/impl/Deserializer.ipp +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2024 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 Deserializer.cpp - */ - -#include - -#include -#include -#include - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - -template -T Deserializer::type_str_to_type_data_( - const std::string& type_str) -{ - // Create CDR message from string - // NOTE: Use 0 length to avoid allocation - auto cdr_message = std::make_unique(0); - - cdr_message->buffer = (unsigned char*)reinterpret_cast(type_str.c_str()); - cdr_message->length = type_str.length(); -#if __BIG_ENDIAN__ - cdr_message->msg_endian = fastdds::rtps::BIGEND; -#else - cdr_message->msg_endian = fastdds::rtps::LITTLEEND; -#endif // if __BIG_ENDIAN__ - - // Reserve payload and create buffer - const auto parameter_length = cdr_message->length; - fastdds::rtps::SerializedPayload_t payload(parameter_length); - fastcdr::FastBuffer fastbuffer((char*)payload.data, parameter_length); - - // Read data - if (cdr_message != nullptr && cdr_message->length >= cdr_message->pos + parameter_length && parameter_length > 0 && payload.data != nullptr) - { - memcpy(payload.data, &cdr_message->buffer[cdr_message->pos], parameter_length); - cdr_message->pos += parameter_length; - } - - // Create CDR deserializer - fastcdr::Cdr deser(fastbuffer, fastcdr::Cdr::DEFAULT_ENDIAN, fastcdr::CdrVersion::XCDRv2); - payload.encapsulation = deser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; - - // Deserialize - T type_data; - fastcdr::deserialize(deser, type_data); - - // Delete CDR message - // NOTE: set wraps attribute to avoid double free (buffer released by string on destruction) - cdr_message->wraps = true; - - return type_data; -} - -} /* namespace participants */ -} /* namespace ddsrecorder */ -} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/replayer/Deserializer.cpp b/ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp similarity index 66% rename from ddsrecorder_participants/src/cpp/replayer/Deserializer.cpp rename to ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp index 0935d3b8d..7b9208123 100644 --- a/ddsrecorder_participants/src/cpp/replayer/Deserializer.cpp +++ b/ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp @@ -13,32 +13,72 @@ // limitations under the License. /** - * @file Deserializer.cpp + * @file Serializer.cpp */ -#include - #include #include -#include -#include - #include +#include #include +#include #include -#include #include -#include namespace eprosima { namespace ddsrecorder { namespace participants { template <> -ddspipe::core::types::TopicQoS Deserializer::deserialize( +std::string Serializer::serialize( + const ddspipe::core::types::TopicQoS& qos) +{ + // TODO: Reuse code from ddspipe_yaml + + YAML::Node qos_yaml; + + qos_yaml[QOS_SERIALIZATION_RELIABILITY] = qos.is_reliable(); + qos_yaml[QOS_SERIALIZATION_DURABILITY] = qos.is_transient_local(); + qos_yaml[QOS_SERIALIZATION_OWNERSHIP] = qos.has_ownership(); + qos_yaml[QOS_SERIALIZATION_KEYED] = qos.keyed.get_value(); + + return YAML::Dump(qos_yaml); +} + +template <> +std::string Serializer::serialize( + const fastdds::dds::xtypes::TypeIdentifier& type_identifier) +{ + return type_data_to_type_str_(type_identifier); +} + +template <> +std::string Serializer::serialize( + const fastdds::dds::xtypes::TypeObject& type_object) +{ + return type_data_to_type_str_(type_object); +} + +template <> +std::string Serializer::serialize( + const DynamicTypesCollection& dynamic_types) +{ + // Remove the const qualifier to serialize the dynamic types collection + auto dynamic_types_ptr = const_cast(&dynamic_types); + + // Serialize dynamic types collection using CDR + fastdds::dds::TypeSupport type_support(new DynamicTypesCollectionPubSubType()); + fastdds::rtps::SerializedPayload_t payload(type_support.get_serialized_size_provider(dynamic_types_ptr)()); + type_support.serialize(dynamic_types_ptr, &payload); + + return std::string(reinterpret_cast(payload.data));; +} + +template <> +ddspipe::core::types::TopicQoS Serializer::deserialize( const std::string& topic_qos_str) { // TODO: Reuse code from ddspipe_yaml @@ -88,21 +128,21 @@ ddspipe::core::types::TopicQoS Deserializer::deserialize( } template <> -fastdds::dds::xtypes::TypeIdentifier Deserializer::deserialize( +fastdds::dds::xtypes::TypeIdentifier Serializer::deserialize( const std::string& type_identifier_str) { return type_str_to_type_data_(type_identifier_str); } template <> -fastdds::dds::xtypes::TypeObject Deserializer::deserialize( +fastdds::dds::xtypes::TypeObject Serializer::deserialize( const std::string& type_object_str) { return type_str_to_type_data_(type_object_str); } template <> -DynamicTypesCollection Deserializer::deserialize( +DynamicTypesCollection Serializer::deserialize( const std::string& raw_data_str) { // Copy raw data into a payload diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 5a197d602..839de029a 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -27,10 +27,10 @@ #include +#include #include #include #include -#include namespace eprosima { namespace ddsrecorder { @@ -155,7 +155,7 @@ void McapHandler::add_schema( if (configuration_.record_types) { - mcap_writer_.update_dynamic_types(*Serializer::serialize(&dynamic_types_)); + mcap_writer_.update_dynamic_types(Serializer::serialize(dynamic_types_)); } // Check if there are any pending samples for this new type. If so, dump them. diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp index bd1d1eb6f..f8cf74a82 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapWriter.cpp @@ -52,41 +52,41 @@ void McapWriter::disable() } void McapWriter::update_dynamic_types( - const fastdds::rtps::SerializedPayload_t& dynamic_types_payload) + const std::string& dynamic_types) { std::lock_guard lock(mutex_); - const auto& update_dynamic_types_payload = [&]() + const auto& update_dynamic_types = [&]() { - if (dynamic_types_payload_ == nullptr) + if (dynamic_types_.empty()) { logInfo(DDSRECORDER_MCAP_WRITER, "MCAP_WRITE | Setting the dynamic types payload to " << - utils::from_bytes(dynamic_types_payload.length) << "."); + utils::from_bytes(dynamic_types.size()) << "."); - size_tracker_.attachment_to_write(dynamic_types_payload.length); + size_tracker_.attachment_to_write(dynamic_types.size()); } else { logInfo(DDSRECORDER_MCAP_WRITER, "MCAP_WRITE | Updating the dynamic types payload from " << - utils::from_bytes(dynamic_types_payload_->length) << " to " << - utils::from_bytes(dynamic_types_payload.length) << "."); + utils::from_bytes(dynamic_types_.size()) << " to " << + utils::from_bytes(dynamic_types.size()) << "."); - size_tracker_.attachment_to_write(dynamic_types_payload.length, dynamic_types_payload_->length); + size_tracker_.attachment_to_write(dynamic_types.size(), dynamic_types_.size()); } }; try { - update_dynamic_types_payload(); + update_dynamic_types(); } catch (const FullFileException& e) { try { on_file_full_nts_(e, size_tracker_.get_min_mcap_size()); - update_dynamic_types_payload(); + update_dynamic_types(); } catch (const FullDiskException& e) { @@ -96,7 +96,7 @@ void McapWriter::update_dynamic_types( } } - dynamic_types_payload_.reset(const_cast(&dynamic_types_payload)); + dynamic_types_ = dynamic_types; file_tracker_->set_current_file_size(size_tracker_.get_potential_mcap_size()); } @@ -138,9 +138,9 @@ void McapWriter::open_new_file_nts_( write_schemas_nts_(); write_channels_nts_(); - if (dynamic_types_payload_ != nullptr && record_types_) + if (record_types_ && dynamic_types_.size() > 0) { - size_tracker_.attachment_to_write(dynamic_types_payload_->length); + size_tracker_.attachment_to_write(dynamic_types_.size()); } file_tracker_->set_current_file_size(size_tracker_.get_potential_mcap_size()); @@ -148,7 +148,7 @@ void McapWriter::open_new_file_nts_( void McapWriter::close_current_file_nts_() { - if (record_types_ && dynamic_types_payload_ != nullptr) + if (record_types_ && dynamic_types_.size() > 0) { // NOTE: This write should never fail since the minimum size accounts for it. write_attachment_nts_(); @@ -275,8 +275,8 @@ void McapWriter::write_attachment_nts_() // Write down the attachment with the dynamic types attachment.name = DYNAMIC_TYPES_ATTACHMENT_NAME; - attachment.data = reinterpret_cast(dynamic_types_payload_->data); - attachment.dataSize = dynamic_types_payload_->length; + attachment.data = reinterpret_cast(const_cast(dynamic_types_.c_str())); + attachment.dataSize = dynamic_types_.size(); attachment.createTime = to_mcap_timestamp(utils::now()); write_nts_(attachment); diff --git a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp index c74084777..af45db3c0 100644 --- a/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/output/BaseHandler.cpp @@ -26,8 +26,8 @@ #include #include +#include #include -#include namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder_participants/src/cpp/recorder/output/Serializer.cpp b/ddsrecorder_participants/src/cpp/recorder/output/Serializer.cpp deleted file mode 100644 index b03c84be8..000000000 --- a/ddsrecorder_participants/src/cpp/recorder/output/Serializer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2023 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 Serializer.cpp - */ - -#include - -#include -#include -#include - -#include -#include - -namespace eprosima { -namespace ddsrecorder { -namespace participants { - - -std::string Serializer::serialize( - const ddspipe::core::types::TopicQoS& qos) -{ - // TODO: Reuse code from ddspipe_yaml - - YAML::Node qos_yaml; - - qos_yaml[QOS_SERIALIZATION_RELIABILITY] = qos.is_reliable(); - qos_yaml[QOS_SERIALIZATION_DURABILITY] = qos.is_transient_local(); - qos_yaml[QOS_SERIALIZATION_OWNERSHIP] = qos.has_ownership(); - qos_yaml[QOS_SERIALIZATION_KEYED] = qos.keyed.get_value(); - - return YAML::Dump(qos_yaml); -} - -std::string Serializer::serialize( - const fastdds::dds::xtypes::TypeIdentifier& type_identifier) -{ - return type_data_to_str_(type_identifier); -} - -std::string Serializer::serialize( - const fastdds::dds::xtypes::TypeObject& type_object) -{ - return type_data_to_str_(type_object); -} - -fastdds::rtps::SerializedPayload_t* Serializer::serialize( - DynamicTypesCollection* dynamic_types) -{ - // Serialize dynamic types collection using CDR - fastdds::dds::TypeSupport type_support(new DynamicTypesCollectionPubSubType()); - auto serialized_payload = new fastdds::rtps::SerializedPayload_t(type_support.get_serialized_size_provider(dynamic_types)()); - type_support.serialize(dynamic_types, serialized_payload); - - return serialized_payload; -} - -} /* namespace participants */ -} /* namespace ddsrecorder */ -} /* namespace eprosima */ diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp index af45d52b7..01ab35b5f 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp @@ -18,8 +18,8 @@ #define SQL_IMPLEMENTATION // Define this in exactly one .cpp file +#include #include -#include #include namespace eprosima { diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index 19172e9f6..966d6a9ba 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -27,9 +27,9 @@ #include +#include #include #include -#include #include #include diff --git a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp index 7889b070e..574a56725 100644 --- a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp @@ -34,9 +34,9 @@ #include #include +#include #include #include -#include #include #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 @@ -80,7 +80,7 @@ void McapReaderParticipant::process_summary( // Apply the QoS stored in the MCAP file as if they were the discovered QoS. const auto topic_qos_str = channel->metadata[QOS_SERIALIZATION_QOS]; - const auto topic_qos = Deserializer::deserialize(topic_qos_str); + const auto topic_qos = Serializer::deserialize(topic_qos_str); topic->topic_qos.set_qos(topic_qos, utils::FuzzyLevelValues::fuzzy_level_fuzzy); @@ -97,7 +97,7 @@ void McapReaderParticipant::process_summary( const std::string dynamic_types_str( reinterpret_cast(dynamic_types_attachment.data), dynamic_types_attachment.dataSize); - types = Deserializer::deserialize(dynamic_types_str); + types = Serializer::deserialize(dynamic_types_str); } close_file_(); diff --git a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp index ae270f090..3d0ce68c8 100644 --- a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp @@ -28,9 +28,9 @@ #include +#include #include #include -#include #include namespace eprosima { namespace ddsrecorder { diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index df57ca575..8c9e01322 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -37,9 +37,9 @@ #include #include +#include #include #include -#include #include #include #include @@ -183,11 +183,11 @@ std::set DdsReplayer::register_dynamic_types_( { // Deserialize type identifier const auto type_identifier_str = utils::base64_decode(dynamic_type.type_information()); - const auto type_identifier = participants::Deserializer::deserialize(type_identifier_str); + const auto type_identifier = participants::Serializer::deserialize(type_identifier_str); // Deserialize type object const auto type_object_str = utils::base64_decode(dynamic_type.type_object()); - const auto type_object = participants::Deserializer::deserialize(type_object_str); + const auto type_object = participants::Serializer::deserialize(type_object_str); // Register in factory fastrtps::types::TypeObjectFactory::get_instance()->add_type_object( From abd8d823d8591e923a32a8dd656166b9ef029770 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 28 May 2024 16:58:03 +0200 Subject: [PATCH 29/52] Rename McapReaderParticipantConfiguration to BaseReaderParticipantConfiguration Signed-off-by: tempate --- .../replayer/BaseReaderParticipant.hpp | 6 +++--- ...iguration.hpp => BaseReaderParticipantConfiguration.hpp} | 6 +++--- .../replayer/McapReaderParticipant.hpp | 4 ++-- .../replayer/SqlReaderParticipant.hpp | 4 ++-- .../src/cpp/replayer/BaseReaderParticipant.cpp | 2 +- .../src/cpp/replayer/McapReaderParticipant.cpp | 2 +- .../src/cpp/replayer/SqlReaderParticipant.cpp | 2 +- .../ddsrecorder_yaml/replayer/YamlReaderConfiguration.hpp | 4 ++-- .../src/cpp/replayer/YamlReaderConfiguration.cpp | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) rename ddsrecorder_participants/include/ddsrecorder_participants/replayer/{McapReaderParticipantConfiguration.hpp => BaseReaderParticipantConfiguration.hpp} (88%) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp index b082ef714..dfab79a66 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp @@ -39,7 +39,7 @@ #include #include -#include +#include #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 #include @@ -71,7 +71,7 @@ class BaseReaderParticipant : public ddspipe::core::IParticipant */ DDSRECORDER_PARTICIPANTS_DllAPI BaseReaderParticipant( - const std::shared_ptr& configuration, + const std::shared_ptr& configuration, const std::shared_ptr& payload_pool, const std::string& file_path); @@ -172,7 +172,7 @@ class BaseReaderParticipant : public ddspipe::core::IParticipant const utils::Timestamp& timestamp); //! Participant Configuration - const std::shared_ptr configuration_; + const std::shared_ptr configuration_; //! DDS Pipe shared Payload Pool std::shared_ptr payload_pool_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipantConfiguration.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipantConfiguration.hpp similarity index 88% rename from ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipantConfiguration.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipantConfiguration.hpp index 9a572f593..d2a901e72 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipantConfiguration.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipantConfiguration.hpp @@ -1,4 +1,4 @@ -// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// Copyright 2024 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. @@ -25,9 +25,9 @@ namespace ddsrecorder { namespace participants { /** - * Class that encapsulates all configuration parameters of a \c McapReaderParticipant . + * Class that encapsulates all configuration parameters of a \c BaseReaderParticipant . */ -struct McapReaderParticipantConfiguration : ddspipe::participants::ParticipantConfiguration +struct BaseReaderParticipantConfiguration : ddspipe::participants::ParticipantConfiguration { utils::Fuzzy begin_time{}; utils::Fuzzy end_time{}; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp index 30e0f79f3..90c6481b3 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp @@ -25,7 +25,7 @@ #include #include -#include +#include #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 #include @@ -57,7 +57,7 @@ class McapReaderParticipant : public BaseReaderParticipant */ DDSRECORDER_PARTICIPANTS_DllAPI McapReaderParticipant( - const std::shared_ptr& configuration, + const std::shared_ptr& configuration, const std::shared_ptr& payload_pool, const std::string& file_path); diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp index c1bbc3bf1..32babfffc 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp @@ -28,7 +28,7 @@ #include #include -#include +#include #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 #include @@ -60,7 +60,7 @@ class SqlReaderParticipant : public BaseReaderParticipant */ DDSRECORDER_PARTICIPANTS_DllAPI SqlReaderParticipant( - const std::shared_ptr& configuration, + const std::shared_ptr& configuration, const std::shared_ptr& payload_pool, const std::string& file_path); diff --git a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp index ffcede2c7..31202400a 100644 --- a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp @@ -39,7 +39,7 @@ namespace ddsrecorder { namespace participants { BaseReaderParticipant::BaseReaderParticipant( - const std::shared_ptr& configuration, + const std::shared_ptr& configuration, const std::shared_ptr& payload_pool, const std::string& file_path) : configuration_(configuration) diff --git a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp index 574a56725..c6028ee03 100644 --- a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp @@ -50,7 +50,7 @@ namespace ddsrecorder { namespace participants { McapReaderParticipant::McapReaderParticipant( - const std::shared_ptr& configuration, + const std::shared_ptr& configuration, const std::shared_ptr& payload_pool, const std::string& file_path) : BaseReaderParticipant(configuration, payload_pool, file_path) diff --git a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp index 3d0ce68c8..dc17058f2 100644 --- a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp @@ -37,7 +37,7 @@ namespace ddsrecorder { namespace participants { SqlReaderParticipant::SqlReaderParticipant( - const std::shared_ptr& configuration, + const std::shared_ptr& configuration, const std::shared_ptr& payload_pool, const std::string& file_path) : BaseReaderParticipant(configuration, payload_pool, file_path) diff --git a/ddsrecorder_yaml/include/ddsrecorder_yaml/replayer/YamlReaderConfiguration.hpp b/ddsrecorder_yaml/include/ddsrecorder_yaml/replayer/YamlReaderConfiguration.hpp index 8699fbc4e..aa636589b 100644 --- a/ddsrecorder_yaml/include/ddsrecorder_yaml/replayer/YamlReaderConfiguration.hpp +++ b/ddsrecorder_yaml/include/ddsrecorder_yaml/replayer/YamlReaderConfiguration.hpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include @@ -61,7 +61,7 @@ class DDSRECORDER_YAML_DllAPI ReplayerConfiguration ddspipe::core::DdsPipeConfiguration ddspipe_configuration; // Participants configurations - std::shared_ptr mcap_reader_configuration; + std::shared_ptr mcap_reader_configuration; std::shared_ptr replayer_configuration; // Replay params diff --git a/ddsrecorder_yaml/src/cpp/replayer/YamlReaderConfiguration.cpp b/ddsrecorder_yaml/src/cpp/replayer/YamlReaderConfiguration.cpp index 436a5eb1d..1761830d7 100644 --- a/ddsrecorder_yaml/src/cpp/replayer/YamlReaderConfiguration.cpp +++ b/ddsrecorder_yaml/src/cpp/replayer/YamlReaderConfiguration.cpp @@ -90,7 +90,7 @@ void ReplayerConfiguration::load_ddsreplayer_configuration_( ///// // Create MCAP Reader Participant Configuration // WARNING: Replayer configuration must have been parsed beforehand - mcap_reader_configuration = std::make_shared(); + mcap_reader_configuration = std::make_shared(); mcap_reader_configuration->id = "McapReaderParticipant"; mcap_reader_configuration->app_id = "DDS_REPLAYER"; mcap_reader_configuration->app_metadata = ""; From 3dd2754b187c490d221884e01f291ec706834f1f Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 7 Jun 2024 12:02:30 +0200 Subject: [PATCH 30/52] Fix assert for ROS 2 topics Signed-off-by: tempate --- ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 839de029a..d2d866001 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -286,7 +286,7 @@ void McapHandler::update_channels_nts_( logInfo(DDSRECORDER_MCAP_HANDLER, "MCAP_WRITE | Updating channel in topic " << channel.first.m_topic_name << "."); - assert(channel.first.m_topic_name == channel.second.topic); + assert(utils::demangle_if_ros_topic(channel.first.m_topic_name) == channel.second.topic); mcap::Channel new_channel(channel.second.topic, "cdr", new_schema_id, channel.second.metadata); mcap_writer_.write(new_channel); From b7e27c9bb3b3cc0f10912080158bbff646c57205 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 7 Jun 2024 12:18:49 +0200 Subject: [PATCH 31/52] Move resource limits tests to MCAP Signed-off-by: tempate --- ddsrecorder/test/blackbox/CMakeLists.txt | 1 - ddsrecorder/test/blackbox/mcap/CMakeLists.txt | 57 +++++++++++++++++++ .../McapResourceLimitsTest.cpp} | 8 +-- .../blackbox/resource_limits/CMakeLists.txt | 54 ------------------ 4 files changed, 61 insertions(+), 59 deletions(-) rename ddsrecorder/test/blackbox/{resource_limits/ResourceLimitsTest.cpp => mcap/McapResourceLimitsTest.cpp} (98%) delete mode 100644 ddsrecorder/test/blackbox/resource_limits/CMakeLists.txt diff --git a/ddsrecorder/test/blackbox/CMakeLists.txt b/ddsrecorder/test/blackbox/CMakeLists.txt index eb1fa88d0..4d964d217 100644 --- a/ddsrecorder/test/blackbox/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/CMakeLists.txt @@ -13,4 +13,3 @@ # limitations under the License. add_subdirectory(mcap) -add_subdirectory(resource_limits) diff --git a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt index 1873b9598..f0c23a862 100644 --- a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt @@ -104,3 +104,60 @@ add_blackbox_executable( "${EXTRA_LIBRARIES}" "${TEST_EXTRA_HEADERS}" ) + +########################## +# McapResourceLimitsTest # +########################## + +set(TEST_NAME McapResourceLimitsTest) + +file( + GLOB_RECURSE TEST_SOURCES + McapResourceLimitsTest.cpp + "${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/*.c*" + ) + +file( + GLOB_RECURSE TEST_LIBRARY_SOURCES + "${PROJECT_SOURCE_DIR}/src/cpp/*.c*" + ) + +list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") + +# Exclude types' files depending on the Fast DDS version +if ("${fastrtps_VERSION}" VERSION_LESS 2.13) + list(FILTER TEST_SOURCES EXCLUDE REGEX "v2/") + list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v2/") +else() + list(FILTER TEST_SOURCES EXCLUDE REGEX "v1/") + list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v1/") +endif() + +set(TEST_LIST + max_file_size + max_size + file_rotation + ) + +set(TEST_NEEDED_SOURCES + ) + +set(TEST_EXTRA_HEADERS + ${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/ + ) + +# Exclude types' files depending on the Fast DDS version +if ("${fastrtps_VERSION}" VERSION_LESS 2.13) + list(FILTER TEST_EXTRA_HEADERS EXCLUDE REGEX "v2/") +else() + list(FILTER TEST_EXTRA_HEADERS EXCLUDE REGEX "v1/") +endif() + +add_blackbox_executable( + "${TEST_NAME}" + "${TEST_SOURCES}" + "${TEST_LIST}" + "${TEST_NEEDED_SOURCES}" + "${TEST_EXTRA_HEADERS}" + "${TEST_LIBRARY_SOURCES}" +) diff --git a/ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp b/ddsrecorder/test/blackbox/mcap/McapResourceLimitsTest.cpp similarity index 98% rename from ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp rename to ddsrecorder/test/blackbox/mcap/McapResourceLimitsTest.cpp index ac070ae51..720c652e3 100644 --- a/ddsrecorder/test/blackbox/resource_limits/ResourceLimitsTest.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapResourceLimitsTest.cpp @@ -44,7 +44,7 @@ using namespace eprosima; using namespace eprosima::fastdds::dds; -class ResourceLimitsTest : public testing::Test +class McapResourceLimitsTest : public testing::Test { public: @@ -196,7 +196,7 @@ class ResourceLimitsTest : public testing::Test * CASES: * - check that the DDS Recorder records data until it reaches the max-file-size. */ -TEST_F(ResourceLimitsTest, max_file_size) +TEST_F(McapResourceLimitsTest, max_file_size) { const std::string OUTPUT_FILE_NAME = "max_file_size_test"; const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME); @@ -237,7 +237,7 @@ TEST_F(ResourceLimitsTest, max_file_size) * - check that the size of each of the DDS Recorder's output files is in bounds. * - check that the aggregate size of the DDS Recorder's output files is in bounds. */ -TEST_F(ResourceLimitsTest, max_size) +TEST_F(McapResourceLimitsTest, max_size) { constexpr std::uint32_t NUMBER_OF_FILES = test::limits::MAX_FILES + 1; const std::string OUTPUT_FILE_NAME = "max_size_test"; @@ -316,7 +316,7 @@ TEST_F(ResourceLimitsTest, max_size) * - check that the aggregate size of the DDS Recorder's output files doesn't exceed the max-size. * - check that the DDS Recorder applies file rotation after reaching the max-size. */ -TEST_F(ResourceLimitsTest, file_rotation) +TEST_F(McapResourceLimitsTest, file_rotation) { constexpr std::uint32_t NUMBER_OF_FILES = 9; const std::string OUTPUT_FILE_NAME = "file_rotation_test"; diff --git a/ddsrecorder/test/blackbox/resource_limits/CMakeLists.txt b/ddsrecorder/test/blackbox/resource_limits/CMakeLists.txt deleted file mode 100644 index 8e17a6054..000000000 --- a/ddsrecorder/test/blackbox/resource_limits/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -# Copyright 2023 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. - -###################### -# ResourceLimitsTest # -###################### - -set(TEST_NAME ResourceLimitsTest) - -file( - GLOB_RECURSE TEST_SOURCES - ResourceLimitsTest.cpp - "${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/*.c*" - ) - -file( - GLOB_RECURSE TEST_LIBRARY_SOURCES - "${PROJECT_SOURCE_DIR}/src/cpp/*.c*" - ) - -list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") - -set(TEST_LIST - max_file_size - max_size - file_rotation - ) - -set(TEST_NEEDED_SOURCES - ) - -set(TEST_EXTRA_HEADERS - ${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/ - ) - -add_blackbox_executable( - "${TEST_NAME}" - "${TEST_SOURCES}" - "${TEST_LIST}" - "${TEST_NEEDED_SOURCES}" - "${TEST_EXTRA_HEADERS}" - "${TEST_LIBRARY_SOURCES}" -) From 62be8a9f9a1939910d23548f7bffe8b439275b91 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 7 Jun 2024 15:11:41 +0200 Subject: [PATCH 32/52] FileCreationTests for SQL Signed-off-by: tempate --- ddsrecorder/test/blackbox/CMakeLists.txt | 1 + .../test/blackbox/FileCreationTest.hpp | 290 +++++ ddsrecorder/test/blackbox/constants.hpp | 1 + ddsrecorder/test/blackbox/sql/CMakeLists.txt | 94 ++ .../test/blackbox/sql/SqlFileCreationTest.cpp | 1112 +++++++++++++++++ 5 files changed, 1498 insertions(+) create mode 100644 ddsrecorder/test/blackbox/FileCreationTest.hpp create mode 100644 ddsrecorder/test/blackbox/sql/CMakeLists.txt create mode 100644 ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp diff --git a/ddsrecorder/test/blackbox/CMakeLists.txt b/ddsrecorder/test/blackbox/CMakeLists.txt index 4d964d217..3c449ebdb 100644 --- a/ddsrecorder/test/blackbox/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/CMakeLists.txt @@ -13,3 +13,4 @@ # limitations under the License. add_subdirectory(mcap) +add_subdirectory(sql) diff --git a/ddsrecorder/test/blackbox/FileCreationTest.hpp b/ddsrecorder/test/blackbox/FileCreationTest.hpp new file mode 100644 index 000000000..7fa8a8556 --- /dev/null +++ b/ddsrecorder/test/blackbox/FileCreationTest.hpp @@ -0,0 +1,290 @@ +// Copyright 2024 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. + + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) + #include "../resources/types/hello_world/v1/HelloWorld.h" + #include "../resources/types/hello_world/v1/HelloWorldPubSubTypes.h" +#else + #include "../resources/types/hello_world/v2/HelloWorld.h" + #include "../resources/types/hello_world/v2/HelloWorldPubSubTypes.h" +#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) + +#include + +#include "constants.hpp" + +using namespace eprosima; +using DdsRecorderState = ddsrecorder::recorder::DdsRecorderStateCode; + +enum class EventKind +{ + NO_EVENT, + EVENT, + EVENT_START, + EVENT_STOP, + EVENT_SUSPEND, +}; + +class FileCreationTest : public testing::Test +{ +public: + + void SetUp() override + { + // Create the participant + fastdds::dds::DomainParticipantQos pqos; + pqos.name(test::PARTICIPANT_ID); + + participant_ = fastdds::dds::DomainParticipantFactory::get_instance()->create_participant(test::DOMAIN, pqos); + + ASSERT_NE(participant_, nullptr); + + // Register the type + fastdds::dds::TypeSupport type(new HelloWorldPubSubType()); + type.register_type(participant_); + + // Create the publisher + publisher_ = participant_->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT, nullptr); + + ASSERT_NE(publisher_, nullptr); + + // Create the RecorderConfiguration + Yaml yml; + configuration_ = std::make_unique(yml); + configuration_->simple_configuration->domain = test::DOMAIN; + } + + void TearDown() override + { + // Delete the participant + if (participant_ != nullptr) + { + participant_->delete_contained_entities(); + fastdds::dds::DomainParticipantFactory::get_instance()->delete_participant(participant_); + } + + // Remove the output files + for (const auto& path : paths_) + { + delete_file_(path); + } + } + +protected: + + std::vector> record_messages_( + const std::string& file_name, + const unsigned int messages1, + const DdsRecorderState state1 = DdsRecorderState::RUNNING, + const unsigned int messages2 = 0, + const DdsRecorderState state2 = DdsRecorderState::RUNNING, + const unsigned int wait = 0, + const EventKind event = EventKind::NO_EVENT) + { + // Create the Recorder + std::shared_ptr file_tracker; + auto recorder = std::make_unique(*configuration_, state1, file_tracker, file_name); + + // Create the topic + const auto topic_name = (configuration_->ros2_types) ? test::ROS2_TOPIC_NAME : test::TOPIC_NAME; + topic_ = participant_->create_topic(topic_name, "HelloWorld", fastdds::dds::TOPIC_QOS_DEFAULT); + + // Send messages + auto sent_messages = send_messages_(messages1); + + if (state1 != state2) + { + // Change the Recorder's state + switch (state2) + { + case DdsRecorderState::RUNNING: + recorder->start(); + break; + case DdsRecorderState::PAUSED: + recorder->pause(); + break; + case DdsRecorderState::SUSPENDED: + recorder->suspend(); + break; + case DdsRecorderState::STOPPED: + recorder->stop(); + break; + default: + break; + } + } + + // Wait for the event window + std::this_thread::sleep_for(std::chrono::seconds(wait)); + + // Send more messages + const auto sent_messages_after_transition = send_messages_(messages2); + sent_messages.insert(sent_messages.end(), sent_messages_after_transition.begin(), sent_messages_after_transition.end()); + + if (event != EventKind::NO_EVENT && state2 == DdsRecorderState::PAUSED) + { + recorder->trigger_event(); + + switch (event) + { + case EventKind::EVENT_START: + recorder->start(); + break; + + case EventKind::EVENT_SUSPEND: + recorder->suspend(); + break; + + case EventKind::EVENT_STOP: + recorder->stop(); + break; + + default: + break; + } + } + + return sent_messages; + } + + std::vector> send_messages_( + const unsigned int number_of_messages) + { + // Create the DataWriter + create_datawriter_(); + + // Wait for the DataReader to match the DataWriter + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + + // Send the messages + std::vector> sent_messages; + + for (std::uint32_t i = 0; i < number_of_messages; i++) + { + // Create the message + HelloWorld hello; + hello.index(i); + + // Send the message + writer_->write(&hello); + + // Serialize the message + HelloWorldPubSubType pubsubType; + const auto payload_size = pubsubType.getSerializedSizeProvider(&hello)(); + auto payload = std::make_shared(payload_size); + pubsubType.serialize(&hello, payload.get()); + + // Store the serialized message + sent_messages.push_back(payload); + + // Wait for the message to be sent + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + } + + // Delete the DataWriter + delete_datawriter_(); + + return sent_messages; + } + + void create_datawriter_() + { + // Configure the DataWriter's QoS to ensure that the DDS Recorder receives all the msgs + fastdds::dds::DataWriterQos wqos = fastdds::dds::DATAWRITER_QOS_DEFAULT; + wqos.reliability().kind = fastdds::dds::RELIABLE_RELIABILITY_QOS; + wqos.durability().kind = fastdds::dds::TRANSIENT_LOCAL_DURABILITY_QOS; + wqos.history().kind = fastdds::dds::KEEP_ALL_HISTORY_QOS; + + // Create the writer + writer_ = publisher_->create_datawriter(topic_, wqos); + + ASSERT_NE(writer_, nullptr); + } + + void delete_datawriter_() + { + if (writer_ != nullptr) + { + publisher_->delete_datawriter(writer_); + } + } + + std::filesystem::path get_output_file_path_( + const std::string& output_file_name) + { + const auto file_path = std::filesystem::current_path() / output_file_name; + + paths_.push_back(file_path); + + return file_path; + } + + bool delete_file_( + const std::filesystem::path& file_path) + { + if (std::filesystem::exists(file_path) && !std::filesystem::remove(file_path)) + { + return false; + } + + const auto file_path_tmp = file_path.string() + ".tmp~"; + + if (std::filesystem::exists(file_path_tmp) && !std::filesystem::remove(file_path_tmp)) + { + return false; + } + + return true; + } + + fastdds::dds::DomainParticipant* participant_ = nullptr; + fastdds::dds::Publisher* publisher_ = nullptr; + fastdds::dds::Topic* topic_ = nullptr; + fastdds::dds::DataWriter* writer_ = nullptr; + + std::vector paths_; + + std::unique_ptr configuration_; +}; diff --git a/ddsrecorder/test/blackbox/constants.hpp b/ddsrecorder/test/blackbox/constants.hpp index a04475855..9a9ade3fa 100644 --- a/ddsrecorder/test/blackbox/constants.hpp +++ b/ddsrecorder/test/blackbox/constants.hpp @@ -35,6 +35,7 @@ using namespace eprosima::ddspipe::core::types; // The domain and topic to publish in. constexpr DomainIdType DOMAIN = 84; const std::string TOPIC_NAME = "DdsRecorderBlackboxTestTopic"; +const std::string ROS2_TOPIC_NAME = "rt/blackbox_test_topic"; // The id of the publishing participant. const ParticipantId PARTICIPANT_ID = "DdsRecorderBlackboxTestParticipant"; diff --git a/ddsrecorder/test/blackbox/sql/CMakeLists.txt b/ddsrecorder/test/blackbox/sql/CMakeLists.txt new file mode 100644 index 000000000..06d24a211 --- /dev/null +++ b/ddsrecorder/test/blackbox/sql/CMakeLists.txt @@ -0,0 +1,94 @@ +# Copyright 2024 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. + +######################## +# SqlFileCreationTest # +######################## + +set(TEST_NAME SqlFileCreationTest) + +file( + GLOB_RECURSE TEST_SOURCES + SqlFileCreationTest.cpp + "${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/*.c*" + ) + +file( + GLOB_RECURSE TEST_LIBRARY_SOURCES + "${PROJECT_SOURCE_DIR}/src/cpp/*.c*" + ) + +list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") + +# Exclude types' files depending on the Fast DDS version +if ("${fastrtps_VERSION}" VERSION_LESS 2.13) + list(FILTER TEST_SOURCES EXCLUDE REGEX "v2/") + list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v2/") +else() + list(FILTER TEST_SOURCES EXCLUDE REGEX "v1/") + list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v1/") +endif() + +set(TEST_LIST + sql_data_msgs + sql_dds_topic + sql_ros2_topic + sql_data_num_msgs + sql_data_num_msgs_downsampling + + # State + transition_running + transition_paused + transition_suspended + transition_stopped + + # Transitions + transition_running_paused + transition_running_suspended + transition_running_stopped + transition_paused_running + transition_paused_suspended + transition_paused_stopped + transition_suspended_running + transition_suspended_paused + transition_suspended_stopped + transition_stopped_running + transition_stopped_suspended + transition_stopped_paused + + # Event window + transition_paused_event_less_window + transition_paused_event_max_window + + # Events + transition_paused_event_start + transition_paused_event_suspend + transition_paused_event_stop + ) + +set(TEST_NEEDED_SOURCES + ) + +set(TEST_EXTRA_HEADERS + ${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/ + ) + +add_blackbox_executable( + "${TEST_NAME}" + "${TEST_SOURCES}" + "${TEST_LIST}" + "${TEST_NEEDED_SOURCES}" + "${TEST_EXTRA_HEADERS}" + "${TEST_LIBRARY_SOURCES}" +) diff --git a/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp b/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp new file mode 100644 index 000000000..f901123ce --- /dev/null +++ b/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp @@ -0,0 +1,1112 @@ +// Copyright 2024 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. + + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include + +#include + +#include "../constants.hpp" +#include "../FileCreationTest.hpp" + +using namespace eprosima; + +class SqlFileCreationTest : public FileCreationTest +{ +public: + + void SetUp() override + { + FileCreationTest::SetUp(); + + // Set the output library to SQL + configuration_->output_library = ddsrecorder::participants::OutputLibrary::sql; + } + +protected: + + void exec_sql_statement_( + const std::string& file_path, + const std::string& statement, + const std::vector& bind_values, + const std::function& process_row) + { + sqlite3* database; + + // Open the SQL database + const auto open_ret = sqlite3_open(file_path.c_str(), &database); + + if (open_ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to open SQL file " << file_path + << " for reading: " << sqlite3_errmsg(database); + sqlite3_close(database); + + throw std::runtime_error(error_msg); + } + + sqlite3_stmt* stmt; + + // Prepare the SQL statement + const auto ret = sqlite3_prepare_v2(database, statement.c_str(), -1, &stmt, nullptr); + + if (ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement: " + << sqlite3_errmsg(database); + sqlite3_finalize(stmt); + + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); + throw std::runtime_error(error_msg); + } + + // Guard the statement to ensure it's always finalized + std::unique_ptr stmt_guard(stmt, sqlite3_finalize); + + // Bind the values to the statement + for (int i = 0; i < (int) bind_values.size(); i++) + { + const auto bind_ret = sqlite3_bind_text(stmt, i+1, bind_values[i].c_str(), -1, SQLITE_STATIC); + + if (bind_ret != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to bind SQL statement to read messages: " + << sqlite3_errmsg(database); + + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); + throw std::runtime_error(error_msg); + } + } + + // Step through the statement and process the rows + int step_ret; + + while ((step_ret = sqlite3_step(stmt)) == SQLITE_ROW) + { + process_row(stmt); + } + + if (step_ret != SQLITE_DONE) + { + const std::string error_msg = utils::Formatter() << "Failed to fetch data: " + << sqlite3_errmsg(database); + + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); + throw std::runtime_error(error_msg); + } + + // Close the database + sqlite3_close(database); + } +}; + +/** + * Verify that the DDS Recorder records properly in an SQL file. + * + * CASES: + * - Verify that the messages' sizes match the recorded data sizes. + * - Verify that the messages' data matches the recorded data. + */ +TEST_F(SqlFileCreationTest, sql_data_msgs) +{ + const std::string OUTPUT_FILE_NAME = "sql_data_msgs"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES = 10; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + auto sent_messages = record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); + + auto sent_message = sent_messages.begin(); + + auto read_message_count = 0; + + // Read the recorded messages + exec_sql_statement_( + OUTPUT_FILE_PATH.string(), + "SELECT data, data_size FROM Messages ORDER BY log_time;", {}, [&](sqlite3_stmt* stmt) + { + read_message_count++; + + // Verify the data size + const auto read_data_size = sqlite3_column_int(stmt, 1); + ASSERT_EQ((*sent_message)->length, read_data_size); + + // Verify the data + const auto read_data = (unsigned char*) reinterpret_cast(sqlite3_column_blob(stmt, 0)); + ASSERT_EQ(strcmp((char*) (*sent_message)->data, (char*) read_data), 0); + + sent_message++; + }); + + // Verify that it read messages + ASSERT_GT(read_message_count, 0); +} + +/** + * Verify that the DDS Recorder records topics properly in an SQL file. + * + * CASES: + * - Verify that the topic's name matches the recorded topic's name. + * - Verify that the topic's type matches the recorded topic's type. + */ +TEST_F(SqlFileCreationTest, sql_dds_topic) +{ + const std::string OUTPUT_FILE_NAME = "sql_dds_topic"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES = 10; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); + + // Read the recorded topics + auto read_topics_count = 0; + + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT name, type FROM Topics;", {}, [&](sqlite3_stmt* stmt) + { + read_topics_count++; + + // Verify the topic's name + const std::string read_topic_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); + ASSERT_EQ(topic_->get_name(), read_topic_name); + + // Verify the topic's type + const std::string read_topic_type = reinterpret_cast(sqlite3_column_text(stmt, 1)); + ASSERT_EQ(topic_->get_type_name(), read_topic_type); + }); + + // Verify that it read messages + ASSERT_GT(read_topics_count, 0); +} + +/** + * Verify that the DDS Recorder records ROS 2 topics properly in an SQL file. + * + * CASES: + * - Verify that the topic's name matches the recorded topic's name. + * - Verify that the topic's type matches the recorded topic's type. + */ +TEST_F(SqlFileCreationTest, sql_ros2_topic) +{ + const std::string OUTPUT_FILE_NAME = "sql_ros2_topic"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES = 10; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + configuration_->ros2_types = true; + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); + + // Read the recorded topics + auto read_topics_count = 0; + + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT name, type FROM Topics;", {}, [&](sqlite3_stmt* stmt) + { + read_topics_count++; + + // Verify the topic's name + const std::string read_topic_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); + ASSERT_EQ(utils::demangle_if_ros_topic(topic_->get_name()), read_topic_name); + + // Verify the topic's type + const std::string read_topic_type = reinterpret_cast(sqlite3_column_text(stmt, 1)); + ASSERT_EQ(utils::demangle_if_ros_type(topic_->get_type_name()), read_topic_type); + }); + + // Verify that it read topics + ASSERT_GT(read_topics_count, 0); +} + +/** + * Verify that the DDS Recorder records every message in an SQL file. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, sql_data_num_msgs) +{ + const std::string OUTPUT_FILE_NAME = "sql_data_num_msgs"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES = 128; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES); + }); +} + +/** + * Verify that the DDS Recorder records every message in an SQL file. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, sql_data_num_msgs_downsampling) +{ + const std::string OUTPUT_FILE_NAME = "sql_data_num_msgs_downsampling"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES = 10; + constexpr int DOWNSAMPLING = 2; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // TODO: Change mechanism setting topic qos' default values from specs + configuration_->topic_qos.downsampling = DOWNSAMPLING; + ddspipe::core::types::TopicQoS::default_topic_qos.set_value(configuration_->topic_qos); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + const auto expected_messages = (NUMBER_OF_MESSAGES / DOWNSAMPLING) + (NUMBER_OF_MESSAGES % DOWNSAMPLING); + ASSERT_EQ(recorded_messages, expected_messages); + }); +} + +// ////////////////////// +// // With transitions // +// ////////////////////// + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file in RUNNING state. + * + * Since the recorder is in RUNNING state, it should record all messages. + * NOTE: The recorder won't change states since both \c STATE_1 and \c STATE_2 are RUNNING. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_running) +{ + const std::string OUTPUT_FILE_NAME = "transition_running"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::RUNNING; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::RUNNING; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_1 + NUMBER_OF_MESSAGES_2); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file in PAUSED state. + * + * Since the recorder is in PAUSED state, it should not record any messages. + * NOTE: The recorder won't change states since both \c STATE_1 and \c STATE_2 are PAUSED. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_paused) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, 0); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file in SUSPENDED state. + * + * Since the recorder is in SUSPENDED state, it should not record any messages. + * NOTE: The recorder won't change states since both \c STATE_1 and \c STATE_2 are SUSPENDED. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_suspended) +{ + const std::string OUTPUT_FILE_NAME = "transition_suspended"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::SUSPENDED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::SUSPENDED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Verify that the SQL file wasn't created + ASSERT_FALSE(std::filesystem::exists(OUTPUT_FILE_PATH)); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file in STOPPED state. + * + * Since the recorder is in STOPPED state, it should not record any messages. + * NOTE: The recorder won't change states since both \c STATE_1 and \c STATE_2 are STOPPED. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_stopped) +{ + const std::string OUTPUT_FILE_NAME = "transition_stopped"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::STOPPED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::STOPPED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Verify that the SQL file wasn't created + ASSERT_FALSE(std::filesystem::exists(OUTPUT_FILE_PATH)); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from RUNNING to PAUSED. + * + * The recorder should record all messages while in RUNNING state and none while in PAUSED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_running_paused) +{ + const std::string OUTPUT_FILE_NAME = "transition_running_paused"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::RUNNING; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_1); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from RUNNING to SUSPENDED. + * + * The recorder should record all messages while in RUNNING state and none while in SUSPENDED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_running_suspended) +{ + const std::string OUTPUT_FILE_NAME = "transition_running_suspended"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::RUNNING; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::SUSPENDED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_1); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from RUNNING to STOPPED. + * + * The recorder should record all messages while in RUNNING state and none while in STOPPED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_running_stopped) +{ + const std::string OUTPUT_FILE_NAME = "transition_running_stopped"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::RUNNING; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::STOPPED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_1); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from PAUSED to RUNNING. + * + * The recorder should not record any messages while in PAUSED state and all messages while in RUNNING state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_paused_running) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_running"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::RUNNING; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_2); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from PAUSED to SUSPENDED. + * + * The recorder should not record any messages while in PAUSED state or while in SUSPENDED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_paused_suspended) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_suspended"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::SUSPENDED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, 0); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from PAUSED to STOPPED. + * + * The recorder should not record any messages while in PAUSED state or while in STOPPED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_paused_stopped) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_stopped"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::STOPPED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, 0); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from SUSPENDED to RUNNING. + * + * The recorder should not record any messages while in SUSPENDED state and all messages while in RUNNING state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_suspended_running) +{ + const std::string OUTPUT_FILE_NAME = "transition_suspended_running"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::SUSPENDED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::RUNNING; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_2); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from SUSPENDED to PAUSED. + * + * The recorder should not record any messages while in SUSPENDED state or while in PAUSED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_suspended_paused) +{ + const std::string OUTPUT_FILE_NAME = "transition_suspended_paused"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::SUSPENDED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, 0); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from SUSPENDED to STOPPED. + * + * The recorder should not record any messages while in SUSPENDED state or while in STOPPED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_suspended_stopped) +{ + const std::string OUTPUT_FILE_NAME = "transition_suspended_stopped"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::SUSPENDED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::STOPPED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Verify that the SQL file wasn't created + ASSERT_FALSE(std::filesystem::exists(OUTPUT_FILE_PATH)); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from STOPPED to RUNNING. + * + * The recorder should not record any messages while in STOPPED state and all messages while in RUNNING state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_stopped_running) +{ + const std::string OUTPUT_FILE_NAME = "transition_stopped_running"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::STOPPED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::RUNNING; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_2); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from STOPPED to PAUSED. + * + * The recorder should not record any messages while in STOPPED state or while in PAUSED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_stopped_paused) +{ + const std::string OUTPUT_FILE_NAME = "transition_stopped_paused"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::STOPPED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, 0); + }); +} + +/** + * @brief Verify that the DDS Recorder records properly in an SQL file after transitioning from STOPPED to SUSPENDED. + * + * The recorder should not record any messages while in STOPPED state or while in SUSPENDED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(SqlFileCreationTest, transition_stopped_suspended) +{ + const std::string OUTPUT_FILE_NAME = "transition_stopped_suspended"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::STOPPED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::SUSPENDED; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + + // Verify that the SQL file wasn't created + ASSERT_FALSE(std::filesystem::exists(OUTPUT_FILE_PATH)); +} + + +// ////////////////// +// // Event window // +// ////////////////// + +/** + * @brief Verify that the DDS Recorder in PAUSED state records properly in an SQL file with an \c EVENT_WINDOW and a + * small \c WAIT between the two batches of messages being sent. + * + * The recorder should record all messages. + * WARNING: This test could fail due to two race conditions. + * + * CASES: + * - Verify that the message count matches the recorded message count. + * - Verify that the oldest recorded message was recorded in the event window. + */ +TEST_F(SqlFileCreationTest, transition_paused_event_less_window) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_event_less_window"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + constexpr auto EVENT_WINDOW = 3; + constexpr auto WAIT = 1; + constexpr auto EVENT = EventKind::EVENT; + + configuration_->event_window = EVENT_WINDOW; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2, WAIT, EVENT); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_1 + NUMBER_OF_MESSAGES_2); + }); + + const auto now = utils::now(); + const auto now_tks = ddsrecorder::participants::to_ticks(now); + + // Find the oldest recorded message + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT MIN(log_time) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the oldest recorded message was recorded in the event window + const auto log_time = reinterpret_cast(sqlite3_column_text(stmt, 0)); + const auto log_time_ts = ddsrecorder::participants::to_std_timestamp(log_time); + const auto log_time_tks = ddsrecorder::participants::to_ticks(log_time_ts); + + const auto NS_TO_SEC = pow(10, -9); + const auto max_time_past = (now_tks - log_time_tks) * NS_TO_SEC; + + ASSERT_LE(max_time_past, EVENT_WINDOW); + }); +} + +/** + * @brief Verify that the DDS Recorder in PAUSED state records properly in an SQL file with an \c EVENT_WINDOW and a + * \c WAIT as long as the \c EVENT_WINDOW between the two batches of messages being sent. + * + * The recorder should record the second batch of messages. + * + * CASES: + * - Verify that the message count matches the recorded message count. + * - Verify that the oldest recorded message was recorded in the event window. + */ +TEST_F(SqlFileCreationTest, transition_paused_event_max_window) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_event_max_window"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + constexpr auto EVENT_WINDOW = 3; + constexpr auto WAIT = EVENT_WINDOW; + constexpr auto EVENT = EventKind::EVENT; + + configuration_->event_window = EVENT_WINDOW; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2, WAIT, EVENT); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_2); + }); + + const auto now = utils::now(); + const auto now_tks = ddsrecorder::participants::to_ticks(now); + + // Find the oldest recorded message + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT MIN(log_time) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the oldest recorded message was recorded in the event window + const auto log_time = reinterpret_cast(sqlite3_column_text(stmt, 0)); + const auto log_time_ts = ddsrecorder::participants::to_std_timestamp(log_time); + const auto log_time_tks = ddsrecorder::participants::to_ticks(log_time_ts); + + const auto NS_TO_SEC = pow(10, -9); + const auto max_time_past = (now_tks - log_time_tks) * NS_TO_SEC; + + ASSERT_LE(max_time_past, EVENT_WINDOW); + }); +} + +// //////////// +// // Events // +// //////////// + +/** + * @brief Verify that the DDS Recorder in PAUSED state records properly in an SQL file with an \c EVENT_START. + * + * The recorder should record all messages. + * + * CASES: + * - Verify that the message count matches the recorded message count. + * - Verify that the oldest recorded message was recorded in the event window. + */ +TEST_F(SqlFileCreationTest, transition_paused_event_start) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_event_start"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + constexpr auto EVENT_WINDOW = 3; + constexpr auto WAIT = 3; + constexpr auto EVENT = EventKind::EVENT_START; + + configuration_->event_window = EVENT_WINDOW; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2, WAIT, EVENT); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_2); + }); + + const auto now = utils::now(); + const auto now_tks = ddsrecorder::participants::to_ticks(now); + + // Find the oldest recorded message + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT MIN(log_time) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the oldest recorded message was recorded in the event window + const auto log_time = reinterpret_cast(sqlite3_column_text(stmt, 0)); + const auto log_time_ts = ddsrecorder::participants::to_std_timestamp(log_time); + const auto log_time_tks = ddsrecorder::participants::to_ticks(log_time_ts); + + const auto NS_TO_SEC = pow(10, -9); + const auto max_time_past = (now_tks - log_time_tks) * NS_TO_SEC; + + ASSERT_LE(max_time_past, EVENT_WINDOW); + }); +} + +/** + * @brief Verify that the DDS Recorder in PAUSED state records properly in an SQL file with an \c EVENT_SUSPEND. + * + * The recorder should record all messages. + * + * CASES: + * - Verify that the message count matches the recorded message count. + * - Verify that the oldest recorded message was recorded in the event window. + */ +TEST_F(SqlFileCreationTest, transition_paused_event_suspend) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_event_suspend"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + constexpr auto EVENT_WINDOW = 3; + constexpr auto WAIT = 3; + constexpr auto EVENT = EventKind::EVENT_SUSPEND; + + configuration_->event_window = EVENT_WINDOW; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2, WAIT, EVENT); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_2); + }); + + const auto now = utils::now(); + const auto now_tks = ddsrecorder::participants::to_ticks(now); + + // Find the oldest recorded message + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT MIN(log_time) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the oldest recorded message was recorded in the event window + const auto log_time = reinterpret_cast(sqlite3_column_text(stmt, 0)); + const auto log_time_ts = ddsrecorder::participants::to_std_timestamp(log_time); + const auto log_time_tks = ddsrecorder::participants::to_ticks(log_time_ts); + + const auto NS_TO_SEC = pow(10, -9); + const auto max_time_past = (now_tks - log_time_tks) * NS_TO_SEC; + + ASSERT_LE(max_time_past, EVENT_WINDOW); + }); +} + +/** + * @brief Verify that the DDS Recorder in PAUSED state records properly in an SQL file with an \c EVENT_STOP. + * + * The recorder should record all messages. + * + * CASES: + * - Verify that the message count matches the recorded message count. + * - Verify that the oldest recorded message was recorded in the event window. + */ +TEST_F(SqlFileCreationTest, transition_paused_event_stop) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_event_stop"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + constexpr auto EVENT_WINDOW = 3; + constexpr auto WAIT = 3; + constexpr auto EVENT = EventKind::EVENT_STOP; + + configuration_->event_window = EVENT_WINDOW; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2, WAIT, EVENT); + + // Count the recorded messages + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT COUNT(*) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the recorded messages count + const auto recorded_messages = sqlite3_column_int(stmt, 0); + ASSERT_EQ(recorded_messages, NUMBER_OF_MESSAGES_2); + }); + + const auto now = utils::now(); + const auto now_tks = ddsrecorder::participants::to_ticks(now); + + // Find the oldest recorded message + exec_sql_statement_(OUTPUT_FILE_PATH.string(), "SELECT MIN(log_time) FROM Messages;", {}, [&](sqlite3_stmt* stmt) + { + // Verify the oldest recorded message was recorded in the event window + const auto log_time = reinterpret_cast(sqlite3_column_text(stmt, 0)); + const auto log_time_ts = ddsrecorder::participants::to_std_timestamp(log_time); + const auto log_time_tks = ddsrecorder::participants::to_ticks(log_time_ts); + + const auto NS_TO_SEC = pow(10, -9); + const auto max_time_past = (now_tks - log_time_tks) * NS_TO_SEC; + + ASSERT_LE(max_time_past, EVENT_WINDOW); + }); +} + +int main( + int argc, + char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} From 78743f0e5dee7ef66b2a6d0922c003ffeb3168b3 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 7 Jun 2024 15:16:13 +0200 Subject: [PATCH 33/52] Strip recording methods from McapFileCreationTest Signed-off-by: tempate --- .../test/blackbox/FileCreationTest.hpp | 2 +- ddsrecorder/test/blackbox/mcap/CMakeLists.txt | 18 +- .../blackbox/mcap/McapFileCreationTest.cpp | 1344 +++++++++-------- 3 files changed, 747 insertions(+), 617 deletions(-) diff --git a/ddsrecorder/test/blackbox/FileCreationTest.hpp b/ddsrecorder/test/blackbox/FileCreationTest.hpp index 7fa8a8556..7ca35b8e9 100644 --- a/ddsrecorder/test/blackbox/FileCreationTest.hpp +++ b/ddsrecorder/test/blackbox/FileCreationTest.hpp @@ -83,7 +83,7 @@ class FileCreationTest : public testing::Test // Register the type fastdds::dds::TypeSupport type(new HelloWorldPubSubType()); - type.register_type(participant_); + participant_->register_type(type); // Create the publisher publisher_ = participant_->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT, nullptr); diff --git a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt index f0c23a862..0a07b84d5 100644 --- a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt @@ -37,24 +37,32 @@ set(TEST_LIST mcap_ros2_topic mcap_data_num_msgs mcap_data_num_msgs_downsampling + + # State transition_running transition_paused transition_stopped transition_suspended + + # Transitions transition_running_paused - transition_running_stopped transition_running_suspended + transition_running_stopped transition_paused_running - transition_paused_stopped transition_paused_suspended - transition_stopped_running - transition_stopped_paused - transition_stopped_suspended + transition_paused_stopped transition_suspended_running transition_suspended_paused transition_suspended_stopped + transition_stopped_running + transition_stopped_paused + transition_stopped_suspended + + # Event window transition_paused_event_less_window transition_paused_event_max_window + + # Events transition_paused_event_start transition_paused_event_stop transition_paused_event_suspend diff --git a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp index 433672b9d..4f752abac 100644 --- a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include +#include +#include +#include +#include #include #include @@ -31,853 +32,974 @@ #include #include -#include -#include +#include + +#include +#include #include #include -#include - -#include "../../resources/types/hello_world/HelloWorld.hpp" -#include "../../resources/types/hello_world/HelloWorldPubSubTypes.hpp" -#include "../../resources/types/hello_world/HelloWorldTypeObjectSupport.hpp" +#include "../constants.hpp" +#include "../FileCreationTest.hpp" using namespace eprosima::ddspipe; using namespace eprosima::ddsrecorder; using namespace eprosima::ddsrecorder::recorder; using namespace eprosima::fastdds::dds; -using DdsRecorderState = eprosima::ddsrecorder::recorder::DdsRecorderStateCode; - -enum class DataTypeKind +class McapFileCreationTest : public FileCreationTest { - HELLO_WORLD, -}; +public: -enum class EventKind -{ - NO_EVENT, - EVENT, - EVENT_START, - EVENT_STOP, - EVENT_SUSPEND, -}; + void SetUp() override + { + FileCreationTest::SetUp(); -namespace test { + // Set the output library to MCAP + configuration_->output_library = ddsrecorder::participants::OutputLibrary::mcap; + } -// Publisher + void TearDown() override + { + mcap_reader_.close(); -const unsigned int DOMAIN = 222; + FileCreationTest::TearDown(); + } -const std::string dds_topic_name = "TypeIntrospectionTopic"; -const std::string dds_type_name = "HelloWorld"; +protected: -const std::string ros2_topic_name = "rt/hello"; -const std::string ros2_type_name = "std_msgs::msg::dds_::String_"; + mcap::LinearMessageView read_messages_( + const std::string& file_path) + { + const auto status = mcap_reader_.open(file_path); -const unsigned int n_msgs = 3; -const std::string send_message = "Hello World"; -const unsigned int index = 6; -const unsigned int downsampling = 3; + // NOTE: This can't be made const since a copy const constructor doesn't exist. + auto messages = mcap_reader_.readMessages(); -eprosima::fastdds::dds::DataWriter* writer_; -eprosima::fastdds::dds::traits::ref_type dynamic_type_; + return messages; + } -} // test + unsigned int count_messages_( + mcap::LinearMessageView& messages) + { + unsigned int received_messages = 0; -std::unique_ptr create_recorder( - const std::string file_name, - const int downsampling, - DdsRecorderState recorder_state = DdsRecorderState::RUNNING, - const unsigned int event_window = 20, - const bool ros2_types = false) -{ - YAML::Node yml; + // TODO: Replace this method with messages.size() or with std::distance when MCAP's API allows it. + for (const auto& message : messages) + { + received_messages++; - eprosima::ddsrecorder::yaml::RecorderConfiguration configuration(yml); - configuration.topic_qos.downsampling = downsampling; - // Set default value for downsampling - // TODO: Change mechanism setting topic qos' default values from specs - eprosima::ddspipe::core::types::TopicQoS::default_topic_qos.set_value(configuration.topic_qos); - configuration.event_window = event_window; - eprosima::ddspipe::core::types::DomainId domainId; - domainId.domain_id = test::DOMAIN; - configuration.simple_configuration->domain = domainId; - configuration.ros2_types = ros2_types; - - std::shared_ptr file_tracker; - - return std::make_unique( - configuration, - recorder_state, - file_tracker, - file_name); -} + // Avoid unused variable warning + (void) message; + } -void create_publisher( - const std::string topic_name, - const std::string type_name, - const unsigned int domain) -{ - eprosima::fastdds::dds::DomainParticipantQos pqos; - pqos.name("TypeIntrospectionExample_Participant_Publisher"); - - // Create the Participant - eprosima::fastdds::dds::DomainParticipant* participant_ = - DomainParticipantFactory::get_instance()->create_participant(domain, pqos); - - // Register the type - eprosima::fastdds::dds::TypeSupport type(new HelloWorldPubSubType()); - type->register_type_object_representation(); - - eprosima::fastdds::dds::xtypes::TypeObjectPair dyn_type_objects; - if (eprosima::fastdds::dds::RETCODE_OK != - eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_objects( - type_name, - dyn_type_objects)) - { - return; + return received_messages; } - test::dynamic_type_ = eprosima::fastdds::dds::DynamicTypeBuilderFactory::get_instance()->create_type_w_type_object( - dyn_type_objects.complete_type_object)->build(); - - // Set type so introspection info is sent - type->auto_fill_type_information(true); - - // Register the type in the Participant - participant_->register_type(type); + double find_max_time_past_( + mcap::LinearMessageView& messages) + { + const auto now = ddsrecorder::participants::to_mcap_timestamp(utils::now()); - // Create the Publisher - eprosima::fastdds::dds::Publisher* publisher_ = participant_->create_publisher(PUBLISHER_QOS_DEFAULT, nullptr); + std::uint64_t max_time_past = 0; - // Create the DDS Topic - eprosima::fastdds::dds::Topic* topic_ = participant_->create_topic(topic_name, type_name, - TOPIC_QOS_DEFAULT); + for (const auto& it : messages) + { + const auto time_past = now - it.message.logTime; - // Create the DDS DataWriter - test::writer_ = publisher_->create_datawriter(topic_, DATAWRITER_QOS_DEFAULT, nullptr); -} + if (time_past > max_time_past) + { + max_time_past = time_past; + } + } -eprosima::fastdds::dds::traits::ref_type send_sample( - const unsigned int index = 1, - const unsigned int time_sleep = 100) -{ - // Create and initialize new dynamic data - // eprosima::fastdds::dds::traits::ref_type dynamic_data_; + const auto NS_TO_SEC = pow(10, -9); + const auto max_time_past_sec = max_time_past * NS_TO_SEC; - if (test::dynamic_type_ == nullptr) - { - return nullptr; + return max_time_past_sec; } - auto dynamic_data_ = eprosima::fastdds::dds::DynamicDataFactory::get_instance()->create_data(test::dynamic_type_); + mcap::McapReader mcap_reader_; +}; - // Set index - dynamic_data_->set_uint32_value(dynamic_data_->get_member_id_by_name("index"), 0); - // Set message - dynamic_data_->set_string_value(dynamic_data_->get_member_id_by_name("message"), test::send_message); - test::writer_->write(dynamic_data_.get()); +/** + * Verify that the DDS Recorder records properly in an MCAP file. + * + * CASES: + * - Verify that the messages' data matches the recorded data. + * - Verify that the messages' sizes match the recorded data sizes. + */ +TEST_F(McapFileCreationTest, mcap_data_msgs) +{ + const std::string OUTPUT_FILE_NAME = "mcap_data_msgs"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - logInfo(DDSRECORDER_EXECUTION, "Message published."); + constexpr auto NUMBER_OF_MESSAGES = 10; - std::this_thread::sleep_for(std::chrono::milliseconds(time_sleep)); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - return dynamic_data_; -} + // Record messages + const auto sent_messages = record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); + auto sent_message = sent_messages.begin(); -eprosima::fastdds::dds::traits::ref_type record( - const std::string file_name, - const unsigned int num_msgs = 1, - const unsigned int downsampling = 1, - const bool ros2_types = false) -{ - eprosima::fastdds::dds::traits::ref_type send_data; - { - // Create Recorder - auto recorder = create_recorder(file_name, downsampling, DdsRecorderState::RUNNING, 20, ros2_types); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); - // Create Publisher - ros2_types ? create_publisher(test::ros2_topic_name, test::dds_type_name, test::DOMAIN) : create_publisher( - test::dds_topic_name, test::dds_type_name, test::DOMAIN); + auto read_message_count = 0; - // Send data - for (unsigned int i = 0; i < num_msgs; i++) - { - send_data = send_sample(test::index); - } - } + for (const auto& it : read_messages) + { + read_message_count++; - return send_data; -} + // Verify the data size + const auto read_data_size = it.message.dataSize; + ASSERT_EQ((*sent_message)->length, read_data_size); -mcap::LinearMessageView get_msgs_mcap( - const std::string file_name, - mcap::McapReader& mcap_reader_) -{ - auto status = mcap_reader_.open(file_name + ".mcap"); + // Verify the data + const auto read_data = (unsigned char*) reinterpret_cast(it.message.data); + ASSERT_EQ(strcmp((char*) (*sent_message)->data, (char*) read_data), 0); - auto messages = mcap_reader_.readMessages(); + sent_message++; + } - return messages; + // Verify that it read messages + ASSERT_GT(read_message_count, 0); } -std::tuple record_with_transitions( - const std::string file_name, - DdsRecorderState init_state, - const unsigned int first_round, - const unsigned int secound_round, - DdsRecorderState current_state, - EventKind event = EventKind::NO_EVENT, - const unsigned int event_window = 20, - unsigned int time_sleep = 0, - const unsigned int downsampling = 1, - const bool ros2_types = false) +/** + * Verify that the DDS Recorder records topics properly in an MCAP file. + * + * CASES: + * - Verify that the topic's name matches the recorded topic's name. + * - Verify that the topic's type matches the recorded topic's type. + */ +TEST_F(McapFileCreationTest, mcap_dds_topic) { - uint64_t current_time; - { - // Create Publisher - ros2_types ? create_publisher(test::ros2_topic_name, test::ros2_type_name, test::DOMAIN) : create_publisher( - test::dds_topic_name, test::dds_type_name, test::DOMAIN); + const std::string OUTPUT_FILE_NAME = "mcap_dds_topic"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - // Create Recorder - std::unique_ptr recorder = - create_recorder(file_name, downsampling, init_state, event_window, ros2_types); + constexpr auto NUMBER_OF_MESSAGES = 10; - // Send data - for (unsigned int i = 0; i < first_round; i++) - { - send_sample(); - } + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - if (init_state != current_state) - { - switch (current_state) - { - case DdsRecorderState::RUNNING: - recorder->start(); - break; - case DdsRecorderState::SUSPENDED: - recorder->suspend(); - break; - case DdsRecorderState::STOPPED: - recorder->stop(); - break; - case DdsRecorderState::PAUSED: - recorder->pause(); - break; - default: - break; - } - } - - if (!time_sleep) - { - time_sleep = rand() % 2; - } - std::this_thread::sleep_for(std::chrono::seconds(time_sleep)); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); - for (unsigned int i = 0; i < secound_round; i++) - { - send_sample(); - } + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); - current_time = std::chrono::duration_cast - (std::chrono::system_clock::now().time_since_epoch()).count(); + auto read_message_count = 0; - if (event != EventKind::NO_EVENT && current_state == DdsRecorderState::PAUSED) - { - recorder->trigger_event(); - if (event == EventKind::EVENT_START) - { - recorder->start(); - } - else if (event == EventKind::EVENT_STOP) - { - recorder->stop(); - } - else if (event == EventKind::EVENT_SUSPEND) - { - recorder->suspend(); - } - } - } + for (const auto& read_message : read_messages) + { + read_message_count++; - mcap::McapReader mcap_reader; - auto messages = get_msgs_mcap(file_name, mcap_reader); + // Verify the topic's name + const auto read_topic_name = read_message.channel->topic; + ASSERT_EQ(topic_->get_name(), read_topic_name); - unsigned int n_received_msgs = 0; - double max_timestamp = 0; - for (auto it = messages.begin(); it != messages.end(); it++) - { - n_received_msgs++; - double time_seconds = ((current_time) - (it->message.logTime)) * pow(10.0, -9.0); - if (time_seconds > max_timestamp) - { - max_timestamp = time_seconds; - } + // Verify the topic's type + const auto read_topic_type = read_message.schema->name; + ASSERT_EQ(topic_->get_type_name(), read_topic_type); } - mcap_reader.close(); - return std::tuple{n_received_msgs, max_timestamp}; + // Verify that it read messages + ASSERT_GT(read_message_count, 0); } -// TEST(McapFileCreationTest, mcap_data_msgs) -// { - -// const std::string file_name = "output_mcap_data_msgs"; -// eprosima::fastdds::dds::traits::ref_type send_data; -// send_data = record(file_name); - -// eprosima::fastdds::dds::DynamicPubSubType pubsubType; -// eprosima::fastdds::rtps::SerializedPayload_t payload; -// payload.reserve( -// pubsubType.getSerializedSizeProvider( -// send_data.get() -// )() -// ); -// pubsubType.serialize(send_data.get(), &payload); - -// mcap::McapReader mcap_reader; -// auto messages = get_msgs_mcap(file_name, mcap_reader); - -// for (auto it = messages.begin(); it != messages.end(); it++) -// { -// auto received_msg = reinterpret_cast(it->message.data); -// for (unsigned int i = 0; i < payload.length; i++) -// { -// ASSERT_EQ(payload.data[i], received_msg[i]) << "wrong data !!"; -// } -// ASSERT_EQ(payload.length, it->message.dataSize) << "length fails !!"; -// } -// mcap_reader.close(); - -// } - -TEST(McapFileCreationTest, mcap_dds_topic) +/** + * Verify that the DDS Recorder records ROS 2 topics properly in an MCAP file. + * + * CASES: + * - Verify that the topic's name matches the recorded topic's name. + * - Verify that the topic's type matches the recorded topic's type. + */ +TEST_F(McapFileCreationTest, mcap_ros2_topic) { + const std::string OUTPUT_FILE_NAME = "mcap_ros2_topic"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - const std::string file_name = "output_mcap_dds_topic"; + constexpr auto NUMBER_OF_MESSAGES = 10; - record(file_name); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - mcap::McapReader mcap_reader; - auto messages = get_msgs_mcap(file_name, mcap_reader); + configuration_->ros2_types = true; - std::string received_topic = ""; - std::string received_data_type_name = ""; + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); - for (auto it = messages.begin(); it != messages.end(); it++) - { - received_topic = it->channel->topic; - received_data_type_name = it->schema->name; - } - mcap_reader.close(); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); - // Test data - ASSERT_EQ(received_topic, test::dds_topic_name); - ASSERT_EQ(received_data_type_name, test::dds_type_name); + auto read_message_count = 0; -} - -TEST(McapFileCreationTest, mcap_ros2_topic) -{ - - const std::string file_name = "output_mcap_ros2_topic"; - - record(file_name, 1, 1, true); - - mcap::McapReader mcap_reader; - auto messages = get_msgs_mcap(file_name, mcap_reader); + for (const auto& read_message : read_messages) + { + read_message_count++; - std::string received_topic = ""; - std::string received_data_type_name = ""; + // Verify the topic's name + const auto read_topic_name = read_message.channel->topic; + ASSERT_EQ(utils::demangle_if_ros_topic(topic_->get_name()), read_topic_name); - for (auto it = messages.begin(); it != messages.end(); it++) - { - received_topic = it->channel->topic; - received_data_type_name = it->schema->name; + // Verify the topic's type + const auto read_topic_type = read_message.schema->name; + ASSERT_EQ(utils::demangle_if_ros_topic(topic_->get_type_name()), read_topic_type); } - mcap_reader.close(); - - // Test data - ASSERT_EQ(received_topic, eprosima::utils::demangle_if_ros_topic(test::ros2_topic_name)); - ASSERT_EQ(received_data_type_name, test::dds_type_name); + // Verify that it read messages + ASSERT_GT(read_message_count, 0); } -TEST(McapFileCreationTest, mcap_data_num_msgs) +TEST_F(McapFileCreationTest, mcap_data_num_msgs) { + const std::string OUTPUT_FILE_NAME = "mcap_data_num_msgs"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - const std::string file_name = "output_mcap_data_num_msgs"; + constexpr auto NUMBER_OF_MESSAGES = 10; - record(file_name, test::n_msgs); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - mcap::McapReader mcap_reader; - auto messages = get_msgs_mcap(file_name, mcap_reader); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); - unsigned int n_received_msgs = 0; - for (auto it = messages.begin(); it != messages.end(); it++) - { - n_received_msgs++; - } - mcap_reader.close(); - - // Test data - ASSERT_EQ(test::n_msgs, n_received_msgs); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES); } -TEST(McapFileCreationTest, mcap_data_num_msgs_downsampling) +TEST_F(McapFileCreationTest, mcap_data_num_msgs_downsampling) { + const std::string OUTPUT_FILE_NAME = "mcap_data_num_msgs_downsampling"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - const std::string file_name = "output_mcap_data_num_msgs_downsampling"; + constexpr auto NUMBER_OF_MESSAGES = 10; + constexpr int DOWNSAMPLING = 2; - record(file_name, test::n_msgs, test::downsampling); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - mcap::McapReader mcap_reader; - auto messages = get_msgs_mcap(file_name, mcap_reader); + // TODO: Change mechanism setting topic qos' default values from specs + configuration_->topic_qos.downsampling = DOWNSAMPLING; + ddspipe::core::types::TopicQoS::default_topic_qos.set_value(configuration_->topic_qos); - unsigned int n_received_msgs = 0; - for (auto it = messages.begin(); it != messages.end(); it++) - { - n_received_msgs++; - } - mcap_reader.close(); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); - // Test data - unsigned int expected_msgs = test::n_msgs / test::downsampling; - if (test::n_msgs % test::downsampling) - { - expected_msgs++; - } - ASSERT_EQ(expected_msgs, n_received_msgs); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + const auto expected_messages = (NUMBER_OF_MESSAGES / DOWNSAMPLING) + (NUMBER_OF_MESSAGES % DOWNSAMPLING); + ASSERT_EQ(read_messages_count, expected_messages); } -////////////////////// -// With transitions // -////////////////////// +// ////////////////////// +// // With transitions // +// ////////////////////// -TEST(McapFileCreationTest, transition_running) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file in RUNNING state. + * + * Since the recorder is in RUNNING state, it should record all messages. + * NOTE: The recorder won't change states since both \c STATE_1 and \c STATE_2 are RUNNING. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_running) { - const std::string file_name = "output_transition_running"; + const std::string OUTPUT_FILE_NAME = "transition_running"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::RUNNING; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::RUNNING; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::RUNNING, - n_data_1, n_data_2, - DdsRecorderState::RUNNING); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, (n_data_1 + n_data_2)); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_1 + NUMBER_OF_MESSAGES_2); } -TEST(McapFileCreationTest, transition_paused) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file in PAUSED state. + * + * Since the recorder is in PAUSED state, it should not record any messages. + * NOTE: The recorder won't change states since both \c STATE_1 and \c STATE_2 are PAUSED. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_paused) { - const std::string file_name = "output_transition_paused"; + const std::string OUTPUT_FILE_NAME = "transition_paused"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::PAUSED, - n_data_1, n_data_2, - DdsRecorderState::PAUSED); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, 0); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, 0); } -TEST(McapFileCreationTest, transition_stopped) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file in SUSPENDED state. + * + * Since the recorder is in SUSPENDED state, it should not record any messages. + * NOTE: The recorder won't change states since both \c STATE_1 and \c STATE_2 are SUSPENDED. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_suspended) { - const std::string file_name = "output_transition_stopped"; - - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + const std::string OUTPUT_FILE_NAME = "transition_suspended"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - auto recording = record_with_transitions( - file_name, - DdsRecorderState::STOPPED, - n_data_1, n_data_2, - DdsRecorderState::STOPPED); + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::SUSPENDED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::SUSPENDED; - unsigned int n_received_msgs = std::get<0>(recording); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - ASSERT_EQ(n_received_msgs, 0); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); -} + // Verify that the MCAP file wasn't created + ASSERT_FALSE(std::filesystem::exists(OUTPUT_FILE_PATH)); +} -TEST(McapFileCreationTest, transition_suspended) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file in STOPPED state. + * + * Since the recorder is in STOPPED state, it should not record any messages. + * NOTE: The recorder won't change states since both \c STATE_1 and \c STATE_2 are STOPPED. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_stopped) { - const std::string file_name = "output_transition_suspended"; + const std::string OUTPUT_FILE_NAME = "transition_stopped"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::STOPPED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::STOPPED; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::SUSPENDED, - n_data_1, n_data_2, - DdsRecorderState::SUSPENDED); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); - - ASSERT_EQ(n_received_msgs, 0); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + // Verify that the MCAP file wasn't created + ASSERT_FALSE(std::filesystem::exists(OUTPUT_FILE_PATH)); } -TEST(McapFileCreationTest, transition_running_paused) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from RUNNING to PAUSED. + * + * The recorder should record all messages while in RUNNING state and none while in PAUSED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_running_paused) { - const std::string file_name = "output_transition_running_paused"; + const std::string OUTPUT_FILE_NAME = "transition_running_paused"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::RUNNING; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::RUNNING, - n_data_1, n_data_2, - DdsRecorderState::PAUSED); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, (n_data_1)); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_1); } -TEST(McapFileCreationTest, transition_running_stopped) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from RUNNING to SUSPENDED. + * + * The recorder should record all messages while in RUNNING state and none while in SUSPENDED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_running_suspended) { - const std::string file_name = "output_transition_running_stopped"; + const std::string OUTPUT_FILE_NAME = "transition_running_suspended"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::RUNNING; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::SUSPENDED; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::RUNNING, - n_data_1, n_data_2, - DdsRecorderState::STOPPED); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, (n_data_1)); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_1); } -TEST(McapFileCreationTest, transition_running_suspended) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from RUNNING to STOPPED. + * + * The recorder should record all messages while in RUNNING state and none while in STOPPED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_running_stopped) { - const std::string file_name = "output_transition_running_suspended"; + const std::string OUTPUT_FILE_NAME = "transition_running_stopped"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::RUNNING; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::STOPPED; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::RUNNING, - n_data_1, n_data_2, - DdsRecorderState::SUSPENDED); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, (n_data_1)); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_1); } -TEST(McapFileCreationTest, transition_paused_running) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from PAUSED to RUNNING. + * + * The recorder should not record any messages while in PAUSED state and all messages while in RUNNING state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_paused_running) { - const std::string file_name = "output_transition_paused_running"; + const std::string OUTPUT_FILE_NAME = "transition_paused_running"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::RUNNING; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::PAUSED, - n_data_1, n_data_2, - DdsRecorderState::RUNNING); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, (n_data_2)); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_2); } -TEST(McapFileCreationTest, transition_paused_stopped) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from PAUSED to SUSPENDED. + * + * The recorder should not record any messages while in PAUSED state or while in SUSPENDED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_paused_suspended) { - const std::string file_name = "output_transition_paused_stopped"; + const std::string OUTPUT_FILE_NAME = "transition_paused_suspended"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::SUSPENDED; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::PAUSED, - n_data_1, n_data_2, - DdsRecorderState::STOPPED); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, 0); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, 0); } -TEST(McapFileCreationTest, transition_paused_suspended) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from PAUSED to STOPPED. + * + * The recorder should not record any messages while in PAUSED state or while in STOPPED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_paused_stopped) { - const std::string file_name = "output_transition_paused_suspended"; + const std::string OUTPUT_FILE_NAME = "transition_paused_stopped"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::STOPPED; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::PAUSED, - n_data_1, n_data_2, - DdsRecorderState::SUSPENDED); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, 0); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, 0); } -TEST(McapFileCreationTest, transition_stopped_running) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from SUSPENDED to RUNNING. + * + * The recorder should not record any messages while in SUSPENDED state and all messages while in RUNNING state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_suspended_running) { - const std::string file_name = "output_transition_stopped_running"; + const std::string OUTPUT_FILE_NAME = "transition_suspended_running"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::SUSPENDED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::RUNNING; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::STOPPED, - n_data_1, n_data_2, - DdsRecorderState::RUNNING); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, (n_data_2)); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_2); } -TEST(McapFileCreationTest, transition_stopped_paused) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from SUSPENDED to PAUSED. + * + * The recorder should not record any messages while in SUSPENDED state or while in PAUSED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_suspended_paused) { - const std::string file_name = "output_transition_stopped_paused"; + const std::string OUTPUT_FILE_NAME = "transition_suspended_paused"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::SUSPENDED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::STOPPED, - n_data_1, n_data_2, - DdsRecorderState::PAUSED); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, 0); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, 0); } -TEST(McapFileCreationTest, transition_stopped_suspended) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from SUSPENDED to STOPPED. + * + * The recorder should not record any messages while in SUSPENDED state or while in STOPPED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_suspended_stopped) { - const std::string file_name = "output_transition_stopped_suspended"; - - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + const std::string OUTPUT_FILE_NAME = "transition_suspended_stopped"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - auto recording = record_with_transitions( - file_name, - DdsRecorderState::SUSPENDED, - n_data_1, n_data_2, - DdsRecorderState::SUSPENDED); + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::SUSPENDED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::STOPPED; - unsigned int n_received_msgs = std::get<0>(recording); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - ASSERT_EQ(n_received_msgs, 0); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + // Verify that the MCAP file wasn't created + ASSERT_FALSE(std::filesystem::exists(OUTPUT_FILE_PATH)); } -TEST(McapFileCreationTest, transition_suspended_running) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from STOPPED to RUNNING. + * + * The recorder should not record any messages while in STOPPED state and all messages while in RUNNING state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_stopped_running) { - const std::string file_name = "output_transition_suspended_running"; + const std::string OUTPUT_FILE_NAME = "transition_stopped_running"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::STOPPED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::RUNNING; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::SUSPENDED, - n_data_1, n_data_2, - DdsRecorderState::RUNNING); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, (n_data_2)); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_2); } -TEST(McapFileCreationTest, transition_suspended_paused) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from STOPPED to PAUSED. + * + * The recorder should not record any messages while in STOPPED state or while in PAUSED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_stopped_paused) { - const std::string file_name = "output_transition_suspended_paused"; + const std::string OUTPUT_FILE_NAME = "transition_stopped_paused"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::STOPPED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::SUSPENDED, - n_data_1, n_data_2, - DdsRecorderState::PAUSED); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - unsigned int n_received_msgs = std::get<0>(recording); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); - ASSERT_EQ(n_received_msgs, 0); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, 0); } -TEST(McapFileCreationTest, transition_suspended_stopped) +/** + * @brief Verify that the DDS Recorder records properly in an MCAP file after transitioning from STOPPED to SUSPENDED. + * + * The recorder should not record any messages while in STOPPED state or while in SUSPENDED state. + * + * CASES: + * - Verify that the message count matches the recorded message count. + */ +TEST_F(McapFileCreationTest, transition_stopped_suspended) { - const std::string file_name = "output_transition_suspended_stopped"; - - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; + const std::string OUTPUT_FILE_NAME = "transition_stopped_suspended"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - auto recording = record_with_transitions( - file_name, - DdsRecorderState::STOPPED, - n_data_1, n_data_2, - DdsRecorderState::SUSPENDED); + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::STOPPED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::SUSPENDED; - unsigned int n_received_msgs = std::get<0>(recording); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - ASSERT_EQ(n_received_msgs, 0); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2); + // Verify that the MCAP file wasn't created + ASSERT_FALSE(std::filesystem::exists(OUTPUT_FILE_PATH)); } -// can fail due to two race conditions but is very unlikely -TEST(McapFileCreationTest, transition_paused_event_less_window) -{ - const std::string file_name = "output_transition_paused_event_less_window"; - - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; - unsigned int event_window = 3; - - auto recording = record_with_transitions( - file_name, - DdsRecorderState::PAUSED, - n_data_1, n_data_2, - DdsRecorderState::PAUSED, - EventKind::EVENT, event_window, 1); - - unsigned int n_received_msgs = std::get<0>(recording); - double max_timestamp = std::get<1>(recording); - ASSERT_EQ(n_received_msgs, (n_data_1 + n_data_2)); - ASSERT_LE(max_timestamp, event_window); +// ////////////////// +// // Event window // +// ////////////////// -} - -TEST(McapFileCreationTest, transition_paused_event_max_window) +/** + * @brief Verify that the DDS Recorder in PAUSED state records properly in an MCAP file with an \c EVENT_WINDOW and a + * small \c WAIT between the two batches of messages being sent. + * + * The recorder should record all messages. + * WARNING: This test could fail due to two race conditions. + * + * CASES: + * - Verify that the message count matches the recorded message count. + * - Verify that the oldest recorded message was recorded in the event window. + */ +TEST_F(McapFileCreationTest, transition_paused_event_less_window) { - const std::string file_name = "output_transition_paused_event_max_window"; + const std::string OUTPUT_FILE_NAME = "transition_paused_event_less_window"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; - unsigned int event_window = 3; + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + constexpr auto EVENT_WINDOW = 3; + constexpr auto WAIT = 1; + constexpr auto EVENT = EventKind::EVENT; - auto recording = record_with_transitions( - file_name, - DdsRecorderState::PAUSED, - n_data_1, n_data_2, - DdsRecorderState::PAUSED, - EventKind::EVENT, event_window, 3); + configuration_->event_window = EVENT_WINDOW; - unsigned int n_received_msgs = std::get<0>(recording); - double max_timestamp = std::get<1>(recording); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - ASSERT_EQ(n_received_msgs, n_data_2); - ASSERT_LE(max_timestamp, event_window); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2, WAIT, EVENT); -} + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); -TEST(McapFileCreationTest, transition_paused_event_start) + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_1 + NUMBER_OF_MESSAGES_2); + + // Verify the oldest recorded message was recorded in the event window + const auto max_time_past = find_max_time_past_(read_messages); + ASSERT_LE(max_time_past, EVENT_WINDOW); +} + +/** + * @brief Verify that the DDS Recorder in PAUSED state records properly in an MCAP file with an \c EVENT_WINDOW and a + * \c WAIT as long as the \c EVENT_WINDOW between the two batches of messages being sent. + * + * The recorder should record the second batch of messages. + * + * CASES: + * - Verify that the message count matches the recorded message count. + * - Verify that the oldest recorded message was recorded in the event window. + */ +TEST_F(McapFileCreationTest, transition_paused_event_max_window) { - const std::string file_name = "output_transition_paused_event_start"; + const std::string OUTPUT_FILE_NAME = "transition_paused_event_max_window"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + constexpr auto EVENT_WINDOW = 3; + constexpr auto WAIT = EVENT_WINDOW; + constexpr auto EVENT = EventKind::EVENT; - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; - unsigned int event_window = 3; + configuration_->event_window = EVENT_WINDOW; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2, WAIT, EVENT); - auto recording = record_with_transitions( - file_name, - DdsRecorderState::PAUSED, - n_data_1, n_data_2, - DdsRecorderState::PAUSED, - EventKind::EVENT_START, event_window, 3); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); - unsigned int n_received_msgs = std::get<0>(recording); - double max_timestamp = std::get<1>(recording); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_2); + + // Verify the oldest recorded message was recorded in the event window + const auto max_time_past = find_max_time_past_(read_messages); + ASSERT_LE(max_time_past, EVENT_WINDOW); +} - ASSERT_EQ(n_received_msgs, n_data_2); - ASSERT_LE(max_timestamp, event_window); +// //////////// +// // Events // +// //////////// + +/** + * @brief Verify that the DDS Recorder in PAUSED state records properly in an MCAP file with an \c EVENT_START. + * + * The recorder should record all messages. + * + * CASES: + * - Verify that the message count matches the recorded message count. + * - Verify that the oldest recorded message was recorded in the event window. + */ +TEST_F(McapFileCreationTest, transition_paused_event_start) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_event_start"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + constexpr auto EVENT_WINDOW = 3; + constexpr auto WAIT = 3; + constexpr auto EVENT = EventKind::EVENT_START; + + configuration_->event_window = EVENT_WINDOW; -} - -TEST(McapFileCreationTest, transition_paused_event_stop) -{ - const std::string file_name = "output_transition_paused_event_stop"; + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2, WAIT, EVENT); + + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; - unsigned int event_window = 3; + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_2); - auto recording = record_with_transitions( - file_name, - DdsRecorderState::PAUSED, - n_data_1, n_data_2, - DdsRecorderState::PAUSED, - EventKind::EVENT_STOP, event_window, 3); + // Verify the oldest recorded message was recorded in the event window + const auto max_time_past = find_max_time_past_(read_messages); + ASSERT_LE(max_time_past, EVENT_WINDOW); +} + +/** + * @brief Verify that the DDS Recorder in PAUSED state records properly in an MCAP file with an \c EVENT_SUSPEND. + * + * The recorder should record all messages. + * + * CASES: + * - Verify that the message count matches the recorded message count. + * - Verify that the oldest recorded message was recorded in the event window. + */ +TEST_F(McapFileCreationTest, transition_paused_event_suspend) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_event_suspend"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + constexpr auto EVENT_WINDOW = 3; + constexpr auto WAIT = 3; + constexpr auto EVENT = EventKind::EVENT_SUSPEND; - unsigned int n_received_msgs = std::get<0>(recording); - double max_timestamp = std::get<1>(recording); + configuration_->event_window = EVENT_WINDOW; - ASSERT_EQ(n_received_msgs, n_data_2); - ASSERT_LE(max_timestamp, event_window); + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); -} + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2, WAIT, EVENT); + + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); -TEST(McapFileCreationTest, transition_paused_event_suspend) -{ - const std::string file_name = "output_transition_paused_event_suspend"; + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_2); - unsigned int n_data_1 = rand() % 10 + 1; - unsigned int n_data_2 = rand() % 10 + 1; - unsigned int event_window = 3; + // Verify the oldest recorded message was recorded in the event window + const auto max_time_past = find_max_time_past_(read_messages); + ASSERT_LE(max_time_past, EVENT_WINDOW); +} + +/** + * @brief Verify that the DDS Recorder in PAUSED state records properly in an MCAP file with an \c EVENT_STOP. + * + * The recorder should record all messages. + * + * CASES: + * - Verify that the message count matches the recorded message count. + * - Verify that the oldest recorded message was recorded in the event window. + */ +TEST_F(McapFileCreationTest, transition_paused_event_stop) +{ + const std::string OUTPUT_FILE_NAME = "transition_paused_event_stop"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); + + constexpr auto NUMBER_OF_MESSAGES_1 = 11; + constexpr auto STATE_1 = DdsRecorderState::PAUSED; + constexpr auto NUMBER_OF_MESSAGES_2 = 9; + constexpr auto STATE_2 = DdsRecorderState::PAUSED; + constexpr auto EVENT_WINDOW = 3; + constexpr auto WAIT = 3; + constexpr auto EVENT = EventKind::EVENT_STOP; + + configuration_->event_window = EVENT_WINDOW; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); - auto recording = record_with_transitions( - file_name, - DdsRecorderState::PAUSED, - n_data_1, n_data_2, - DdsRecorderState::PAUSED, - EventKind::EVENT_SUSPEND, event_window, 3); + // Record messages + record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES_1, STATE_1, NUMBER_OF_MESSAGES_2, STATE_2, WAIT, EVENT); - unsigned int n_received_msgs = std::get<0>(recording); - double max_timestamp = std::get<1>(recording); + // Read the recorded messages + auto read_messages = read_messages_(OUTPUT_FILE_PATH); - ASSERT_EQ(n_received_msgs, n_data_2); - ASSERT_LE(max_timestamp, event_window); + // Verify the recorded messages count + const auto read_messages_count = count_messages_(read_messages); + ASSERT_EQ(read_messages_count, NUMBER_OF_MESSAGES_2); + // Verify the oldest recorded message was recorded in the event window + const auto max_time_past = find_max_time_past_(read_messages); + ASSERT_LE(max_time_past, EVENT_WINDOW); } int main( From 4e4446beaec24bbf149df9ed7f58339b0fa6253d Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 7 Jun 2024 15:23:13 +0200 Subject: [PATCH 34/52] Only write dynamic types in SQL when closing the file Signed-off-by: tempate --- .../recorder/sql/SqlWriter.hpp | 23 ++++++++++++ .../src/cpp/recorder/sql/SqlHandler.cpp | 2 +- .../src/cpp/recorder/sql/SqlWriter.cpp | 36 +++++++++++++++---- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp index 3e30805ab..37b3bcc26 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp @@ -20,11 +20,18 @@ #include #include +#include #include #include #include +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include +#else + #include +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + namespace eprosima { namespace ddsrecorder { namespace participants { @@ -52,6 +59,17 @@ class DDSRECORDER_PARTICIPANTS_DllAPI SqlWriter : public BaseWriter void write( const T& data); + /** + * @brief Updates the dynamic types. + * + * The dynamic types are written down when the MCAP file is being closed. + * This is done so that dynamic types can be updated even when the writer is disabled. + * + * @param dynamic_type The dynamic type to add to \c dynamic_types_. + */ + void update_dynamic_types( + const DynamicType& dynamic_type); + protected: /** @@ -68,6 +86,8 @@ class DDSRECORDER_PARTICIPANTS_DllAPI SqlWriter : public BaseWriter /** * @brief Closes the current file. * + * Writes the dynamic types to the SQL file. + * * @throws \c InconsistencyException if closing the current file fails. */ void close_current_file_nts_() override; @@ -97,6 +117,9 @@ class DDSRECORDER_PARTICIPANTS_DllAPI SqlWriter : public BaseWriter // The SQLite database sqlite3* database_; + // The received dynamic types + std::vector dynamic_types_; + // The size of an empty SQL file static constexpr std::uint64_t MIN_SQL_SIZE{20480}; }; diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp index 01ab35b5f..ceaba34fb 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp @@ -83,7 +83,7 @@ void SqlHandler::add_schema( if (configuration_.record_types) { const auto dynamic_type = dynamic_types_.dynamic_types().back(); - sql_writer_.write(dynamic_type); + sql_writer_.update_dynamic_types(dynamic_type); } // Check if there are any pending samples for this new type. If so, dump them. diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index 966d6a9ba..a213caf22 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -51,6 +51,14 @@ SqlWriter::SqlWriter( { } +void SqlWriter::update_dynamic_types( + const DynamicType& dynamic_type) +{ + std::lock_guard lock(mutex_); + + dynamic_types_.push_back(dynamic_type); +} + void SqlWriter::open_new_file_nts_( const std::uint64_t min_file_size) { @@ -123,16 +131,16 @@ void SqlWriter::open_new_file_nts_( create_sql_table_("Messages", create_messages_table); } -void SqlWriter::close_current_file_nts_() -{ - sqlite3_close(database_); - file_tracker_->close_file(); -} - template <> void SqlWriter::write_nts_( const DynamicType& dynamic_type) { + if (!enabled_) + { + logWarning(DDSRECORDER_SQL_WRITER, "Attempting to write a dynamic type in a disabled writer."); + return; + } + logInfo(DDSRECORDER_SQL_WRITER, "Writing dynamic type " << dynamic_type.type_name() << "."); // Define the SQL statement @@ -288,6 +296,22 @@ void SqlWriter::write_nts_( sqlite3_finalize(statement); } +// NOTE: The method has to be defined after the definition of write_nts_ for DynamicType +void SqlWriter::close_current_file_nts_() +{ + if (record_types_ && dynamic_types_.size() > 0) + { + // Write the dynamic types + for (const auto& dynamic_type : dynamic_types_) + { + write_nts_(dynamic_type); + } + } + + sqlite3_close(database_); + file_tracker_->close_file(); +} + void SqlWriter::create_sql_table_( const std::string& table_name, const std::string& table_definition) From 60af7018757e521faebb23fabba47b385c2fb394 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 11 Jun 2024 08:31:59 +0200 Subject: [PATCH 35/52] Store & read whether topics & types were formatted for ROS 2 Signed-off-by: tempate --- .../recorder/sql/SqlWriter.hpp | 6 +++- .../replayer/BaseReaderParticipant.hpp | 4 +-- .../replayer/SqlReaderParticipant.hpp | 14 +++++--- .../src/cpp/recorder/mcap/McapHandler.cpp | 9 ++--- .../src/cpp/recorder/sql/SqlHandler.cpp | 2 +- .../src/cpp/recorder/sql/SqlWriter.cpp | 29 ++++++++++----- .../cpp/replayer/BaseReaderParticipant.cpp | 4 +-- .../src/cpp/replayer/SqlReaderParticipant.cpp | 36 ++++++++++++------- 8 files changed, 68 insertions(+), 36 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp index 37b3bcc26..e5a099d50 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp @@ -43,7 +43,8 @@ class DDSRECORDER_PARTICIPANTS_DllAPI SqlWriter : public BaseWriter SqlWriter( const OutputSettings& configuration, std::shared_ptr& file_tracker, - const bool record_types = true); + const bool record_types = true, + const bool ros2_types = false); /** * @brief Writes data to the output file. @@ -120,6 +121,9 @@ class DDSRECORDER_PARTICIPANTS_DllAPI SqlWriter : public BaseWriter // The received dynamic types std::vector dynamic_types_; + // Whether to format types for ROS 2 + const bool ros2_types_; + // The size of an empty SQL file static constexpr std::uint64_t MIN_SQL_SIZE{20480}; }; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp index dfab79a66..768e36595 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp @@ -143,13 +143,13 @@ class BaseReaderParticipant : public ddspipe::core::IParticipant * * @param topic_name: Name of the topic. * @param type_name: Name of the type. - * @param is_ros2_type: Whether the type is a ROS2 type. + * @param is_ros2_topic: Whether the topic is a ROS2 topic. * @return A new \c DdsTopic instance. */ ddspipe::core::types::DdsTopic create_topic_( const std::string& topic_name, const std::string& type_name, - const bool is_ros2_type); + const bool is_ros2_topic); /** * @brief Given a fuzzy timestamp, return the timestamp to start replaying. diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp index 32babfffc..76219f2a2 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp @@ -126,13 +126,17 @@ class SqlReaderParticipant : public BaseReaderParticipant const std::string& topic_name); /** - * @brief Find the type of the topic with name \c topic_name. + * @brief Find the information related to \c topic_name. * - * @param topic_name: Name of the topic to find its type. - * @return Type of the topic with name \c topic_name. + * @param topic_name: Name of the topic. + * @param type_name: Type of the topic. + * @param is_ros2_type: Whether the topic is a ROS 2 type. */ - std::string find_type_of_topic_( - const std::string& topic_name); + void find_topic_info_( + const std::string& topic_name, + std::string& type_name, + std::string& topic_qos, + bool& is_ros2_type); // Database sqlite3* database_; diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index d2d866001..5a34dd53c 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -246,10 +246,11 @@ mcap::ChannelId McapHandler::create_channel_id_nts_( // Create new channel mcap::KeyValueMap metadata = {}; metadata[QOS_SERIALIZATION_QOS] = Serializer::serialize(topic.topic_qos); - std::string topic_name = - configuration_.ros2_types ? utils::demangle_if_ros_topic(topic.m_topic_name) : topic.m_topic_name; - // Set ROS2_TYPES to "false" if the given topic_name is equal to topic.m_topic_name, otherwise set it to "true". - metadata[ROS2_TYPES] = topic_name.compare(topic.m_topic_name) ? "true" : "false"; + + const auto topic_name = configuration_.ros2_types ? utils::demangle_if_ros_topic(topic.m_topic_name) : topic.m_topic_name; + const auto is_topic_ros2_type = configuration_.ros2_types && topic_name != topic.m_topic_name; + + metadata[ROS2_TYPES] = is_topic_ros2_type ? "true" : "false"; mcap::Channel new_channel(topic_name, "cdr", schema_id, metadata); mcap_writer_.write(new_channel); diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp index ceaba34fb..ee590887c 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp @@ -35,7 +35,7 @@ SqlHandler::SqlHandler( const BaseHandlerStateCode& init_state /* = BaseHandlerStateCode::RUNNING */, const std::function& on_disk_full_lambda /* = nullptr */) : BaseHandler(config, payload_pool) - , sql_writer_(config.output_settings, file_tracker, config.record_types) + , sql_writer_(config.output_settings, file_tracker, config.record_types, config.ros2_types) { logInfo(DDSRECORDER_SQL_HANDLER, "Creating SQL handler instance."); diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index a213caf22..9022e4617 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -46,8 +47,10 @@ namespace participants { SqlWriter::SqlWriter( const OutputSettings& configuration, std::shared_ptr& file_tracker, - const bool record_types) + const bool record_types, + const bool ros2_types) : BaseWriter(configuration, file_tracker, record_types, MIN_SQL_SIZE) + , ros2_types_(ros2_types) { } @@ -94,7 +97,8 @@ void SqlWriter::open_new_file_nts_( CREATE TABLE IF NOT EXISTS Types ( name TEXT PRIMARY KEY NOT NULL, information TEXT NOT NULL, - object TEXT NOT NULL + object TEXT NOT NULL, + is_ros2_type TEXT NOT NULL ); )"}; @@ -107,6 +111,7 @@ void SqlWriter::open_new_file_nts_( name TEXT PRIMARY KEY NOT NULL, type TEXT NOT NULL, qos TEXT NOT NULL, + is_ros2_topic TEXT NOT NULL, FOREIGN KEY(type) REFERENCES Types(name) ); )"}; @@ -145,8 +150,8 @@ void SqlWriter::write_nts_( // Define the SQL statement const char* insert_statement = R"( - INSERT INTO Types (name, information, object) - VALUES (?, ?, ?); + INSERT INTO Types (name, information, object, is_ros2_type) + VALUES (?, ?, ?, ?); )"; // Prepare the SQL statement @@ -164,9 +169,13 @@ void SqlWriter::write_nts_( } // Bind the DynamicType to the SQL statement - sqlite3_bind_text(statement, 1, dynamic_type.type_name().c_str(), -1, SQLITE_TRANSIENT); + const auto type_name = ros2_types_ ? utils::demangle_if_ros_type(dynamic_type.type_name()) : dynamic_type.type_name(); + const auto is_type_ros2_type = ros2_types_ && type_name != dynamic_type.type_name(); + + sqlite3_bind_text(statement, 1, type_name.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(statement, 2, dynamic_type.type_information().c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(statement, 3, dynamic_type.type_object().c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 4, is_type_ros2_type ? "true" : "false", -1, SQLITE_TRANSIENT); // Execute the SQL statement const auto step_ret = sqlite3_step(statement); @@ -256,8 +265,8 @@ void SqlWriter::write_nts_( // Define the SQL statement const char* insert_statement = R"( - INSERT INTO Topics (name, type, qos) - VALUES (?, ?, ?); + INSERT INTO Topics (name, type, qos, is_ros2_topic) + VALUES (?, ?, ?, ?); )"; // Prepare the SQL statement @@ -275,9 +284,13 @@ void SqlWriter::write_nts_( } // Bind the Topic to the SQL statement - sqlite3_bind_text(statement, 1, topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); + const auto topic_name = ros2_types_ ? utils::demangle_if_ros_topic(topic.topic_name()) : topic.topic_name(); + const auto is_topic_ros2_type = ros2_types_ && topic_name != topic.topic_name(); + + sqlite3_bind_text(statement, 1, topic_name.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(statement, 2, topic.type_name.c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_text(statement, 3, Serializer::serialize(topic.topic_qos).c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 4, is_topic_ros2_type ? "true" : "false", -1, SQLITE_TRANSIENT); // Execute the SQL statement const auto step_ret = sqlite3_step(statement); diff --git a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp index 31202400a..1be5ea9f4 100644 --- a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp @@ -130,11 +130,11 @@ std::unique_ptr BaseReaderParticipant::cr ddspipe::core::types::DdsTopic BaseReaderParticipant::create_topic_( const std::string& topic_name, const std::string& type_name, - const bool is_ros2_type) + const bool is_ros2_topic) { ddspipe::core::types::DdsTopic topic; - if (is_ros2_type) + if (is_ros2_topic) { topic.m_topic_name = utils::mangle_if_ros_topic(topic_name); topic.type_name = utils::mangle_if_ros_type(type_name); diff --git a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp index dc17058f2..0de13c3bf 100644 --- a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp @@ -16,6 +16,7 @@ * @file SqlReaderParticipant.cpp */ +#include #include #include @@ -24,6 +25,7 @@ #include #include #include +#include #include #include @@ -54,13 +56,15 @@ void SqlReaderParticipant::process_summary( { open_file_(); - exec_sql_statement_("SELECT name, type, qos FROM Topics;", {}, [&](sqlite3_stmt* stmt) + exec_sql_statement_("SELECT name, type, qos, is_ros2_topic FROM Topics;", {}, [&](sqlite3_stmt* stmt) { // Create a DdsTopic to publish the message const std::string topic_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); const std::string type_name = reinterpret_cast(sqlite3_column_text(stmt, 1)); + const bool is_topic_ros2_type = strcmp(reinterpret_cast(sqlite3_column_text(stmt, 3)), "True") == 0; + const auto topic = utils::Heritable::make_heritable( - create_topic_(topic_name, type_name, true)); + create_topic_(topic_name, type_name, is_topic_ros2_type)); // Apply the QoS stored in the MCAP file as if they were the discovered QoS. const auto topic_qos_str = reinterpret_cast(sqlite3_column_text(stmt, 2)); @@ -75,17 +79,18 @@ void SqlReaderParticipant::process_summary( topics.insert(topic); }); - exec_sql_statement_("SELECT name, information, object FROM Types;", {}, [&](sqlite3_stmt* stmt) + exec_sql_statement_("SELECT name, information, object, is_ros2_type FROM Types;", {}, [&](sqlite3_stmt* stmt) { // Read the type data from the database const std::string type_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); const std::string type_information = reinterpret_cast(sqlite3_column_text(stmt, 1)); const std::string type_object = reinterpret_cast(sqlite3_column_text(stmt, 2)); + const bool is_type_ros2_type = strcmp(reinterpret_cast(sqlite3_column_text(stmt, 3)), "True") == 0; // Create a DynamicType to store the type data DynamicType type; - type.type_name(type_name); + type.type_name(is_type_ros2_type ? utils::mangle_if_ros_type(type_name) : type_name); type.type_information(type_information); type.type_object(type_object); @@ -197,10 +202,14 @@ ddspipe::core::types::DdsTopic SqlReaderParticipant::find_topic_( return topics_[topic_name]; } - const auto type_name = find_type_of_topic_(topic_name); + std::string type_name; + std::string topic_qos; + bool is_ros2_topic; + + find_topic_info_(topic_name, type_name, topic_qos, is_ros2_topic); // Create the DdsTopic - const auto topic = create_topic_(topic_name, type_name, false); + const auto topic = create_topic_(topic_name, type_name, is_ros2_topic); // Store the topic in the cache topics_[topic_name] = topic; @@ -208,12 +217,13 @@ ddspipe::core::types::DdsTopic SqlReaderParticipant::find_topic_( return topic; } -std::string SqlReaderParticipant::find_type_of_topic_( - const std::string& topic_name) +void SqlReaderParticipant::find_topic_info_( + const std::string& topic_name, + std::string& type_name, + std::string& topic_qos, + bool& is_ros2_topic) { - std::string type_name; - - exec_sql_statement_("SELECT type FROM Topics WHERE name = ?;", {topic_name}, [&](sqlite3_stmt* stmt) + exec_sql_statement_("SELECT type, topic_qos, is_ros2_topic FROM Topics WHERE name = ?;", {topic_name}, [&](sqlite3_stmt* stmt) { if (!type_name.empty()) { @@ -224,9 +234,9 @@ std::string SqlReaderParticipant::find_type_of_topic_( } type_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); + topic_qos = reinterpret_cast(sqlite3_column_text(stmt, 1)); + is_ros2_topic = sqlite3_column_int(stmt, 2) == 0; }); - - return type_name; } void SqlReaderParticipant::exec_sql_statement_( From b25c8328c3ccdd260b966b57771a9e84ec202332 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 11 Jun 2024 08:56:13 +0200 Subject: [PATCH 36/52] LogErrorTest for SQL Signed-off-by: tempate --- ddsrecorder/test/blackbox/constants.hpp | 13 +++ ddsrecorder/test/blackbox/sql/CMakeLists.txt | 28 ++++++ .../test/blackbox/sql/SqlLogErrorTest.cpp | 91 +++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp diff --git a/ddsrecorder/test/blackbox/constants.hpp b/ddsrecorder/test/blackbox/constants.hpp index 9a9ade3fa..2480da52a 100644 --- a/ddsrecorder/test/blackbox/constants.hpp +++ b/ddsrecorder/test/blackbox/constants.hpp @@ -43,6 +43,19 @@ const ParticipantId PARTICIPANT_ID = "DdsRecorderBlackboxTestParticipant"; // The maximum amount of time (in seconds) to wait for the subscriber to acknowledge messages. const fastdds::Duration_t MAX_WAITING_TIME(10); +namespace handler { + +constexpr auto MAX_PENDING_SAMPLES = 5000; +constexpr auto BUFFER_SIZE = 100; +constexpr auto EVENT_WINDOW = 20; +constexpr auto CLEANUP_PERIOD = 0; +constexpr auto LOG_PUBLISH_TIME = false; +constexpr auto ONLY_WITH_SCHEMA = false; +constexpr auto RECORD_TYPES = false; +constexpr auto ROS2_TYPES = false; + +} + namespace limits { constexpr std::uint32_t MAX_SIZE = 30000; diff --git a/ddsrecorder/test/blackbox/sql/CMakeLists.txt b/ddsrecorder/test/blackbox/sql/CMakeLists.txt index 06d24a211..25e787301 100644 --- a/ddsrecorder/test/blackbox/sql/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/sql/CMakeLists.txt @@ -92,3 +92,31 @@ add_blackbox_executable( "${TEST_EXTRA_HEADERS}" "${TEST_LIBRARY_SOURCES}" ) + +################### +# SqlLogErrorTest # +################### + +set(TEST_NAME SqlLogErrorTest) + +set(TEST_SOURCES + SqlLogErrorTest.cpp + ) + +set(TEST_LIST + fail_to_open_file + ) + +set(EXTRA_LIBRARIES + ${MODULE_FIND_PACKAGES} + ) + + +add_blackbox_executable( + "${TEST_NAME}" + "${TEST_SOURCES}" + "${TEST_LIST}" + "${TEST_NEEDED_SOURCES}" + "${EXTRA_LIBRARIES}" + "${TEST_EXTRA_HEADERS}" +) diff --git a/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp b/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp new file mode 100644 index 000000000..c5ec5c8a4 --- /dev/null +++ b/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp @@ -0,0 +1,91 @@ +// Copyright 2024 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. + +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "../constants.hpp" + +using namespace eprosima; + +/** + * Test case to verify a logError is displayed when the opening mcap file fails + * + * CASES: + * This test attemps to open a mcap file in a folder that does not exist, leading to + * its correspondent Log Error. An additional logError failing to rename the SQL file + * will appear when the McapHandler destructor is called (this happens after + * log_checker.check_valid() assertion) + */ +TEST(SqlLogErrorTest, fail_to_open_file) { + + // Create an instance of the Log Checker to capture the LogError + utils::testing::LogChecker log_checker(utils::Log::Kind::Error, 1, 1); + + // Verify that no logs have been captured yet + ASSERT_FALSE(log_checker.check_valid()); + + // Configure a fake file path and name to trigger the error + ddsrecorder::participants::OutputSettings output_settings; + output_settings.filepath = "./fake_folder"; + output_settings.filename = "output_dummy"; + + // Create the SQL Handler's Configuration + ddsrecorder::participants::SqlHandlerConfiguration config( + output_settings, + test::handler::MAX_PENDING_SAMPLES, + test::handler::BUFFER_SIZE, + test::handler::EVENT_WINDOW, + test::handler::CLEANUP_PERIOD, + test::handler::LOG_PUBLISH_TIME, + test::handler::ONLY_WITH_SCHEMA, + test::handler::RECORD_TYPES, + test::handler::ROS2_TYPES); + + std::shared_ptr payload_pool; + const auto init_state = ddsrecorder::participants::BaseHandlerStateCode::RUNNING; + + // Create the FileTracker + auto file_tracker = std::make_shared(config.output_settings); + + // Verify that an InitializationException was thrown + ASSERT_THROW( + ddsrecorder::participants::SqlHandler(config, payload_pool, file_tracker, init_state), + utils::InitializationException); + + // Verify that a logError was captured + ASSERT_TRUE(log_checker.check_valid()); +} + +int main( + int argc, + char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} From aa37d106c499b54dee3e2faf32e5b05f1bf231d4 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 11 Jun 2024 09:19:54 +0200 Subject: [PATCH 37/52] Fix McapLogErrorTest Signed-off-by: tempate --- ddsrecorder/test/blackbox/mcap/CMakeLists.txt | 12 +-- .../test/blackbox/mcap/McapLogErrorTest.cpp | 99 +++++++++++++++++++ .../test/blackbox/mcap/McapLogErrorTests.cpp | 92 ----------------- 3 files changed, 104 insertions(+), 99 deletions(-) create mode 100644 ddsrecorder/test/blackbox/mcap/McapLogErrorTest.cpp delete mode 100644 ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp diff --git a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt index 0a07b84d5..430fe2a44 100644 --- a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt @@ -84,15 +84,14 @@ add_blackbox_executable( "${TEST_LIBRARY_SOURCES}" ) +#################### +# McapLogErrorTest # +#################### -######################## -# Mcap Log Error Tests # -######################## - -set(TEST_NAME McapLogErrorTests) +set(TEST_NAME McapLogErrorTest) set(TEST_SOURCES - McapLogErrorTests.cpp + McapLogErrorTest.cpp ) set(TEST_LIST @@ -103,7 +102,6 @@ set(EXTRA_LIBRARIES ${MODULE_FIND_PACKAGES} ) - add_blackbox_executable( "${TEST_NAME}" "${TEST_SOURCES}" diff --git a/ddsrecorder/test/blackbox/mcap/McapLogErrorTest.cpp b/ddsrecorder/test/blackbox/mcap/McapLogErrorTest.cpp new file mode 100644 index 000000000..ee3e46273 --- /dev/null +++ b/ddsrecorder/test/blackbox/mcap/McapLogErrorTest.cpp @@ -0,0 +1,99 @@ +// Copyright 2024 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. + +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "../constants.hpp" + +using namespace eprosima; + +/** + * Test case to verify a logError is displayed when the opening mcap file fails + * + * CASES: + * This test attemps to open a mcap file in a folder that does not exist, leading to + * its correspondent Log Error. An additional logError failing to rename the MCAP file + * will appear when the McapHandler destructor is called (this happens after + * log_checker.check_valid() assertion) + */ +TEST(McapLogErrorTest, fail_to_open_file) { + + // Create an instance of the Log Checker to capture the LogError + utils::testing::LogChecker log_checker(utils::Log::Kind::Error, 1, 1); + + // Verify that no logs have been captured yet + ASSERT_FALSE(log_checker.check_valid()); + + // Configure a non-existent file path and name to trigger the error + ddsrecorder::participants::OutputSettings output_settings; + output_settings.filepath = "./fake_folder"; + output_settings.filename = "output_dummy"; + + // Configure the max sizes to avoid triggering a different error + output_settings.max_file_size = 10000; + output_settings.max_size = output_settings.max_file_size; + + // Create the MCAP Handler's Configuration + mcap::McapWriterOptions mcap_writer_options{"ros2"}; + + ddsrecorder::participants::McapHandlerConfiguration config( + output_settings, + test::handler::MAX_PENDING_SAMPLES, + test::handler::BUFFER_SIZE, + test::handler::EVENT_WINDOW, + test::handler::CLEANUP_PERIOD, + test::handler::LOG_PUBLISH_TIME, + test::handler::ONLY_WITH_SCHEMA, + mcap_writer_options, + test::handler::RECORD_TYPES, + test::handler::ROS2_TYPES); + + std::shared_ptr payload_pool; + const auto init_state = ddsrecorder::participants::BaseHandlerStateCode::RUNNING; + + // Create the FileTracker + auto file_tracker = std::make_shared(config.output_settings); + + // Verify that an InitializationException was thrown + ASSERT_THROW( + ddsrecorder::participants::McapHandler(config, payload_pool, file_tracker, init_state), + utils::InitializationException); + + // Verify that a logError was captured + ASSERT_TRUE(log_checker.check_valid()); +} + +int main( + int argc, + char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp b/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp deleted file mode 100644 index cb902d39f..000000000 --- a/ddsrecorder/test/blackbox/mcap/McapLogErrorTests.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include - -const int MAX_PENDING_SAMPLES = 1024; -const int BUFFER_SIZE = 100; -const int EVENT_WINDOW = 60; -const int CLEANUP_PERIOD = 3600; -const bool LOG_PUBLISH_TIME = true; -const bool ONLY_WITH_SCHEMA = false; -const bool RECORD_TYPES = true; -const bool ROS2_TYPES = false; - -/** - * Test case to verify a logError is displayed when the opening mcap file fails - * - * CASES: - * This test attemps to open a mcap file in a folder that does not exist, leading to - * its correspondent Log Error. An additional logError failing to rename the MCAP file - * will appear when the McapHandler destructor is called (this happens after - * log_checker.check_valid() assertion) - */ -TEST(McapLogErrorTests, fail_to_open_file) { - - // Create an instance of the Log Checker, in charge of capturing 1 LogError - eprosima::utils::testing::LogChecker log_checker( - eprosima::utils::Log::Kind::Error, - 1, - 1); - - // Check no logs have been captured yet - ASSERT_FALSE(log_checker.check_valid()); - - eprosima::ddsrecorder::participants::OutputSettings output_settings; - output_settings.filepath = "./fake_folder"; // This folder does not exist -> error opening file - output_settings.filename = "output_dummy"; - output_settings.prepend_timestamp = false; - output_settings.timestamp_format = "%Y-%m-%d_%H-%M-%S"; - output_settings.local_timestamp = true; - output_settings.max_file_size = 100 * 1000; // 100KB - output_settings.max_size = output_settings.max_file_size; // 100KB - - mcap::McapWriterOptions mcap_writer_options{"ros2"}; - - eprosima::ddsrecorder::participants::McapHandlerConfiguration config( - output_settings, - MAX_PENDING_SAMPLES, - BUFFER_SIZE, - EVENT_WINDOW, - CLEANUP_PERIOD, - LOG_PUBLISH_TIME, - ONLY_WITH_SCHEMA, - mcap_writer_options, - RECORD_TYPES, - ROS2_TYPES - ); - - std::shared_ptr payload_pool; - eprosima::ddsrecorder::participants::BaseHandlerStateCode init_state = - eprosima::ddsrecorder::participants::BaseHandlerStateCode::RUNNING; - - // Create the McapWriter - auto file_tracker = std::make_shared(config.output_settings); - - // Check if an InitializationException is thrown - ASSERT_THROW( - eprosima::ddsrecorder::participants::McapHandler mcap_handler(config, payload_pool, file_tracker, init_state), - eprosima::utils::InitializationException); - - // Assert that logErrors were captured - ASSERT_TRUE(log_checker.check_valid()); -} - -int main( - int argc, - char** argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} From f5768ab9d3b57dcf81e9db42dd6556ffea809862 Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 13 Jun 2024 11:33:19 +0200 Subject: [PATCH 38/52] Strip replaying methods from McapFileReadTest & McapFileReadWithTypeTest Signed-off-by: tempate --- ddsreplayer/src/cpp/tool/DdsReplayer.cpp | 2 +- ddsreplayer/src/cpp/tool/DdsReplayer.hpp | 2 +- ddsreplayer/test/blackbox/FileReadTest.hpp | 270 ++++++++++++++++++ ddsreplayer/test/blackbox/mcap/CMakeLists.txt | 30 +- .../test/blackbox/mcap/McapFileReadTest.cpp | 152 ++-------- .../test/blackbox/mcap/McapFileReadTest.hpp | 29 ++ .../mcap/McapFileReadWithTypeTest.cpp | 171 ++--------- .../mcap/McapFileReadWithTypeTest.hpp | 31 ++ .../mcap/resources/helloworld_file.mcap | Bin 1522 -> 0 bytes .../helloworld_withtypes_file_info.md | 83 ------ .../blackbox/mcap/resources/ros2_file.mcap | Bin 3529 -> 0 bytes .../config/config_file.yaml} | 0 .../config/config_file_begin_time.yaml} | 0 .../config/config_file_begin_time_notype.yaml | 15 + .../config_file_begin_time_with_types.yaml | 0 .../config/config_file_end_time.yaml} | 0 .../config/config_file_end_time_notype.yaml | 15 + .../config_file_end_time_with_types.yaml | 0 .../config/config_file_less_hz.yaml} | 0 .../config}/config_file_less_hz_notype.yaml | 0 .../config/config_file_less_hz_withtypes.yaml | 12 + .../config/config_file_more_hz.yaml} | 0 .../config}/config_file_more_hz_notype.yaml | 0 .../config/config_file_more_hz_withtypes.yaml | 12 + .../config}/config_file_notype.yaml | 0 ...onfig_file_start_replay_time_earlier.yaml} | 0 ...file_start_replay_time_earlier_notype.yaml | 15 + ..._start_replay_time_earlier_with_types.yaml | 0 .../config/config_file_withtypes.yaml | 11 + ddsreplayer/test/resources/constants.hpp | 34 +++ .../dds/ConfigurationDynTypesSubscriber.cpp | 0 .../dds/ConfigurationDynTypesSubscriber.h | 4 + .../dds/ConfigurationSubscriber.cpp | 0 .../dds/ConfigurationSubscriber.h | 14 + .../test/resources/dds/DataToCheck.hpp | 33 +++ .../recordings/basic/README.md} | 0 .../recordings/basic/configuration.mcap} | Bin .../types/configuration/Configuration.hpp | 0 .../types/configuration/Configuration.idl | 0 .../configuration/ConfigurationCdrAux.hpp | 0 .../configuration/ConfigurationCdrAux.ipp | 0 .../ConfigurationPubSubTypes.cxx | 0 .../configuration/ConfigurationPubSubTypes.h} | 0 .../ConfigurationPubSubTypes.hpp | 24 +- .../ConfigurationTypeObjectSupport.cxx | 0 .../ConfigurationTypeObjectSupport.hpp | 0 .../hello_world/HelloWorldPubSubTypes.hpp | 133 --------- 47 files changed, 568 insertions(+), 524 deletions(-) create mode 100644 ddsreplayer/test/blackbox/FileReadTest.hpp create mode 100644 ddsreplayer/test/blackbox/mcap/McapFileReadTest.hpp create mode 100644 ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.hpp delete mode 100644 ddsreplayer/test/blackbox/mcap/resources/helloworld_file.mcap delete mode 100644 ddsreplayer/test/blackbox/mcap/resources/helloworld_withtypes_file_info.md delete mode 100644 ddsreplayer/test/blackbox/mcap/resources/ros2_file.mcap rename ddsreplayer/test/{blackbox/mcap/resources/config_file_withtypes.yaml => resources/config/config_file.yaml} (100%) rename ddsreplayer/test/{blackbox/mcap/resources/config_file_begin_time_notype.yaml => resources/config/config_file_begin_time.yaml} (100%) create mode 100644 ddsreplayer/test/resources/config/config_file_begin_time_notype.yaml rename ddsreplayer/test/{blackbox/mcap/resources => resources/config}/config_file_begin_time_with_types.yaml (100%) rename ddsreplayer/test/{blackbox/mcap/resources/config_file_end_time_notype.yaml => resources/config/config_file_end_time.yaml} (100%) create mode 100644 ddsreplayer/test/resources/config/config_file_end_time_notype.yaml rename ddsreplayer/test/{blackbox/mcap/resources => resources/config}/config_file_end_time_with_types.yaml (100%) rename ddsreplayer/test/{blackbox/mcap/resources/config_file_less_hz_withtypes.yaml => resources/config/config_file_less_hz.yaml} (100%) rename ddsreplayer/test/{blackbox/mcap/resources => resources/config}/config_file_less_hz_notype.yaml (100%) create mode 100644 ddsreplayer/test/resources/config/config_file_less_hz_withtypes.yaml rename ddsreplayer/test/{blackbox/mcap/resources/config_file_more_hz_withtypes.yaml => resources/config/config_file_more_hz.yaml} (100%) rename ddsreplayer/test/{blackbox/mcap/resources => resources/config}/config_file_more_hz_notype.yaml (100%) create mode 100644 ddsreplayer/test/resources/config/config_file_more_hz_withtypes.yaml rename ddsreplayer/test/{blackbox/mcap/resources => resources/config}/config_file_notype.yaml (100%) rename ddsreplayer/test/{blackbox/mcap/resources/config_file_start_replay_time_earlier_notype.yaml => resources/config/config_file_start_replay_time_earlier.yaml} (100%) create mode 100644 ddsreplayer/test/resources/config/config_file_start_replay_time_earlier_notype.yaml rename ddsreplayer/test/{blackbox/mcap/resources => resources/config}/config_file_start_replay_time_earlier_with_types.yaml (100%) create mode 100644 ddsreplayer/test/resources/config/config_file_withtypes.yaml create mode 100644 ddsreplayer/test/resources/constants.hpp rename ddsreplayer/test/{blackbox/mcap => resources}/dds/ConfigurationDynTypesSubscriber.cpp (100%) rename ddsreplayer/test/{blackbox/mcap => resources}/dds/ConfigurationDynTypesSubscriber.h (94%) rename ddsreplayer/test/{blackbox/mcap => resources}/dds/ConfigurationSubscriber.cpp (100%) rename ddsreplayer/test/{blackbox/mcap => resources}/dds/ConfigurationSubscriber.h (78%) create mode 100644 ddsreplayer/test/resources/dds/DataToCheck.hpp rename ddsreplayer/test/{blackbox/mcap/resources/helloworld_file_info.md => resources/recordings/basic/README.md} (100%) rename ddsreplayer/test/{blackbox/mcap/resources/configuration_withtypes.mcap => resources/recordings/basic/configuration.mcap} (100%) rename ddsreplayer/test/{blackbox/mcap/dds => resources}/types/configuration/Configuration.hpp (100%) rename ddsreplayer/test/{blackbox/mcap/dds => resources}/types/configuration/Configuration.idl (100%) rename ddsreplayer/test/{blackbox/mcap/dds => resources}/types/configuration/ConfigurationCdrAux.hpp (100%) rename ddsreplayer/test/{blackbox/mcap/dds => resources}/types/configuration/ConfigurationCdrAux.ipp (100%) rename ddsreplayer/test/{blackbox/mcap/dds => resources}/types/configuration/ConfigurationPubSubTypes.cxx (100%) rename ddsreplayer/test/{blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.hpp => resources/types/configuration/ConfigurationPubSubTypes.h} (100%) rename ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp => ddsreplayer/test/resources/types/configuration/ConfigurationPubSubTypes.hpp (83%) rename ddsreplayer/test/{blackbox/mcap/dds => resources}/types/configuration/ConfigurationTypeObjectSupport.cxx (100%) rename ddsreplayer/test/{blackbox/mcap/dds => resources}/types/configuration/ConfigurationTypeObjectSupport.hpp (100%) delete mode 100644 resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.hpp diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index 8c9e01322..a99343d51 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -52,7 +52,7 @@ namespace replayer { DdsReplayer::DdsReplayer( yaml::ReplayerConfiguration& configuration, - std::string& input_file) + const std::string& input_file) : configuration_(configuration) { // Create Payload Pool diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp index bd2f3d133..e71ba5b27 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp @@ -62,7 +62,7 @@ class DdsReplayer */ DdsReplayer( yaml::ReplayerConfiguration& configuration, - std::string& input_file); + const std::string& input_file); /** * @brief DdsReplayer destructor. diff --git a/ddsreplayer/test/blackbox/FileReadTest.hpp b/ddsreplayer/test/blackbox/FileReadTest.hpp new file mode 100644 index 000000000..51b538b45 --- /dev/null +++ b/ddsreplayer/test/blackbox/FileReadTest.hpp @@ -0,0 +1,270 @@ +// Copyright 2024 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. + +#include +#include +#include +#include + +#include + +#include + +#include + +#include + +#include + +#include "../resources/constants.hpp" +#include "../resources/dds/DataToCheck.hpp" +#include "../resources/dds/HelloWorldDynTypesSubscriber.h" +#include "../resources/dds/HelloWorldSubscriber.h" + +using namespace eprosima; + +/** + * @brief Test fixture for testing the DDS Replayer with different input files. + * + * Include tests that must pass with different input files. + */ +class FileReadTest : public testing::Test +{ +public: + + /** + * Verify that the DDS Replayer replays messages correctly. + * + * CASES: + * - Verify that the shared \c replay_ method replays messages. + */ + static void trivial_test( + const std::string& input_file, + const bool publish_types = false, + const bool is_ros2_topic = false) + { + const auto configuration = "../../resources/config/config_file.yaml"; + const auto data = replay_(configuration, input_file, publish_types); + + ASSERT_TRUE(true); + } + + /** + * Verify that the DDS Replayer replays simple messages correctly. + * + * CASES: + * - Verify that the received data is correct. + * - Verify that the message was sent at the correct rate. + */ + static void data_to_check_test( + const std::string& input_file, + const bool publish_types = false, + const bool is_ros2_topic = false) + { + const auto configuration = "../../resources/config/config_file.yaml"; + const auto data = replay_(configuration, input_file, publish_types); + + // Verify that the received data is correct + ASSERT_EQ(data.n_received_msgs, 11); + ASSERT_EQ(data.type_msg, "HelloWorld"); + ASSERT_EQ(data.message_msg, "Hello World"); + ASSERT_EQ(data.min_index_msg, 0); + ASSERT_EQ(data.max_index_msg, 10); + + // Verify that the average miliseconds between messages is about 200 ms + const auto expected_mean_ms_between_msgs = 200; + const auto expected_error = 0.01; + + const auto min_expected_ms = expected_mean_ms_between_msgs * (1 - expected_error); + const auto max_expected_ms = expected_mean_ms_between_msgs * (1 + expected_error); + + ASSERT_GT(data.mean_ms_between_msgs, min_expected_ms); + ASSERT_LT(data.mean_ms_between_msgs, max_expected_ms); + } + + /** + * Verify that the DDS Replayer replays messages published at a high frequency correctly. + * + * CASES: + * - Verify that the messages were received at the correct rate. + */ + static void more_playback_rate_test( + const std::string& input_file, + const bool publish_types = false, + const bool is_ros2_topic = false) + { + const auto configuration = "../../resources/config/config_file_more_hz.yaml"; + const auto data = replay_(configuration, input_file, publish_types); + + // Verify that the average miliseconds between messages is about 100 ms + const auto expected_mean_ms_between_msgs = 100; + const auto expected_error = 0.01; + + const auto min_expected_ms = expected_mean_ms_between_msgs * (1 - expected_error); + const auto max_expected_ms = expected_mean_ms_between_msgs * (1 + expected_error); + + ASSERT_GT(data.mean_ms_between_msgs, min_expected_ms); + ASSERT_LT(data.mean_ms_between_msgs, max_expected_ms); + } + + /** + * Verify that the DDS Replayer replays messages published at a low frequency correctly. + * + * CASES: + * - Verify that the messages were received at the correct rate. + */ + static void less_playback_rate_test( + const std::string& input_file, + const bool publish_types = false, + const bool is_ros2_topic = false) + { + const auto configuration = "../../resources/config/config_file_less_hz.yaml"; + const auto data = replay_(configuration, input_file, publish_types); + + // Verify that the average miliseconds between messages is about 400 ms + const auto expected_mean_ms_between_msgs = 400; + const auto expected_error = 0.01; + + const auto min_expected_ms = expected_mean_ms_between_msgs * (1 - expected_error); + const auto max_expected_ms = expected_mean_ms_between_msgs * (1 + expected_error); + + ASSERT_GT(data.mean_ms_between_msgs, min_expected_ms); + ASSERT_LT(data.mean_ms_between_msgs, max_expected_ms); + } + + /** + * Verify that the DDS Replayer replays messages only from the begin-time. + * + * CASES: + * - Verify that the right number of messages were received. + * - Verify that the messages received are the correct ones. + */ + static void begin_time_test( + const std::string& input_file, + const bool publish_types = false, + const bool is_ros2_topic = false) + { + const auto configuration = "../../resources/config/config_file_begin_time.yaml"; + const auto data = replay_(configuration, input_file, publish_types); + + // Verify that only the messages after the begin-time were received + ASSERT_EQ(data.n_received_msgs, 3); + ASSERT_EQ(data.min_index_msg, 8); + ASSERT_EQ(data.max_index_msg, 10); + } + + /** + * Verify that the DDS Replayer replays messages only until the end-time. + * + * CASES: + * - Verify that the right number of messages were received. + * - Verify that the messages received are the correct ones. + */ + static void end_time_test( + const std::string& input_file, + const bool publish_types = false, + const bool is_ros2_topic = false) + { + const auto configuration = "../../resources/config/config_file_end_time.yaml"; + const auto data = replay_(configuration, input_file, publish_types); + + // Verify that only the messages before the end-time were received + ASSERT_EQ(data.n_received_msgs, 8); + ASSERT_EQ(data.min_index_msg, 0); + ASSERT_EQ(data.max_index_msg, 7); + } + + /** + * Verify that the DDS Replayer replays messages when the start-replay-time is earlier than the earliest message. + * + * CASES: + * - Verify that the right number of messages were received. + * - Verify that the messages received are the correct ones. + */ + static void start_replay_time_earlier_test( + const std::string& input_file, + const bool publish_types = false, + const bool is_ros2_topic = false) + { + const auto configuration = "../../resources/config/config_file_start_replay_time_earlier.yaml"; + const auto data = replay_(configuration, input_file, publish_types); + + // Verify that all the messages were received + ASSERT_EQ(data.n_received_msgs, 11); + ASSERT_EQ(data.min_index_msg, 0); + ASSERT_EQ(data.max_index_msg, 10); + } + +protected: + + /** + * The order in which objects are created is relevant; + * if the replayer was created before the subscriber, + * a segmentation fault may occur as the dynamic type + * could be received by the subscriber's participant + * before the DDS subscriber is created (which is required + * for creating a DataReader with the received type). + */ + static DataToCheck replay_( + const std::string& configuration_path, + const std::string& input_file, + bool publish_types = false, + bool is_ros2_topic = false) + { + DataToCheck data; + + // Create Subscriber + std::unique_ptr subscriber; + + const auto topic_name = is_ros2_topic ? test::ROS2_TOPIC_NAME : test::DDS_TOPIC_NAME; + + if (publish_types) + { + subscriber = std::make_unique(topic_name, test::DOMAIN, data); + } + else + { + subscriber = std::make_unique(topic_name, test::DOMAIN, data); + } + + // Configuration + ddsrecorder::yaml::ReplayerConfiguration configuration(configuration_path); + configuration.replayer_configuration->domain.domain_id = test::DOMAIN; + + // Create replayer instance + auto replayer = std::make_unique(configuration, input_file); + + // Give time for replayer and subscriber to match. + // Waiting for the subscriber to match the replayer + // before starting to replay messages does not ensure + // that no samples will be lost (even if using reliable QoS). + // This is because endpoint matching does not occur + // at the same exact moment in both ends of communication, + // so the replayer's writer might have not yet matched the + // subscriber even if the latter already has (matched the writer). + // Transient local QoS would be a solution for this, + // but it is not used as it might pollute frequency arrival + // measurements. + std::this_thread::sleep_for(std::chrono::seconds(1)); + + // Start replaying data + replayer->process_file(); + + replayer->stop(); + + // Replayer waits on destruction a maximum of wait-all-acked-timeout + // ms until all sent msgs are acknowledged + return data; + } +}; diff --git a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt index f65e65bf1..804935112 100644 --- a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt +++ b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt @@ -28,7 +28,7 @@ set(TEST_SOURCES set(TEST_LIST trivial - dds_data_to_check + data_to_check less_playback_rate more_playback_rate begin_time @@ -37,13 +37,13 @@ set(TEST_LIST ) set(TEST_NEEDED_SOURCES - resources/configuration_withtypes.mcap - resources/config_file_notype.yaml - resources/config_file_less_hz_notype.yaml - resources/config_file_more_hz_notype.yaml - resources/config_file_begin_time_notype.yaml - resources/config_file_end_time_notype.yaml - resources/config_file_start_replay_time_earlier_notype.yaml + ../../resources/config/config_file.yaml + ../../resources/config/config_file_less_hz.yaml + ../../resources/config/config_file_more_hz.yaml + ../../resources/config/config_file_begin_time.yaml + ../../resources/config/config_file_end_time.yaml + ../../resources/config/config_file_start_replay_time_earlier.yaml + ../../resources/recordings/basic/configuration.mcap ) set(TEST_EXTRA_HEADERS @@ -83,13 +83,13 @@ set(TEST_LIST ) set(TEST_NEEDED_SOURCES - resources/configuration_withtypes.mcap - resources/config_file_withtypes.yaml - resources/config_file_less_hz_withtypes.yaml - resources/config_file_more_hz_withtypes.yaml - resources/config_file_begin_time_with_types.yaml - resources/config_file_end_time_with_types.yaml - resources/config_file_start_replay_time_earlier_with_types.yaml + ../../resources/config/config_file.yaml + ../../resources/config/config_file_less_hz.yaml + ../../resources/config/config_file_more_hz.yaml + ../../resources/config/config_file_begin_time_with_types.yaml + ../../resources/config/config_file_end_time_with_types.yaml + ../../resources/config/config_file_start_replay_time_earlier_with_types.yaml + ../../resources/recordings/basic/configuration.mcap ) set(TEST_EXTRA_HEADERS diff --git a/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp b/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp index 251fcd071..13f022607 100644 --- a/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp +++ b/ddsreplayer/test/blackbox/mcap/McapFileReadTest.cpp @@ -12,166 +12,46 @@ // See the License for the specific language governing permissions and // limitations under the License. -// #define MCAP_IMPLEMENTATION - -#include #include -#include "dds/ConfigurationSubscriber.h" - -#include "tool/DdsReplayer.hpp" - -#include -#include -#include - -using namespace eprosima::fastdds::dds; -using namespace eprosima::fastdds::rtps; -using namespace eprosima::fastdds; -using namespace eprosima::ddsrecorder::replayer; - -namespace test { - -// Publisher - -const unsigned int DOMAIN = 110; - -const std::string topic_name = "configuration_topic"; - -} // test - - -void create_subscriber_replayer( - DataToCheck& data, - const std::string& configuration_path = "resources/config_file_notype.yaml", - std::string input_file = "resources/configuration_withtypes.mcap") -{ - { - // Create Subscriber - ConfigurationSubscriber subscriber( - test::topic_name, - static_cast(test::DOMAIN), - data); - - std::cout << "subscriber created !!!!" << std::endl; - { - // Configuration - eprosima::ddsrecorder::yaml::ReplayerConfiguration configuration(configuration_path); - configuration.replayer_configuration->domain.domain_id = test::DOMAIN; - - // Create replayer instance - auto replayer = std::make_unique(configuration, input_file); - - std::cout << "replayer created !!!!" << std::endl; - - // Give time for replayer and subscriber to match. - // Waiting for the subscriber to match the replayer - // before starting to replay messages does not ensure - // that no samples will be lost (even if using reliable QoS). - // This is because endpoint matching does not occur - // at the same exact moment in both ends of communication, - // so the replayer's writer might have not yet matched the - // subscriber even if the latter already has (matched the writer). - // Transient local QoS would be a solution for this, - // but it is not used as it might pollute frequency arrival - // measurements. - std::this_thread::sleep_for(std::chrono::seconds(1)); - - // Start replaying data - replayer->process_file(); - - std::cout << "finish process_file!!!!" << std::endl; - - replayer->stop(); - - std::cout << "replayer stop!!!!" << std::endl; - - } - // Replayer waits on destruction a maximum of wait-all-acked-timeout - // ms until all sent msgs are acknowledged - std::cout << "replayer destroyed!!!!" << std::endl; - } - std::cout << "subscriber destroyed!!!!" << std::endl; +#include - std::cout << "process info..." << std::endl; +#include "McapFileReadTest.hpp" -} -TEST(McapFileReadTest, trivial) +TEST_F(McapFileReadTest, trivial) { - // info to check - DataToCheck data; - create_subscriber_replayer(data); - ASSERT_TRUE(true); + trivial_test(input_file_); } -TEST(McapFileReadTest, dds_data_to_check) +TEST_F(McapFileReadTest, data_to_check) { - // info to check - DataToCheck data; - create_subscriber_replayer(data); - ASSERT_EQ(data.n_received_msgs, 10); - ASSERT_EQ(data.type_msg, "Configuration"); - ASSERT_EQ(data.min_index_msg, 1); - ASSERT_EQ(data.max_index_msg, 10); - // ms ~ 200 - ASSERT_GT(data.mean_ms_between_msgs, 1197.5); - ASSERT_LT(data.mean_ms_between_msgs, 1202.5); + data_to_check_test(input_file_); } -TEST(McapFileReadTest, more_playback_rate) +TEST_F(McapFileReadTest, more_playback_rate) { - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_more_hz_notype.yaml"; - create_subscriber_replayer(data, configuration); - // ms ~ 100 - ASSERT_GT(data.mean_ms_between_msgs, 597.5); - ASSERT_LT(data.mean_ms_between_msgs, 602.5); + more_playback_rate_test(input_file_); } -TEST(McapFileReadTest, less_playback_rate) +TEST_F(McapFileReadTest, less_playback_rate) { - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_less_hz_notype.yaml"; - create_subscriber_replayer(data, configuration); - // ms ~ 400 - ASSERT_GT(data.mean_ms_between_msgs, 2397.5); - ASSERT_LT(data.mean_ms_between_msgs, 2403.5); + less_playback_rate_test(input_file_); } -TEST(McapFileReadTest, begin_time) +TEST_F(McapFileReadTest, begin_time) { - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_begin_time_notype.yaml"; - create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 7); - ASSERT_EQ(data.min_index_msg, 4); - ASSERT_EQ(data.max_index_msg, 10); + begin_time_test(input_file_); } -TEST(McapFileReadTest, end_time) +TEST_F(McapFileReadTest, end_time) { - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_end_time_notype.yaml"; - create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 3); - ASSERT_EQ(data.min_index_msg, 1); - ASSERT_EQ(data.max_index_msg, 3); + end_time_test(input_file_); } -TEST(McapFileReadTest, start_replay_time_earlier) +TEST_F(McapFileReadTest, start_replay_time_earlier) { - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_start_replay_time_earlier_notype.yaml"; - create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 10); - ASSERT_EQ(data.min_index_msg, 1); - ASSERT_EQ(data.max_index_msg, 10); + start_replay_time_earlier_test(input_file_); } int main( diff --git a/ddsreplayer/test/blackbox/mcap/McapFileReadTest.hpp b/ddsreplayer/test/blackbox/mcap/McapFileReadTest.hpp new file mode 100644 index 000000000..9e3918832 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/McapFileReadTest.hpp @@ -0,0 +1,29 @@ +// Copyright 2024 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. + +#include + +#include "../FileReadTest.hpp" + +/** + * @brief Test class for Mcap file read tests. + * + * Include the tests that are exclusive to MCAP files. + */ +class McapFileReadTest : public FileReadTest +{ +protected: + + const std::string input_file_{"../../resources/recordings/basic/configuration.mcap"}; +}; diff --git a/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp b/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp index 141beedb7..8a4f189c5 100644 --- a/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp +++ b/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp @@ -12,179 +12,64 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include -#include "dds/ConfigurationDynTypesSubscriber.h" - -#include "tool/DdsReplayer.hpp" - -#include -#include -#include - -using namespace eprosima::fastdds::dds; -using namespace eprosima::fastdds::rtps; -using namespace eprosima::fastdds; -using namespace eprosima::ddsrecorder::replayer; - -namespace test { - -// Publisher - -const unsigned int DOMAIN = 110; - -const std::string dds_topic_name = "configuration_topic"; -const std::string ros2_topic_name = "rt/topic"; - -const std::string dds_type_name = "Configuration"; -const std::string ros2_type_name = "std_msgs::msg::dds_::String_"; - +#include -} // test +#include "McapFileReadWithTypeTest.hpp" -/** - * The order in which objects are created is relevant; - * if the replayer was created before the subscriber, - * a segmentation fault may occur as the dynamic type - * could be received by the subscriber's participant - * before the DDS subscriber is created (which is required - * for creating a DataReader with the received type). - */ -void create_subscriber_replayer( - DataToCheck& data, - const std::string& configuration_path = "resources/config_file_withtypes.yaml", - std::string input_file = "resources/configuration_withtypes.mcap", - bool ros2 = false) +TEST_F(McapFileReadWithTypeTest, trivial) { - { - std::string topic_name = ros2 ? test::ros2_topic_name : test::dds_topic_name; - - // Create Subscriber - ConfigurationDynTypesSubscriber subscriber( - topic_name, - static_cast(test::DOMAIN), - data); - - std::cout << "subscriber created !!!!" << std::endl; - - { - // Configuration - eprosima::ddsrecorder::yaml::ReplayerConfiguration configuration(configuration_path); - configuration.replayer_configuration->domain.domain_id = test::DOMAIN; - - // Create replayer instance - auto replayer = std::make_unique(configuration, input_file); - - std::cout << "replayer created !!!!" << std::endl; - - // Give time for replayer and subscriber to match. - // Waiting for the subscriber to match the replayer - // before starting to replay messages does not ensure - // that no samples will be lost (even if using reliable QoS). - // This is because endpoint matching does not occur - // at the same exact moment in both ends of communication, - // so the replayer's writer might have not yet matched the - // subscriber even if the latter already has (matched the writer). - // Transient local QoS would be a solution for this, - // but it is not used as it might pollute frequency arrival - // measurements. - std::this_thread::sleep_for(std::chrono::seconds(1)); - - // Start replaying data - replayer->process_file(); - - replayer->stop(); - - std::cout << "replayer stop!!!!" << std::endl; + trivial_test(input_file_type_, publish_type_); +} - } - // Replayer waits on destruction a maximum of wait-all-acked-timeout - // ms until all sent msgs are acknowledged - std::cout << "replayer destroyed!!!!" << std::endl; - } - std::cout << "subscriber destroyed!!!!" << std::endl; +TEST_F(McapFileReadWithTypeTest, dds_data_to_check) +{ + data_to_check_test(input_file_type_, publish_type_); +} - std::cout << "process info..." << std::endl; +TEST_F(McapFileReadWithTypeTest, ros2_data_to_check) +{ + constexpr auto IS_ROS2_TOPIC = true; + data_to_check_test(input_file_ros2_, publish_type_, IS_ROS2_TOPIC); } -TEST(McapFileReadWithTypeTest, trivial) +TEST_F(McapFileReadWithTypeTest, dds_more_playback_rate) { - // info to check - DataToCheck data; - create_subscriber_replayer(data); - ASSERT_TRUE(true); + more_playback_rate_test(input_file_type_, publish_type_); } -TEST(McapFileReadWithTypeTest, dds_data_to_check) +TEST_F(McapFileReadWithTypeTest, ros2_more_playback_rate) { - // info to check - DataToCheck data; - create_subscriber_replayer(data); - ASSERT_EQ(data.n_received_msgs, 10); - ASSERT_EQ(data.type_msg, test::dds_type_name); - // ASSERT_EQ(data.message_msg, "Configuration"); - ASSERT_EQ(data.min_index_msg, 1); - ASSERT_EQ(data.max_index_msg, 10); - // ms ~ 200 - ASSERT_GT(data.mean_ms_between_msgs, 1197.5); - ASSERT_LT(data.mean_ms_between_msgs, 1202.5); + constexpr auto IS_ROS2_TOPIC = true; + more_playback_rate_test(input_file_ros2_, publish_type_, IS_ROS2_TOPIC); } -TEST(McapFileReadWithTypeTest, dds_more_playback_rate) +TEST_F(McapFileReadWithTypeTest, dds_less_playback_rate) { - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_more_hz_withtypes.yaml"; - create_subscriber_replayer(data, configuration); - // ms ~ 100 - ASSERT_GT(data.mean_ms_between_msgs, 597.5); - ASSERT_LT(data.mean_ms_between_msgs, 602.5); + less_playback_rate_test(input_file_type_, publish_type_); } -TEST(McapFileReadWithTypeTest, dds_less_playback_rate) +TEST_F(McapFileReadWithTypeTest, ros2_less_playback_rate) { - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_less_hz_withtypes.yaml"; - create_subscriber_replayer(data, configuration); - // ms ~ 400 - ASSERT_GT(data.mean_ms_between_msgs, 2397.5); - ASSERT_LT(data.mean_ms_between_msgs, 2403.5); + constexpr auto IS_ROS2_TOPIC = true; + less_playback_rate_test(input_file_ros2_, publish_type_, IS_ROS2_TOPIC); } -TEST(McapFileReadWithTypeTest, begin_time) +TEST_F(McapFileReadWithTypeTest, begin_time) { - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_begin_time_with_types.yaml"; - create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 7); - ASSERT_EQ(data.min_index_msg, 4); - ASSERT_EQ(data.max_index_msg, 10); + begin_time_test(input_file_type_, publish_type_); } -TEST(McapFileReadWithTypeTest, end_time) +TEST_F(McapFileReadWithTypeTest, end_time) { - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_end_time_with_types.yaml"; - create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 3); - ASSERT_EQ(data.min_index_msg, 1); - ASSERT_EQ(data.max_index_msg, 3); + end_time_test(input_file_type_, publish_type_); } TEST(McapFileReadWithTypeTest, start_replay_time_earlier) { - // info to check - DataToCheck data; - const std::string configuration = "resources/config_file_start_replay_time_earlier_with_types.yaml"; - create_subscriber_replayer(data, configuration); - ASSERT_EQ(data.n_received_msgs, 10); - ASSERT_EQ(data.min_index_msg, 1); - ASSERT_EQ(data.max_index_msg, 10); + start_replay_time_earlier_test(input_file_type_, publish_type_); } int main( diff --git a/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.hpp b/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.hpp new file mode 100644 index 000000000..f44af97fa --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.hpp @@ -0,0 +1,31 @@ +// Copyright 2024 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. + +#include + +#include "McapFileReadTest.hpp" + +/** + * @brief Test class for Mcap file read tests that publish the type. + * + * Include the tests that are exclusive to publishing the type in MCAP files. + */ +class McapFileReadWithTypeTest : public McapFileReadTest +{ +protected: + + const bool publish_type_ = true; + const std::string input_file_type_{"../../resources/recordings/basic/configuration.mcap"}; + const std::string input_file_ros2_{"../../resources/recordings/ros2/ros2.mcap"}; +}; diff --git a/ddsreplayer/test/blackbox/mcap/resources/helloworld_file.mcap b/ddsreplayer/test/blackbox/mcap/resources/helloworld_file.mcap deleted file mode 100644 index 018e2c20e6cb676e74b1c527fd9eec97a036e7eb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1522 zcmeD5b#@Fe;N@bJWPkt`AXSuKY{Uzsb25{1lM@RR4D>AY4A_L2AS(Dpvkl@u$BXZ| zx%4uKRs(4Pf}iS+Tp(suaY@QEMz9cr##a5m32Mww`52Z(#<~b>RAbdxc$dj!p$rSd zowLU~R-W9r=I;{+f0-$aYDrd0_uuuu_h;sb`u7`;Wf_%cyx+mKob_NEm#oFIj{Q?> zqHgXD_Of$i@MZ91(60aHz2VcB^zzN&r{0Qx`1+Mg{o3UIru$pWY>rBY?MjTAa;^4C z)A#=`)^VL!`|bZ70h30xGOuX=%_XWQ{!&XLIaJ7h@ ziR{(;C!^f9NNl}uK*Q2h!9n>x)5r zb12{c>Y92GKM%@Z%DSc-#9s>KKm4_9I*5M<$~U)Iwiv`0W`>w&oVQ{4tQ`yR??7lW9?z{nr~WWmz+6{sjbG<}1)%z<#VfOlQsunR$+PEINE22vnqVScd#kSa>e$xKYj%*iaNv{EQ3Doy1| zDJ?=3$S==JEh^5)EU;2YOUx-w<;qU2Oih7uSTcZyfB+K^g4_?XS-&K|ATyaZ7IHg* ztz%%|fzlw05df6*U=az6ZxNsv69YF?5h#ctfFlCRK-ZuJ6_684 z;`gBH&`Up9$;byvDj>jY0M$DW!e@ZXu$+U+yhfMd-U&^Apcn%IxE>A`R)|OS3)}%reT(WCW?}V2002|A_-2eap diff --git a/ddsreplayer/test/blackbox/mcap/resources/helloworld_withtypes_file_info.md b/ddsreplayer/test/blackbox/mcap/resources/helloworld_withtypes_file_info.md deleted file mode 100644 index 9fbf33f33..000000000 --- a/ddsreplayer/test/blackbox/mcap/resources/helloworld_withtypes_file_info.md +++ /dev/null @@ -1,83 +0,0 @@ -# RECORDING - -## Run [publisher](https://github.com/eProsima/DDS-Record-Replay/tree/main/resources/dds/TypeLookupService) - -* PUBLISHER_QOS_DEFAULT -* TOPIC_QOS_DEFAULT -* DATAWRITER_QOS_DEFAULT - -``` -./TypeLookupService --entity publisher --interval 200 -``` - -## Run DDS Recorder - -``` -ddsrecorder -``` - -# INFORMATION - -## TOPICS - -/dds/topic 13 - -HelloWorld - - index 0 - message "Hello World" - - index 1 - message "Hello World" - - index 2 - message "Hello World" - - index 3 - message "Hello World" - - index 4 - message "Hello World" - - index 5 - message "Hello World" - - index 6 - message "Hello World" - - index 7 - message "Hello World" - - index 8 - message "Hello World" - - index 9 - message "Hello World" - - index 10 - message "Hello World" - - index 11 - message "Hello World" - - index 12 - message "Hello World" - -/ddsrecorder/status 1 - -DdsRecorderStatus - - previous "CLOSED" - current "RUNNING" - info "" - -## START TIME -2023-05-26 -1:48:43.944 PM CEST - -## END TIME -2023-05-26 -1:48:48.029 PM CEST - -## DURATION -0:00:04.085 diff --git a/ddsreplayer/test/blackbox/mcap/resources/ros2_file.mcap b/ddsreplayer/test/blackbox/mcap/resources/ros2_file.mcap deleted file mode 100644 index 4a44b37e8549ba8b93d151faed0d54ea9512073b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3529 zcmb_f3vd(189rMM*s=|#HLt{gFo7WmtdnF}59*K;#*!VsAF`x2mG326_UVD{Bw5PC zN$N?=5YjSvfEm*`Vd}zQiffX>B%NeRCy-FLw1ITU3=cO`2PnmLLK2smICS@JPZkhJ zGSh$NZuh(Y-~Au^@9uwFsy7mKc&;*SF(y$4Xu?5WmkV0XNBL-kHMKQ;U0GrP9G zTYJ!xacr``!u93Ux`o^GH)7RT6E>Bx|6E;;hk4b0q7o_2%Ob4lY<``YPSI!LoYCD@%*5Ut{}s z&&yi8{-;|CH&jFv>VKRa{_DW?>L=#UPwVehKdFuj%hs!gPrbf~a7^rcPaW(3@ZMLW zh3}nMzaT!oWb2T6s(;tNuYFuh^^6xB8r2E@``Cg* zk3F|%<@0@`XL#klv=!#;TKeFc?dLtu{ODXKUxbPC zUxY92y=Mes4H}hrb8>?&$jU zLbw4=A^iG$!2t0bv?1gTQh{)e8#z83v{5$9`+|XoL3b8-=%C;46IO#B<1I0Kz65Q8+nI?6NWYKv2=NfhL!oU*7y|)?HvRxSWenfI(!nsph8qP^h(JMjHkkM_ zM_EH>tf@j@PCNC9Hbax1AWBOC3!8>~ZWDpXDt8DX`HdjzXTHMTrZ)I$=%lrkoJ(hp zyKRnmv%aC7u{#o?WK4WZFMFA0BOGtH#@$YLh|(jOyUZ`^qw7o+a1xi^5vTo*2tyFx zY@et}6a{+9G*+n3#zowIlgN?h10ZF*$P!~v2x1VXIgc+OuwgGrv%JOP=i4k6hT%OH zOI5JV>XqyRDrZ3u}xJ z?WFwW5lUafxng&)R|=CDC)KydNs19CSRM6heHE?diaAF}s5Mv0G5QqbE6BI+6(dpD zUfDsFn?qEffusHIc9+hP0PzrL9bHoEhq-7fsqO5Fy0s<(_%=gz7444Zwx(zamDp5O zXDo?U>pH}Ib^#e{g0Yngv?zV&HIidSv=KHaO4%GbcZ;YbC7)8pi}N8Dllf?9r&^jt zPIA86^RY}4u*NhoXrvYTm%9H_^of#4DU^qETm2x9IBAX)dqjVwukbDI572`B1=fWi z+yO_#rEdsPx?%|Lrcd-ANZ1KN)W?H-{Z@S-ZLlTa0mX#}?5mr1SECU21=>7NM%-VK z;*JtyV-puDtJHX#sx>jKTh5)`K<4}Ajve}Lufg5rW)Mr}_MG8raM};f3XnGlZ(WO0?D`iIXXc_C13H8$>cs{Fr}R9~yX}A$F9J}pfvBhfpBH1H3WeFI zFBsvK2-A^pm<@rD6lRNz<_fVC2ommj=wI0moL#^!Y#>ULGD?i+fE*Z!u#u zc}+UnfP)JOk_Xr0wBBP@@dD`&DI?%8G^sc?%5t(^a09V&A1IK!ULTkI?2QCy0bGsZ zaJ^2&`2wu6^#4rC>PDMIN0CRYjmMsgAfgps6VzfdE?1$nCNGU2t zP)f~|Am+@h5km^3GUHJ+I1N*XrGQ2VhI}-vDQG54fd+Or2YCWC;KKKjl#lZXaf?a_ zM_45j2`4{zNsecg!B_y)7VW+e^bdaMWaBI&12_ptmUUtg0MiW4l5GMVNHD=5rNNTm zrbjO3-ZhY z8@ZDC#xf`OK4b)kW}y*=tAgsVIkG2;Jy{a>0b%7 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_withtypes.yaml b/ddsreplayer/test/resources/config/config_file.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_withtypes.yaml rename to ddsreplayer/test/resources/config/config_file.yaml diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_notype.yaml b/ddsreplayer/test/resources/config/config_file_begin_time.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_notype.yaml rename to ddsreplayer/test/resources/config/config_file_begin_time.yaml diff --git a/ddsreplayer/test/resources/config/config_file_begin_time_notype.yaml b/ddsreplayer/test/resources/config/config_file_begin_time_notype.yaml new file mode 100644 index 000000000..51362440d --- /dev/null +++ b/ddsreplayer/test/resources/config/config_file_begin_time_notype.yaml @@ -0,0 +1,15 @@ +topics: + - name: configuration_topic + type: Configuration + qos: + reliability: true # Use QoS RELIABLE + +replayer: + replay-types: false + begin-time: + local: false + format: "%H-%M-%S_%Y-%m-%d" + datetime: 13-04-45_2024-06-25 + +specs: + wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_with_types.yaml b/ddsreplayer/test/resources/config/config_file_begin_time_with_types.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_begin_time_with_types.yaml rename to ddsreplayer/test/resources/config/config_file_begin_time_with_types.yaml diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_notype.yaml b/ddsreplayer/test/resources/config/config_file_end_time.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_notype.yaml rename to ddsreplayer/test/resources/config/config_file_end_time.yaml diff --git a/ddsreplayer/test/resources/config/config_file_end_time_notype.yaml b/ddsreplayer/test/resources/config/config_file_end_time_notype.yaml new file mode 100644 index 000000000..f2c8a9f5e --- /dev/null +++ b/ddsreplayer/test/resources/config/config_file_end_time_notype.yaml @@ -0,0 +1,15 @@ +topics: + - name: configuration_topic + type: Configuration + qos: + reliability: true # Use QoS RELIABLE + +replayer: + replay-types: false + end-time: + local: false + format: "%H-%M-%S_%Y-%m-%d" + datetime: 13-04-45_2024-06-25 + +specs: + wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_with_types.yaml b/ddsreplayer/test/resources/config/config_file_end_time_with_types.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_end_time_with_types.yaml rename to ddsreplayer/test/resources/config/config_file_end_time_with_types.yaml diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_withtypes.yaml b/ddsreplayer/test/resources/config/config_file_less_hz.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_withtypes.yaml rename to ddsreplayer/test/resources/config/config_file_less_hz.yaml diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_notype.yaml b/ddsreplayer/test/resources/config/config_file_less_hz_notype.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_less_hz_notype.yaml rename to ddsreplayer/test/resources/config/config_file_less_hz_notype.yaml diff --git a/ddsreplayer/test/resources/config/config_file_less_hz_withtypes.yaml b/ddsreplayer/test/resources/config/config_file_less_hz_withtypes.yaml new file mode 100644 index 000000000..6c8167c04 --- /dev/null +++ b/ddsreplayer/test/resources/config/config_file_less_hz_withtypes.yaml @@ -0,0 +1,12 @@ +topics: + - name: configuration_topic + type: Configuration + qos: + reliability: true # Use QoS RELIABLE + +replayer: + replay-types: true + rate: 0.5 + +specs: + wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_withtypes.yaml b/ddsreplayer/test/resources/config/config_file_more_hz.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_withtypes.yaml rename to ddsreplayer/test/resources/config/config_file_more_hz.yaml diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_notype.yaml b/ddsreplayer/test/resources/config/config_file_more_hz_notype.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_more_hz_notype.yaml rename to ddsreplayer/test/resources/config/config_file_more_hz_notype.yaml diff --git a/ddsreplayer/test/resources/config/config_file_more_hz_withtypes.yaml b/ddsreplayer/test/resources/config/config_file_more_hz_withtypes.yaml new file mode 100644 index 000000000..9c218bf6f --- /dev/null +++ b/ddsreplayer/test/resources/config/config_file_more_hz_withtypes.yaml @@ -0,0 +1,12 @@ +topics: + - name: configuration_topic + type: Configuration + qos: + reliability: true # Use QoS RELIABLE + +replayer: + replay-types: true + rate: 2.0 + +specs: + wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_notype.yaml b/ddsreplayer/test/resources/config/config_file_notype.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_notype.yaml rename to ddsreplayer/test/resources/config/config_file_notype.yaml diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_notype.yaml b/ddsreplayer/test/resources/config/config_file_start_replay_time_earlier.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_notype.yaml rename to ddsreplayer/test/resources/config/config_file_start_replay_time_earlier.yaml diff --git a/ddsreplayer/test/resources/config/config_file_start_replay_time_earlier_notype.yaml b/ddsreplayer/test/resources/config/config_file_start_replay_time_earlier_notype.yaml new file mode 100644 index 000000000..4a3e41aef --- /dev/null +++ b/ddsreplayer/test/resources/config/config_file_start_replay_time_earlier_notype.yaml @@ -0,0 +1,15 @@ +topics: + - name: configuration_topic + type: Configuration + qos: + reliability: true # Use QoS RELIABLE + +replayer: + replay-types: false + start-replay-time: + local: false + format: "%H-%M-%S_%Y-%m-%d" + datetime: 07-00-00_2022-09-26 + +specs: + wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_with_types.yaml b/ddsreplayer/test/resources/config/config_file_start_replay_time_earlier_with_types.yaml similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/config_file_start_replay_time_earlier_with_types.yaml rename to ddsreplayer/test/resources/config/config_file_start_replay_time_earlier_with_types.yaml diff --git a/ddsreplayer/test/resources/config/config_file_withtypes.yaml b/ddsreplayer/test/resources/config/config_file_withtypes.yaml new file mode 100644 index 000000000..ba243c206 --- /dev/null +++ b/ddsreplayer/test/resources/config/config_file_withtypes.yaml @@ -0,0 +1,11 @@ +topics: + - name: configuration_topic + type: Configuration + qos: + reliability: true # Use QoS RELIABLE + +replayer: + replay-types: true + +specs: + wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/resources/constants.hpp b/ddsreplayer/test/resources/constants.hpp new file mode 100644 index 000000000..e6a62b8b2 --- /dev/null +++ b/ddsreplayer/test/resources/constants.hpp @@ -0,0 +1,34 @@ +// Copyright 2024 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 constants.hpp + */ + +#pragma once + +#include + + +namespace test { + +constexpr std::uint32_t DOMAIN = 110; + +const auto DDS_TOPIC_NAME = "/dds/topic"; +const auto DDS_TYPE_NAME = "HelloWorld"; + +const auto ROS2_TOPIC_NAME = "rt/topic"; +const auto ROS2_TYPE_NAME = "std_msgs::msg::dds_::String_"; + +} // namespace test diff --git a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp b/ddsreplayer/test/resources/dds/ConfigurationDynTypesSubscriber.cpp similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp rename to ddsreplayer/test/resources/dds/ConfigurationDynTypesSubscriber.cpp diff --git a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.h b/ddsreplayer/test/resources/dds/ConfigurationDynTypesSubscriber.h similarity index 94% rename from ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.h rename to ddsreplayer/test/resources/dds/ConfigurationDynTypesSubscriber.h index 385a8ff60..3b8fd3219 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.h +++ b/ddsreplayer/test/resources/dds/ConfigurationDynTypesSubscriber.h @@ -34,6 +34,7 @@ #include "types/configuration/ConfigurationPubSubTypes.hpp" +<<<<<<<< HEAD:ddsreplayer/test/resources/ConfigurationDynTypesSubscriber.h struct DataToCheck { unsigned int n_received_msgs; @@ -43,6 +44,9 @@ struct DataToCheck double mean_ms_between_msgs; double cummulated_ms_between_msgs; }; +======== +#include "DataToCheck.hpp" +>>>>>>>> 384b8b8 (Strip replaying methods from McapFileReadTest & McapFileReadWithTypeTest):ddsreplayer/test/resources/dds/HelloWorldDynTypesSubscriber.h /** * @brief Class used to group into a single working unit a Subscriber with a DataReader and its listener. diff --git a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.cpp similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp rename to ddsreplayer/test/resources/dds/ConfigurationSubscriber.cpp diff --git a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.h similarity index 78% rename from ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h rename to ddsreplayer/test/resources/dds/ConfigurationSubscriber.h index 514cec863..c3909fa68 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h +++ b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.h @@ -24,7 +24,12 @@ #include #include +<<<<<<< HEAD:ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h #include "types/configuration/ConfigurationPubSubTypes.hpp" +======= +<<<<<<<< HEAD:ddsreplayer/test/resources/ConfigurationSubscriber.h +#include "types/configuration/ConfigurationPubSubTypes.h" +>>>>>>> b00497a (Strip replaying methods from McapFileReadTest & McapFileReadWithTypeTest):ddsreplayer/test/resources/dds/ConfigurationSubscriber.h struct DataToCheck { @@ -35,6 +40,15 @@ struct DataToCheck double mean_ms_between_msgs; double cummulated_ms_between_msgs; }; +======== +#include "DataToCheck.hpp" + +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include "../types/v1/hello_world/HelloWorldPubSubTypes.h" +#else + #include "../types/v2/hello_world/HelloWorldPubSubTypes.h" +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 +>>>>>>>> 384b8b8 (Strip replaying methods from McapFileReadTest & McapFileReadWithTypeTest):ddsreplayer/test/resources/dds/HelloWorldSubscriber.h /** * @brief Class used to group into a single working unit a Subscriber with a DataReader and its listener. diff --git a/ddsreplayer/test/resources/dds/DataToCheck.hpp b/ddsreplayer/test/resources/dds/DataToCheck.hpp new file mode 100644 index 000000000..dbbb90f89 --- /dev/null +++ b/ddsreplayer/test/resources/dds/DataToCheck.hpp @@ -0,0 +1,33 @@ +// Copyright 2024 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 DataToCheck.hpp + */ + +#pragma once + +#include + + +struct DataToCheck +{ + unsigned int n_received_msgs; + std::string type_msg; + std::string message_msg; + int min_index_msg; + int max_index_msg; + double mean_ms_between_msgs; + double cummulated_ms_between_msgs; +}; diff --git a/ddsreplayer/test/blackbox/mcap/resources/helloworld_file_info.md b/ddsreplayer/test/resources/recordings/basic/README.md similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/helloworld_file_info.md rename to ddsreplayer/test/resources/recordings/basic/README.md diff --git a/ddsreplayer/test/blackbox/mcap/resources/configuration_withtypes.mcap b/ddsreplayer/test/resources/recordings/basic/configuration.mcap similarity index 100% rename from ddsreplayer/test/blackbox/mcap/resources/configuration_withtypes.mcap rename to ddsreplayer/test/resources/recordings/basic/configuration.mcap diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.hpp b/ddsreplayer/test/resources/types/configuration/Configuration.hpp similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.hpp rename to ddsreplayer/test/resources/types/configuration/Configuration.hpp diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.idl b/ddsreplayer/test/resources/types/configuration/Configuration.idl similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/configuration/Configuration.idl rename to ddsreplayer/test/resources/types/configuration/Configuration.idl diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.hpp b/ddsreplayer/test/resources/types/configuration/ConfigurationCdrAux.hpp similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.hpp rename to ddsreplayer/test/resources/types/configuration/ConfigurationCdrAux.hpp diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.ipp b/ddsreplayer/test/resources/types/configuration/ConfigurationCdrAux.ipp similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationCdrAux.ipp rename to ddsreplayer/test/resources/types/configuration/ConfigurationCdrAux.ipp diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx b/ddsreplayer/test/resources/types/configuration/ConfigurationPubSubTypes.cxx similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx rename to ddsreplayer/test/resources/types/configuration/ConfigurationPubSubTypes.cxx diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.hpp b/ddsreplayer/test/resources/types/configuration/ConfigurationPubSubTypes.h similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.hpp rename to ddsreplayer/test/resources/types/configuration/ConfigurationPubSubTypes.h diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp b/ddsreplayer/test/resources/types/configuration/ConfigurationPubSubTypes.hpp similarity index 83% rename from ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp rename to ddsreplayer/test/resources/types/configuration/ConfigurationPubSubTypes.hpp index 556d4c05e..f5e4f1ca1 100644 --- a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp +++ b/ddsreplayer/test/resources/types/configuration/ConfigurationPubSubTypes.hpp @@ -13,15 +13,15 @@ // limitations under the License. /*! - * @file HelloWorldPubSubTypes.hpp + * @file ConfigurationPubSubTypes.hpp * This header file contains the declaration of the serialization functions. * * This file was generated by the tool fastddsgen. */ -#ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP -#define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP +#ifndef FAST_DDS_GENERATED__CONFIGURATION_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__CONFIGURATION_PUBSUBTYPES_HPP #include #include @@ -29,28 +29,28 @@ #include #include -#include "HelloWorld.hpp" +#include "Configuration.hpp" #if !defined(GEN_API_VER) || (GEN_API_VER != 2) #error \ - Generated HelloWorld is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen. + Generated Configuration 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 HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld + * @brief This class represents the TopicDataType of the type Configuration defined by the user in the IDL file. + * @ingroup Configuration */ -class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType +class ConfigurationPubSubType : public eprosima::fastdds::dds::TopicDataType { public: - typedef HelloWorld type; + typedef Configuration type; - eProsima_user_DllExport HelloWorldPubSubType(); + eProsima_user_DllExport ConfigurationPubSubType(); - eProsima_user_DllExport ~HelloWorldPubSubType() override; + eProsima_user_DllExport ~ConfigurationPubSubType() override; eProsima_user_DllExport bool serialize( const void* const data, @@ -129,5 +129,5 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType }; -#endif // FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP +#endif // FAST_DDS_GENERATED__CONFIGURATION_PUBSUBTYPES_HPP diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.cxx b/ddsreplayer/test/resources/types/configuration/ConfigurationTypeObjectSupport.cxx similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.cxx rename to ddsreplayer/test/resources/types/configuration/ConfigurationTypeObjectSupport.cxx diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.hpp b/ddsreplayer/test/resources/types/configuration/ConfigurationTypeObjectSupport.hpp similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.hpp rename to ddsreplayer/test/resources/types/configuration/ConfigurationTypeObjectSupport.hpp diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.hpp b/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.hpp deleted file mode 100644 index 556d4c05e..000000000 --- a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.hpp +++ /dev/null @@ -1,133 +0,0 @@ -// 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 HelloWorldPubSubTypes.hpp - * This header file contains the declaration of the serialization functions. - * - * This file was generated by the tool fastddsgen. - */ - - -#ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP -#define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP - -#include -#include -#include -#include -#include - -#include "HelloWorld.hpp" - - -#if !defined(GEN_API_VER) || (GEN_API_VER != 2) -#error \ - Generated HelloWorld 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 HelloWorld defined by the user in the IDL file. - * @ingroup HelloWorld - */ -class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType -{ -public: - - typedef HelloWorld type; - - eProsima_user_DllExport HelloWorldPubSubType(); - - eProsima_user_DllExport ~HelloWorldPubSubType() override; - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload) override - { - return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport bool serialize( - const void* const data, - eprosima::fastdds::rtps::SerializedPayload_t* payload, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool deserialize( - eprosima::fastdds::rtps::SerializedPayload_t* payload, - void* data) override; - - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data) override - { - return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); - } - - eProsima_user_DllExport std::function getSerializedSizeProvider( - const void* const data, - eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; - - eProsima_user_DllExport bool getKey( - const void* const data, - eprosima::fastdds::rtps::InstanceHandle_t* ihandle, - bool force_md5 = false) override; - - eProsima_user_DllExport void* createData() override; - - eProsima_user_DllExport void deleteData( - void* data) override; - - //Register TypeObject representation in Fast DDS TypeObjectRegistry - eProsima_user_DllExport void register_type_object_representation() 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; - } - - eProsima_user_DllExport inline bool is_plain( - eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override - { - static_cast(data_representation); - 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 - { - static_cast(memory); - return false; - } - -#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE - - eprosima::fastdds::MD5 m_md5; - unsigned char* m_keyBuffer; - -}; - -#endif // FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP - From a7f41ce339da64819f4072d7193b48454102cfac Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 13 Jun 2024 11:41:46 +0200 Subject: [PATCH 39/52] FileReadTest for SQL Signed-off-by: tempate --- ddsreplayer/test/blackbox/CMakeLists.txt | 1 + ddsreplayer/test/blackbox/sql/CMakeLists.txt | 137 ++++++++++++++++++ .../test/blackbox/sql/SqlFileReadTest.cpp | 63 ++++++++ .../test/blackbox/sql/SqlFileReadTest.hpp | 29 ++++ .../blackbox/sql/SqlFileReadWithTypeTest.cpp | 81 +++++++++++ .../blackbox/sql/SqlFileReadWithTypeTest.hpp | 31 ++++ .../resources/recordings/basic/helloworld.db | Bin 0 -> 28672 bytes .../test/resources/recordings/ros2/ros2.db | Bin 0 -> 28672 bytes .../recordings/type/helloworld_with_type.db | Bin 0 -> 28672 bytes 9 files changed, 342 insertions(+) create mode 100644 ddsreplayer/test/blackbox/sql/CMakeLists.txt create mode 100644 ddsreplayer/test/blackbox/sql/SqlFileReadTest.cpp create mode 100644 ddsreplayer/test/blackbox/sql/SqlFileReadTest.hpp create mode 100644 ddsreplayer/test/blackbox/sql/SqlFileReadWithTypeTest.cpp create mode 100644 ddsreplayer/test/blackbox/sql/SqlFileReadWithTypeTest.hpp create mode 100644 ddsreplayer/test/resources/recordings/basic/helloworld.db create mode 100644 ddsreplayer/test/resources/recordings/ros2/ros2.db create mode 100644 ddsreplayer/test/resources/recordings/type/helloworld_with_type.db diff --git a/ddsreplayer/test/blackbox/CMakeLists.txt b/ddsreplayer/test/blackbox/CMakeLists.txt index 4d964d217..3c449ebdb 100644 --- a/ddsreplayer/test/blackbox/CMakeLists.txt +++ b/ddsreplayer/test/blackbox/CMakeLists.txt @@ -13,3 +13,4 @@ # limitations under the License. add_subdirectory(mcap) +add_subdirectory(sql) diff --git a/ddsreplayer/test/blackbox/sql/CMakeLists.txt b/ddsreplayer/test/blackbox/sql/CMakeLists.txt new file mode 100644 index 000000000..fc3bd346b --- /dev/null +++ b/ddsreplayer/test/blackbox/sql/CMakeLists.txt @@ -0,0 +1,137 @@ +# Copyright 2024 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. + +################### +# SqlFileReadTest # +################### + +set(TEST_NAME SqlFileReadTest) + +# Determine Fast DDS version +if ("${fastrtps_VERSION}" VERSION_LESS 2.13) + set(DDS_TYPES_VERSION "v1") +else() + set(DDS_TYPES_VERSION "v2") +endif() + +file( + GLOB_RECURSE TEST_SOURCES + SqlFileReadTest.cpp + "${PROJECT_SOURCE_DIR}/test/resources/dds/*.c*" + "${PROJECT_SOURCE_DIR}/test/resources/types/*.c*" + ) + +list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") + +# Exclude types' files depending on the Fast DDS version +if ("${fastrtps_VERSION}" VERSION_LESS 2.13) + list(FILTER TEST_SOURCES EXCLUDE REGEX "v2/") +else() + list(FILTER TEST_SOURCES EXCLUDE REGEX "v1/") +endif() + +set(TEST_LIST + trivial + data_to_check + less_playback_rate + more_playback_rate + begin_time + end_time + start_replay_time_earlier + ) + +set(TEST_NEEDED_SOURCES + ../../resources/config/config_file.yaml + ../../resources/config/config_file_less_hz.yaml + ../../resources/config/config_file_more_hz.yaml + ../../resources/config/config_file_begin_time.yaml + ../../resources/config/config_file_end_time.yaml + ../../resources/config/config_file_start_replay_time_earlier.yaml + ../../resources/recordings/basic/helloworld.db + ) + +set(TEST_EXTRA_HEADERS + ) + +add_blackbox_executable( + "${TEST_NAME}" + "${TEST_SOURCES}" + "${TEST_LIST}" + "${TEST_NEEDED_SOURCES}" + "${TEST_EXTRA_HEADERS}" +) + +########################### +# SqlFileReadWithTypeTest # +########################### + +set(TEST_NAME SqlFileReadWithTypeTest) + +# Determine Fast DDS version +if ("${fastrtps_VERSION}" VERSION_LESS 2.13) + set(DDS_TYPES_VERSION "v1") +else() + set(DDS_TYPES_VERSION "v2") +endif() + +file( + GLOB_RECURSE TEST_SOURCES + SqlFileReadWithTypeTest.cpp + "${PROJECT_SOURCE_DIR}/test/resources/dds/*.c*" + "${PROJECT_SOURCE_DIR}/test/resources/types/*.c*" + ) + +list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") + +# Exclude types' files depending on the Fast DDS version +if ("${fastrtps_VERSION}" VERSION_LESS 2.13) + list(FILTER TEST_SOURCES EXCLUDE REGEX "v2/") +else() + list(FILTER TEST_SOURCES EXCLUDE REGEX "v1/") +endif() + +set(TEST_LIST + trivial + dds_data_to_check + ros2_data_to_check + dds_less_playback_rate + ros2_less_playback_rate + dds_more_playback_rate + ros2_more_playback_rate + begin_time + end_time + start_replay_time_earlier + ) + +set(TEST_NEEDED_SOURCES + ../../resources/config/config_file.yaml + ../../resources/config/config_file_less_hz.yaml + ../../resources/config/config_file_more_hz.yaml + ../../resources/config/config_file_begin_time_with_types.yaml + ../../resources/config/config_file_end_time_with_types.yaml + ../../resources/config/config_file_start_replay_time_earlier_with_types.yaml + ../../resources/recordings/ros2/ros2.db + ../../resources/recordings/type/helloworld_with_type.db + ) + +set(TEST_EXTRA_HEADERS + ) + +add_blackbox_executable( + "${TEST_NAME}" + "${TEST_SOURCES}" + "${TEST_LIST}" + "${TEST_NEEDED_SOURCES}" + "${TEST_EXTRA_HEADERS}" +) diff --git a/ddsreplayer/test/blackbox/sql/SqlFileReadTest.cpp b/ddsreplayer/test/blackbox/sql/SqlFileReadTest.cpp new file mode 100644 index 000000000..98cea4bf7 --- /dev/null +++ b/ddsreplayer/test/blackbox/sql/SqlFileReadTest.cpp @@ -0,0 +1,63 @@ +// Copyright 2024 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. + +#include + +#include + +#include "SqlFileReadTest.hpp" + + +TEST_F(SqlFileReadTest, trivial) +{ + trivial_test(input_file_); +} + +TEST_F(SqlFileReadTest, data_to_check) +{ + data_to_check_test(input_file_); +} + +TEST_F(SqlFileReadTest, more_playback_rate) +{ + more_playback_rate_test(input_file_); +} + +TEST_F(SqlFileReadTest, less_playback_rate) +{ + less_playback_rate_test(input_file_); +} + +TEST_F(SqlFileReadTest, begin_time) +{ + begin_time_test(input_file_); +} + +TEST_F(SqlFileReadTest, end_time) +{ + end_time_test(input_file_); +} + +TEST_F(SqlFileReadTest, start_replay_time_earlier) +{ + start_replay_time_earlier_test(input_file_); +} + +int main( + int argc, + char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/ddsreplayer/test/blackbox/sql/SqlFileReadTest.hpp b/ddsreplayer/test/blackbox/sql/SqlFileReadTest.hpp new file mode 100644 index 000000000..0abe069ae --- /dev/null +++ b/ddsreplayer/test/blackbox/sql/SqlFileReadTest.hpp @@ -0,0 +1,29 @@ +// Copyright 2024 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. + +#include + +#include "../FileReadTest.hpp" + +/** + * @brief Test class for SQL file read tests. + * + * Include the tests that are exclusive to SQL files. + */ +class SqlFileReadTest : public FileReadTest +{ +protected: + + const std::string input_file_{"../../resources/recordings/basic/helloworld.db"}; +}; diff --git a/ddsreplayer/test/blackbox/sql/SqlFileReadWithTypeTest.cpp b/ddsreplayer/test/blackbox/sql/SqlFileReadWithTypeTest.cpp new file mode 100644 index 000000000..cc5860092 --- /dev/null +++ b/ddsreplayer/test/blackbox/sql/SqlFileReadWithTypeTest.cpp @@ -0,0 +1,81 @@ +// Copyright 2024 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. + +#include + +#include + +#include "SqlFileReadWithTypeTest.hpp" + + +TEST_F(SqlFileReadWithTypeTest, trivial) +{ + trivial_test(input_file_type_, publish_type_); +} + +TEST_F(SqlFileReadWithTypeTest, dds_data_to_check) +{ + data_to_check_test(input_file_type_, publish_type_); +} + +TEST_F(SqlFileReadWithTypeTest, ros2_data_to_check) +{ + constexpr auto IS_ROS2_TOPIC = true; + data_to_check_test(input_file_ros2_, publish_type_, IS_ROS2_TOPIC); +} + +TEST_F(SqlFileReadWithTypeTest, dds_more_playback_rate) +{ + more_playback_rate_test(input_file_type_, publish_type_); +} + +TEST_F(SqlFileReadWithTypeTest, ros2_more_playback_rate) +{ + constexpr auto IS_ROS2_TOPIC = true; + more_playback_rate_test(input_file_ros2_, publish_type_, IS_ROS2_TOPIC); +} + +TEST_F(SqlFileReadWithTypeTest, dds_less_playback_rate) +{ + less_playback_rate_test(input_file_type_, publish_type_); +} + +TEST_F(SqlFileReadWithTypeTest, ros2_less_playback_rate) +{ + constexpr auto IS_ROS2_TOPIC = true; + less_playback_rate_test(input_file_ros2_, publish_type_, IS_ROS2_TOPIC); +} + +TEST_F(SqlFileReadWithTypeTest, begin_time) +{ + begin_time_test(input_file_type_, publish_type_); +} + +TEST_F(SqlFileReadWithTypeTest, end_time) +{ + end_time_test(input_file_type_, publish_type_); +} + +TEST_F(SqlFileReadWithTypeTest, start_replay_time_earlier) +{ + start_replay_time_earlier_test(input_file_type_, publish_type_); +} + +int main( + int argc, + char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/ddsreplayer/test/blackbox/sql/SqlFileReadWithTypeTest.hpp b/ddsreplayer/test/blackbox/sql/SqlFileReadWithTypeTest.hpp new file mode 100644 index 000000000..82d90be4d --- /dev/null +++ b/ddsreplayer/test/blackbox/sql/SqlFileReadWithTypeTest.hpp @@ -0,0 +1,31 @@ +// Copyright 2024 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. + +#include + +#include "SqlFileReadTest.hpp" + +/** + * @brief Test class for SQL file read tests that publish the type. + * + * Include the tests that are exclusive to publishing the type in SQL files. + */ +class SqlFileReadWithTypeTest : public SqlFileReadTest +{ +protected: + + const bool publish_type_ = true; + const std::string input_file_type_{"../../resources/recordings/type/helloworld_with_type.db"}; + const std::string input_file_ros2_{"../../resources/recordings/ros2/ros2.db"}; +}; diff --git a/ddsreplayer/test/resources/recordings/basic/helloworld.db b/ddsreplayer/test/resources/recordings/basic/helloworld.db new file mode 100644 index 0000000000000000000000000000000000000000..22acc01e4be3b5bb22f2dac1205ce8064c3c9135 GIT binary patch literal 28672 zcmeI*&r{=6902g7h4QPVI_qxburp!C0}Q(~KVOm^nYE>%bcF(?z`~5vX`3uW(uQqP zu^b#(^z6a^!vDd$2luvK_8)K@FODa@IKG#(kV0U!jtBJnhUUl1>-*;WNysz_4VxP) zrfV?I>{g@dG6MA$Mbp#=3`0@W9sC->uU?7biJ{&M9@By8>n86|^E*!x$=|5h#4pt3 z@5z^m?Z5R*mJ7>?L!y~Et_vtVFK35ILsqPz2Zyf9ErB}<$ zj5C2^>P(?n*7913SuYhq|S{#tFjwl`n#6R&Xoc=&XK9!aHA^cn4gkq*mb5b5V4RsTTCZ2G6xrro?r#jbs9 z)ZLp}oV(!_>Th?k6U;_psfEJs?riX?TiaP`?~w-kWY8_k zx%48L%ojhY?QjRR2JY;lzd$^%eRn>4oIc*d71@J&LqGAB+^{~+s+MECVCh(T;fvv5 z-kWaKZ99sS+s>5^kIMyNss2W=+nsu2yRBn~UblUl#jEt1;yAfJC)XTC+&TIVcD=O zd&h2BddslPYR$yor|CRm{5$JW;3F*^>7oyeu z%Z;?-{RzXBQ}@1*ZmVsK2P1kFZw~0+|9?#-UnhTpO$-7c00JNY0w4eaAOHd&00JNY z0w8eP1SX@?^u?8m$i1jAMrJQvRUr5O6|oOqQmgaSPz50@D+$R8%i|{IXfPCc0{H-; zM5M5aETYh?M3S?Fx0g8*3>6zJlz?PGR#a6C%Su3q6D66I%vdng@L-{MghW*pBrYrz zk0f3aI8HT(gQ3VH+Xn#TkR;0zFS22wI3!AVMR>&=3Wg$2l^Y-wi$q00Qg~J@5)h}7 ztfIkCkwHR<^C}WlQQ&Z5SAM_ALLMndW>qs13`L%E|F^Re=M^O2{es8Ggpg1QVtGMQ zS@kn|lq%Cg_rOGU_QjR8O)cj?p0Bi3EEbC1F$*uDsP{t7;KPqrIKGSz5~3(8Ve#?t z1@B3m#FF!WI{7Pwf1rQ>2!H?xfB*=900@8p2!H?xfB*>mX9VJO^giADKOFHt0b}e_ AxBvhE literal 0 HcmV?d00001 diff --git a/ddsreplayer/test/resources/recordings/ros2/ros2.db b/ddsreplayer/test/resources/recordings/ros2/ros2.db new file mode 100644 index 0000000000000000000000000000000000000000..22acc01e4be3b5bb22f2dac1205ce8064c3c9135 GIT binary patch literal 28672 zcmeI*&r{=6902g7h4QPVI_qxburp!C0}Q(~KVOm^nYE>%bcF(?z`~5vX`3uW(uQqP zu^b#(^z6a^!vDd$2luvK_8)K@FODa@IKG#(kV0U!jtBJnhUUl1>-*;WNysz_4VxP) zrfV?I>{g@dG6MA$Mbp#=3`0@W9sC->uU?7biJ{&M9@By8>n86|^E*!x$=|5h#4pt3 z@5z^m?Z5R*mJ7>?L!y~Et_vtVFK35ILsqPz2Zyf9ErB}<$ zj5C2^>P(?n*7913SuYhq|S{#tFjwl`n#6R&Xoc=&XK9!aHA^cn4gkq*mb5b5V4RsTTCZ2G6xrro?r#jbs9 z)ZLp}oV(!_>Th?k6U;_psfEJs?riX?TiaP`?~w-kWY8_k zx%48L%ojhY?QjRR2JY;lzd$^%eRn>4oIc*d71@J&LqGAB+^{~+s+MECVCh(T;fvv5 z-kWaKZ99sS+s>5^kIMyNss2W=+nsu2yRBn~UblUl#jEt1;yAfJC)XTC+&TIVcD=O zd&h2BddslPYR$yor|CRm{5$JW;3F*^>7oyeu z%Z;?-{RzXBQ}@1*ZmVsK2P1kFZw~0+|9?#-UnhTpO$-7c00JNY0w4eaAOHd&00JNY z0w8eP1SX@?^u?8m$i1jAMrJQvRUr5O6|oOqQmgaSPz50@D+$R8%i|{IXfPCc0{H-; zM5M5aETYh?M3S?Fx0g8*3>6zJlz?PGR#a6C%Su3q6D66I%vdng@L-{MghW*pBrYrz zk0f3aI8HT(gQ3VH+Xn#TkR;0zFS22wI3!AVMR>&=3Wg$2l^Y-wi$q00Qg~J@5)h}7 ztfIkCkwHR<^C}WlQQ&Z5SAM_ALLMndW>qs13`L%E|F^Re=M^O2{es8Ggpg1QVtGMQ zS@kn|lq%Cg_rOGU_QjR8O)cj?p0Bi3EEbC1F$*uDsP{t7;KPqrIKGSz5~3(8Ve#?t z1@B3m#FF!WI{7Pwf1rQ>2!H?xfB*=900@8p2!H?xfB*>mX9VJO^giADKOFHt0b}e_ AxBvhE literal 0 HcmV?d00001 diff --git a/ddsreplayer/test/resources/recordings/type/helloworld_with_type.db b/ddsreplayer/test/resources/recordings/type/helloworld_with_type.db new file mode 100644 index 0000000000000000000000000000000000000000..22acc01e4be3b5bb22f2dac1205ce8064c3c9135 GIT binary patch literal 28672 zcmeI*&r{=6902g7h4QPVI_qxburp!C0}Q(~KVOm^nYE>%bcF(?z`~5vX`3uW(uQqP zu^b#(^z6a^!vDd$2luvK_8)K@FODa@IKG#(kV0U!jtBJnhUUl1>-*;WNysz_4VxP) zrfV?I>{g@dG6MA$Mbp#=3`0@W9sC->uU?7biJ{&M9@By8>n86|^E*!x$=|5h#4pt3 z@5z^m?Z5R*mJ7>?L!y~Et_vtVFK35ILsqPz2Zyf9ErB}<$ zj5C2^>P(?n*7913SuYhq|S{#tFjwl`n#6R&Xoc=&XK9!aHA^cn4gkq*mb5b5V4RsTTCZ2G6xrro?r#jbs9 z)ZLp}oV(!_>Th?k6U;_psfEJs?riX?TiaP`?~w-kWY8_k zx%48L%ojhY?QjRR2JY;lzd$^%eRn>4oIc*d71@J&LqGAB+^{~+s+MECVCh(T;fvv5 z-kWaKZ99sS+s>5^kIMyNss2W=+nsu2yRBn~UblUl#jEt1;yAfJC)XTC+&TIVcD=O zd&h2BddslPYR$yor|CRm{5$JW;3F*^>7oyeu z%Z;?-{RzXBQ}@1*ZmVsK2P1kFZw~0+|9?#-UnhTpO$-7c00JNY0w4eaAOHd&00JNY z0w8eP1SX@?^u?8m$i1jAMrJQvRUr5O6|oOqQmgaSPz50@D+$R8%i|{IXfPCc0{H-; zM5M5aETYh?M3S?Fx0g8*3>6zJlz?PGR#a6C%Su3q6D66I%vdng@L-{MghW*pBrYrz zk0f3aI8HT(gQ3VH+Xn#TkR;0zFS22wI3!AVMR>&=3Wg$2l^Y-wi$q00Qg~J@5)h}7 ztfIkCkwHR<^C}WlQQ&Z5SAM_ALLMndW>qs13`L%E|F^Re=M^O2{es8Ggpg1QVtGMQ zS@kn|lq%Cg_rOGU_QjR8O)cj?p0Bi3EEbC1F$*uDsP{t7;KPqrIKGSz5~3(8Ve#?t z1@B3m#FF!WI{7Pwf1rQ>2!H?xfB*=900@8p2!H?xfB*>mX9VJO^giADKOFHt0b}e_ AxBvhE literal 0 HcmV?d00001 From 7c787d2db11c92c926688e895ef74202d61293f7 Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 13 Jun 2024 12:43:22 +0200 Subject: [PATCH 40/52] Identify topics in SQL by the topic_name, type_name pair Signed-off-by: tempate --- .../replayer/SqlReaderParticipant.hpp | 30 +------ .../src/cpp/recorder/sql/SqlWriter.cpp | 17 ++-- .../src/cpp/replayer/SqlReaderParticipant.cpp | 79 +++++++------------ 3 files changed, 41 insertions(+), 85 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp index 76219f2a2..0f1f3656a 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -113,36 +114,11 @@ class SqlReaderParticipant : public BaseReaderParticipant const std::vector& bind_values, const std::function& process_row); - /** - * @brief Get the \c DdsTopic for \c topic_name. - * - * If the topic is in the cache, return it. - * If not, find the topic's type in the database, create a topic, and store it in the cache. - * - * @param topic_name: Name of the topic to be found. - * @return \c DdsTopic instance for \c topic_name. - */ - ddspipe::core::types::DdsTopic find_topic_( - const std::string& topic_name); - - /** - * @brief Find the information related to \c topic_name. - * - * @param topic_name: Name of the topic. - * @param type_name: Type of the topic. - * @param is_ros2_type: Whether the topic is a ROS 2 type. - */ - void find_topic_info_( - const std::string& topic_name, - std::string& type_name, - std::string& topic_qos, - bool& is_ros2_type); - // Database sqlite3* database_; - // Topics cache - std::map topics_; + // Link a topic name and a type name to a DdsTopic instance + std::map, ddspipe::core::types::DdsTopic> topics_; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index 9022e4617..8836b5fc5 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -108,10 +108,11 @@ void SqlWriter::open_new_file_nts_( const std::string create_topics_table{ R"( CREATE TABLE IF NOT EXISTS Topics ( - name TEXT PRIMARY KEY NOT NULL, + name TEXT NOT NULL, type TEXT NOT NULL, qos TEXT NOT NULL, is_ros2_topic TEXT NOT NULL, + PRIMARY KEY(name, type), FOREIGN KEY(type) REFERENCES Types(name) ); )"}; @@ -126,10 +127,11 @@ void SqlWriter::open_new_file_nts_( data BLOB NOT NULL, data_size INTEGER NOT NULL, topic TEXT NOT NULL, + type TEXT NOT NULL, key TEXT NOT NULL, log_time DATETIME NOT NULL, publish_time DATETIME NOT NULL, - FOREIGN KEY(topic) REFERENCES Topics(name) + FOREIGN KEY(topic, type) REFERENCES Topics(name, type) ); )"}; @@ -208,8 +210,8 @@ void SqlWriter::write_nts_( // Define the SQL statement const char* insert_statement = R"( - INSERT INTO Messages (data, data_size, topic, key, log_time, publish_time) - VALUES (?, ?, ?, ?, ?, ?); + INSERT INTO Messages (data, data_size, topic, type, key, log_time, publish_time) + VALUES (?, ?, ?, ?, ?, ?, ?); )"; // Prepare the SQL statement @@ -230,9 +232,10 @@ void SqlWriter::write_nts_( sqlite3_bind_blob(statement, 1, msg.get_data(), msg.get_data_size(), SQLITE_TRANSIENT); sqlite3_bind_int64(statement, 2, msg.get_data_size()); sqlite3_bind_text(statement, 3, msg.topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 4, msg.key.c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 5, to_sql_timestamp(msg.log_time).c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 6, to_sql_timestamp(msg.publish_time).c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 4, msg.topic.type_name.c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 5, msg.key.c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 6, to_sql_timestamp(msg.log_time).c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 7, to_sql_timestamp(msg.publish_time).c_str(), -1, SQLITE_TRANSIENT); // Execute the SQL statement const auto step_ret = sqlite3_step(statement); diff --git a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp index 0de13c3bf..01c67fb1d 100644 --- a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -73,7 +74,16 @@ void SqlReaderParticipant::process_summary( topic->topic_qos.set_qos(topic_qos, utils::FuzzyLevelValues::fuzzy_level_fuzzy); // Store the topic in the cache - topics_[topic_name] = *topic; + const auto topic_id = std::make_pair(topic_name, type_name); + + if (topics_.find(topic_id) != topics_.end()) + { + logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, + "Topic " << topic_name << " with type " << type_name << " already exists. Skipping..."); + return; + } + + topics_[topic_id] = *topic; // Store the topic in the set topics.insert(topic); @@ -119,7 +129,7 @@ void SqlReaderParticipant::process_messages() utils::the_end_of_time()); exec_sql_statement_( - "SELECT log_time, topic, data, data_size FROM Messages " + "SELECT log_time, topic, type, data, data_size FROM Messages " "WHERE log_time >= ? AND log_time <= ? " "ORDER BY log_time;", {begin_time, end_time}, @@ -132,7 +142,20 @@ void SqlReaderParticipant::process_messages() // Create a DdsTopic to publish the message const std::string topic_name = reinterpret_cast(sqlite3_column_text(stmt, 1)); - const auto topic = find_topic_(topic_name); + const std::string type_name = reinterpret_cast(sqlite3_column_text(stmt, 2)); + + const auto topic_id = std::make_pair(topic_name, type_name); + + // Find the topic + if (topics_.find(topic_id) == topics_.end()) + { + logError(DDSREPLAYER_MCAP_READER_PARTICIPANT, + "Failed to find topic " << topic_name << " with type " << type_name << ". " + "Did you process the summary before the messages? Skipping..."); + return; + } + + const auto topic = topics_[topic_id]; // Find the reader for the topic if (readers_.find(topic) == readers_.end()) @@ -152,8 +175,8 @@ void SqlReaderParticipant::process_messages() std::chrono::time_point_cast(initial_timestamp + delay_ns); // Create a RtpsPayloadData from the raw data - const auto raw_data = sqlite3_column_blob(stmt, 2); - const auto raw_data_size = sqlite3_column_int(stmt, 3); + const auto raw_data = sqlite3_column_blob(stmt, 3); + const auto raw_data_size = sqlite3_column_int(stmt, 4); auto data = create_payload_(raw_data, raw_data_size); // Set source timestamp @@ -193,52 +216,6 @@ void SqlReaderParticipant::close_file_() sqlite3_close(database_); } -ddspipe::core::types::DdsTopic SqlReaderParticipant::find_topic_( - const std::string& topic_name) -{ - // Check if the topic is in the cache - if (topics_.find(topic_name) != topics_.end()) - { - return topics_[topic_name]; - } - - std::string type_name; - std::string topic_qos; - bool is_ros2_topic; - - find_topic_info_(topic_name, type_name, topic_qos, is_ros2_topic); - - // Create the DdsTopic - const auto topic = create_topic_(topic_name, type_name, is_ros2_topic); - - // Store the topic in the cache - topics_[topic_name] = topic; - - return topic; -} - -void SqlReaderParticipant::find_topic_info_( - const std::string& topic_name, - std::string& type_name, - std::string& topic_qos, - bool& is_ros2_topic) -{ - exec_sql_statement_("SELECT type, topic_qos, is_ros2_topic FROM Topics WHERE name = ?;", {topic_name}, [&](sqlite3_stmt* stmt) - { - if (!type_name.empty()) - { - const std::string error_msg = utils::Formatter() << "Multiple types found for topic " << topic_name; - - logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "FAIL_SQL_READ | " << error_msg); - throw std::runtime_error(error_msg); - } - - type_name = reinterpret_cast(sqlite3_column_text(stmt, 0)); - topic_qos = reinterpret_cast(sqlite3_column_text(stmt, 1)); - is_ros2_topic = sqlite3_column_int(stmt, 2) == 0; - }); -} - void SqlReaderParticipant::exec_sql_statement_( const std::string& statement, const std::vector& bind_values, From ae8737b3f6f7202deb60ad62d3cbe88007183a0d Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 13 Jun 2024 12:50:21 +0200 Subject: [PATCH 41/52] Fix comments and logs incorrectly referring to MCAP Signed-off-by: tempate --- .../replayer/ReplayerParticipant.hpp | 2 +- .../replayer/SqlReaderParticipant.hpp | 4 ++-- .../src/cpp/replayer/BaseReaderParticipant.cpp | 4 ++-- .../src/cpp/replayer/SqlReaderParticipant.cpp | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/ReplayerParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/ReplayerParticipant.hpp index 2e6614d0b..e4229e1b1 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/ReplayerParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/ReplayerParticipant.hpp @@ -24,7 +24,7 @@ namespace ddsrecorder { namespace participants { /** - * Participant kind in charge of replaying messages read by a \c McapReaderParticipant. + * Participant kind in charge of replaying messages read by a \c BaseReaderParticipant. * It is mostly equivalent to a \c rtps::SimpleParticipant without reader, only writer. */ class ReplayerParticipant : public ddspipe::participants::rtps::SimpleParticipant diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp index 0f1f3656a..869400e99 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp @@ -42,7 +42,7 @@ namespace ddsrecorder { namespace participants { /** - * Participant that reads MCAP files and passes its messages to other DDS Pipe participants. + * Participant that reads SQL files and passes its messages to other DDS Pipe participants. * * @implements BaseReaderParticipant */ @@ -57,7 +57,7 @@ class SqlReaderParticipant : public BaseReaderParticipant * * @param config: Structure encapsulating all configuration options. * @param payload_pool: Owner of every payload contained in sent messages. - * @param file_path: Path to the MCAP file with the messages to be read and sent. + * @param file_path: Path to the SQL file with the messages to be read and sent. */ DDSRECORDER_PARTICIPANTS_DllAPI SqlReaderParticipant( diff --git a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp index 1be5ea9f4..722401d3d 100644 --- a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp @@ -81,7 +81,7 @@ std::shared_ptr BaseReaderParticipant::create_reader( { if (!utils::can_cast(topic)) { - logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, "Not creating Writer for topic " << topic.topic_name()); + logWarning(DDSREPLAYER_SQL_READER_PARTICIPANT, "Not creating Writer for topic " << topic.topic_name()); return std::make_shared(); } @@ -162,7 +162,7 @@ utils::Timestamp BaseReaderParticipant::when_to_start_replay_( if (time < now) { - logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, + logWarning(DDSREPLAYER_SQL_READER_PARTICIPANT, "Provided start-replay-time already expired, starting immediately..."); return now; } diff --git a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp index 01c67fb1d..c5595bfbf 100644 --- a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp @@ -67,7 +67,7 @@ void SqlReaderParticipant::process_summary( const auto topic = utils::Heritable::make_heritable( create_topic_(topic_name, type_name, is_topic_ros2_type)); - // Apply the QoS stored in the MCAP file as if they were the discovered QoS. + // Apply the QoS stored in the SQL file as if they were the discovered QoS. const auto topic_qos_str = reinterpret_cast(sqlite3_column_text(stmt, 2)); const auto topic_qos = Serializer::deserialize(topic_qos_str); @@ -78,7 +78,7 @@ void SqlReaderParticipant::process_summary( if (topics_.find(topic_id) != topics_.end()) { - logWarning(DDSREPLAYER_MCAP_READER_PARTICIPANT, + logWarning(DDSREPLAYER_SQL_READER_PARTICIPANT, "Topic " << topic_name << " with type " << type_name << " already exists. Skipping..."); return; } @@ -149,7 +149,7 @@ void SqlReaderParticipant::process_messages() // Find the topic if (topics_.find(topic_id) == topics_.end()) { - logError(DDSREPLAYER_MCAP_READER_PARTICIPANT, + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "Failed to find topic " << topic_name << " with type " << type_name << ". " "Did you process the summary before the messages? Skipping..."); return; @@ -160,12 +160,12 @@ void SqlReaderParticipant::process_messages() // Find the reader for the topic if (readers_.find(topic) == readers_.end()) { - logError(DDSREPLAYER_MCAP_READER_PARTICIPANT, + logError(DDSREPLAYER_SQL_READER_PARTICIPANT, "Failed to replay message in topic " << topic << ": topic not found, skipping..."); return; } - logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, + logInfo(DDSREPLAYER_SQL_READER_PARTICIPANT, "Scheduling message to be replayed in topic " << topic << "."); // Set publication delay from original log time and configured playback rate @@ -186,7 +186,7 @@ void SqlReaderParticipant::process_messages() // Wait until it's time to write the message wait_until_timestamp_(time_to_write); - logInfo(DDSREPLAYER_MCAP_READER_PARTICIPANT, + logInfo(DDSREPLAYER_SQL_READER_PARTICIPANT, "Replaying message in topic " << topic << "."); // Insert new data in internal reader queue From 5d06ebab8809b84b041a35a1a99525732c58a023 Mon Sep 17 00:00:00 2001 From: tempate Date: Fri, 14 Jun 2024 11:13:40 +0200 Subject: [PATCH 42/52] Identify messages by their writer GUID and sequence number Signed-off-by: tempate --- .../recorder/message/SqlMessage.hpp | 8 ++++++ .../src/cpp/recorder/message/SqlMessage.cpp | 2 ++ .../src/cpp/recorder/sql/SqlWriter.cpp | 27 ++++++++++++------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp index 9d2ae82fd..b89c23f00 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp @@ -21,10 +21,12 @@ #include #include +#include #include #include #include +#include #include #include @@ -66,6 +68,12 @@ struct SqlMessage : public BaseMessage void set_key( fastrtps::types::DynamicType_ptr dynamic_type); + // Writer GUID + ddspipe::core::types::Guid writer_guid; + + // Sequence number + fastrtps::rtps::SequenceNumber_t sequence_number; + // Hashed value identifying the instance ddspipe::core::types::InstanceHandle instance_handle; diff --git a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp index 9fff3bda9..9c4a019f6 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp @@ -42,6 +42,8 @@ SqlMessage::SqlMessage( const bool log_publish_time, const std::string& key /* = "" */) : BaseMessage(data, payload_pool, topic, log_publish_time) + , writer_guid(data.sample_identity.writer_guid()) + , sequence_number(data.sample_identity.sequence_number()) , instance_handle(data.instanceHandle) , key(key) { diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index 8836b5fc5..41ca4c5a1 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -123,7 +123,8 @@ void SqlWriter::open_new_file_nts_( const std::string create_messages_table{ R"( CREATE TABLE IF NOT EXISTS Messages ( - id INTEGER PRIMARY KEY AUTOINCREMENT, + writer_guid TEXT NOT NULL, + sequence_number INTEGER NOT NULL, data BLOB NOT NULL, data_size INTEGER NOT NULL, topic TEXT NOT NULL, @@ -131,6 +132,7 @@ void SqlWriter::open_new_file_nts_( key TEXT NOT NULL, log_time DATETIME NOT NULL, publish_time DATETIME NOT NULL, + PRIMARY KEY(writer_guid, sequence_number), FOREIGN KEY(topic, type) REFERENCES Topics(name, type) ); )"}; @@ -210,8 +212,8 @@ void SqlWriter::write_nts_( // Define the SQL statement const char* insert_statement = R"( - INSERT INTO Messages (data, data_size, topic, type, key, log_time, publish_time) - VALUES (?, ?, ?, ?, ?, ?, ?); + INSERT INTO Messages (writer_guid, sequence_number, data, data_size, topic, type, key, log_time, publish_time) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?); )"; // Prepare the SQL statement @@ -229,13 +231,18 @@ void SqlWriter::write_nts_( } // Bind the SqlMessage to the SQL statement - sqlite3_bind_blob(statement, 1, msg.get_data(), msg.get_data_size(), SQLITE_TRANSIENT); - sqlite3_bind_int64(statement, 2, msg.get_data_size()); - sqlite3_bind_text(statement, 3, msg.topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 4, msg.topic.type_name.c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 5, msg.key.c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 6, to_sql_timestamp(msg.log_time).c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 7, to_sql_timestamp(msg.publish_time).c_str(), -1, SQLITE_TRANSIENT); + std::ostringstream writer_guid_ss; + writer_guid_ss << msg.writer_guid; + + sqlite3_bind_text(statement, 1, writer_guid_ss.str().c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_int64(statement, 2, msg.sequence_number.to64long()); + sqlite3_bind_blob(statement, 3, msg.get_data(), msg.get_data_size(), SQLITE_TRANSIENT); + sqlite3_bind_int64(statement, 4, msg.get_data_size()); + sqlite3_bind_text(statement, 5, msg.topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 6, msg.topic.type_name.c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 7, msg.key.c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 8, to_sql_timestamp(msg.log_time).c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 9, to_sql_timestamp(msg.publish_time).c_str(), -1, SQLITE_TRANSIENT); // Execute the SQL statement const auto step_ret = sqlite3_step(statement); From babdf2fd8528b6035262f588eed3d0bbb4b3b5d5 Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 27 Jun 2024 16:57:53 +0200 Subject: [PATCH 43/52] Rebase fix Signed-off-by: tempate --- .../test/blackbox/FileCreationTest.hpp | 19 +- .../blackbox/mcap/McapFileCreationTest.cpp | 4 +- .../test/blackbox/sql/SqlFileCreationTest.cpp | 2 +- .../common/serialize/Serializer.hpp | 6 +- .../common/time_utils.hpp | 2 +- .../recorder/message/SqlMessage.hpp | 6 +- .../recorder/output/BaseHandler.hpp | 4 +- .../recorder/sql/SqlHandler.hpp | 7 +- .../recorder/sql/SqlWriter.hpp | 7 +- .../replayer/BaseReaderParticipant.hpp | 7 +- .../replayer/McapReaderParticipant.hpp | 7 +- .../replayer/SqlReaderParticipant.hpp | 7 +- .../src/cpp/common/serialize/Serializer.cpp | 1 + .../src/cpp/common/time_utils.cpp | 4 +- .../src/cpp/recorder/mcap/McapHandler.cpp | 2 - .../src/cpp/recorder/message/SqlMessage.cpp | 327 +++++++++--------- .../src/cpp/recorder/sql/SqlHandler.cpp | 8 +- .../src/cpp/recorder/sql/SqlWriter.cpp | 2 +- .../cpp/replayer/BaseReaderParticipant.cpp | 4 +- .../cpp/replayer/McapReaderParticipant.cpp | 9 +- .../src/cpp/replayer/SqlReaderParticipant.cpp | 2 +- ddsreplayer/src/cpp/tool/DdsReplayer.cpp | 69 +--- ddsreplayer/src/cpp/tool/DdsReplayer.hpp | 18 - ddsreplayer/test/blackbox/FileReadTest.hpp | 10 +- ddsreplayer/test/blackbox/mcap/CMakeLists.txt | 21 +- .../mcap/McapFileReadWithTypeTest.cpp | 2 +- .../dds/ConfigurationDynTypesSubscriber.h | 14 +- .../resources/dds/ConfigurationSubscriber.cpp | 2 +- .../resources/dds/ConfigurationSubscriber.h | 21 +- .../TypeLookupServicePublisher.cpp | 2 +- .../TypeLookupServicePublisher.h | 2 +- .../TypeLookupServiceSubscriber.cpp | 4 +- 32 files changed, 230 insertions(+), 372 deletions(-) diff --git a/ddsrecorder/test/blackbox/FileCreationTest.hpp b/ddsrecorder/test/blackbox/FileCreationTest.hpp index 7ca35b8e9..6c1d62517 100644 --- a/ddsrecorder/test/blackbox/FileCreationTest.hpp +++ b/ddsrecorder/test/blackbox/FileCreationTest.hpp @@ -43,18 +43,13 @@ #include -#if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include "../resources/types/hello_world/v1/HelloWorld.h" - #include "../resources/types/hello_world/v1/HelloWorldPubSubTypes.h" -#else - #include "../resources/types/hello_world/v2/HelloWorld.h" - #include "../resources/types/hello_world/v2/HelloWorldPubSubTypes.h" -#endif // if FASTRTPS_VERSION_MAJOR < 2 || (FASTRTPS_VERSION_MAJOR == 2 && FASTRTPS_VERSION_MINOR < 13) - #include #include "constants.hpp" +#include "../resources/types/hello_world/HelloWorld.hpp" +#include "../resources/types/hello_world/HelloWorldPubSubTypes.h" + using namespace eprosima; using DdsRecorderState = ddsrecorder::recorder::DdsRecorderStateCode; @@ -114,7 +109,7 @@ class FileCreationTest : public testing::Test protected: - std::vector> record_messages_( + std::vector> record_messages_( const std::string& file_name, const unsigned int messages1, const DdsRecorderState state1 = DdsRecorderState::RUNNING, @@ -189,7 +184,7 @@ class FileCreationTest : public testing::Test return sent_messages; } - std::vector> send_messages_( + std::vector> send_messages_( const unsigned int number_of_messages) { // Create the DataWriter @@ -199,7 +194,7 @@ class FileCreationTest : public testing::Test std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Send the messages - std::vector> sent_messages; + std::vector> sent_messages; for (std::uint32_t i = 0; i < number_of_messages; i++) { @@ -213,7 +208,7 @@ class FileCreationTest : public testing::Test // Serialize the message HelloWorldPubSubType pubsubType; const auto payload_size = pubsubType.getSerializedSizeProvider(&hello)(); - auto payload = std::make_shared(payload_size); + auto payload = std::make_shared(payload_size); pubsubType.serialize(&hello, payload.get()); // Store the serialized message diff --git a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp index 4f752abac..74267f321 100644 --- a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp @@ -256,7 +256,7 @@ TEST_F(McapFileCreationTest, mcap_data_num_msgs) const std::string OUTPUT_FILE_NAME = "mcap_data_num_msgs"; const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - constexpr auto NUMBER_OF_MESSAGES = 10; + constexpr auto NUMBER_OF_MESSAGES = 128; ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); @@ -276,7 +276,7 @@ TEST_F(McapFileCreationTest, mcap_data_num_msgs_downsampling) const std::string OUTPUT_FILE_NAME = "mcap_data_num_msgs_downsampling"; const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".mcap"); - constexpr auto NUMBER_OF_MESSAGES = 10; + constexpr auto NUMBER_OF_MESSAGES = 128; constexpr int DOWNSAMPLING = 2; ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); diff --git a/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp b/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp index f901123ce..913ddb4d3 100644 --- a/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp @@ -294,7 +294,7 @@ TEST_F(SqlFileCreationTest, sql_data_num_msgs_downsampling) const std::string OUTPUT_FILE_NAME = "sql_data_num_msgs_downsampling"; const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); - constexpr auto NUMBER_OF_MESSAGES = 10; + constexpr auto NUMBER_OF_MESSAGES = 128; constexpr int DOWNSAMPLING = 2; ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/Serializer.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/Serializer.hpp index 5770f4bb1..40b9c8e81 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/Serializer.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/Serializer.hpp @@ -56,15 +56,13 @@ class DDSRECORDER_PARTICIPANTS_DllAPI Serializer protected: /** - * @brief Serialize a \c TypeObject or a \c TypeIdentifier into a \c SerializedPayload_t. + * @brief Serialize a \c TypeObject or a \c TypeIdentifier into a string. * * @param [in] object \c TypeObject or \c TypeIdentifier to serialize - * @return \c SerializedPayload_t with the serialization */ template static std::string type_data_to_type_str_( - const T& data, - const size_t size); + const T& data); /** * @brief Deserialize \c type_str into a \c TypeObject or a \c TypeIdentifier. diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp index 603b47d40..f25399a55 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp @@ -81,7 +81,7 @@ mcap::Timestamp to_mcap_timestamp( */ DDSRECORDER_PARTICIPANTS_DllAPI std::string to_sql_timestamp( - const fastrtps::rtps::Time_t& time, + const fastdds::rtps::Time_t& time, const bool local_time = false); /** diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp index b89c23f00..acbcb75da 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -66,13 +66,13 @@ struct SqlMessage : public BaseMessage * @param dynamic_type DynamicType of the message. */ void set_key( - fastrtps::types::DynamicType_ptr dynamic_type); + fastdds::dds::DynamicType::_ref_type dynamic_type); // Writer GUID ddspipe::core::types::Guid writer_guid; // Sequence number - fastrtps::rtps::SequenceNumber_t sequence_number; + fastdds::rtps::SequenceNumber_t sequence_number; // Hashed value identifying the instance ddspipe::core::types::InstanceHandle instance_handle; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp index 01b599818..5e25e67e2 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandler.hpp @@ -32,7 +32,7 @@ #include -#include +#include #include #include @@ -366,7 +366,7 @@ class BaseHandler : public ddspipe::participants::ISchemaHandler ////////////////////////////// //! Received types set - std::map received_types_; + std::map received_types_; //! Dynamic types collection DynamicTypesCollection dynamic_types_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp index a920128b2..2cc594be7 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp @@ -24,7 +24,8 @@ #include #include -#include +#include +#include #include #include @@ -96,7 +97,9 @@ class SqlHandler : public BaseHandler */ DDSRECORDER_PARTICIPANTS_DllAPI void add_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) override; + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_id) override; /** * @brief Add a data sample to the given \c topic. diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp index e5a099d50..e386d3bb5 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp @@ -23,15 +23,10 @@ #include #include +#include #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include -#else - #include -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - namespace eprosima { namespace ddsrecorder { namespace participants { diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp index 768e36595..9f0663551 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/BaseReaderParticipant.hpp @@ -38,15 +38,10 @@ #include +#include #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include -#else - #include -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - namespace eprosima { namespace ddsrecorder { namespace participants { diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp index 90c6481b3..c7b027abe 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/McapReaderParticipant.hpp @@ -23,16 +23,11 @@ #include +#include #include #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include -#else - #include -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - namespace eprosima { namespace ddsrecorder { namespace participants { diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp index 869400e99..c742bcb99 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/replayer/SqlReaderParticipant.hpp @@ -27,16 +27,11 @@ #include #include +#include #include #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include -#else - #include -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - namespace eprosima { namespace ddsrecorder { namespace participants { diff --git a/ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp b/ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp index 7b9208123..3fc693ebf 100644 --- a/ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp +++ b/ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp @@ -26,6 +26,7 @@ #include #include +#include #include namespace eprosima { diff --git a/ddsrecorder_participants/src/cpp/common/time_utils.cpp b/ddsrecorder_participants/src/cpp/common/time_utils.cpp index 6132925bc..3042a630f 100644 --- a/ddsrecorder_participants/src/cpp/common/time_utils.cpp +++ b/ddsrecorder_participants/src/cpp/common/time_utils.cpp @@ -69,7 +69,7 @@ utils::Timestamp to_std_timestamp( } mcap::Timestamp to_mcap_timestamp( - const fastrtps::rtps::Time_t& time) + const fastdds::rtps::Time_t& time) { return time.seconds() * NS_PER_SEC + time.nanosec(); } @@ -81,7 +81,7 @@ mcap::Timestamp to_mcap_timestamp( } std::string to_sql_timestamp( - const fastrtps::rtps::Time_t& time, + const fastdds::rtps::Time_t& time, const bool local_time /* = false */) { char datetime_str[30]; diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 5a34dd53c..9ea69fa5c 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -93,8 +93,6 @@ void McapHandler::add_schema( return; } - // const std::string type_name = dynamic_type->get_name(); - // Check if it exists already if (received_types_.find(type_name) != received_types_.end()) { diff --git a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp index 9c4a019f6..15e797e91 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp @@ -21,13 +21,6 @@ #include -#include -#include -#include -#include -#include -#include - #include @@ -50,167 +43,167 @@ SqlMessage::SqlMessage( } void SqlMessage::set_key( - fastrtps::types::DynamicType_ptr dynamic_type) + fastdds::dds::DynamicType::_ref_type dynamic_type) { - // Deserialize the payload - fastrtps::types::DynamicPubSubType pub_sub_type(dynamic_type); - fastrtps::types::DynamicData_ptr dynamic_data; - dynamic_data = fastrtps::types::DynamicDataFactory::get_instance()->create_data(dynamic_type); - - pub_sub_type.deserialize(&payload, dynamic_data.get()); - - // Clear non-key values to free-up unnecessary space - // dynamic_data->clear_nonkey_values(); - - // Serialize the key members into a JSON - nlohmann::json key_json; - - std::map members_map; - dynamic_type->get_all_members(members_map); - - for (const auto& member : members_map) - { - if (!member.second->key_annotation()) - { - // The member is not a key - continue; - } - - const auto descriptor = member.second->get_descriptor(); - - if (descriptor == nullptr) - { - // The member has no descriptor - continue; - } - - switch (descriptor->get_kind()) - { - case fastrtps::types::TK_BOOLEAN: - { - key_json[descriptor->get_name()] = dynamic_data->get_bool_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_BYTE: - { - key_json[descriptor->get_name()] = dynamic_data->get_byte_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_INT16: - { - key_json[descriptor->get_name()] = dynamic_data->get_int16_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_INT32: - { - key_json[descriptor->get_name()] = dynamic_data->get_int32_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_INT64: - { - key_json[descriptor->get_name()] = dynamic_data->get_int64_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_UINT16: - { - key_json[descriptor->get_name()] = dynamic_data->get_uint16_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_UINT32: - { - key_json[descriptor->get_name()] = dynamic_data->get_uint32_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_UINT64: - { - key_json[descriptor->get_name()] = dynamic_data->get_uint64_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_FLOAT32: - { - key_json[descriptor->get_name()] = dynamic_data->get_float32_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_FLOAT64: - { - key_json[descriptor->get_name()] = dynamic_data->get_float64_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_FLOAT128: - { - key_json[descriptor->get_name()] = dynamic_data->get_float128_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_CHAR8: - { - key_json[descriptor->get_name()] = dynamic_data->get_char8_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_CHAR16: - { - key_json[descriptor->get_name()] = dynamic_data->get_char16_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_STRING8: - { - key_json[descriptor->get_name()] = dynamic_data->get_string_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_STRING16: - { - key_json[descriptor->get_name()] = dynamic_data->get_wstring_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_ALIAS: - { - // TODO - break; - } - case fastrtps::types::TK_ENUM: - { - key_json[descriptor->get_name()] = dynamic_data->get_enum_value(descriptor->get_id()); - break; - } - case fastrtps::types::TK_BITMASK: - { - // TODO - break; - } - case fastrtps::types::TK_ANNOTATION: - { - // TODO - break; - } - case fastrtps::types::TK_STRUCTURE: - { - // TODO - break; - } - case fastrtps::types::TK_UNION: - { - // TODO - break; - } - case fastrtps::types::TK_BITSET: - { - // TODO - break; - } - case fastrtps::types::TK_SEQUENCE: - { - // TODO - break; - } - case fastrtps::types::TK_ARRAY: - { - // TODO - break; - } - } - } - - // Dump the JSON into a string - key = key_json.dump(); + // // Deserialize the payload + // fastdds::dds::xtypes::DynamicPubSubType pub_sub_type(dynamic_type); + // fastdds::dds::xtypes::DynamicData_ptr dynamic_data; + // dynamic_data = fastdds::dds::xtypes::DynamicDataFactory::get_instance()->create_data(dynamic_type); + + // pub_sub_type.deserialize(&payload, dynamic_data.get()); + + // // Clear non-key values to free-up unnecessary space + // // dynamic_data->clear_nonkey_values(); + + // // Serialize the key members into a JSON + // nlohmann::json key_json; + + // std::map members_map; + // dynamic_type->get_all_members(members_map); + + // for (const auto& member : members_map) + // { + // if (!member.second->key_annotation()) + // { + // // The member is not a key + // continue; + // } + + // const auto descriptor = member.second->get_descriptor(); + + // if (descriptor == nullptr) + // { + // // The member has no descriptor + // continue; + // } + + // switch (descriptor->get_kind()) + // { + // case fastdds::dds::xtypes::TK_BOOLEAN: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_bool_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_BYTE: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_byte_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_INT16: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_int16_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_INT32: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_int32_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_INT64: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_int64_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_UINT16: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_uint16_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_UINT32: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_uint32_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_UINT64: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_uint64_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_FLOAT32: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_float32_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_FLOAT64: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_float64_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_FLOAT128: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_float128_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_CHAR8: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_char8_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_CHAR16: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_char16_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_STRING8: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_string_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_STRING16: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_wstring_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_ALIAS: + // { + // // TODO + // break; + // } + // case fastdds::dds::xtypes::TK_ENUM: + // { + // key_json[descriptor->get_name()] = dynamic_data->get_enum_value(descriptor->get_id()); + // break; + // } + // case fastdds::dds::xtypes::TK_BITMASK: + // { + // // TODO + // break; + // } + // case fastdds::dds::xtypes::TK_ANNOTATION: + // { + // // TODO + // break; + // } + // case fastdds::dds::xtypes::TK_STRUCTURE: + // { + // // TODO + // break; + // } + // case fastdds::dds::xtypes::TK_UNION: + // { + // // TODO + // break; + // } + // case fastdds::dds::xtypes::TK_BITSET: + // { + // // TODO + // break; + // } + // case fastdds::dds::xtypes::TK_SEQUENCE: + // { + // // TODO + // break; + // } + // case fastdds::dds::xtypes::TK_ARRAY: + // { + // // TODO + // break; + // } + // } + // } + + // // Dump the JSON into a string + // key = key_json.dump(); } } /* namespace participants */ diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp index ee590887c..705730850 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp @@ -55,7 +55,9 @@ SqlHandler::~SqlHandler() } void SqlHandler::add_schema( - const fastrtps::types::DynamicType_ptr& dynamic_type) + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + const std::string& type_name, + const fastdds::dds::xtypes::TypeIdentifier& type_id) { // NOTE: Process schemas even if in STOPPED state to avoid losing them (only sent/received once in discovery) std::lock_guard lock(mtx_); @@ -66,8 +68,6 @@ void SqlHandler::add_schema( return; } - const auto type_name = dynamic_type->get_name(); - // Check if it exists already if (received_types_.find(type_name) != received_types_.end()) { @@ -78,7 +78,7 @@ void SqlHandler::add_schema( received_types_[type_name] = dynamic_type; // Add type to the collection of dynamic types - store_dynamic_type_(type_name); + store_dynamic_type_(type_name, type_id); if (configuration_.record_types) { diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index 41ca4c5a1..b573f305f 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -29,13 +29,13 @@ #include #include +#include #include #include #include #include #if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include #else #include #endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 diff --git a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp index 722401d3d..db967deb7 100644 --- a/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/BaseReaderParticipant.cpp @@ -116,9 +116,7 @@ std::unique_ptr BaseReaderParticipant::cr payload.data = (unsigned char*) reinterpret_cast(raw_data); // Reserve and copy the payload into the payload pool - fastrtps::rtps::IPayloadPool* null_payload_pool = nullptr; - - payload_pool_->get_payload(payload, null_payload_pool, data->payload); + payload_pool_->get_payload(payload, data->payload); data->payload_owner = payload_pool_.get(); // Remove the raw data pointer to avoid freeing it on destruction diff --git a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp index c6028ee03..35f1f48ba 100644 --- a/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/McapReaderParticipant.cpp @@ -36,15 +36,10 @@ #include #include +#include #include #include -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include -#else - #include -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - namespace eprosima { namespace ddsrecorder { namespace participants { @@ -152,7 +147,7 @@ void McapReaderParticipant::process_messages() // Set source timestamp // NOTE: this is important for QoS such as LifespanQosPolicy - data->source_timestamp = fastrtps::rtps::Time_t(to_ticks(scheduled_write_ts) / 1e9); + data->source_timestamp = fastdds::Time_t(to_ticks(scheduled_write_ts) / 1e9); // Wait until it's time to write the message wait_until_timestamp_(scheduled_write_ts); diff --git a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp index c5595bfbf..dc7dde383 100644 --- a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp @@ -181,7 +181,7 @@ void SqlReaderParticipant::process_messages() // Set source timestamp // NOTE: this is important for QoS such as LifespanQosPolicy - data->source_timestamp = fastrtps::rtps::Time_t(to_ticks(time_to_write) / 1e9); + data->source_timestamp = fastdds::Time_t(to_ticks(time_to_write) / 1e9); // Wait until it's time to write the message wait_until_timestamp_(time_to_write); diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index a99343d51..8e1b72849 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -134,9 +134,6 @@ DdsReplayer::DdsReplayer( // Register the dynamic types const auto& registered_types = register_dynamic_types_(types); - // Create writers to publish the dynamic types - create_dynamic_types_writers_(topics, registered_types); - // Create DDS Pipe pipe_ = std::make_unique( configuration.ddspipe_configuration, @@ -183,15 +180,16 @@ std::set DdsReplayer::register_dynamic_types_( { // Deserialize type identifier const auto type_identifier_str = utils::base64_decode(dynamic_type.type_information()); - const auto type_identifier = participants::Serializer::deserialize(type_identifier_str); + const auto type_identifier = participants::Serializer::deserialize(type_identifier_str); // Deserialize type object const auto type_object_str = utils::base64_decode(dynamic_type.type_object()); - const auto type_object = participants::Serializer::deserialize(type_object_str); + const auto type_object = participants::Serializer::deserialize(type_object_str); // Register in factory - fastrtps::types::TypeObjectFactory::get_instance()->add_type_object( - dynamic_type.type_name(), &type_identifier, &type_object); + fastdds::dds::xtypes::TypeIdentifierPair type_identifiers; + fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().register_type_object( + type_object, type_identifiers); registered_types.insert(dynamic_type.type_name()); } @@ -199,63 +197,6 @@ std::set DdsReplayer::register_dynamic_types_( return registered_types; } -void DdsReplayer::create_dynamic_types_writers_( - const std::set>& topics, - const std::set& registered_types) -{ - for (const auto& topic : topics) - { - if (registered_types.find(topic->type_name) == registered_types.end()) - { - continue; - } - - // Make a copy of the Topic to customize it according to the Participant's configured QoS. - utils::Heritable topic_copy = topic->copy(); - - // Apply the Manual Topics for this participant. - for (const auto& [manual_topic, _] : configuration_.ddspipe_configuration.get_manual_topics(*topic)) - { - topic_copy->topic_qos.set_qos(manual_topic->topic_qos, utils::FuzzyLevelValues::fuzzy_level_hard); - } - - // Create Datawriter in this topic so dynamic type can be shared in EDP - // TODO: Avoid creating the dynamic writer when the topic is not allowed. - create_dynamic_type_writer_(topic_copy); - } -} - -void DdsReplayer::create_dynamic_type_writer_( - utils::Heritable topic) -{ - // Decode type identifer and object strings - const auto type_identifier_str = utils::base64_decode(dynamic_type.type_information()); - const auto type_object_str = utils::base64_decode(dynamic_type.type_object()); - - // Deserialize type identifer and object strings - fastdds::dds::xtypes::TypeIdentifier type_identifier = - Deserializer::deserialize(type_identifier_str); - fastdds::dds::xtypes::TypeObject type_object = - Deserializer::deserialize(type_object_str); - - // Create a TypeIdentifierPair to use in register_type_identifier - fastdds::dds::xtypes::TypeIdentifierPair type_identifiers; - type_identifiers.type_identifier1(type_identifier); - - // Register in factory - auto& factory = fastdds::dds::DomainParticipantFactory::get_instance(); - - if (fastdds::dds::RETCODE_OK != factory->type_object_registry().register_type_object(type_object, type_identifiers)) - { - logWarning(DDSREPLAYER_REPLAYER, - "Failed to register " << dynamic_type.type_name() << " DynamicType."); - } - else - { - registered_types_.insert({dynamic_type.type_name(), type_identifiers}); - } -} - } /* namespace replayer */ } /* namespace ddsrecorder */ } /* namespace eprosima */ diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp index e71ba5b27..bf12c76bc 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp @@ -101,24 +101,6 @@ class DdsReplayer std::set register_dynamic_types_( const participants::DynamicTypesCollection& dynamic_types); - /** - * @brief Create the dynamic types' writers for \c topics. - * - * @param topics: The topics to create the writers for. - * @param registered_types: The types to create the writers for. - */ - void create_dynamic_types_writers_( - const std::set>& topics, - const std::set& registered_types); - - /** - * @brief Create the dynamic types' writer for \c topic. - * - * @param topic: The topic to create the writer for. - */ - void create_dynamic_type_writer_( - utils::Heritable topic); - //! Replayer Configuration const yaml::ReplayerConfiguration configuration_; diff --git a/ddsreplayer/test/blackbox/FileReadTest.hpp b/ddsreplayer/test/blackbox/FileReadTest.hpp index 51b538b45..4dd4a254f 100644 --- a/ddsreplayer/test/blackbox/FileReadTest.hpp +++ b/ddsreplayer/test/blackbox/FileReadTest.hpp @@ -29,8 +29,8 @@ #include "../resources/constants.hpp" #include "../resources/dds/DataToCheck.hpp" -#include "../resources/dds/HelloWorldDynTypesSubscriber.h" -#include "../resources/dds/HelloWorldSubscriber.h" +#include "../resources/dds/ConfigurationSubscriber.h" +#include "../resources/dds/ConfigurationDynTypesSubscriber.h" using namespace eprosima; @@ -77,7 +77,7 @@ class FileReadTest : public testing::Test // Verify that the received data is correct ASSERT_EQ(data.n_received_msgs, 11); - ASSERT_EQ(data.type_msg, "HelloWorld"); + ASSERT_EQ(data.type_msg, "Configuration"); ASSERT_EQ(data.message_msg, "Hello World"); ASSERT_EQ(data.min_index_msg, 0); ASSERT_EQ(data.max_index_msg, 10); @@ -231,11 +231,11 @@ class FileReadTest : public testing::Test if (publish_types) { - subscriber = std::make_unique(topic_name, test::DOMAIN, data); + subscriber = std::make_unique(topic_name, test::DOMAIN, data); } else { - subscriber = std::make_unique(topic_name, test::DOMAIN, data); + subscriber = std::make_unique(topic_name, test::DOMAIN, data); } // Configuration diff --git a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt index 804935112..84c4bc9cc 100644 --- a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt +++ b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt @@ -20,10 +20,10 @@ set(TEST_NAME McapFileReadTest) set(TEST_SOURCES McapFileReadTest.cpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/Configuration.hpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp + ${PROJECT_SOURCE_DIR}/test/resources/types/configuration/ConfigurationPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/test/resources/types/configuration/ConfigurationTypeObjectSupport.cxx + ${PROJECT_SOURCE_DIR}/test/resources/dds/ConfigurationSubscriber.cpp + ${PROJECT_SOURCE_DIR}/test/resources/dds/ConfigurationDynTypesSubscriber.cpp ) set(TEST_LIST @@ -64,13 +64,12 @@ add_blackbox_executable( set(TEST_NAME McapFileReadWithTypeTest) set(TEST_SOURCES - McapFileReadWithTypeTest.cpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/Configuration.hpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/ConfigurationPubSubTypes.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/configuration/ConfigurationTypeObjectSupport.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/ConfigurationSubscriber.cpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/ConfigurationDynTypesSubscriber.cpp - ) + McapFileReadWithTypeTest.cpp + ${PROJECT_SOURCE_DIR}/test/resources/types/configuration/ConfigurationPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/test/resources/types/configuration/ConfigurationTypeObjectSupport.cxx + ${PROJECT_SOURCE_DIR}/test/resources/dds/ConfigurationSubscriber.cpp + ${PROJECT_SOURCE_DIR}/test/resources/dds/ConfigurationDynTypesSubscriber.cpp +) set(TEST_LIST trivial diff --git a/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp b/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp index 8a4f189c5..f4302b4bf 100644 --- a/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp +++ b/ddsreplayer/test/blackbox/mcap/McapFileReadWithTypeTest.cpp @@ -67,7 +67,7 @@ TEST_F(McapFileReadWithTypeTest, end_time) end_time_test(input_file_type_, publish_type_); } -TEST(McapFileReadWithTypeTest, start_replay_time_earlier) +TEST_F(McapFileReadWithTypeTest, start_replay_time_earlier) { start_replay_time_earlier_test(input_file_type_, publish_type_); } diff --git a/ddsreplayer/test/resources/dds/ConfigurationDynTypesSubscriber.h b/ddsreplayer/test/resources/dds/ConfigurationDynTypesSubscriber.h index 3b8fd3219..c8f81d8cd 100644 --- a/ddsreplayer/test/resources/dds/ConfigurationDynTypesSubscriber.h +++ b/ddsreplayer/test/resources/dds/ConfigurationDynTypesSubscriber.h @@ -32,21 +32,9 @@ #include #include -#include "types/configuration/ConfigurationPubSubTypes.hpp" +#include "../types/configuration/Configuration.hpp" -<<<<<<<< HEAD:ddsreplayer/test/resources/ConfigurationDynTypesSubscriber.h -struct DataToCheck -{ - unsigned int n_received_msgs; - std::string type_msg; - int min_index_msg; - int max_index_msg; - double mean_ms_between_msgs; - double cummulated_ms_between_msgs; -}; -======== #include "DataToCheck.hpp" ->>>>>>>> 384b8b8 (Strip replaying methods from McapFileReadTest & McapFileReadWithTypeTest):ddsreplayer/test/resources/dds/HelloWorldDynTypesSubscriber.h /** * @brief Class used to group into a single working unit a Subscriber with a DataReader and its listener. diff --git a/ddsreplayer/test/resources/dds/ConfigurationSubscriber.cpp b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.cpp index f109df2af..efaf43e45 100644 --- a/ddsreplayer/test/resources/dds/ConfigurationSubscriber.cpp +++ b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.cpp @@ -31,7 +31,7 @@ #include #include -#include "types/configuration/ConfigurationPubSubTypes.hpp" +#include "../types/configuration/ConfigurationPubSubTypes.hpp" #include "ConfigurationSubscriber.h" using namespace eprosima::fastdds::dds; diff --git a/ddsreplayer/test/resources/dds/ConfigurationSubscriber.h b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.h index c3909fa68..612f598f8 100644 --- a/ddsreplayer/test/resources/dds/ConfigurationSubscriber.h +++ b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.h @@ -24,32 +24,19 @@ #include #include +<<<<<<< HEAD <<<<<<< HEAD:ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h #include "types/configuration/ConfigurationPubSubTypes.hpp" ======= <<<<<<<< HEAD:ddsreplayer/test/resources/ConfigurationSubscriber.h #include "types/configuration/ConfigurationPubSubTypes.h" >>>>>>> b00497a (Strip replaying methods from McapFileReadTest & McapFileReadWithTypeTest):ddsreplayer/test/resources/dds/ConfigurationSubscriber.h +======= +#include "../types/configuration/Configuration.hpp" +>>>>>>> 8d371bc (Rebase fix) -struct DataToCheck -{ - unsigned int n_received_msgs; - std::string type_msg; - int min_index_msg; - int max_index_msg; - double mean_ms_between_msgs; - double cummulated_ms_between_msgs; -}; -======== #include "DataToCheck.hpp" -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 - #include "../types/v1/hello_world/HelloWorldPubSubTypes.h" -#else - #include "../types/v2/hello_world/HelloWorldPubSubTypes.h" -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 ->>>>>>>> 384b8b8 (Strip replaying methods from McapFileReadTest & McapFileReadWithTypeTest):ddsreplayer/test/resources/dds/HelloWorldSubscriber.h - /** * @brief Class used to group into a single working unit a Subscriber with a DataReader and its listener. * diff --git a/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp b/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp index 56463ce3c..bfb30b08e 100644 --- a/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp +++ b/resources/dds/TypeLookupService/TypeLookupServicePublisher.cpp @@ -245,7 +245,7 @@ void TypeLookupServicePublisher::publish(unsigned int msg_index) // Print the message published std::cout << "Message published: " << std::endl; - // eprosima::fastrtps::types::DynamicDataHelper::print(dynamic_data_); + // eprosima::fastdds::dds::xtypes::DynamicDataHelper::print(dynamic_data_); std::cout << "-----------------------------------------------------" << std::endl; } diff --git a/resources/dds/TypeLookupService/TypeLookupServicePublisher.h b/resources/dds/TypeLookupService/TypeLookupServicePublisher.h index 0b2c9483e..11de415ae 100644 --- a/resources/dds/TypeLookupService/TypeLookupServicePublisher.h +++ b/resources/dds/TypeLookupService/TypeLookupServicePublisher.h @@ -108,7 +108,7 @@ class TypeLookupServicePublisher : public eprosima::fastdds::dds::DomainParticip eprosima::fastdds::dds::traits::ref_type generate_helloworld_type_() const; //! Generate the Complete DynamicType - eprosima::fastrtps::types::DynamicType_ptr generate_complete_type_() const; + eprosima::fastdds::dds::xtypes::DynamicType_ptr generate_complete_type_() const; /** * @brief Fill HelloWold message with actual data diff --git a/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp b/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp index ff29bf7a5..8fa5c094a 100644 --- a/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp +++ b/resources/dds/TypeLookupService/TypeLookupServiceSubscriber.cpp @@ -144,7 +144,7 @@ void TypeLookupServiceSubscriber::on_data_available( { // Create a new DynamicData to read the sample eprosima::fastdds::dds::DynamicData::_ref_type new_dynamic_data; - new_dynamic_data = eprosima::fastrtps::types::DynamicDataFactory::get_instance()->create_data(dynamic_type_); + new_dynamic_data = eprosima::fastdds::dds::xtypes::DynamicDataFactory::get_instance()->create_data(dynamic_type_); SampleInfo info; @@ -156,7 +156,7 @@ void TypeLookupServiceSubscriber::on_data_available( samples_++; std::cout << "Message " << samples_ << " received:\n" << std::endl; - eprosima::fastrtps::types::DynamicDataHelper::print(new_dynamic_data); + eprosima::fastdds::dds::xtypes::DynamicDataHelper::print(new_dynamic_data); std::cout << "-----------------------------------------------------" << std::endl; // Stop if all expecting messages has been received (max_messages number reached) From 350f322ae18d182fbd6452c240310c371c4f46ca Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 1 Jul 2024 11:38:15 +0200 Subject: [PATCH 44/52] Store a message's key in SQL with v3.0 Signed-off-by: tempate --- .../recorder/message/SqlMessage.hpp | 16 +- .../src/cpp/recorder/message/SqlMessage.cpp | 235 ++++++------------ 2 files changed, 90 insertions(+), 161 deletions(-) diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp index acbcb75da..be5e63ff7 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp @@ -21,6 +21,8 @@ #include #include +#include + #include #include @@ -66,7 +68,7 @@ struct SqlMessage : public BaseMessage * @param dynamic_type DynamicType of the message. */ void set_key( - fastdds::dds::DynamicType::_ref_type dynamic_type); + const fastdds::dds::DynamicType::_ref_type& dynamic_type); // Writer GUID ddspipe::core::types::Guid writer_guid; @@ -79,6 +81,18 @@ struct SqlMessage : public BaseMessage // String containing the JSON-serialized instance key std::string key; + +protected: + + /** + * @brief Remove non-key values from the JSON. + * + * @param dynamic_type DynamicType of the message. + * @param key_json JSON object containing the key values. + */ + void remove_nonkey_values( + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + nlohmann::json& key_json); }; } /* namespace participants */ diff --git a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp index 15e797e91..81be8b5c5 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp @@ -18,9 +18,18 @@ #include +#include #include +#include +#include +#include +#include +#include + +#include + #include @@ -43,167 +52,73 @@ SqlMessage::SqlMessage( } void SqlMessage::set_key( - fastdds::dds::DynamicType::_ref_type dynamic_type) + const fastdds::dds::DynamicType::_ref_type& dynamic_type) +{ + // Deserialize the payload + fastdds::dds::DynamicPubSubType pub_sub_type(dynamic_type); + auto dynamic_data = fastdds::dds::DynamicDataFactory::get_instance()->create_data(dynamic_type); + + pub_sub_type.deserialize(&payload, &dynamic_data); + + // Clear non-key values to free-up unnecessary space + dynamic_data->clear_nonkey_values(); + + // Serialize the key members into a JSON + const auto ret = fastdds::dds::json_serialize( + dynamic_data, key, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + + if (ret != fastdds::dds::RETCODE_OK) + { + logWarning(SQL_MESSAGE, "Failed to serialize key members into JSON"); + } + + nlohmann::json key_json = nlohmann::json::parse(key); + + // Remove non-key values + remove_nonkey_values(dynamic_type, key_json); + + // Serialize the JSON back into a string + key = key_json.dump(); +} + +void SqlMessage::remove_nonkey_values( + const fastdds::dds::DynamicType::_ref_type& dynamic_type, + nlohmann::json& key_json) { - // // Deserialize the payload - // fastdds::dds::xtypes::DynamicPubSubType pub_sub_type(dynamic_type); - // fastdds::dds::xtypes::DynamicData_ptr dynamic_data; - // dynamic_data = fastdds::dds::xtypes::DynamicDataFactory::get_instance()->create_data(dynamic_type); - - // pub_sub_type.deserialize(&payload, dynamic_data.get()); - - // // Clear non-key values to free-up unnecessary space - // // dynamic_data->clear_nonkey_values(); - - // // Serialize the key members into a JSON - // nlohmann::json key_json; - - // std::map members_map; - // dynamic_type->get_all_members(members_map); - - // for (const auto& member : members_map) - // { - // if (!member.second->key_annotation()) - // { - // // The member is not a key - // continue; - // } - - // const auto descriptor = member.second->get_descriptor(); - - // if (descriptor == nullptr) - // { - // // The member has no descriptor - // continue; - // } - - // switch (descriptor->get_kind()) - // { - // case fastdds::dds::xtypes::TK_BOOLEAN: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_bool_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_BYTE: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_byte_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_INT16: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_int16_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_INT32: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_int32_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_INT64: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_int64_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_UINT16: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_uint16_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_UINT32: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_uint32_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_UINT64: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_uint64_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_FLOAT32: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_float32_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_FLOAT64: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_float64_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_FLOAT128: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_float128_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_CHAR8: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_char8_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_CHAR16: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_char16_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_STRING8: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_string_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_STRING16: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_wstring_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_ALIAS: - // { - // // TODO - // break; - // } - // case fastdds::dds::xtypes::TK_ENUM: - // { - // key_json[descriptor->get_name()] = dynamic_data->get_enum_value(descriptor->get_id()); - // break; - // } - // case fastdds::dds::xtypes::TK_BITMASK: - // { - // // TODO - // break; - // } - // case fastdds::dds::xtypes::TK_ANNOTATION: - // { - // // TODO - // break; - // } - // case fastdds::dds::xtypes::TK_STRUCTURE: - // { - // // TODO - // break; - // } - // case fastdds::dds::xtypes::TK_UNION: - // { - // // TODO - // break; - // } - // case fastdds::dds::xtypes::TK_BITSET: - // { - // // TODO - // break; - // } - // case fastdds::dds::xtypes::TK_SEQUENCE: - // { - // // TODO - // break; - // } - // case fastdds::dds::xtypes::TK_ARRAY: - // { - // // TODO - // break; - // } - // } - // } - - // // Dump the JSON into a string - // key = key_json.dump(); + fastdds::dds::DynamicTypeMembersById members_by_id; + + if (dynamic_type->get_all_members(members_by_id) != fastdds::dds::RETCODE_OK) + { + logWarning(DDSRECORDER_DYNTYPES_KEY, "Failed to get all members"); + return; + } + + for (const auto& member_by_id : members_by_id) + { + const auto member = member_by_id.second; + + fastdds::dds::MemberDescriptor::_ref_type member_descriptor{ + fastdds::dds::traits::make_shared()}; + + if (member->get_descriptor(member_descriptor) != fastdds::dds::RETCODE_OK) + { + logWarning(DDSRECORDER_DYNTYPES_KEY, "Failed to get member descriptor"); + continue; + } + + const auto member_name = static_cast(member_descriptor->name()); + + if (member_descriptor->is_key()) + { + // Recursively remove non-key values from nested types + remove_nonkey_values(member_descriptor->type(), key_json[member_name]); + } + else + { + // Remove non-key value + key_json.erase(member_name); + } + } } } /* namespace participants */ From e18bb16649b4fed3fa454f46b78b0daf254c4417 Mon Sep 17 00:00:00 2001 From: tempate Date: Tue, 2 Jul 2024 09:04:09 +0200 Subject: [PATCH 45/52] Write SQL samples in bulk Signed-off-by: tempate --- .../src/cpp/recorder/sql/SqlHandler.cpp | 9 ++- .../src/cpp/recorder/sql/SqlWriter.cpp | 73 +++++++++++++------ 2 files changed, 60 insertions(+), 22 deletions(-) diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp index 705730850..78fdb1073 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp @@ -110,6 +110,10 @@ void SqlHandler::write_samples_( { logInfo(DDSRECORDER_SQL_HANDLER, "Writing samples to SQL file."); + // Samples to write in bulk + std::vector samples_to_write; + samples_to_write.reserve(samples.size()); + while (!samples.empty()) { const auto sql_sample = static_cast(samples.front().get()); @@ -135,10 +139,13 @@ void SqlHandler::write_samples_( set_key_(*const_cast(sql_sample)); } - sql_writer_.write(*sql_sample); + samples_to_write.push_back(*sql_sample); samples.pop_front(); } + + // Write the samples in bulk + sql_writer_.write(samples_to_write); } void SqlHandler::set_key_( diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index b573f305f..b9da69dea 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -16,7 +16,9 @@ * @file SqlWriter.cpp */ +#include #include +#include #include @@ -200,17 +202,17 @@ void SqlWriter::write_nts_( template <> void SqlWriter::write_nts_( - const SqlMessage& msg) + const std::vector& messages) { if (!enabled_) { - logWarning(DDSRECORDER_SQL_WRITER, "Attempting to write a message in a disabled writer."); + logWarning(DDSRECORDER_SQL_WRITER, "Attempting to write messages in a disabled writer."); return; } - logInfo(DDSRECORDER_SQL_WRITER, "Writing message: " << utils::from_bytes(msg.get_data_size()) << "."); + logInfo(DDSRECORDER_SQL_WRITER, "Writing << " << messages.size() << " messages."); - // Define the SQL statement + // Define the SQL statement for batch insert const char* insert_statement = R"( INSERT INTO Messages (writer_guid, sequence_number, data, data_size, topic, type, key, log_time, publish_time) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?); @@ -222,7 +224,7 @@ void SqlWriter::write_nts_( if (prep_ret != SQLITE_OK) { - const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement to write message: " + const std::string error_msg = utils::Formatter() << "Failed to prepare SQL statement to write messages: " << sqlite3_errmsg(database_); sqlite3_finalize(statement); @@ -230,26 +232,55 @@ void SqlWriter::write_nts_( throw utils::InconsistencyException(error_msg); } - // Bind the SqlMessage to the SQL statement - std::ostringstream writer_guid_ss; - writer_guid_ss << msg.writer_guid; + // Begin transaction + if (sqlite3_exec(database_, "BEGIN TRANSACTION;", nullptr, nullptr, nullptr) != SQLITE_OK) + { + const std::string error_msg = utils::Formatter() << "Failed to begin transaction: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); - sqlite3_bind_text(statement, 1, writer_guid_ss.str().c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_int64(statement, 2, msg.sequence_number.to64long()); - sqlite3_bind_blob(statement, 3, msg.get_data(), msg.get_data_size(), SQLITE_TRANSIENT); - sqlite3_bind_int64(statement, 4, msg.get_data_size()); - sqlite3_bind_text(statement, 5, msg.topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 6, msg.topic.type_name.c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 7, msg.key.c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 8, to_sql_timestamp(msg.log_time).c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 9, to_sql_timestamp(msg.publish_time).c_str(), -1, SQLITE_TRANSIENT); + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_WRITE | " << error_msg); + throw utils::InconsistencyException(error_msg); + } - // Execute the SQL statement - const auto step_ret = sqlite3_step(statement); + for (const auto& message : messages) + { + // Bind the SqlMessage to the SQL statement + std::ostringstream writer_guid_ss; + writer_guid_ss << message.writer_guid; + + sqlite3_bind_text(statement, 1, writer_guid_ss.str().c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_int64(statement, 2, message.sequence_number.to64long()); + sqlite3_bind_blob(statement, 3, message.get_data(), message.get_data_size(), SQLITE_TRANSIENT); + sqlite3_bind_int64(statement, 4, message.get_data_size()); + sqlite3_bind_text(statement, 5, message.topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 6, message.topic.type_name.c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 7, message.key.c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 8, to_sql_timestamp(message.log_time).c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 9, to_sql_timestamp(message.publish_time).c_str(), -1, SQLITE_TRANSIENT); + + // Execute the SQL statement + const auto step_ret = sqlite3_step(statement); + + if (step_ret != SQLITE_DONE) + { + const std::string error_msg = utils::Formatter() << "Failed to write message to SQL database: " + << sqlite3_errmsg(database_); + sqlite3_finalize(statement); + sqlite3_exec(database_, "ROLLBACK;", nullptr, nullptr, nullptr); - if (step_ret != SQLITE_DONE) + logError(DDSRECORDER_SQL_WRITER, "FAIL_SQL_WRITE | " << error_msg); + throw utils::InconsistencyException(error_msg); + } + + // Reset the statement for the next execution + sqlite3_reset(statement); + } + + // Commit transaction + if (sqlite3_exec(database_, "COMMIT;", nullptr, nullptr, nullptr) != SQLITE_OK) { - const std::string error_msg = utils::Formatter() << "Failed to write message to SQL database: " + const std::string error_msg = utils::Formatter() << "Failed to commit transaction: " << sqlite3_errmsg(database_); sqlite3_finalize(statement); From 7a45dd056ae2f8b2bfe40a062bbb9245b506780d Mon Sep 17 00:00:00 2001 From: tempate Date: Wed, 3 Jul 2024 08:20:52 +0200 Subject: [PATCH 46/52] Refactor Yaml configuration Signed-off-by: tempate --- ddsrecorder/src/cpp/tool/DdsRecorder.cpp | 139 ++++---- .../blackbox/mcap/McapFileCreationTest.cpp | 2 +- .../blackbox/mcap/McapResourceLimitsTest.cpp | 13 +- .../test/blackbox/sql/SqlFileCreationTest.cpp | 2 +- .../test/blackbox/sql/SqlLogErrorTest.cpp | 1 - .../recorder/mcap/McapHandler.hpp | 3 + .../mcap/McapHandlerConfiguration.hpp | 5 +- .../recorder/message/BaseMessage.hpp | 3 +- .../recorder/message/SqlMessage.hpp | 1 - .../output/BaseHandlerConfiguration.hpp | 5 - .../recorder/output/OutputSettings.hpp | 7 - .../recorder/sql/SqlHandlerConfiguration.hpp | 2 - .../src/cpp/recorder/mcap/McapHandler.cpp | 1 + .../src/cpp/recorder/message/BaseMessage.cpp | 13 +- .../src/cpp/recorder/message/McapMessage.cpp | 7 +- .../src/cpp/recorder/message/SqlMessage.cpp | 3 +- .../src/cpp/recorder/sql/SqlHandler.cpp | 2 +- .../recorder/YamlReaderConfiguration.hpp | 54 +++- .../recorder/yaml_configuration_tags.hpp | 76 +++-- .../src/cpp/recorder/YamlReader.cpp | 28 +- .../cpp/recorder/YamlReaderConfiguration.cpp | 296 +++++++++++------- 21 files changed, 358 insertions(+), 305 deletions(-) diff --git a/ddsrecorder/src/cpp/tool/DdsRecorder.cpp b/ddsrecorder/src/cpp/tool/DdsRecorder.cpp index b57fa24a6..92fa00358 100644 --- a/ddsrecorder/src/cpp/tool/DdsRecorder.cpp +++ b/ddsrecorder/src/cpp/tool/DdsRecorder.cpp @@ -89,35 +89,30 @@ DdsRecorder::DdsRecorder( output_settings.prepend_timestamp = false; } - switch (configuration_.output_library) - { - case participants::OutputLibrary::mcap: - output_settings.extension = ".mcap"; - break; - case participants::OutputLibrary::sql: - output_settings.extension = ".db"; - break; - default: - utils::tsnh(utils::Formatter() << "The library " << configuration_.output_library << " is not valid."); - break; - } + const auto space_available = std::filesystem::space(output_settings.filepath).available; + output_settings.max_file_size = space_available; + output_settings.max_size = space_available; - output_settings.safety_margin = configuration_.safety_margin; - output_settings.file_rotation = configuration_.output_resource_limits_file_rotation; - output_settings.max_file_size = configuration_.output_resource_limits_max_file_size; - - if (output_settings.max_file_size == 0) + // Configure the resource-limits + if (configuration_.mcap_enabled) { - output_settings.max_file_size = std::filesystem::space(output_settings.filepath).available; - } + output_settings.safety_margin = configuration_.mcap_resource_limits_safety_margin; + output_settings.file_rotation = configuration_.mcap_resource_limits_file_rotation; - output_settings.max_size = configuration_.output_resource_limits_max_size; + if (configuration_.mcap_resource_limits_max_file_size > 0) + { + output_settings.max_file_size = configuration_.mcap_resource_limits_max_file_size; + output_settings.max_size = configuration_.mcap_resource_limits_max_file_size; + } - if (output_settings.max_size == 0) - { - output_settings.max_size = output_settings.max_file_size; + if (configuration_.mcap_resource_limits_max_size > 0) + { + output_settings.max_size = configuration_.mcap_resource_limits_max_size; + } } + output_settings.extension = (configuration_.mcap_enabled) ? ".mcap" : ".db"; + if (file_tracker == nullptr) { // Create the File Tracker @@ -127,64 +122,50 @@ DdsRecorder::DdsRecorder( const auto handler_state = recorder_to_handler_state_(init_state); const auto on_disk_full_lambda = std::bind(&DdsRecorder::on_disk_full, this); - switch (configuration_.output_library) + if (configuration_.mcap_enabled) { - case participants::OutputLibrary::mcap: - { - // Create MCAP Handler configuration - participants::McapHandlerConfiguration handler_config( - output_settings, - configuration_.max_pending_samples, - configuration_.buffer_size, - configuration_.event_window, - configuration_.cleanup_period, - configuration_.log_publish_time, - configuration_.only_with_type, - configuration_.mcap_writer_options, - configuration_.record_types, - configuration_.ros2_types); - - // Create MCAP Handler - handler_ = std::make_shared( - handler_config, - payload_pool_, - file_tracker, - handler_state, - on_disk_full_lambda); - - break; - } - case participants::OutputLibrary::sql: - { - // Create SQL Handler configuration - participants::SqlHandlerConfiguration handler_config( - output_settings, - configuration_.max_pending_samples, - configuration_.buffer_size, - configuration_.event_window, - configuration_.cleanup_period, - configuration_.log_publish_time, - configuration_.only_with_type, - configuration_.record_types, - configuration_.ros2_types); - - // Create MCAP Handler - handler_ = std::make_shared( - handler_config, - payload_pool_, - file_tracker, - handler_state, - on_disk_full_lambda); - - break; - } - default: - { - utils::tsnh(utils::Formatter() << "The library " << configuration_.output_library << " is not valid."); - break; - } + // Create MCAP Handler configuration + participants::McapHandlerConfiguration handler_config( + output_settings, + configuration_.max_pending_samples, + configuration_.buffer_size, + configuration_.event_window, + configuration_.cleanup_period, + configuration_.mcap_log_publish_time, + configuration_.only_with_type, + configuration_.mcap_writer_options, + configuration_.record_types, + configuration_.ros2_types); + + // Create MCAP Handler + handler_ = std::make_shared( + handler_config, + payload_pool_, + file_tracker, + handler_state, + on_disk_full_lambda); + } + else if (configuration_.sql_enabled) + { + // Create SQL Handler configuration + participants::SqlHandlerConfiguration handler_config( + output_settings, + configuration_.max_pending_samples, + configuration_.buffer_size, + configuration_.event_window, + configuration_.cleanup_period, + configuration_.only_with_type, + configuration_.record_types, + configuration_.ros2_types); + + // Create SQL Handler + handler_ = std::make_shared( + handler_config, + payload_pool_, + file_tracker, + handler_state, + on_disk_full_lambda); } - // Create DynTypes Participant dyn_participant_ = std::make_shared( diff --git a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp index 74267f321..d0674b824 100644 --- a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp @@ -57,7 +57,7 @@ class McapFileCreationTest : public FileCreationTest FileCreationTest::SetUp(); // Set the output library to MCAP - configuration_->output_library = ddsrecorder::participants::OutputLibrary::mcap; + configuration_->mcap_enabled = true; } void TearDown() override diff --git a/ddsrecorder/test/blackbox/mcap/McapResourceLimitsTest.cpp b/ddsrecorder/test/blackbox/mcap/McapResourceLimitsTest.cpp index 720c652e3..b3d7526f1 100644 --- a/ddsrecorder/test/blackbox/mcap/McapResourceLimitsTest.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapResourceLimitsTest.cpp @@ -76,6 +76,7 @@ class McapResourceLimitsTest : public testing::Test Yaml yml; configuration_ = std::make_unique(yml); configuration_->simple_configuration->domain = test::DOMAIN; + configuration_->mcap_enabled = true; configuration_->mcap_writer_options.compression = mcap::Compression::None; configuration_->buffer_size = 1; } @@ -201,7 +202,7 @@ TEST_F(McapResourceLimitsTest, max_file_size) const std::string OUTPUT_FILE_NAME = "max_file_size_test"; const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME); - configuration_->output_resource_limits_max_file_size = test::limits::MAX_FILE_SIZE; + configuration_->mcap_resource_limits_max_file_size = test::limits::MAX_FILE_SIZE; // Delete the output file if it exists ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); @@ -243,8 +244,8 @@ TEST_F(McapResourceLimitsTest, max_size) const std::string OUTPUT_FILE_NAME = "max_size_test"; const auto OUTPUT_FILE_PATHS = get_output_file_paths_(NUMBER_OF_FILES, OUTPUT_FILE_NAME); - configuration_->output_resource_limits_max_file_size = test::limits::MAX_FILE_SIZE; - configuration_->output_resource_limits_max_size = test::limits::MAX_SIZE; + configuration_->mcap_resource_limits_max_file_size = test::limits::MAX_FILE_SIZE; + configuration_->mcap_resource_limits_max_size = test::limits::MAX_SIZE; // Delete the output files if they exist for (const auto& path : OUTPUT_FILE_PATHS) @@ -322,9 +323,9 @@ TEST_F(McapResourceLimitsTest, file_rotation) const std::string OUTPUT_FILE_NAME = "file_rotation_test"; const auto OUTPUT_FILE_PATHS = get_output_file_paths_(NUMBER_OF_FILES + 1, OUTPUT_FILE_NAME); - configuration_->output_resource_limits_max_file_size = test::limits::MAX_FILE_SIZE; - configuration_->output_resource_limits_max_size = test::limits::MAX_SIZE; - configuration_->output_resource_limits_file_rotation = true; + configuration_->mcap_resource_limits_max_file_size = test::limits::MAX_FILE_SIZE; + configuration_->mcap_resource_limits_max_size = test::limits::MAX_SIZE; + configuration_->mcap_resource_limits_file_rotation = true; // Delete the output files if they exist for (const auto& path : OUTPUT_FILE_PATHS) diff --git a/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp b/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp index 913ddb4d3..8e5cbfe74 100644 --- a/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp @@ -51,7 +51,7 @@ class SqlFileCreationTest : public FileCreationTest FileCreationTest::SetUp(); // Set the output library to SQL - configuration_->output_library = ddsrecorder::participants::OutputLibrary::sql; + configuration_->sql_enabled = true; } protected: diff --git a/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp b/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp index c5ec5c8a4..934bc81ea 100644 --- a/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp +++ b/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp @@ -62,7 +62,6 @@ TEST(SqlLogErrorTest, fail_to_open_file) { test::handler::BUFFER_SIZE, test::handler::EVENT_WINDOW, test::handler::CLEANUP_PERIOD, - test::handler::LOG_PUBLISH_TIME, test::handler::ONLY_WITH_SCHEMA, test::handler::RECORD_TYPES, test::handler::ROS2_TYPES); diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index 7c7a14599..6d95c59c2 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -189,6 +189,9 @@ class McapHandler : public BaseHandler mcap::SchemaId get_schema_id_nts_( const std::string& schema_name); + //! Configuration + const McapHandlerConfiguration configuration_; + //! MCAP writer McapWriter mcap_writer_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp index 903a54e6f..cb0957756 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandlerConfiguration.hpp @@ -49,14 +49,17 @@ struct McapHandlerConfiguration : public BaseHandlerConfiguration buffer_size, event_window, cleanup_period, - log_publishTime, only_with_schema, record_types, ros2_types) + , log_publishTime(log_publishTime) , mcap_writer_options(mcap_writer_options) { } + //! Store messages with logTime set to sample publication timestamp + bool log_publishTime; + //! Mcap writer configuration options mcap::McapWriterOptions mcap_writer_options; }; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp index 01f2af213..d6289cc55 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp @@ -52,8 +52,7 @@ struct BaseMessage BaseMessage( const ddspipe::core::types::RtpsPayloadData& data, std::shared_ptr payload_pool, - const ddspipe::core::types::DdsTopic& topic, - const bool log_publish_time); + const ddspipe::core::types::DdsTopic& topic); /** * @brief Message copy constructor diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp index be5e63ff7..f6d19c9d7 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp @@ -53,7 +53,6 @@ struct SqlMessage : public BaseMessage const ddspipe::core::types::RtpsPayloadData& payload, std::shared_ptr payload_pool, const ddspipe::core::types::DdsTopic& topic, - const bool log_publish_time, const std::string& key = ""); /** diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandlerConfiguration.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandlerConfiguration.hpp index cb457dc6b..05ed613f5 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandlerConfiguration.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/BaseHandlerConfiguration.hpp @@ -35,7 +35,6 @@ struct BaseHandlerConfiguration const unsigned int buffer_size, const unsigned int event_window, const unsigned int cleanup_period, - const bool log_publishTime, const bool only_with_schema, const bool record_types, const bool ros2_types) @@ -44,7 +43,6 @@ struct BaseHandlerConfiguration , buffer_size(buffer_size) , event_window(event_window) , cleanup_period(cleanup_period) - , log_publishTime(log_publishTime) , only_with_schema(only_with_schema) , record_types(record_types) , ros2_types(ros2_types) @@ -66,9 +64,6 @@ struct BaseHandlerConfiguration //! Remove from buffer samples older than *now - event_window* with this period [s] (applies to paused state) unsigned int cleanup_period; - //! Store messages with logTime set to sample publication timestamp - bool log_publishTime; - //! Only write messages whose schema is registered (i.e. discard pending samples when leaving RUNNING state) bool only_with_schema; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/OutputSettings.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/OutputSettings.hpp index c297e03a5..2a2005f97 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/OutputSettings.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/output/OutputSettings.hpp @@ -27,13 +27,6 @@ namespace eprosima { namespace ddsrecorder { namespace participants { -//! Supported output libraries -ENUMERATION_BUILDER( - OutputLibrary, - mcap, //! MCAP library. - sql //! SQL library. - ); - /** * Structure encapsulating all output configuration options. */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp index 1d9b4f58b..66722fbea 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp @@ -36,7 +36,6 @@ struct SqlHandlerConfiguration : public BaseHandlerConfiguration const unsigned int buffer_size, const unsigned int event_window, const unsigned int cleanup_period, - const bool log_publishTime, const bool only_with_schema, const bool record_types, const bool ros2_types) @@ -46,7 +45,6 @@ struct SqlHandlerConfiguration : public BaseHandlerConfiguration buffer_size, event_window, cleanup_period, - log_publishTime, only_with_schema, record_types, ros2_types) diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 9ea69fa5c..e41785cf1 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -45,6 +45,7 @@ McapHandler::McapHandler( const BaseHandlerStateCode& init_state /* = BaseHandlerStateCode::RUNNING */, const std::function& on_disk_full_lambda /* = nullptr */) : BaseHandler(config, payload_pool) + , configuration_(config) , mcap_writer_(config.output_settings, config.mcap_writer_options, file_tracker, config.record_types) { logInfo(DDSRECORDER_MCAP_HANDLER, diff --git a/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp index c7cbc7fea..e24c1f7fa 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp @@ -48,21 +48,12 @@ BaseMessage::BaseMessage( BaseMessage::BaseMessage( const ddspipe::core::types::RtpsPayloadData& data, std::shared_ptr payload_pool, - const ddspipe::core::types::DdsTopic& topic, - const bool log_publish_time) + const ddspipe::core::types::DdsTopic& topic) : BaseMessage(data.payload, payload_pool.get()) { this->topic = topic; + ddspipe::core::types::DataTime::now(log_time); publish_time = data.source_timestamp; - - if (log_publish_time) - { - log_time = publish_time; - } - else - { - ddspipe::core::types::DataTime::now(log_time); - } } BaseMessage::BaseMessage( diff --git a/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp index 52fe280d9..d5931481b 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp @@ -32,7 +32,7 @@ McapMessage::McapMessage( const ddspipe::core::types::DdsTopic& topic, const mcap::ChannelId channel_id, const bool log_publish_time) - : BaseMessage(data, payload_pool, topic, log_publish_time) + : BaseMessage(data, payload_pool, topic) , mcap::Message() { sequence = number_of_msgs.fetch_add(1); @@ -43,6 +43,11 @@ McapMessage::McapMessage( publishTime = to_mcap_timestamp(publish_time); logTime = to_mcap_timestamp(log_time); + + if (log_publish_time) + { + log_time = publish_time; + } } } /* namespace participants */ diff --git a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp index 81be8b5c5..fa019a95f 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp @@ -41,9 +41,8 @@ SqlMessage::SqlMessage( const ddspipe::core::types::RtpsPayloadData& data, std::shared_ptr payload_pool, const ddspipe::core::types::DdsTopic& topic, - const bool log_publish_time, const std::string& key /* = "" */) - : BaseMessage(data, payload_pool, topic, log_publish_time) + : BaseMessage(data, payload_pool, topic) , writer_guid(data.sample_identity.writer_guid()) , sequence_number(data.sample_identity.sequence_number()) , instance_handle(data.instanceHandle) diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp index 78fdb1073..41c54b713 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp @@ -102,7 +102,7 @@ void SqlHandler::add_data( std::unique_lock lock(mtx_); process_new_sample_nts_(std::make_shared( - data, payload_pool_, topic, configuration_.log_publishTime)); + data, payload_pool_, topic)); } void SqlHandler::write_samples_( diff --git a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp index a1b97f87a..ef729318a 100644 --- a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp +++ b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp @@ -18,6 +18,10 @@ #pragma once +#include +#include +#include + #include #include @@ -71,27 +75,35 @@ class DDSRECORDER_YAML_DllAPI RecorderConfiguration std::shared_ptr simple_configuration; std::shared_ptr recorder_configuration; + // Recording generic params + unsigned int buffer_size = 100; + unsigned int cleanup_period; + unsigned int event_window = 20; + int max_pending_samples = 5000; // -1 <-> no limit || 0 <-> no pending samples + bool only_with_type = false; + bool record_types = true; + bool ros2_types = false; + // Output file params - participants::OutputLibrary output_library = participants::OutputLibrary::mcap; std::string output_filepath = "."; std::string output_filename = "output"; std::string output_timestamp_format = "%Y-%m-%d_%H-%M-%S_%Z"; bool output_local_timestamp = true; - uint64_t safety_margin = 0; - // Output resource limits - bool output_resource_limits_file_rotation = false; - std::uint64_t output_resource_limits_max_size = 0; - std::uint64_t output_resource_limits_max_file_size = 0; - - // Recording params - unsigned int buffer_size = 100; - unsigned int event_window = 20; - bool log_publish_time = false; - bool only_with_type = false; + // Mcap params + bool mcap_enabled = false; + bool mcap_log_publish_time = false; mcap::McapWriterOptions mcap_writer_options{"ros2"}; - bool record_types = true; - bool ros2_types = false; + + // Mcap resource limits params + bool mcap_resource_limits_file_rotation = false; + std::uint64_t mcap_resource_limits_max_size = 0; + std::uint64_t mcap_resource_limits_max_file_size = 0; + std::uint64_t mcap_resource_limits_safety_margin = 0; + + // Sql params + bool sql_enabled = false; + bool sql_store_data_serialized = true; // Remote controller configuration bool enable_remote_controller = true; @@ -102,8 +114,6 @@ class DDSRECORDER_YAML_DllAPI RecorderConfiguration // Specs unsigned int n_threads = 12; - int max_pending_samples = 5000; // -1 <-> no limit || 0 <-> no pending samples - unsigned int cleanup_period; ddspipe::core::types::TopicQoS topic_qos{}; ddspipe::core::MonitorConfiguration monitor_configuration{}; @@ -117,6 +127,18 @@ class DDSRECORDER_YAML_DllAPI RecorderConfiguration const Yaml& yml, const ddspipe::yaml::YamlReaderVersion& version); + void load_recorder_output_configuration_( + const Yaml& yml, + const ddspipe::yaml::YamlReaderVersion& version); + + void load_recorder_mcap_configuration_( + const Yaml& yml, + const ddspipe::yaml::YamlReaderVersion& version); + + void load_recorder_sql_configuration_( + const Yaml& yml, + const ddspipe::yaml::YamlReaderVersion& version); + void load_controller_configuration_( const Yaml& yml, const ddspipe::yaml::YamlReaderVersion& version); diff --git a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp index d821e60ba..79d8eb60d 100644 --- a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp +++ b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp @@ -35,42 +35,58 @@ constexpr const char* RECORDER_DDS_TAG("dds"); /////////////////////////// constexpr const char* RECORDER_RECORDER_TAG("recorder"); +// Generic tags +constexpr const char* RECORDER_BUFFER_SIZE_TAG("buffer-size"); +constexpr const char* RECORDER_CLEANUP_PERIOD_TAG("cleanup-period"); +constexpr const char* RECORDER_EVENT_WINDOW_TAG("event-window"); +constexpr const char* RECORDER_MAX_PENDING_SAMPLES_TAG("max-pending-samples"); +constexpr const char* RECORDER_ONLY_WITH_TYPE_TAG("only-with-type"); +constexpr const char* RECORDER_RECORD_TYPES_TAG("record-types"); +constexpr const char* RECORDER_ROS2_TYPES_TAG("ros2-types"); + // Output related tags constexpr const char* RECORDER_OUTPUT_TAG("output"); -constexpr const char* RECORDER_OUTPUT_LIBRARY_TAG("library"); -constexpr const char* RECORDER_OUTPUT_LIBRARY_MCAP_TAG("mcap"); -constexpr const char* RECORDER_OUTPUT_LIBRARY_SQL_TAG("sql"); constexpr const char* RECORDER_OUTPUT_PATH_FILE_TAG("path"); constexpr const char* RECORDER_OUTPUT_FILE_NAME_TAG("filename"); constexpr const char* RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG("timestamp-format"); constexpr const char* RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG("local-timestamp"); -constexpr const char* RECORDER_OUTPUT_SAFETY_MARGIN_TAG("safety-margin"); -constexpr const char* RECORDER_OUTPUT_RESOURCE_LIMITS_TAG("resource-limits"); -constexpr const char* RECORDER_OUTPUT_RESOURCE_LIMITS_FILE_ROTATION_TAG("file-rotation"); -constexpr const char* RECORDER_OUTPUT_RESOURCE_LIMITS_MAX_SIZE_TAG("max-size"); -constexpr const char* RECORDER_OUTPUT_RESOURCE_LIMITS_MAX_FILE_SIZE_TAG("max-file-size"); -// Advanced recorder configuration options -constexpr const char* RECORDER_BUFFER_SIZE_TAG("buffer-size"); -constexpr const char* RECORDER_EVENT_WINDOW_TAG("event-window"); -constexpr const char* RECORDER_LOG_PUBLISH_TIME_TAG("log-publish-time"); -constexpr const char* RECORDER_ONLY_WITH_TYPE_TAG("only-with-type"); -constexpr const char* RECORDER_RECORD_TYPES_TAG("record-types"); -constexpr const char* RECORDER_ROS2_TYPES_TAG("ros2-types"); +/////////////// +// Mcap tags // +/////////////// + +constexpr const char* RECORDER_MCAP_TAG("mcap"); +constexpr const char* RECORDER_MCAP_ENABLE_TAG("enable"); +constexpr const char* RECORDER_MCAP_LOG_PUBLISH_TIME_TAG("log-publish-time"); // Compression settings -constexpr const char* RECORDER_COMPRESSION_SETTINGS_TAG("compression"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_ALGORITHM_TAG("algorithm"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_ALGORITHM_NONE_TAG("none"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_ALGORITHM_LZ4_TAG("lz4"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_ALGORITHM_ZSTD_TAG("zstd"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_LEVEL_TAG("level"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_LEVEL_FASTEST_TAG("fastest"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_LEVEL_FAST_TAG("fast"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_LEVEL_DEFAULT_TAG("default"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_LEVEL_SLOW_TAG("slow"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_LEVEL_SLOWEST_TAG("slowest"); -constexpr const char* RECORDER_COMPRESSION_SETTINGS_FORCE_TAG("force"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_TAG("compression"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_ALGORITHM_TAG("algorithm"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_ALGORITHM_NONE_TAG("none"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_ALGORITHM_LZ4_TAG("lz4"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_ALGORITHM_ZSTD_TAG("zstd"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_TAG("level"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_FASTEST_TAG("fastest"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_FAST_TAG("fast"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_DEFAULT_TAG("default"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_SLOW_TAG("slow"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_SLOWEST_TAG("slowest"); +constexpr const char* RECORDER_MCAP_COMPRESSION_SETTINGS_FORCE_TAG("force"); + +// Resource limits tags +constexpr const char* RECORDER_MCAP_RESOURCE_LIMITS_TAG("resource-limits"); +constexpr const char* RECORDER_MCAP_RESOURCE_LIMITS_FILE_ROTATION_TAG("file-rotation"); +constexpr const char* RECORDER_MCAP_RESOURCE_LIMITS_MAX_SIZE_TAG("max-size"); +constexpr const char* RECORDER_MCAP_RESOURCE_LIMITS_MAX_FILE_SIZE_TAG("max-file-size"); +constexpr const char* RECORDER_MCAP_RESOURCE_LIMITS_SAFETY_MARGIN_TAG("safety-margin"); + +////////////// +// SQL tags // +////////////// + +constexpr const char* RECORDER_SQL_TAG("sql"); +constexpr const char* RECORDER_SQL_ENABLE_TAG("enable"); +constexpr const char* RECORDER_SQL_STORE_DATA_SERIALIZED_TAG("store-data-serialized"); //////////////////////////////////// // Remote controller related tags // @@ -81,12 +97,6 @@ constexpr const char* RECORDER_REMOTE_CONTROLLER_INITIAL_STATE_TAG("initial-stat constexpr const char* RECORDER_REMOTE_CONTROLLER_COMMAND_TOPIC_NAME_TAG("command-topic-name"); constexpr const char* RECORDER_REMOTE_CONTROLLER_STATUS_TOPIC_NAME_TAG("status-topic-name"); -//////////////// -// Specs tags // -//////////////// -constexpr const char* RECORDER_SPECS_MAX_PENDING_SAMPLES_TAG("max-pending-samples"); -constexpr const char* RECORDER_SPECS_CLEANUP_PERIOD_TAG("cleanup-period"); - } /* namespace yaml */ } /* namespace ddsrecorder */ } /* namespace eprosima */ diff --git a/ddsrecorder_yaml/src/cpp/recorder/YamlReader.cpp b/ddsrecorder_yaml/src/cpp/recorder/YamlReader.cpp index 88c487386..017e72d99 100644 --- a/ddsrecorder_yaml/src/cpp/recorder/YamlReader.cpp +++ b/ddsrecorder_yaml/src/cpp/recorder/YamlReader.cpp @@ -33,35 +33,35 @@ YamlReader::get( mcap::McapWriterOptions mcap_writer_options{"ros2"}; // Parse optional compression algorithm - if (YamlReader::is_tag_present(yml, RECORDER_COMPRESSION_SETTINGS_ALGORITHM_TAG)) + if (YamlReader::is_tag_present(yml, RECORDER_MCAP_COMPRESSION_SETTINGS_ALGORITHM_TAG)) { - auto algorithm_yml = YamlReader::get_value_in_tag(yml, RECORDER_COMPRESSION_SETTINGS_ALGORITHM_TAG); + auto algorithm_yml = YamlReader::get_value_in_tag(yml, RECORDER_MCAP_COMPRESSION_SETTINGS_ALGORITHM_TAG); mcap_writer_options.compression = YamlReader::get_enumeration(algorithm_yml, { - {RECORDER_COMPRESSION_SETTINGS_ALGORITHM_NONE_TAG, mcap::Compression::None}, - {RECORDER_COMPRESSION_SETTINGS_ALGORITHM_LZ4_TAG, mcap::Compression::Lz4}, - {RECORDER_COMPRESSION_SETTINGS_ALGORITHM_ZSTD_TAG, mcap::Compression::Zstd}, + {RECORDER_MCAP_COMPRESSION_SETTINGS_ALGORITHM_NONE_TAG, mcap::Compression::None}, + {RECORDER_MCAP_COMPRESSION_SETTINGS_ALGORITHM_LZ4_TAG, mcap::Compression::Lz4}, + {RECORDER_MCAP_COMPRESSION_SETTINGS_ALGORITHM_ZSTD_TAG, mcap::Compression::Zstd}, }); } // Parse optional compression level - if (YamlReader::is_tag_present(yml, RECORDER_COMPRESSION_SETTINGS_LEVEL_TAG)) + if (YamlReader::is_tag_present(yml, RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_TAG)) { - auto level_yml = YamlReader::get_value_in_tag(yml, RECORDER_COMPRESSION_SETTINGS_LEVEL_TAG); + auto level_yml = YamlReader::get_value_in_tag(yml, RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_TAG); mcap_writer_options.compressionLevel = YamlReader::get_enumeration(level_yml, { - {RECORDER_COMPRESSION_SETTINGS_LEVEL_FASTEST_TAG, mcap::CompressionLevel::Fastest}, - {RECORDER_COMPRESSION_SETTINGS_LEVEL_FAST_TAG, mcap::CompressionLevel::Fast}, - {RECORDER_COMPRESSION_SETTINGS_LEVEL_DEFAULT_TAG, mcap::CompressionLevel::Default}, - {RECORDER_COMPRESSION_SETTINGS_LEVEL_SLOW_TAG, mcap::CompressionLevel::Slow}, - {RECORDER_COMPRESSION_SETTINGS_LEVEL_SLOWEST_TAG, mcap::CompressionLevel::Slowest}, + {RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_FASTEST_TAG, mcap::CompressionLevel::Fastest}, + {RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_FAST_TAG, mcap::CompressionLevel::Fast}, + {RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_DEFAULT_TAG, mcap::CompressionLevel::Default}, + {RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_SLOW_TAG, mcap::CompressionLevel::Slow}, + {RECORDER_MCAP_COMPRESSION_SETTINGS_LEVEL_SLOWEST_TAG, mcap::CompressionLevel::Slowest}, }); } // Parse optional compression force - if (YamlReader::is_tag_present(yml, RECORDER_COMPRESSION_SETTINGS_FORCE_TAG)) + if (YamlReader::is_tag_present(yml, RECORDER_MCAP_COMPRESSION_SETTINGS_FORCE_TAG)) { - mcap_writer_options.forceCompression = YamlReader::get(yml, RECORDER_COMPRESSION_SETTINGS_FORCE_TAG, + mcap_writer_options.forceCompression = YamlReader::get(yml, RECORDER_MCAP_COMPRESSION_SETTINGS_FORCE_TAG, version); } diff --git a/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp b/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp index ec5b7f604..abe3ac0fb 100644 --- a/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp +++ b/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp @@ -17,6 +17,9 @@ * */ +#include +#include + #include #include @@ -62,30 +65,42 @@ RecorderConfiguration::RecorderConfiguration( bool RecorderConfiguration::is_valid( utils::Formatter& error_msg) const noexcept { - if (output_resource_limits_max_size > 0) + if (!mcap_enabled && !sql_enabled) + { + error_msg << "At least one of MCAP or SQL libraries must be enabled."; + return false; + } + + if (mcap_enabled && sql_enabled) + { + error_msg << "Both MCAP and SQL libraries cannot be enabled at the same time."; + return false; + } + + if (mcap_resource_limits_max_size > 0) { - if (output_resource_limits_max_file_size == 0) + if (mcap_resource_limits_max_file_size == 0) { error_msg << "The max file size cannot be unlimited when the max size is limited."; return false; } - if (output_resource_limits_max_size < output_resource_limits_max_file_size) + if (mcap_resource_limits_max_size < mcap_resource_limits_max_file_size) { error_msg << "The max size cannot be lower than the max file size."; return false; } } - if (output_resource_limits_file_rotation) + if (mcap_resource_limits_file_rotation) { - if (output_resource_limits_max_file_size == 0) + if (mcap_resource_limits_max_file_size == 0) { error_msg << "The max file size cannot be unlimited when file rotation is enabled."; return false; } - if (output_resource_limits_max_size == 0) + if (mcap_resource_limits_max_size == 0) { error_msg << "The max size cannot be unlimited when file rotation is enabled."; return false; @@ -212,142 +227,199 @@ void RecorderConfiguration::load_recorder_configuration_( const Yaml& yml, const YamlReaderVersion& version) { - if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_TAG)) + ///// + // Get optional buffer size + if (YamlReader::is_tag_present(yml, RECORDER_BUFFER_SIZE_TAG)) { - auto output_yml = YamlReader::get_value_in_tag(yml, RECORDER_OUTPUT_TAG); + buffer_size = YamlReader::get_positive_int(yml, RECORDER_BUFFER_SIZE_TAG); + } - ///// - // Get optional library - if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_LIBRARY_TAG)) - { - output_library = YamlReader::get_enumeration( - YamlReader::get_value_in_tag(output_yml, RECORDER_OUTPUT_LIBRARY_TAG), - { - {RECORDER_OUTPUT_LIBRARY_MCAP_TAG, participants::OutputLibrary::mcap}, - {RECORDER_OUTPUT_LIBRARY_SQL_TAG, participants::OutputLibrary::sql} - }); - } + // Get cleanup period + if (YamlReader::is_tag_present(yml, RECORDER_CLEANUP_PERIOD_TAG)) + { + cleanup_period = YamlReader::get_positive_int(yml, RECORDER_CLEANUP_PERIOD_TAG); + } - ///// - // Get optional file path - if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_PATH_FILE_TAG)) - { - output_filepath = YamlReader::get(output_yml, RECORDER_OUTPUT_PATH_FILE_TAG, version); - } + ///// + // Get optional event window length + if (YamlReader::is_tag_present(yml, RECORDER_EVENT_WINDOW_TAG)) + { + event_window = YamlReader::get_positive_int(yml, RECORDER_EVENT_WINDOW_TAG); + } - ///// - // Get optional file name - if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_FILE_NAME_TAG)) + // Get max pending samples + if (YamlReader::is_tag_present(yml, RECORDER_MAX_PENDING_SAMPLES_TAG)) + { + max_pending_samples = YamlReader::get(yml, RECORDER_MAX_PENDING_SAMPLES_TAG, version); + if (max_pending_samples < -1) { - output_filename = YamlReader::get(output_yml, RECORDER_OUTPUT_FILE_NAME_TAG, version); + throw eprosima::utils::ConfigurationException( + utils::Formatter() << "Error reading value under tag <" << RECORDER_MAX_PENDING_SAMPLES_TAG << + "> : value cannot be lower than -1."); } + } - ///// - // Get optional timestamp format - if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG)) - { - output_timestamp_format = YamlReader::get(output_yml, RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG, - version); - } + ///// + // Get optional only_with_type + if (YamlReader::is_tag_present(yml, RECORDER_ONLY_WITH_TYPE_TAG)) + { + only_with_type = YamlReader::get(yml, RECORDER_ONLY_WITH_TYPE_TAG, version); + } - ///// - // Get optional timestamp format - if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG)) - { - output_local_timestamp = YamlReader::get(output_yml, RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG, version); - } + ///// + // Get optional record_types + if (YamlReader::is_tag_present(yml, RECORDER_RECORD_TYPES_TAG)) + { + record_types = YamlReader::get(yml, RECORDER_RECORD_TYPES_TAG, version); + } - ///// - // Get optional safety margin - if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_SAFETY_MARGIN_TAG)) - { - safety_margin = - static_cast(YamlReader::get_nonnegative_int(output_yml, - RECORDER_OUTPUT_SAFETY_MARGIN_TAG)); - } + ///// + // Get optional ros2_types + if (YamlReader::is_tag_present(yml, RECORDER_ROS2_TYPES_TAG)) + { + ros2_types = YamlReader::get(yml, RECORDER_ROS2_TYPES_TAG, version); + } - // Get optional resource limits - if (YamlReader::is_tag_present(output_yml, RECORDER_OUTPUT_RESOURCE_LIMITS_TAG)) - { - auto resource_limits_yml = YamlReader::get_value_in_tag(output_yml, RECORDER_OUTPUT_RESOURCE_LIMITS_TAG); - - ///// - // Get optional file rotation - if (YamlReader::is_tag_present(resource_limits_yml, RECORDER_OUTPUT_RESOURCE_LIMITS_FILE_ROTATION_TAG)) - { - output_resource_limits_file_rotation = YamlReader::get(resource_limits_yml, - RECORDER_OUTPUT_RESOURCE_LIMITS_FILE_ROTATION_TAG, version); - } - - ///// - // Get optional max file size - if (YamlReader::is_tag_present(resource_limits_yml, RECORDER_OUTPUT_RESOURCE_LIMITS_MAX_FILE_SIZE_TAG)) - { - const auto& max_file_size = YamlReader::get(resource_limits_yml, - RECORDER_OUTPUT_RESOURCE_LIMITS_MAX_FILE_SIZE_TAG, - version); - output_resource_limits_max_file_size = eprosima::utils::to_bytes(max_file_size); - } - - ///// - // Get optional max size - if (YamlReader::is_tag_present(resource_limits_yml, RECORDER_OUTPUT_RESOURCE_LIMITS_MAX_SIZE_TAG)) - { - const auto& max_size = YamlReader::get(resource_limits_yml, - RECORDER_OUTPUT_RESOURCE_LIMITS_MAX_SIZE_TAG, - version); - output_resource_limits_max_size = eprosima::utils::to_bytes(max_size); - } - } + ///// + // Get optional output configuration + if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_TAG)) + { + const auto output_yml = YamlReader::get_value_in_tag(yml, RECORDER_OUTPUT_TAG); + load_recorder_output_configuration_(output_yml, version); } ///// - // Get optional buffer size - if (YamlReader::is_tag_present(yml, RECORDER_BUFFER_SIZE_TAG)) + // Get optional mcap configuration + if (YamlReader::is_tag_present(yml, RECORDER_MCAP_TAG)) { - buffer_size = YamlReader::get_positive_int(yml, RECORDER_BUFFER_SIZE_TAG); + const auto mcap_yml = YamlReader::get_value_in_tag(yml, RECORDER_MCAP_TAG); + load_recorder_mcap_configuration_(mcap_yml, version); } ///// - // Get optional event window length - if (YamlReader::is_tag_present(yml, RECORDER_EVENT_WINDOW_TAG)) + // Get optional sql configuration + if (YamlReader::is_tag_present(yml, RECORDER_SQL_TAG)) { - event_window = YamlReader::get_positive_int(yml, RECORDER_EVENT_WINDOW_TAG); + const auto sql_yml = YamlReader::get_value_in_tag(yml, RECORDER_SQL_TAG); + load_recorder_sql_configuration_(sql_yml, version); } +} +void RecorderConfiguration::load_recorder_output_configuration_( + const Yaml& yml, + const YamlReaderVersion& version) +{ ///// - // Get optional log publishTime - if (YamlReader::is_tag_present(yml, RECORDER_LOG_PUBLISH_TIME_TAG)) + // Get optional file path + if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_PATH_FILE_TAG)) { - log_publish_time = YamlReader::get(yml, RECORDER_LOG_PUBLISH_TIME_TAG, version); + output_filepath = YamlReader::get(yml, RECORDER_OUTPUT_PATH_FILE_TAG, version); } ///// - // Get optional only_with_type - if (YamlReader::is_tag_present(yml, RECORDER_ONLY_WITH_TYPE_TAG)) + // Get optional file name + if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_FILE_NAME_TAG)) { - only_with_type = YamlReader::get(yml, RECORDER_ONLY_WITH_TYPE_TAG, version); + output_filename = YamlReader::get(yml, RECORDER_OUTPUT_FILE_NAME_TAG, version); + } + + ///// + // Get optional timestamp format + if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG)) + { + output_timestamp_format = YamlReader::get(yml, RECORDER_OUTPUT_TIMESTAMP_FORMAT_TAG, + version); + } + + ///// + // Get optional timestamp format + if (YamlReader::is_tag_present(yml, RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG)) + { + output_local_timestamp = YamlReader::get(yml, RECORDER_OUTPUT_LOCAL_TIMESTAMP_TAG, version); + } +} + +void RecorderConfiguration::load_recorder_mcap_configuration_( + const Yaml& yml, + const YamlReaderVersion& version) +{ + ///// + // Get mandatory enable + mcap_enabled = YamlReader::get(yml, RECORDER_MCAP_ENABLE_TAG, version); + + ///// + // Get optional log publishTime + if (YamlReader::is_tag_present(yml, RECORDER_MCAP_LOG_PUBLISH_TIME_TAG)) + { + mcap_log_publish_time = YamlReader::get(yml, RECORDER_MCAP_LOG_PUBLISH_TIME_TAG, version); } ///// // Get optional compression settings - if (YamlReader::is_tag_present(yml, RECORDER_COMPRESSION_SETTINGS_TAG)) + if (YamlReader::is_tag_present(yml, RECORDER_MCAP_COMPRESSION_SETTINGS_TAG)) { - mcap_writer_options = YamlReader::get(yml, RECORDER_COMPRESSION_SETTINGS_TAG, version); + mcap_writer_options = YamlReader::get(yml, RECORDER_MCAP_COMPRESSION_SETTINGS_TAG, version); } ///// - // Get optional record_types - if (YamlReader::is_tag_present(yml, RECORDER_RECORD_TYPES_TAG)) + // Get optional resource limits + if (YamlReader::is_tag_present(yml, RECORDER_MCAP_RESOURCE_LIMITS_TAG)) { - record_types = YamlReader::get(yml, RECORDER_RECORD_TYPES_TAG, version); + auto resource_limits_yml = YamlReader::get_value_in_tag(yml, RECORDER_MCAP_RESOURCE_LIMITS_TAG); + + ///// + // Get optional file rotation + if (YamlReader::is_tag_present(resource_limits_yml, RECORDER_MCAP_RESOURCE_LIMITS_FILE_ROTATION_TAG)) + { + mcap_resource_limits_file_rotation = YamlReader::get(resource_limits_yml, + RECORDER_MCAP_RESOURCE_LIMITS_FILE_ROTATION_TAG, version); + } + + ///// + // Get optional max file size + if (YamlReader::is_tag_present(resource_limits_yml, RECORDER_MCAP_RESOURCE_LIMITS_MAX_FILE_SIZE_TAG)) + { + const auto& max_file_size = YamlReader::get(resource_limits_yml, + RECORDER_MCAP_RESOURCE_LIMITS_MAX_FILE_SIZE_TAG, + version); + mcap_resource_limits_max_file_size = eprosima::utils::to_bytes(max_file_size); + } + + ///// + // Get optional max size + if (YamlReader::is_tag_present(resource_limits_yml, RECORDER_MCAP_RESOURCE_LIMITS_MAX_SIZE_TAG)) + { + const auto& max_size = YamlReader::get(resource_limits_yml, + RECORDER_MCAP_RESOURCE_LIMITS_MAX_SIZE_TAG, + version); + mcap_resource_limits_max_size = eprosima::utils::to_bytes(max_size); + } + + ///// + // Get optional safety margin + if (YamlReader::is_tag_present(resource_limits_yml, RECORDER_MCAP_RESOURCE_LIMITS_SAFETY_MARGIN_TAG)) + { + const auto& safety_margin = YamlReader::get(resource_limits_yml, + RECORDER_MCAP_RESOURCE_LIMITS_SAFETY_MARGIN_TAG, + version); + mcap_resource_limits_safety_margin = eprosima::utils::to_bytes(safety_margin); + } } +} +void RecorderConfiguration::load_recorder_sql_configuration_( + const Yaml& yml, + const YamlReaderVersion& version) +{ ///// - // Get optional ros2_types - if (YamlReader::is_tag_present(yml, RECORDER_ROS2_TYPES_TAG)) + // Get mandatory enable + sql_enabled = YamlReader::get(yml, RECORDER_SQL_ENABLE_TAG, version); + + ///// + // Get optional log publishTime + if (YamlReader::is_tag_present(yml, RECORDER_SQL_STORE_DATA_SERIALIZED_TAG)) { - ros2_types = YamlReader::get(yml, RECORDER_ROS2_TYPES_TAG, version); + sql_store_data_serialized = YamlReader::get(yml, RECORDER_SQL_STORE_DATA_SERIALIZED_TAG, version); } } @@ -411,24 +483,6 @@ void RecorderConfiguration::load_specs_configuration_( TopicQoS::default_topic_qos.set_value(topic_qos); } - // Get max pending samples - if (YamlReader::is_tag_present(yml, RECORDER_SPECS_MAX_PENDING_SAMPLES_TAG)) - { - max_pending_samples = YamlReader::get(yml, RECORDER_SPECS_MAX_PENDING_SAMPLES_TAG, version); - if (max_pending_samples < -1) - { - throw eprosima::utils::ConfigurationException( - utils::Formatter() << "Error reading value under tag <" << RECORDER_SPECS_MAX_PENDING_SAMPLES_TAG << - "> : value cannot be lower than -1."); - } - } - - // Get cleanup period - if (YamlReader::is_tag_present(yml, RECORDER_SPECS_CLEANUP_PERIOD_TAG)) - { - cleanup_period = YamlReader::get_positive_int(yml, RECORDER_SPECS_CLEANUP_PERIOD_TAG); - } - ///// // Get optional Log Configuration if (YamlReader::is_tag_present(yml, LOG_CONFIGURATION_TAG)) From 7630fb5a98195f53ec328d56fc8f624092f4897d Mon Sep 17 00:00:00 2001 From: tempate Date: Wed, 3 Jul 2024 08:31:05 +0200 Subject: [PATCH 47/52] Fix the check when setting the current file size Signed-off-by: tempate --- .../src/cpp/recorder/output/FileTracker.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ddsrecorder_participants/src/cpp/recorder/output/FileTracker.cpp b/ddsrecorder_participants/src/cpp/recorder/output/FileTracker.cpp index 43edaca01..1f2bdd97a 100644 --- a/ddsrecorder_participants/src/cpp/recorder/output/FileTracker.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/output/FileTracker.cpp @@ -169,14 +169,16 @@ void FileTracker::set_current_file_size( utils::from_bytes(configuration_.max_file_size) << ")."); } - const auto size_diff = file_size - current_file_.size; + // If there's an overflow, the new size is too big + const auto new_size = size_ + file_size; - if (size_ + size_diff > configuration_.max_size) + if (new_size > configuration_.max_size || new_size < size_) { logWarning(DDSRECORDER_FILE_TRACKER, "The aggregate output size (" << + utils::from_bytes(size_) << ") plus the new file size (" << utils::from_bytes(file_size) << ") is greater than the maximum size (" << - utils::from_bytes(configuration_.max_file_size) << ")."); + utils::from_bytes(configuration_.max_size) << ")."); } current_file_.size = file_size; From 8ab4f8bd5143fce7873cd5f570c9051b6b8ec591 Mon Sep 17 00:00:00 2001 From: tempate Date: Thu, 4 Jul 2024 09:39:34 +0200 Subject: [PATCH 48/52] Save data in CDR & JSON format Signed-off-by: tempate --- ddsrecorder/src/cpp/tool/DdsRecorder.cpp | 3 +- .../test/blackbox/FileCreationTest.hpp | 2 +- ddsrecorder/test/blackbox/constants.hpp | 2 + .../test/blackbox/sql/SqlFileCreationTest.cpp | 6 +-- .../test/blackbox/sql/SqlLogErrorTest.cpp | 3 +- .../recorder/message/BaseMessage.hpp | 4 +- .../recorder/message/SqlMessage.hpp | 16 +++++- .../recorder/sql/SqlHandler.hpp | 3 ++ .../recorder/sql/SqlHandlerConfiguration.hpp | 16 +++++- .../recorder/sql/SqlWriter.hpp | 7 ++- .../src/cpp/recorder/message/BaseMessage.cpp | 4 +- .../src/cpp/recorder/message/McapMessage.cpp | 4 +- .../src/cpp/recorder/message/SqlMessage.cpp | 34 ++++++++---- .../src/cpp/recorder/sql/SqlHandler.cpp | 24 +++++++-- .../src/cpp/recorder/sql/SqlWriter.cpp | 52 ++++++++++++++----- .../src/cpp/replayer/SqlReaderParticipant.cpp | 4 +- .../recorder/YamlReaderConfiguration.hpp | 3 +- .../recorder/yaml_configuration_tags.hpp | 5 +- .../cpp/recorder/YamlReaderConfiguration.cpp | 13 +++-- 19 files changed, 156 insertions(+), 49 deletions(-) diff --git a/ddsrecorder/src/cpp/tool/DdsRecorder.cpp b/ddsrecorder/src/cpp/tool/DdsRecorder.cpp index 92fa00358..0ce7c1661 100644 --- a/ddsrecorder/src/cpp/tool/DdsRecorder.cpp +++ b/ddsrecorder/src/cpp/tool/DdsRecorder.cpp @@ -156,7 +156,8 @@ DdsRecorder::DdsRecorder( configuration_.cleanup_period, configuration_.only_with_type, configuration_.record_types, - configuration_.ros2_types); + configuration_.ros2_types, + configuration_.sql_data_format); // Create SQL Handler handler_ = std::make_shared( diff --git a/ddsrecorder/test/blackbox/FileCreationTest.hpp b/ddsrecorder/test/blackbox/FileCreationTest.hpp index 6c1d62517..028ac1945 100644 --- a/ddsrecorder/test/blackbox/FileCreationTest.hpp +++ b/ddsrecorder/test/blackbox/FileCreationTest.hpp @@ -215,7 +215,7 @@ class FileCreationTest : public testing::Test sent_messages.push_back(payload); // Wait for the message to be sent - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + std::this_thread::sleep_for(std::chrono::milliseconds(10)); } // Delete the DataWriter diff --git a/ddsrecorder/test/blackbox/constants.hpp b/ddsrecorder/test/blackbox/constants.hpp index 2480da52a..b3ec807c4 100644 --- a/ddsrecorder/test/blackbox/constants.hpp +++ b/ddsrecorder/test/blackbox/constants.hpp @@ -26,6 +26,7 @@ #include #include +#include namespace test { @@ -53,6 +54,7 @@ constexpr auto LOG_PUBLISH_TIME = false; constexpr auto ONLY_WITH_SCHEMA = false; constexpr auto RECORD_TYPES = false; constexpr auto ROS2_TYPES = false; +constexpr auto DATA_FORMAT = ddsrecorder::participants::DataFormat::both; } diff --git a/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp b/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp index 8e5cbfe74..476531aed 100644 --- a/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp @@ -135,8 +135,8 @@ class SqlFileCreationTest : public FileCreationTest * Verify that the DDS Recorder records properly in an SQL file. * * CASES: - * - Verify that the messages' sizes match the recorded data sizes. - * - Verify that the messages' data matches the recorded data. + * - Verify that the messages' data_cdr_size match the recorded data_cdr sizes. + * - Verify that the messages' data_cdr matches the recorded data_cdr. */ TEST_F(SqlFileCreationTest, sql_data_msgs) { @@ -157,7 +157,7 @@ TEST_F(SqlFileCreationTest, sql_data_msgs) // Read the recorded messages exec_sql_statement_( OUTPUT_FILE_PATH.string(), - "SELECT data, data_size FROM Messages ORDER BY log_time;", {}, [&](sqlite3_stmt* stmt) + "SELECT data_cdr, data_cdr_size FROM Messages ORDER BY log_time;", {}, [&](sqlite3_stmt* stmt) { read_message_count++; diff --git a/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp b/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp index 934bc81ea..4274d0935 100644 --- a/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp +++ b/ddsrecorder/test/blackbox/sql/SqlLogErrorTest.cpp @@ -64,7 +64,8 @@ TEST(SqlLogErrorTest, fail_to_open_file) { test::handler::CLEANUP_PERIOD, test::handler::ONLY_WITH_SCHEMA, test::handler::RECORD_TYPES, - test::handler::ROS2_TYPES); + test::handler::ROS2_TYPES, + test::handler::DATA_FORMAT); std::shared_ptr payload_pool; const auto init_state = ddsrecorder::participants::BaseHandlerStateCode::RUNNING; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp index d6289cc55..e1e1653a5 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/BaseMessage.hpp @@ -78,12 +78,12 @@ struct BaseMessage /** * @brief Get the message's payload data */ - std::byte* get_data() const; + std::byte* get_data_cdr() const; /** * @brief Get the message's payload size */ - std::uint32_t get_data_size() const; + std::uint32_t get_data_cdr_size() const; //! Serialized payload fastdds::rtps::SerializedPayload_t payload{}; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp index f6d19c9d7..cd2088b82 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/message/SqlMessage.hpp @@ -55,6 +55,17 @@ struct SqlMessage : public BaseMessage const ddspipe::core::types::DdsTopic& topic, const std::string& key = ""); + /** + * @brief Deserialize the payload's data into a JSON object. + * + * The following steps are performed: + * - Deserialize the payload data into a DynamicData. + * - Serialize the DynamicData into a JSON object. + * - Store the JSON object in the payload's data attribute. + */ + void deserialize( + const fastdds::dds::DynamicType::_ref_type& dynamic_type); + /** * @brief Set the key of the message. * @@ -78,6 +89,9 @@ struct SqlMessage : public BaseMessage // Hashed value identifying the instance ddspipe::core::types::InstanceHandle instance_handle; + // String containing the JSON-serialized payload + std::string data_json; + // String containing the JSON-serialized instance key std::string key; @@ -89,7 +103,7 @@ struct SqlMessage : public BaseMessage * @param dynamic_type DynamicType of the message. * @param key_json JSON object containing the key values. */ - void remove_nonkey_values( + void remove_nonkey_values_( const fastdds::dds::DynamicType::_ref_type& dynamic_type, nlohmann::json& key_json); }; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp index 2cc594be7..6ffaf8a6d 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandler.hpp @@ -147,6 +147,9 @@ class SqlHandler : public BaseHandler void set_key_( SqlMessage& sql_sample); + //! Configuration + const SqlHandlerConfiguration configuration_; + //! SQL writer SqlWriter sql_writer_; diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp index 66722fbea..969ddad54 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlHandlerConfiguration.hpp @@ -18,6 +18,8 @@ #pragma once +#include + #include #include @@ -25,6 +27,13 @@ namespace eprosima { namespace ddsrecorder { namespace participants { +ENUMERATION_BUILDER( + DataFormat, + cdr, + json, + both + ); + /** * Structure encapsulating the \c SqlHandler configuration options. */ @@ -38,7 +47,8 @@ struct SqlHandlerConfiguration : public BaseHandlerConfiguration const unsigned int cleanup_period, const bool only_with_schema, const bool record_types, - const bool ros2_types) + const bool ros2_types, + const DataFormat data_format) : BaseHandlerConfiguration( output_settings, max_pending_samples, @@ -48,8 +58,12 @@ struct SqlHandlerConfiguration : public BaseHandlerConfiguration only_with_schema, record_types, ros2_types) + , data_format(data_format) { } + + //! Whether to store data in cdr, in json, or in both. + DataFormat data_format; }; } /* namespace participants */ diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp index e386d3bb5..c51426301 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/sql/SqlWriter.hpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace eprosima { namespace ddsrecorder { @@ -39,7 +40,8 @@ class DDSRECORDER_PARTICIPANTS_DllAPI SqlWriter : public BaseWriter const OutputSettings& configuration, std::shared_ptr& file_tracker, const bool record_types = true, - const bool ros2_types = false); + const bool ros2_types = false, + const DataFormat data_format = DataFormat::both); /** * @brief Writes data to the output file. @@ -119,6 +121,9 @@ class DDSRECORDER_PARTICIPANTS_DllAPI SqlWriter : public BaseWriter // Whether to format types for ROS 2 const bool ros2_types_; + // Whether to record the data in cdr, in json, or in both formats + const DataFormat data_format_; + // The size of an empty SQL file static constexpr std::uint64_t MIN_SQL_SIZE{20480}; }; diff --git a/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp index e24c1f7fa..de75fae5e 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/BaseMessage.cpp @@ -74,12 +74,12 @@ BaseMessage::~BaseMessage() } } -std::byte* BaseMessage::get_data() const +std::byte* BaseMessage::get_data_cdr() const { return reinterpret_cast(payload.data); } -std::uint32_t BaseMessage::get_data_size() const +std::uint32_t BaseMessage::get_data_cdr_size() const { return payload.length; } diff --git a/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp index d5931481b..77f35bb9b 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/McapMessage.cpp @@ -38,8 +38,8 @@ McapMessage::McapMessage( sequence = number_of_msgs.fetch_add(1); channelId = channel_id; - this->data = get_data(); - dataSize = get_data_size(); + this->data = get_data_cdr(); + dataSize = get_data_cdr_size(); publishTime = to_mcap_timestamp(publish_time); logTime = to_mcap_timestamp(log_time); diff --git a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp index fa019a95f..980224b24 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp @@ -50,37 +50,49 @@ SqlMessage::SqlMessage( { } -void SqlMessage::set_key( +void SqlMessage::deserialize( const fastdds::dds::DynamicType::_ref_type& dynamic_type) { + if (!data_json.empty()) + { + // The payload has already been deserialized + return; + } + // Deserialize the payload fastdds::dds::DynamicPubSubType pub_sub_type(dynamic_type); auto dynamic_data = fastdds::dds::DynamicDataFactory::get_instance()->create_data(dynamic_type); pub_sub_type.deserialize(&payload, &dynamic_data); - // Clear non-key values to free-up unnecessary space - dynamic_data->clear_nonkey_values(); - - // Serialize the key members into a JSON + // Serialize the payload into a JSON const auto ret = fastdds::dds::json_serialize( - dynamic_data, key, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + dynamic_data, data_json, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); if (ret != fastdds::dds::RETCODE_OK) { - logWarning(SQL_MESSAGE, "Failed to serialize key members into JSON"); + logWarning(SQL_MESSAGE, "Failed to serialize payload into JSON"); + } +} + +void SqlMessage::set_key( + const fastdds::dds::DynamicType::_ref_type& dynamic_type) +{ + if (data_json.empty()) + { + deserialize(dynamic_type); } - nlohmann::json key_json = nlohmann::json::parse(key); + nlohmann::json key_json = nlohmann::json::parse(data_json); // Remove non-key values - remove_nonkey_values(dynamic_type, key_json); + remove_nonkey_values_(dynamic_type, key_json); // Serialize the JSON back into a string key = key_json.dump(); } -void SqlMessage::remove_nonkey_values( +void SqlMessage::remove_nonkey_values_( const fastdds::dds::DynamicType::_ref_type& dynamic_type, nlohmann::json& key_json) { @@ -110,7 +122,7 @@ void SqlMessage::remove_nonkey_values( if (member_descriptor->is_key()) { // Recursively remove non-key values from nested types - remove_nonkey_values(member_descriptor->type(), key_json[member_name]); + remove_nonkey_values_(member_descriptor->type(), key_json[member_name]); } else { diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp index 41c54b713..d32d9d1e1 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlHandler.cpp @@ -35,7 +35,8 @@ SqlHandler::SqlHandler( const BaseHandlerStateCode& init_state /* = BaseHandlerStateCode::RUNNING */, const std::function& on_disk_full_lambda /* = nullptr */) : BaseHandler(config, payload_pool) - , sql_writer_(config.output_settings, file_tracker, config.record_types, config.ros2_types) + , configuration_(config) + , sql_writer_(config.output_settings, file_tracker, config.record_types, config.ros2_types, config.data_format) { logInfo(DDSRECORDER_SQL_HANDLER, "Creating SQL handler instance."); @@ -116,7 +117,7 @@ void SqlHandler::write_samples_( while (!samples.empty()) { - const auto sql_sample = static_cast(samples.front().get()); + auto sql_sample = static_cast(const_cast(samples.front().get())); if (sql_sample == nullptr) { @@ -133,10 +134,25 @@ void SqlHandler::write_samples_( written_topics_.insert(topic); } - // Write the sample + if (configuration_.data_format == DataFormat::json || configuration_.data_format == DataFormat::both) + { + if (received_types_.find(sql_sample->topic.type_name) == received_types_.end()) + { + logWarning(DDSRECORDER_SQL_HANDLER, + "Message on topic " << sql_sample->topic.m_topic_name << + " with type " << sql_sample->topic.type_name << + " cannot be formatted to JSON since the type has not been received."); + } + else + { + // Deserialize the payload + sql_sample->deserialize(received_types_[sql_sample->topic.type_name]); + } + } + if (sql_sample->key.empty()) { - set_key_(*const_cast(sql_sample)); + set_key_(*sql_sample); } samples_to_write.push_back(*sql_sample); diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index b9da69dea..364bb2ed8 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -50,9 +51,11 @@ SqlWriter::SqlWriter( const OutputSettings& configuration, std::shared_ptr& file_tracker, const bool record_types, - const bool ros2_types) + const bool ros2_types, + const DataFormat data_format) : BaseWriter(configuration, file_tracker, record_types, MIN_SQL_SIZE) , ros2_types_(ros2_types) + , data_format_(data_format) { } @@ -127,8 +130,9 @@ void SqlWriter::open_new_file_nts_( CREATE TABLE IF NOT EXISTS Messages ( writer_guid TEXT NOT NULL, sequence_number INTEGER NOT NULL, - data BLOB NOT NULL, - data_size INTEGER NOT NULL, + data_json TEXT, + data_cdr BLOB, + data_cdr_size INTEGER, topic TEXT NOT NULL, type TEXT NOT NULL, key TEXT NOT NULL, @@ -214,8 +218,8 @@ void SqlWriter::write_nts_( // Define the SQL statement for batch insert const char* insert_statement = R"( - INSERT INTO Messages (writer_guid, sequence_number, data, data_size, topic, type, key, log_time, publish_time) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?); + INSERT INTO Messages (writer_guid, sequence_number, data_json, data_cdr, data_cdr_size, topic, type, key, log_time, publish_time) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?); )"; // Prepare the SQL statement @@ -246,18 +250,42 @@ void SqlWriter::write_nts_( for (const auto& message : messages) { // Bind the SqlMessage to the SQL statement + + // Bind the sample identity std::ostringstream writer_guid_ss; writer_guid_ss << message.writer_guid; sqlite3_bind_text(statement, 1, writer_guid_ss.str().c_str(), -1, SQLITE_TRANSIENT); sqlite3_bind_int64(statement, 2, message.sequence_number.to64long()); - sqlite3_bind_blob(statement, 3, message.get_data(), message.get_data_size(), SQLITE_TRANSIENT); - sqlite3_bind_int64(statement, 4, message.get_data_size()); - sqlite3_bind_text(statement, 5, message.topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 6, message.topic.type_name.c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 7, message.key.c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 8, to_sql_timestamp(message.log_time).c_str(), -1, SQLITE_TRANSIENT); - sqlite3_bind_text(statement, 9, to_sql_timestamp(message.publish_time).c_str(), -1, SQLITE_TRANSIENT); + + // Bind the sample data + std::string data_json = ""; + std::byte* data_cdr = new std::byte{0}; + std::uint32_t data_cdr_size = 0; + + if (data_format_ == DataFormat::both || data_format_ == DataFormat::json) + { + data_json = message.data_json; + } + + if (data_format_ == DataFormat::both || data_format_ == DataFormat::cdr) + { + data_cdr = message.get_data_cdr(); + data_cdr_size = message.get_data_cdr_size(); + } + + sqlite3_bind_text(statement, 3, data_json.c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_blob(statement, 4, data_cdr, data_cdr_size, SQLITE_TRANSIENT); + sqlite3_bind_int64(statement, 5, data_cdr_size); + + // Bind the topic data + sqlite3_bind_text(statement, 6, message.topic.topic_name().c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 7, message.topic.type_name.c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 8, message.key.c_str(), -1, SQLITE_TRANSIENT); + + // Bind the time data + sqlite3_bind_text(statement, 9, to_sql_timestamp(message.log_time).c_str(), -1, SQLITE_TRANSIENT); + sqlite3_bind_text(statement, 10, to_sql_timestamp(message.publish_time).c_str(), -1, SQLITE_TRANSIENT); // Execute the SQL statement const auto step_ret = sqlite3_step(statement); diff --git a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp index dc7dde383..62e80856b 100644 --- a/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp +++ b/ddsrecorder_participants/src/cpp/replayer/SqlReaderParticipant.cpp @@ -129,8 +129,8 @@ void SqlReaderParticipant::process_messages() utils::the_end_of_time()); exec_sql_statement_( - "SELECT log_time, topic, type, data, data_size FROM Messages " - "WHERE log_time >= ? AND log_time <= ? " + "SELECT log_time, topic, type, data_cdr, data_cdr_size FROM Messages " + "WHERE log_time >= ? AND log_time <= ? AND data_cdr_size > 0 " "ORDER BY log_time;", {begin_time, end_time}, [&](sqlite3_stmt* stmt) diff --git a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp index ef729318a..37cc5db6b 100644 --- a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp +++ b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/YamlReaderConfiguration.hpp @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -103,7 +104,7 @@ class DDSRECORDER_YAML_DllAPI RecorderConfiguration // Sql params bool sql_enabled = false; - bool sql_store_data_serialized = true; + ddsrecorder::participants::DataFormat sql_data_format = ddsrecorder::participants::DataFormat::both; // Remote controller configuration bool enable_remote_controller = true; diff --git a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp index 79d8eb60d..7a1293cbb 100644 --- a/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp +++ b/ddsrecorder_yaml/include/ddsrecorder_yaml/recorder/yaml_configuration_tags.hpp @@ -86,7 +86,10 @@ constexpr const char* RECORDER_MCAP_RESOURCE_LIMITS_SAFETY_MARGIN_TAG("safety-ma constexpr const char* RECORDER_SQL_TAG("sql"); constexpr const char* RECORDER_SQL_ENABLE_TAG("enable"); -constexpr const char* RECORDER_SQL_STORE_DATA_SERIALIZED_TAG("store-data-serialized"); +constexpr const char* RECORDER_SQL_DATA_FORMAT_TAG("data-format"); +constexpr const char* RECORDER_SQL_DATA_FORMAT_CDR_TAG("cdr"); +constexpr const char* RECORDER_SQL_DATA_FORMAT_JSON_TAG("json"); +constexpr const char* RECORDER_SQL_DATA_FORMAT_BOTH_TAG("both"); //////////////////////////////////// // Remote controller related tags // diff --git a/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp b/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp index abe3ac0fb..a925b7a07 100644 --- a/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp +++ b/ddsrecorder_yaml/src/cpp/recorder/YamlReaderConfiguration.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -417,9 +418,15 @@ void RecorderConfiguration::load_recorder_sql_configuration_( ///// // Get optional log publishTime - if (YamlReader::is_tag_present(yml, RECORDER_SQL_STORE_DATA_SERIALIZED_TAG)) - { - sql_store_data_serialized = YamlReader::get(yml, RECORDER_SQL_STORE_DATA_SERIALIZED_TAG, version); + if (YamlReader::is_tag_present(yml, RECORDER_SQL_DATA_FORMAT_TAG)) + { + const auto data_format_yml = YamlReader::get_value_in_tag(yml, RECORDER_SQL_DATA_FORMAT_TAG); + sql_data_format = YamlReader::get_enumeration(data_format_yml, + { + {RECORDER_SQL_DATA_FORMAT_CDR_TAG, ddsrecorder::participants::DataFormat::cdr}, + {RECORDER_SQL_DATA_FORMAT_JSON_TAG, ddsrecorder::participants::DataFormat::json}, + {RECORDER_SQL_DATA_FORMAT_BOTH_TAG, ddsrecorder::participants::DataFormat::both} + }); } } From b6ae665995133d60ed60fd07de7830d675e89be3 Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 8 Jul 2024 12:15:28 +0200 Subject: [PATCH 49/52] Refactor documentation Signed-off-by: tempate --- docs/rst/recording/usage/configuration.rst | 238 ++++++++++++--------- 1 file changed, 131 insertions(+), 107 deletions(-) diff --git a/docs/rst/recording/usage/configuration.rst b/docs/rst/recording/usage/configuration.rst index d2eefdfee..554e2c573 100644 --- a/docs/rst/recording/usage/configuration.rst +++ b/docs/rst/recording/usage/configuration.rst @@ -332,58 +332,10 @@ The recorder output file does support the following configuration settings under - ``boolean`` - ``true`` - * - Safety margin - - ``safety_margin`` - - Configure safety margin (bytes) used |br| - in MCAP file size estimations. - - ``unsigned int`` - - ``0`` - - * - Resource limits - - ``resource-limits`` - - :ref:`recorder_usage_configuration_resource_limits` - - ``map`` - - ``unlimited`` - When DDS Recorder application is launched (or when remotely controlled, every time a ``start/pause`` command is received while in ``SUSPENDED/STOPPED`` state), a temporary file with ``filename`` name (+timestamp prefix) and ``.mcap.tmp~`` extension is created in ``path``. This file is not readable until the application terminates, receives a ``suspend/stop/close`` command, or the file reaches its maximum size (see :ref:`Resource Limits `). On such event, the temporal file is renamed to have ``.mcap`` extension in the same location, and is then ready to be processed. -.. _recorder_usage_configuration_resource_limits: - -Resource Limits -""""""""""""""" - -The ``resource-limits`` tag allows users to limit the size of the *DDS Recorder's* output. -The ``max-file-size`` tag specifies the maximum size of each output file and the ``max-size`` tag specifies the maximum aggregate size of all output files. -If the ``max-size`` is higher than the ``max-file-size``, the |ddsrecorder| will create multiple files with a maximum size of ``max-file-size``. -By default, however, the ``max-file-size`` is unlimited (``0B``) and the ``max-size`` is the same as the ``max-file-size``; that is, by default the |ddsrecorder| creates a single file of unlimited size. - -.. warning:: - - If the ``max-file-size`` or the ``max-size`` are set to a value lower than the available space in the disk, the |ddsrecorder| will replace them with the available space in the disk. - -To keep the |ddsrecorder| recording after reaching the ``max-size``, users can set the ``file-rotation`` tag to ``true``. -Enabling ``file-rotation`` allows the |ddsrecorder| to overwrite old files to free space for new ones. - -.. note:: - - To keep the |ddsrecorder| from overwriting previous output files, users can set ``{"avoid_overwriting_output": true}`` as the argument (``"args"``) of the ``stop`` command (see :ref:`Control Commands `). - If set, the |ddsrecorder| will not overwrite its output files, at the cost of possibly exceeding the ``max-size``. - -.. note:: - - If an output file is moved, deleted, or renamed, the |ddsrecorder| will keep the size of the file reserved and rotate between the remaining files. - -**Example of usage** - -.. code-block:: yaml - - resource-limits: - max-file-size: 250KB - max-size: 2MiB - file-rotation: true - Buffer size ^^^^^^^^^^^ @@ -391,6 +343,15 @@ Buffer size This avoids disk access each time a sample is received. By default, its value is set to ``100``. +.. _recorder_usage_configuration_cleanup_period: + +Cleanup Period +^^^^^^^^^^^^^^ + +As explained in :ref:`Event Window `, a |ddsrecorder| in paused mode awaits for an event command to write in disk all samples received in the last ``event-window`` seconds. +To accomplish this, received samples are stored in memory until the aforementioned event is triggered and, in order to limit memory consumption, outdated (received more than ``event-window`` seconds ago) samples are removed from this buffer every ``cleanup-period`` seconds. +By default, its value is equal to twice the ``event-window``. + .. _recorder_usage_configuration_event_window: Event Window @@ -402,14 +363,27 @@ Thus, when an event is triggered from the remote controller, samples received in In other words, the ``event-window`` acts as a sliding time window that allows to save the collected samples in this time window only when the remote controller event is received. By default, its value is set to ``20`` seconds. -.. _recorder_usage_configuration_logpublishtime: +.. _recorder_usage_configuration_max_number_pending_samples: -Log Publish Time -^^^^^^^^^^^^^^^^ +Maximum Number of Pending Samples +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -By default (``log-publish-time: false``) received messages are stored in the MCAP file with ``logTime`` value equals to the reception timestamp. -Additionally, the timestamp corresponding to when messages were initially published (``publishTime``) is also included in the information dumped to MCAP files. -In some applications, it may be required to use the ``publishTime`` as ``logTime``, which can be achieved by providing the ``log-publish-time: true`` configuration option. +It is possible that a |ddsrecorder| starts receiving data from a topic that it has not yet registered, i.e. a topic for which it does not know the data type. +In this case, messages are kept in an internal circular buffer until their associated type information is received, event on which they are written to disk. + +However, the recorder execution might end before this event ever occurs. +Depending on configuration (see :ref:`recorder_usage_configuration_onlywithtype`), messages kept in the pending samples buffer will be stored or not on closure. +Hence, note that memory consumption would continuously grow whenever a sample with unknown type information is received. + +To avoid the exhaustion of memory resources in such scenarios, a configuration option is provided which lets the user set a limit on memory usage. +The ``max-pending-samples`` parameter allows to configure the size of the aforementioned circular buffers **for each topic** that is discovered. +The default value is equal to ``5000`` samples, with ``-1`` meaning no limit, and ``0`` no pending samples. + +Depending on the combination of this configuration option and the value of ``only-with-type``, the following situations may arise when a message with unknown type is received: + +* If ``max-pending-samples`` is ``-1``, or if it is greater than ``0`` and the circular buffer is not full, the sample is added to the collection. +* If ``max-pending-samples`` is greater than ``0`` and the circular buffer reaches its maximum capacity, the oldest sample with same type as the received one is popped, and either written without type (``only-with-type: false``) or discarded (``only-with-type: true``). +* If ``max-pending-samples`` is ``0``, the message is written without type if ``only-with-type: false``, and discarded otherwise. .. _recorder_usage_configuration_onlywithtype: @@ -419,10 +393,45 @@ Only With Type By default, all (allowed) received messages are recorded regardless of whether their associated type information has been received. However, a user can enforce that **only** samples whose type is received are recorded by setting ``only-with-type: true``. +.. _recorder_usage_configuration_recordtypes: + +Record Types +^^^^^^^^^^^^ + +By default, all type information received during execution is stored in a dedicated MCAP file section. +This information is then leveraged by |ddsreplayer| on playback, publishing recorded types in addition to data samples, which may be required for receiver applications relying on :term:`Dynamic Types` (see :ref:`Replay Types `). +However, a user may choose to disable this feature by setting ``record-types: false``. + +.. _recorder_usage_configuration_topictypeformat: + +Topic type format +^^^^^^^^^^^^^^^^^ + +The optional ``ros2-types`` tag enables specification of the format for storing schemas. +When set to ``true``, schemas are stored in ROS 2 message format (.msg). +If set to ``false``, schemas are stored in OMG IDL format (.idl). +By default it is set to ``false``. + +.. _recorder_usage_configuration_mcap: + +MCAP Configuration +^^^^^^^^^^^^^^^^^^ + +The ``enable`` tag allows users to enable or disable whether to record data in an MCAP file. + +.. _recorder_usage_configuration_logpublishtime: + +Log Publish Time +"""""""""""""""" + +By default (``log-publish-time: false``) received messages are stored in the MCAP file with ``logTime`` value equals to the reception timestamp. +Additionally, the timestamp corresponding to when messages were initially published (``publishTime``) is also included in the information dumped to MCAP files. +In some applications, it may be required to use the ``publishTime`` as ``logTime``, which can be achieved by providing the ``log-publish-time: true`` configuration option. + .. _recorder_usage_configuration_compression: Compression -^^^^^^^^^^^ +""""""""""" Compression settings for writing to an MCAP file can be specified under the ``compression`` configuration tag. The supported compression options are: @@ -470,24 +479,58 @@ The supported compression options are: - ``true`` |br| ``false`` -.. _recorder_usage_configuration_recordtypes: +.. _recorder_usage_configuration_resource_limits: -Record Types -^^^^^^^^^^^^ +Resource Limits +""""""""""""""" -By default, all type information received during execution is stored in a dedicated MCAP file section. -This information is then leveraged by |ddsreplayer| on playback, publishing recorded types in addition to data samples, which may be required for receiver applications relying on :term:`Dynamic Types` (see :ref:`Replay Types `). -However, a user may choose to disable this feature by setting ``record-types: false``. +The ``resource-limits`` tag allows users to limit the size of the *DDS Recorder's* output. +The ``max-file-size`` tag specifies the maximum size of each output file and the ``max-size`` tag specifies the maximum aggregate size of all output files. +If the ``max-size`` is higher than the ``max-file-size``, the |ddsrecorder| will create multiple files with a maximum size of ``max-file-size``. +By default, however, the ``max-file-size`` is unlimited (``0B``) and the ``max-size`` is the same as the ``max-file-size``; that is, by default the |ddsrecorder| creates a single file of unlimited size. +The ``safety-margin`` tag allows users to set a safety margin (in bytes) used when estimating the size of MCAP files. +By default, the safety margin is set to ``0``. -.. _recorder_usage_configuration_topictypeformat: +.. warning:: -Topic type format + If the ``max-file-size`` or the ``max-size`` are set to a value lower than the available space in the disk, the |ddsrecorder| will replace them with the available space in the disk. + +To keep the |ddsrecorder| recording after reaching the ``max-size``, users can set the ``file-rotation`` tag to ``true``. +Enabling ``file-rotation`` allows the |ddsrecorder| to overwrite old files to free space for new ones. + +.. note:: + + To keep the |ddsrecorder| from overwriting previous output files, users can set ``{"avoid_overwriting_output": true}`` as the argument (``"args"``) of the ``stop`` command (see :ref:`Control Commands `). + If set, the |ddsrecorder| will not overwrite its output files, at the cost of possibly exceeding the ``max-size``. + +.. note:: + + If an output file is moved, deleted, or renamed, the |ddsrecorder| will keep the size of the file reserved and rotate between the remaining files. + +**Example of usage** + +.. code-block:: yaml + + resource-limits: + max-file-size: 250KB + max-size: 2MiB + file-rotation: true + safety-margin: 10KB + +.. _recorder_usage_configuration_sql: + +SQL Configuration ^^^^^^^^^^^^^^^^^ -The optional ``ros2-types`` tag enables specification of the format for storing schemas. -When set to ``true``, schemas are stored in ROS 2 message format (.msg). -If set to ``false``, schemas are stored in OMG IDL format (.idl). -By default it is set to ``false``. +The ``enable`` tag allows users to enable or disable whether to record data in an SQL database. + +.. _recorder_usage_configuration_sql_data_format: + +Data Format +""""""""""" + +The ``data-format`` tag allows users to specify the format in which data is stored in the SQL database. +The data can be stored in ``cdr`` (which makes the data replayable by the |ddsreplayer|), in ``json`` (which makes the data human-readable), or in ``both`` (default). .. _recorder_usage_configuration_remote_controller: @@ -570,33 +613,6 @@ This improves the performance of the internal data communications. This value should be set by each user depending on each system characteristics. In case this value is not set, the default number of threads used is :code:`12`. -Maximum Number of Pending Samples -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -It is possible that a |ddsrecorder| starts receiving data from a topic that it has not yet registered, i.e. a topic for which it does not know the data type. -In this case, messages are kept in an internal circular buffer until their associated type information is received, event on which they are written to disk. - -However, the recorder execution might end before this event ever occurs. -Depending on configuration (see :ref:`recorder_usage_configuration_onlywithtype`), messages kept in the pending samples buffer will be stored or not on closure. -Hence, note that memory consumption would continuously grow whenever a sample with unknown type information is received. - -To avoid the exhaustion of memory resources in such scenarios, a configuration option is provided which lets the user set a limit on memory usage. -The ``max-pending-samples`` parameter allows to configure the size of the aforementioned circular buffers **for each topic** that is discovered. -The default value is equal to ``5000`` samples, with ``-1`` meaning no limit, and ``0`` no pending samples. - -Depending on the combination of this configuration option and the value of ``only-with-type``, the following situations may arise when a message with unknown type is received: - -* If ``max-pending-samples`` is ``-1``, or if it is greater than ``0`` and the circular buffer is not full, the sample is added to the collection. -* If ``max-pending-samples`` is greater than ``0`` and the circular buffer reaches its maximum capacity, the oldest sample with same type as the received one is popped, and either written without type (``only-with-type: false``) or discarded (``only-with-type: true``). -* If ``max-pending-samples`` is ``0``, the message is written without type if ``only-with-type: false``, and discarded otherwise. - -Cleanup Period -^^^^^^^^^^^^^^ - -As explained in :ref:`Event Window `, a |ddsrecorder| in paused mode awaits for an event command to write in disk all samples received in the last ``event-window`` seconds. -To accomplish this, received samples are stored in memory until the aforementioned event is triggered and, in order to limit memory consumption, outdated (received more than ``event-window`` seconds ago) samples are removed from this buffer every ``cleanup-period`` seconds. -By default, its value is equal to twice the ``event-window``. - .. _recorder_specs_topic_qos: QoS @@ -837,28 +853,38 @@ A complete example of all the configurations described on this page can be found - "127.0.0.1" recorder: + buffer-size: 50 + cleanup-period: 90 + event-window: 60 + max-pending-samples: 10 + only-with-type: false + record-types: true + ros2-types: false + output: filename: "output" path: "." timestamp-format: "%Y-%m-%d_%H-%M-%S_%Z" local-timestamp: false - safety-margin: 500 + + mcap: + enable: true + log-publish-time: false resource-limits: max-file-size: 250KB max-size: 2MiB file-rotation: true + safety-margin: 10KB - buffer-size: 50 - event-window: 60 - log-publish-time: false - only-with-type: false - compression: - algorithm: lz4 - level: slowest - force: true - record-types: true - ros2-types: false + compression: + algorithm: lz4 + level: slowest + force: true + + sql: + enable: false + data-format: "json" remote-controller: enable: true @@ -869,8 +895,6 @@ A complete example of all the configurations described on this page can be found specs: threads: 8 - max-pending-samples: 10 - cleanup-period: 90 qos: max-rx-rate: 20 From b4277d6bf812f7d393ecb14c2261734f1e052300 Mon Sep 17 00:00:00 2001 From: tempate Date: Wed, 17 Jul 2024 10:23:42 +0200 Subject: [PATCH 50/52] Rebase fix Signed-off-by: tempate --- .../test/blackbox/FileCreationTest.hpp | 2 +- ddsrecorder/test/blackbox/mcap/CMakeLists.txt | 29 +--- ddsrecorder/test/blackbox/sql/CMakeLists.txt | 15 +- .../hello_world/HelloWorldPubSubTypes.hpp | 133 ++++++++++++++++++ .../common/serialize/impl/Serializer.ipp | 2 +- .../common/time_utils.hpp | 2 +- .../src/cpp/common/serialize/Serializer.cpp | 2 +- .../src/cpp/recorder/mcap/McapHandler.cpp | 4 +- .../src/cpp/recorder/message/SqlMessage.cpp | 6 +- .../src/cpp/recorder/sql/SqlWriter.cpp | 7 +- ddsreplayer/test/blackbox/sql/CMakeLists.txt | 32 ----- .../resources/dds/ConfigurationSubscriber.h | 9 -- 12 files changed, 149 insertions(+), 94 deletions(-) create mode 100644 ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp diff --git a/ddsrecorder/test/blackbox/FileCreationTest.hpp b/ddsrecorder/test/blackbox/FileCreationTest.hpp index 028ac1945..0deee4058 100644 --- a/ddsrecorder/test/blackbox/FileCreationTest.hpp +++ b/ddsrecorder/test/blackbox/FileCreationTest.hpp @@ -48,7 +48,7 @@ #include "constants.hpp" #include "../resources/types/hello_world/HelloWorld.hpp" -#include "../resources/types/hello_world/HelloWorldPubSubTypes.h" +#include "../resources/types/hello_world/HelloWorldPubSubTypes.hpp" using namespace eprosima; using DdsRecorderState = ddsrecorder::recorder::DdsRecorderStateCode; diff --git a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt index 430fe2a44..37f64783c 100644 --- a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt @@ -24,13 +24,9 @@ file( "${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/*.c*" ) -file( - GLOB_RECURSE TEST_LIBRARY_SOURCES - "${PROJECT_SOURCE_DIR}/src/cpp/*.c*" +set(TEST_LIBRARY_SOURCES ) -list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") - set(TEST_LIST mcap_data_msgs mcap_dds_topic @@ -123,22 +119,9 @@ file( "${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/*.c*" ) -file( - GLOB_RECURSE TEST_LIBRARY_SOURCES - "${PROJECT_SOURCE_DIR}/src/cpp/*.c*" +set(TEST_LIBRARY_SOURCES ) -list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") - -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER TEST_SOURCES EXCLUDE REGEX "v2/") - list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER TEST_SOURCES EXCLUDE REGEX "v1/") - list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - set(TEST_LIST max_file_size max_size @@ -149,16 +132,8 @@ set(TEST_NEEDED_SOURCES ) set(TEST_EXTRA_HEADERS - ${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/ ) -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER TEST_EXTRA_HEADERS EXCLUDE REGEX "v2/") -else() - list(FILTER TEST_EXTRA_HEADERS EXCLUDE REGEX "v1/") -endif() - add_blackbox_executable( "${TEST_NAME}" "${TEST_SOURCES}" diff --git a/ddsrecorder/test/blackbox/sql/CMakeLists.txt b/ddsrecorder/test/blackbox/sql/CMakeLists.txt index 25e787301..f4082764c 100644 --- a/ddsrecorder/test/blackbox/sql/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/sql/CMakeLists.txt @@ -24,22 +24,9 @@ file( "${PROJECT_SOURCE_DIR}/test/resources/types/hello_world/*.c*" ) -file( - GLOB_RECURSE TEST_LIBRARY_SOURCES - "${PROJECT_SOURCE_DIR}/src/cpp/*.c*" +set(TEST_LIBRARY_SOURCES ) -list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") - -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER TEST_SOURCES EXCLUDE REGEX "v2/") - list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER TEST_SOURCES EXCLUDE REGEX "v1/") - list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "v1/") -endif() - set(TEST_LIST sql_data_msgs sql_dds_topic diff --git a/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp new file mode 100644 index 000000000..556d4c05e --- /dev/null +++ b/ddsrecorder/test/resources/types/hello_world/HelloWorldPubSubTypes.hpp @@ -0,0 +1,133 @@ +// 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 HelloWorldPubSubTypes.hpp + * This header file contains the declaration of the serialization functions. + * + * This file was generated by the tool fastddsgen. + */ + + +#ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP +#define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP + +#include +#include +#include +#include +#include + +#include "HelloWorld.hpp" + + +#if !defined(GEN_API_VER) || (GEN_API_VER != 2) +#error \ + Generated HelloWorld 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 HelloWorld defined by the user in the IDL file. + * @ingroup HelloWorld + */ +class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType +{ +public: + + typedef HelloWorld type; + + eProsima_user_DllExport HelloWorldPubSubType(); + + eProsima_user_DllExport ~HelloWorldPubSubType() override; + + eProsima_user_DllExport bool serialize( + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload) override + { + return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport bool serialize( + const void* const data, + eprosima::fastdds::rtps::SerializedPayload_t* payload, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool deserialize( + eprosima::fastdds::rtps::SerializedPayload_t* payload, + void* data) override; + + eProsima_user_DllExport std::function getSerializedSizeProvider( + const void* const data) override + { + return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION); + } + + eProsima_user_DllExport std::function getSerializedSizeProvider( + const void* const data, + eprosima::fastdds::dds::DataRepresentationId_t data_representation) override; + + eProsima_user_DllExport bool getKey( + const void* const data, + eprosima::fastdds::rtps::InstanceHandle_t* ihandle, + bool force_md5 = false) override; + + eProsima_user_DllExport void* createData() override; + + eProsima_user_DllExport void deleteData( + void* data) override; + + //Register TypeObject representation in Fast DDS TypeObjectRegistry + eProsima_user_DllExport void register_type_object_representation() 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; + } + + eProsima_user_DllExport inline bool is_plain( + eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override + { + static_cast(data_representation); + 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 + { + static_cast(memory); + return false; + } + +#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE + + eprosima::fastdds::MD5 m_md5; + unsigned char* m_keyBuffer; + +}; + +#endif // FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP + diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/impl/Serializer.ipp b/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/impl/Serializer.ipp index 4f4e264c8..622e68f23 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/impl/Serializer.ipp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/serialize/impl/Serializer.ipp @@ -25,7 +25,7 @@ #include #include -#include +#include #include namespace eprosima { diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp index f25399a55..5c2fe9364 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/time_utils.hpp @@ -23,7 +23,7 @@ #include -#include +#include #include diff --git a/ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp b/ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp index 3fc693ebf..96b1cd271 100644 --- a/ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp +++ b/ddsrecorder_participants/src/cpp/common/serialize/Serializer.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include namespace eprosima { diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index e41785cf1..a501ac20d 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -22,6 +22,8 @@ #include +#include + #include #include @@ -118,7 +120,7 @@ void McapHandler::add_schema( encoding = "omgidl"; std::stringstream idl; - auto ret = idl_serialize(dynamic_type, idl); + auto ret = fastdds::dds::idl_serialize(dynamic_type, idl); if (ret != fastdds::dds::RETCODE_OK) { logError(DDSRECORDER_MCAP_HANDLER, "MCAP_WRITE | Failed to serialize DynamicType to idl for type wth name: " << dynamic_type->get_name().to_string()); diff --git a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp index 980224b24..57bf0d09f 100644 --- a/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/message/SqlMessage.cpp @@ -66,8 +66,12 @@ void SqlMessage::deserialize( pub_sub_type.deserialize(&payload, &dynamic_data); // Serialize the payload into a JSON + std::stringstream data_json_stream; + const auto ret = fastdds::dds::json_serialize( - dynamic_data, data_json, fastdds::dds::DynamicDataJsonFormat::EPROSIMA); + dynamic_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, data_json_stream); + + data_json = data_json_stream.str(); if (ret != fastdds::dds::RETCODE_OK) { diff --git a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp index 364bb2ed8..08506094b 100644 --- a/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/sql/SqlWriter.cpp @@ -31,17 +31,12 @@ #include #include +#include #include #include #include #include #include -#include - -#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 -#else - #include -#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 namespace eprosima { namespace ddsrecorder { diff --git a/ddsreplayer/test/blackbox/sql/CMakeLists.txt b/ddsreplayer/test/blackbox/sql/CMakeLists.txt index fc3bd346b..691b9d617 100644 --- a/ddsreplayer/test/blackbox/sql/CMakeLists.txt +++ b/ddsreplayer/test/blackbox/sql/CMakeLists.txt @@ -18,13 +18,6 @@ set(TEST_NAME SqlFileReadTest) -# Determine Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(DDS_TYPES_VERSION "v1") -else() - set(DDS_TYPES_VERSION "v2") -endif() - file( GLOB_RECURSE TEST_SOURCES SqlFileReadTest.cpp @@ -32,15 +25,6 @@ file( "${PROJECT_SOURCE_DIR}/test/resources/types/*.c*" ) -list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") - -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER TEST_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER TEST_SOURCES EXCLUDE REGEX "v1/") -endif() - set(TEST_LIST trivial data_to_check @@ -78,13 +62,6 @@ add_blackbox_executable( set(TEST_NAME SqlFileReadWithTypeTest) -# Determine Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - set(DDS_TYPES_VERSION "v1") -else() - set(DDS_TYPES_VERSION "v2") -endif() - file( GLOB_RECURSE TEST_SOURCES SqlFileReadWithTypeTest.cpp @@ -92,15 +69,6 @@ file( "${PROJECT_SOURCE_DIR}/test/resources/types/*.c*" ) -list(FILTER TEST_LIBRARY_SOURCES EXCLUDE REGEX "/main.cpp") - -# Exclude types' files depending on the Fast DDS version -if ("${fastrtps_VERSION}" VERSION_LESS 2.13) - list(FILTER TEST_SOURCES EXCLUDE REGEX "v2/") -else() - list(FILTER TEST_SOURCES EXCLUDE REGEX "v1/") -endif() - set(TEST_LIST trivial dds_data_to_check diff --git a/ddsreplayer/test/resources/dds/ConfigurationSubscriber.h b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.h index 612f598f8..b653db146 100644 --- a/ddsreplayer/test/resources/dds/ConfigurationSubscriber.h +++ b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.h @@ -24,16 +24,7 @@ #include #include -<<<<<<< HEAD -<<<<<<< HEAD:ddsreplayer/test/blackbox/mcap/dds/ConfigurationSubscriber.h -#include "types/configuration/ConfigurationPubSubTypes.hpp" -======= -<<<<<<<< HEAD:ddsreplayer/test/resources/ConfigurationSubscriber.h -#include "types/configuration/ConfigurationPubSubTypes.h" ->>>>>>> b00497a (Strip replaying methods from McapFileReadTest & McapFileReadWithTypeTest):ddsreplayer/test/resources/dds/ConfigurationSubscriber.h -======= #include "../types/configuration/Configuration.hpp" ->>>>>>> 8d371bc (Rebase fix) #include "DataToCheck.hpp" From 508b90b83e6962cdb7175c8f3930eb352b81cdc4 Mon Sep 17 00:00:00 2001 From: tempate Date: Mon, 22 Jul 2024 09:19:11 +0200 Subject: [PATCH 51/52] Tests for data-format Signed-off-by: tempate --- .../test/blackbox/FileCreationTest.hpp | 73 ++++++++-- .../blackbox/mcap/McapFileCreationTest.cpp | 4 +- ddsrecorder/test/blackbox/sql/CMakeLists.txt | 5 +- .../test/blackbox/sql/SqlFileCreationTest.cpp | 131 ++++++++++++++++-- 4 files changed, 187 insertions(+), 26 deletions(-) diff --git a/ddsrecorder/test/blackbox/FileCreationTest.hpp b/ddsrecorder/test/blackbox/FileCreationTest.hpp index 0deee4058..d0cf13fa6 100644 --- a/ddsrecorder/test/blackbox/FileCreationTest.hpp +++ b/ddsrecorder/test/blackbox/FileCreationTest.hpp @@ -34,6 +34,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -77,8 +84,8 @@ class FileCreationTest : public testing::Test ASSERT_NE(participant_, nullptr); // Register the type - fastdds::dds::TypeSupport type(new HelloWorldPubSubType()); - participant_->register_type(type); + type_support_ = fastdds::dds::TypeSupport(new HelloWorldPubSubType()); + participant_->register_type(type_support_); // Create the publisher publisher_ = participant_->create_publisher(fastdds::dds::PUBLISHER_QOS_DEFAULT, nullptr); @@ -109,7 +116,7 @@ class FileCreationTest : public testing::Test protected: - std::vector> record_messages_( + std::vector record_messages_( const std::string& file_name, const unsigned int messages1, const DdsRecorderState state1 = DdsRecorderState::RUNNING, @@ -184,7 +191,7 @@ class FileCreationTest : public testing::Test return sent_messages; } - std::vector> send_messages_( + std::vector send_messages_( const unsigned int number_of_messages) { // Create the DataWriter @@ -194,25 +201,20 @@ class FileCreationTest : public testing::Test std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Send the messages - std::vector> sent_messages; + std::vector sent_messages; for (std::uint32_t i = 0; i < number_of_messages; i++) { // Create the message HelloWorld hello; hello.index(i); + hello.message("Hello World!"); // Send the message writer_->write(&hello); - // Serialize the message - HelloWorldPubSubType pubsubType; - const auto payload_size = pubsubType.getSerializedSizeProvider(&hello)(); - auto payload = std::make_shared(payload_size); - pubsubType.serialize(&hello, payload.get()); - - // Store the serialized message - sent_messages.push_back(payload); + // Store the message + sent_messages.push_back(hello); // Wait for the message to be sent std::this_thread::sleep_for(std::chrono::milliseconds(10)); @@ -224,6 +226,50 @@ class FileCreationTest : public testing::Test return sent_messages; } + std::shared_ptr to_cdr( + const HelloWorld& message) + { + HelloWorldPubSubType pubsubType; + const auto payload_size = pubsubType.getSerializedSizeProvider(&message)(); + auto payload = std::make_shared(payload_size); + pubsubType.serialize(&message, payload.get()); + + return payload; + } + + std::string to_json( + const HelloWorld& message) + { + // Get type object + fastdds::dds::xtypes::TypeObjectPair type_objects; + fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_objects( + type_support_->getName(), + type_objects); + + // Build dynamic type + fastdds::dds::DynamicType::_ref_type dyn_type = + fastdds::dds::DynamicTypeBuilderFactory::get_instance()->create_type_w_type_object( + type_objects.complete_type_object)->build(); + + // Build dynamic data + fastdds::dds::DynamicData::_ref_type dyn_data = + fastdds::dds::DynamicDataFactory::get_instance()->create_data(dyn_type); + + // Transform the message into DynamicData + const auto payload_size = type_support_->getSerializedSizeProvider(&message)(); + auto payload = std::make_shared(payload_size); + type_support_->serialize(&message, payload.get()); + + fastdds::dds::TypeSupport dyn_type_support(new fastdds::dds::DynamicPubSubType(dyn_type)); + dyn_type_support->deserialize(payload.get(), &dyn_data); + + // Serialize DynamicType into its IDL representation + std::stringstream data_json; + json_serialize(dyn_data, fastdds::dds::DynamicDataJsonFormat::EPROSIMA, data_json); + + return data_json.str(); + } + void create_datawriter_() { // Configure the DataWriter's QoS to ensure that the DDS Recorder receives all the msgs @@ -275,6 +321,7 @@ class FileCreationTest : public testing::Test } fastdds::dds::DomainParticipant* participant_ = nullptr; + fastdds::dds::TypeSupport type_support_; fastdds::dds::Publisher* publisher_ = nullptr; fastdds::dds::Topic* topic_ = nullptr; fastdds::dds::DataWriter* writer_ = nullptr; diff --git a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp index d0674b824..9fb75bc41 100644 --- a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp @@ -154,11 +154,11 @@ TEST_F(McapFileCreationTest, mcap_data_msgs) // Verify the data size const auto read_data_size = it.message.dataSize; - ASSERT_EQ((*sent_message)->length, read_data_size); + ASSERT_EQ(to_cdr(*sent_message)->length, read_data_size); // Verify the data const auto read_data = (unsigned char*) reinterpret_cast(it.message.data); - ASSERT_EQ(strcmp((char*) (*sent_message)->data, (char*) read_data), 0); + ASSERT_EQ(strcmp((char*) to_cdr(*sent_message)->data, (char*) read_data), 0); sent_message++; } diff --git a/ddsrecorder/test/blackbox/sql/CMakeLists.txt b/ddsrecorder/test/blackbox/sql/CMakeLists.txt index f4082764c..75918ab62 100644 --- a/ddsrecorder/test/blackbox/sql/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/sql/CMakeLists.txt @@ -28,12 +28,15 @@ set(TEST_LIBRARY_SOURCES ) set(TEST_LIST - sql_data_msgs sql_dds_topic sql_ros2_topic sql_data_num_msgs sql_data_num_msgs_downsampling + sql_data_format_cdr + sql_data_format_json + sql_data_format_both + # State transition_running transition_paused diff --git a/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp b/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp index 476531aed..d89fb0818 100644 --- a/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/sql/SqlFileCreationTest.cpp @@ -135,18 +135,73 @@ class SqlFileCreationTest : public FileCreationTest * Verify that the DDS Recorder records properly in an SQL file. * * CASES: - * - Verify that the messages' data_cdr_size match the recorded data_cdr sizes. + * - Verify that the messages' data_cdr_size matches the recorded data_cdr sizes. * - Verify that the messages' data_cdr matches the recorded data_cdr. + * - Verify that the messages' data_json is empty. */ -TEST_F(SqlFileCreationTest, sql_data_msgs) +TEST_F(SqlFileCreationTest, sql_data_format_cdr) { - const std::string OUTPUT_FILE_NAME = "sql_data_msgs"; + const std::string OUTPUT_FILE_NAME = "sql_data_cdr_msgs"; const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); constexpr auto NUMBER_OF_MESSAGES = 10; ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + configuration_->sql_data_format = ddsrecorder::participants::DataFormat::cdr; + + // Record messages + auto sent_messages = record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); + + auto sent_message = sent_messages.begin(); + + auto read_message_count = 0; + + // Read the recorded messages + exec_sql_statement_( + OUTPUT_FILE_PATH.string(), + "SELECT data_cdr_size, data_cdr, data_json FROM Messages ORDER BY log_time;", {}, [&](sqlite3_stmt* stmt) + { + read_message_count++; + + // Verify the data_cdr_size + const auto read_data_cdr_size = sqlite3_column_int(stmt, 0); + ASSERT_EQ(to_cdr(*sent_message)->length, read_data_cdr_size); + + // Verify the data_cdr + const auto read_data_cdr = (unsigned char*) reinterpret_cast(sqlite3_column_blob(stmt, 1)); + ASSERT_EQ(strcmp((char*) to_cdr(*sent_message)->data, (char*) read_data_cdr), 0); + + // Verify the data_json + const std::string read_data_json = reinterpret_cast(sqlite3_column_text(stmt, 2)); + ASSERT_EQ(read_data_json.size(), 0); + + sent_message++; + }); + + // Verify that it read messages + ASSERT_GT(read_message_count, 0); +} + +/** + * Verify that the DDS Recorder records properly in an SQL file. + * + * CASES: + * - Verify that the messages' data_cdr_size is 0. + * - Verify that the messages' data_cdr is empty. + * - Verify that the messages' data_json matches the recorded data_json. + */ +TEST_F(SqlFileCreationTest, sql_data_format_json) +{ + const std::string OUTPUT_FILE_NAME = "sql_data_json_msgs"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES = 10; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + configuration_->sql_data_format = ddsrecorder::participants::DataFormat::json; + // Record messages auto sent_messages = record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); @@ -157,17 +212,73 @@ TEST_F(SqlFileCreationTest, sql_data_msgs) // Read the recorded messages exec_sql_statement_( OUTPUT_FILE_PATH.string(), - "SELECT data_cdr, data_cdr_size FROM Messages ORDER BY log_time;", {}, [&](sqlite3_stmt* stmt) + "SELECT data_cdr_size, data_cdr, data_json FROM Messages ORDER BY log_time;", {}, [&](sqlite3_stmt* stmt) { read_message_count++; - // Verify the data size - const auto read_data_size = sqlite3_column_int(stmt, 1); - ASSERT_EQ((*sent_message)->length, read_data_size); + // Verify the data_cdr_size + const auto read_data_cdr_size = sqlite3_column_int(stmt, 0); + ASSERT_EQ(read_data_cdr_size, 0); + + // Verify the data_cdr + const auto read_data_cdr = sqlite3_column_bytes(stmt, 1); + ASSERT_EQ(read_data_cdr, 0); + + // Verify the data_json + const std::string read_data_json = reinterpret_cast(sqlite3_column_text(stmt, 2)); + ASSERT_EQ(to_json(*sent_message), read_data_json); + + sent_message++; + }); + + // Verify that it read messages + ASSERT_GT(read_message_count, 0); +} + +/** + * Verify that the DDS Recorder records properly in an SQL file. + * + * CASES: + * - Verify that the messages' data_cdr_size matches the recorded data_cdr sizes. + * - Verify that the messages' data_cdr matches the recorded data_cdr. + * - Verify that the messages' data_json matches the recorded data_json. + */ +TEST_F(SqlFileCreationTest, sql_data_format_both) +{ + const std::string OUTPUT_FILE_NAME = "sql_data_cdr_msgs"; + const auto OUTPUT_FILE_PATH = get_output_file_path_(OUTPUT_FILE_NAME + ".db"); + + constexpr auto NUMBER_OF_MESSAGES = 10; + + ASSERT_TRUE(delete_file_(OUTPUT_FILE_PATH)); + + configuration_->sql_data_format = ddsrecorder::participants::DataFormat::both; + + // Record messages + auto sent_messages = record_messages_(OUTPUT_FILE_NAME, NUMBER_OF_MESSAGES); + + auto sent_message = sent_messages.begin(); + + auto read_message_count = 0; + + // Read the recorded messages + exec_sql_statement_( + OUTPUT_FILE_PATH.string(), + "SELECT data_cdr_size, data_cdr, data_json FROM Messages ORDER BY log_time;", {}, [&](sqlite3_stmt* stmt) + { + read_message_count++; + + // Verify the data_cdr_size + const auto read_data_cdr_size = sqlite3_column_int(stmt, 0); + ASSERT_EQ(to_cdr(*sent_message)->length, read_data_cdr_size); + + // Verify the data_cdr + const auto read_data_cdr = (unsigned char*) reinterpret_cast(sqlite3_column_blob(stmt, 1)); + ASSERT_EQ(strcmp((char*) to_cdr(*sent_message)->data, (char*) read_data_cdr), 0); - // Verify the data - const auto read_data = (unsigned char*) reinterpret_cast(sqlite3_column_blob(stmt, 0)); - ASSERT_EQ(strcmp((char*) (*sent_message)->data, (char*) read_data), 0); + // Verify the data_json + const std::string read_data_json = reinterpret_cast(sqlite3_column_text(stmt, 2)); + ASSERT_EQ(to_json(*sent_message), read_data_json); sent_message++; }); From ecd77eb1432736ce1afd48a4d6e4ed83e15efa03 Mon Sep 17 00:00:00 2001 From: tempate Date: Wed, 24 Jul 2024 12:12:47 +0200 Subject: [PATCH 52/52] Fixes to the DDS Replayer tests Signed-off-by: tempate --- ddsreplayer/test/blackbox/FileReadTest.hpp | 29 ++++++++++-------- ddsreplayer/test/blackbox/sql/CMakeLists.txt | 2 +- .../test/blackbox/sql/SqlFileReadTest.hpp | 2 +- .../test/resources/config/config_file.yaml | 2 +- .../config/config_file_begin_time.yaml | 2 +- .../config/config_file_end_time.yaml | 2 +- ddsreplayer/test/resources/constants.hpp | 2 +- .../resources/dds/ConfigurationSubscriber.cpp | 2 ++ .../test/resources/dds/DataToCheck.hpp | 14 ++++----- .../basic/{helloworld.db => configuration.db} | Bin 28672 -> 28672 bytes .../recordings/basic/configuration.mcap | Bin 2944 -> 2034 bytes 11 files changed, 31 insertions(+), 26 deletions(-) rename ddsreplayer/test/resources/recordings/basic/{helloworld.db => configuration.db} (76%) diff --git a/ddsreplayer/test/blackbox/FileReadTest.hpp b/ddsreplayer/test/blackbox/FileReadTest.hpp index 4dd4a254f..25ac7c1a3 100644 --- a/ddsreplayer/test/blackbox/FileReadTest.hpp +++ b/ddsreplayer/test/blackbox/FileReadTest.hpp @@ -13,6 +13,7 @@ // limitations under the License. #include +#include #include #include #include @@ -76,10 +77,10 @@ class FileReadTest : public testing::Test const auto data = replay_(configuration, input_file, publish_types); // Verify that the received data is correct - ASSERT_EQ(data.n_received_msgs, 11); + ASSERT_EQ(data.n_received_msgs, 10); ASSERT_EQ(data.type_msg, "Configuration"); - ASSERT_EQ(data.message_msg, "Hello World"); - ASSERT_EQ(data.min_index_msg, 0); + ASSERT_EQ(data.message_msg, "Configuration"); + ASSERT_EQ(data.min_index_msg, 1); ASSERT_EQ(data.max_index_msg, 10); // Verify that the average miliseconds between messages is about 200 ms @@ -159,8 +160,8 @@ class FileReadTest : public testing::Test const auto data = replay_(configuration, input_file, publish_types); // Verify that only the messages after the begin-time were received - ASSERT_EQ(data.n_received_msgs, 3); - ASSERT_EQ(data.min_index_msg, 8); + ASSERT_EQ(data.n_received_msgs, 7); + ASSERT_EQ(data.min_index_msg, 4); ASSERT_EQ(data.max_index_msg, 10); } @@ -180,9 +181,9 @@ class FileReadTest : public testing::Test const auto data = replay_(configuration, input_file, publish_types); // Verify that only the messages before the end-time were received - ASSERT_EQ(data.n_received_msgs, 8); - ASSERT_EQ(data.min_index_msg, 0); - ASSERT_EQ(data.max_index_msg, 7); + ASSERT_EQ(data.n_received_msgs, 3); + ASSERT_EQ(data.min_index_msg, 1); + ASSERT_EQ(data.max_index_msg, 3); } /** @@ -201,8 +202,8 @@ class FileReadTest : public testing::Test const auto data = replay_(configuration, input_file, publish_types); // Verify that all the messages were received - ASSERT_EQ(data.n_received_msgs, 11); - ASSERT_EQ(data.min_index_msg, 0); + ASSERT_EQ(data.n_received_msgs, 10); + ASSERT_EQ(data.min_index_msg, 1); ASSERT_EQ(data.max_index_msg, 10); } @@ -235,15 +236,17 @@ class FileReadTest : public testing::Test } else { - subscriber = std::make_unique(topic_name, test::DOMAIN, data); + subscriber = std::make_unique(topic_name, test::DOMAIN, data); } // Configuration - ddsrecorder::yaml::ReplayerConfiguration configuration(configuration_path); + const auto full_configuration_path = std::filesystem::current_path() / configuration_path; + ddsrecorder::yaml::ReplayerConfiguration configuration(full_configuration_path.string()); configuration.replayer_configuration->domain.domain_id = test::DOMAIN; // Create replayer instance - auto replayer = std::make_unique(configuration, input_file); + const auto input_file_path = std::filesystem::current_path() / input_file; + auto replayer = std::make_unique(configuration, input_file_path.string()); // Give time for replayer and subscriber to match. // Waiting for the subscriber to match the replayer diff --git a/ddsreplayer/test/blackbox/sql/CMakeLists.txt b/ddsreplayer/test/blackbox/sql/CMakeLists.txt index 691b9d617..e5be1b5cf 100644 --- a/ddsreplayer/test/blackbox/sql/CMakeLists.txt +++ b/ddsreplayer/test/blackbox/sql/CMakeLists.txt @@ -42,7 +42,7 @@ set(TEST_NEEDED_SOURCES ../../resources/config/config_file_begin_time.yaml ../../resources/config/config_file_end_time.yaml ../../resources/config/config_file_start_replay_time_earlier.yaml - ../../resources/recordings/basic/helloworld.db + ../../resources/recordings/basic/configuration.db ) set(TEST_EXTRA_HEADERS diff --git a/ddsreplayer/test/blackbox/sql/SqlFileReadTest.hpp b/ddsreplayer/test/blackbox/sql/SqlFileReadTest.hpp index 0abe069ae..beba02647 100644 --- a/ddsreplayer/test/blackbox/sql/SqlFileReadTest.hpp +++ b/ddsreplayer/test/blackbox/sql/SqlFileReadTest.hpp @@ -25,5 +25,5 @@ class SqlFileReadTest : public FileReadTest { protected: - const std::string input_file_{"../../resources/recordings/basic/helloworld.db"}; + const std::string input_file_{"../../resources/recordings/basic/configuration.db"}; }; diff --git a/ddsreplayer/test/resources/config/config_file.yaml b/ddsreplayer/test/resources/config/config_file.yaml index ba243c206..9a9f25d33 100644 --- a/ddsreplayer/test/resources/config/config_file.yaml +++ b/ddsreplayer/test/resources/config/config_file.yaml @@ -5,7 +5,7 @@ topics: reliability: true # Use QoS RELIABLE replayer: - replay-types: true + replay-types: false specs: wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/resources/config/config_file_begin_time.yaml b/ddsreplayer/test/resources/config/config_file_begin_time.yaml index 51362440d..2d4d3aa64 100644 --- a/ddsreplayer/test/resources/config/config_file_begin_time.yaml +++ b/ddsreplayer/test/resources/config/config_file_begin_time.yaml @@ -9,7 +9,7 @@ replayer: begin-time: local: false format: "%H-%M-%S_%Y-%m-%d" - datetime: 13-04-45_2024-06-25 + datetime: 10-39-40_2024-07-22 specs: wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/resources/config/config_file_end_time.yaml b/ddsreplayer/test/resources/config/config_file_end_time.yaml index f2c8a9f5e..b623d04b9 100644 --- a/ddsreplayer/test/resources/config/config_file_end_time.yaml +++ b/ddsreplayer/test/resources/config/config_file_end_time.yaml @@ -9,7 +9,7 @@ replayer: end-time: local: false format: "%H-%M-%S_%Y-%m-%d" - datetime: 13-04-45_2024-06-25 + datetime: 10-39-40_2024-07-22 specs: wait-all-acked-timeout: 2000 diff --git a/ddsreplayer/test/resources/constants.hpp b/ddsreplayer/test/resources/constants.hpp index e6a62b8b2..4b119f84e 100644 --- a/ddsreplayer/test/resources/constants.hpp +++ b/ddsreplayer/test/resources/constants.hpp @@ -23,7 +23,7 @@ namespace test { -constexpr std::uint32_t DOMAIN = 110; +constexpr std::uint32_t DOMAIN = 80; const auto DDS_TOPIC_NAME = "/dds/topic"; const auto DDS_TYPE_NAME = "HelloWorld"; diff --git a/ddsreplayer/test/resources/dds/ConfigurationSubscriber.cpp b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.cpp index efaf43e45..73e6816c4 100644 --- a/ddsreplayer/test/resources/dds/ConfigurationSubscriber.cpp +++ b/ddsreplayer/test/resources/dds/ConfigurationSubscriber.cpp @@ -177,6 +177,7 @@ void ConfigurationSubscriber::init_info( { data_->n_received_msgs = 0; data_->type_msg = type_name; + data_->message_msg = ""; data_->min_index_msg = -1; data_->max_index_msg = -1; data_->cummulated_ms_between_msgs = -1; @@ -188,6 +189,7 @@ void ConfigurationSubscriber::fill_info( uint64_t time_arrive_msg) { data_->n_received_msgs++; + data_->message_msg = configuration_.message().data(); if (data_->min_index_msg == -1 || data_->min_index_msg > static_cast(configuration_.index())) { diff --git a/ddsreplayer/test/resources/dds/DataToCheck.hpp b/ddsreplayer/test/resources/dds/DataToCheck.hpp index dbbb90f89..f875f6221 100644 --- a/ddsreplayer/test/resources/dds/DataToCheck.hpp +++ b/ddsreplayer/test/resources/dds/DataToCheck.hpp @@ -23,11 +23,11 @@ struct DataToCheck { - unsigned int n_received_msgs; - std::string type_msg; - std::string message_msg; - int min_index_msg; - int max_index_msg; - double mean_ms_between_msgs; - double cummulated_ms_between_msgs; + unsigned int n_received_msgs{0}; + std::string type_msg{""}; + std::string message_msg{""}; + int min_index_msg{0}; + int max_index_msg{0}; + double mean_ms_between_msgs{0}; + double cummulated_ms_between_msgs{0}; }; diff --git a/ddsreplayer/test/resources/recordings/basic/helloworld.db b/ddsreplayer/test/resources/recordings/basic/configuration.db similarity index 76% rename from ddsreplayer/test/resources/recordings/basic/helloworld.db rename to ddsreplayer/test/resources/recordings/basic/configuration.db index 22acc01e4be3b5bb22f2dac1205ce8064c3c9135..0b42676b8243c1f3f8ef518c1d1177a609ca8ac8 100644 GIT binary patch literal 28672 zcmeI)&u`+`9RP3}2!v#Uw}&m7u14~3$)uY#{%w<0)EeR>%x1`hFheHoiZR9^Ou~=Y zCYj81DuvxcrTz(3)l)CMRK51NQg5x)TeXM1^;-4X-uj*mGcW_0fEbBYzfXC_em~56 zAHRe=18;wCr{-GpQPZv)E-err5hO|cl%@%Sh@u!lu@{19C)7JYk7VEesNE>R6z?xl z{~^MQPl?!nslP4#G4|KRr%S&aRRPjL00ck)1V8`;KmY_l;QK7_^(S+Y_?3Ur}r4nNEt}5f3i_6wA5pquxJK!j(`g*cFRb2E z3>I;lt(tjVL*2`kbzT06b$MO(X|q~#Yjum>Kyrob1ARmfTkY~`%{jhN*@yY;11UZrv8R_MIGsps`vM&G9kn8Uf(FzQw}_w`j< zNruDm%pH=bH7eF~=j;?+=aSKOo8ED$Hylb_Z!gmMQ7{s}eVhE6@`jUtZhspZ7)pNH zTLTHV;X2v(U6`|`b6xeCQ?i>5Uvl3!0Q$B2T&}Tw2NfmwrYmnWKMjTBKe;_h(-$dm z{^Q)$9vO+pK}gRs`{r`EOZFWQJ=&GIwLbZ>-<8Z=n$ z4Zunu9AA%*1i)QE{l^b@EbF-d5HBWNq*{GBoLui%{q5g(4Y%#6=e%1xFwWhy z+)~wT_W91mGu(XZP4f-^RQSwUycul%X^wqzkmpQXeiL_3+rXPmeC!9m`KWi=cKY)0 z;ILH|9{bHpKfxvXnveUOepWfSe|cDxSe%JM!P|Nqx`u!@@v%{q>Sg~qx?Mab!^`WP zSMf}fh8i)VEU`-^|BZO`trx4(J@8UYGJJRWit?T?>3yeS zVCH`PbNJ_c|C8YN{{z&Y3F@C{0|5j;00ck)1V8`;KmY_l00ck)1VCWM1Xe;qlDx^y zh`=YIyUS5ra>!i-{QmzUaZbd3z4Y5#%L{*sejfQtcsKNI&?Ntbl0Q)BxQn+;@~gQD zd3X5-TU#v0ut$uTVvdfOBaz`n##9;3WLWm~&o9s}!!g3b%LHDXB(e50PGMJX5Wiea zc&lk7);M-GQTNwhLDdtP#A>36Vgtn^6l*9}QEa1VqiCS$qKMOb<$m5~Q9uck?0oqO zFPVsMxD4FK=@R4gKfDeEu{z>{y?n*9y!aWbe8%%M$F2#fHI8RwL1sl+V8!8?qLPwD zQRp}em_0Z?dvtR4)GVmuwJfKvE(#JWODRDfrY;JCDhMe7sYfSNpPyV^odtEg!pQX1 zc|qjWl$_#+sq=!sN-8h09cO+*^~mJv$}FhkHCv~z&I*Fei899xQ)dO9PpJaOb)3kA z>fy=N6@Q|EbALB9mD(s6 zyJL)H6j5X)SyGgaP2Mu2lgv&gA7b1r3^BZr{qipKsC`+dxbX)y{VLjVB~009sH0T2KI5C8!X009vAJ_v9jlO)G^ zb9Hgt8qtMuYs^Q-tr3|Yw?;TJZjHI{xHUp^%bcF(?z`~5vX`3uW(uQqP zu^b#(^z6a^!vDd$2luvK_8)K@FODa@IKG#(kV0U!jtBJnhUUl1>-*;WNysz_4VxP) zrfV?I>{g@dG6MA$Mbp#=3`0@W9sC->uU?7biJ{&M9@By8>n86|^E*!x$=|5h#4pt3 z@5z^m?Z5R*mJ7>?L!y~Et_vtVFK35ILsqPz2Zyf9ErB}<$ zj5C2^>P(?n*7913SuYhq|S{#tFjwl`n#6R&Xoc=&XK9!aHA^cn4gkq*mb5b5V4RsTTCZ2G6xrro?r#jbs9 z)ZLp}oV(!_>Th?k6U;_psfEJs?riX?TiaP`?~w-kWY8_k zx%48L%ojhY?QjRR2JY;lzd$^%eRn>4oIc*d71@J&LqGAB+^{~+s+MECVCh(T;fvv5 z-kWaKZ99sS+s>5^kIMyNss2W=+nsu2yRBn~UblUl#jEt1;yAfJC)XTC+&TIVcD=O zd&h2BddslPYR$yor|CRm{5$JW;3F*^>7oyeu z%Z;?-{RzXBQ}@1*ZmVsK2P1kFZw~0+|9?#-UnhTpO$-7c00JNY0w4eaAOHd&00JNY z0w8eP1SX@?^u?8m$i1jAMrJQvRUr5O6|oOqQmgaSPz50@D+$R8%i|{IXfPCc0{H-; zM5M5aETYh?M3S?Fx0g8*3>6zJlz?PGR#a6C%Su3q6D66I%vdng@L-{MghW*pBrYrz zk0f3aI8HT(gQ3VH+Xn#TkR;0zFS22wI3!AVMR>&=3Wg$2l^Y-wi$q00Qg~J@5)h}7 ztfIkCkwHR<^C}WlQQ&Z5SAM_ALLMndW>qs13`L%E|F^Re=M^O2{es8Ggpg1QVtGMQ zS@kn|lq%Cg_rOGU_QjR8O)cj?p0Bi3EEbC1F$*uDsP{t7;KPqrIKGSz5~3(8Ve#?t z1@B3m#FF!WI{7Pwf1rQ>2!H?xfB*=900@8p2!H?xfB*>mX9VJO^giADKOFHt0b}e_ AxBvhE diff --git a/ddsreplayer/test/resources/recordings/basic/configuration.mcap b/ddsreplayer/test/resources/recordings/basic/configuration.mcap index fb9f2c4fd833c167bfc2328991135f25328a1e32..6f9e36ca5727f234ab69869b608d47398df3cbbe 100644 GIT binary patch delta 1314 zcmZn=|HMBbpx)HLBFWMq$-+3*%+ky#IVH*5(A+fHBF)&+*dR5@*wiS=!Z0}{*@T^e zfuSfhCpED+l?})&Gte{EGhoYN0s-X ziXBv~##a5m3DGP|1sSHrq}DqtOuQ`Bz`<~tq2ShG20`h&$IeX-JdkAmpF>A5R5Vxf z(kzc-lXrC9sXew}F`KB-#IMm#$rNT-b4E%7)ojnq%h7-SW9v;LsZ9dbao9 zu4ex~`#9ye)Birtr&nKHKY3}%BKZT?^=HTL?ofQSB}9kW)ahPn$LHc4lZARs{Y$?- zSJKKdI4K(a_>RNo4BNFK_Ilm%dnYiy^75Z#^77~}`wd^dR zua(snoj;Swxb6+d;z<`zG@bnaQANN{!$;t6y&Ovrqto1JU8M`$RFk-6CahV`Cm}8D z=pB4dGW)OD@4%Zvt2xVpuVowFc%SusiQBqMy0aqso`@T4JN+!4Wi`*T8CQ8W{*~;} zaZI$i;PF>srEsqYm&^1|^=GC@Ng6*p)^Wf2i;$DiMTRfs3non1*r;@P(Ua#jdlzxO z1bU29SF3)`56gW{b6$&x2b4r}B7Z zgnWhECQW*`m-C~7V{wW2X8HQ zPvU5uypmHK92%fd0%2IN!CWf>6k`I*fHXpk1F<+FKqL^LYv_dtGZaIk1!MptgFH0Q zfPzrgIjA}ohROC^Y&@`X0#t@fp3Y@tb{nd$4H|!Zf-nt<&|*dkU52}wZSsFE37KP{ o00V+V2*m)`%B#*k*_T^f24=Q5sC)y0_DXNDPG4uo00Ukw0BftEK>z>% literal 2944 zcmbUjTW}P|adkQg=|C?;@i17NvB46L)9D^Mon;~K>Fy-XM$rj953sbiyE?7dduVs> zlp{qj3c(WCWea1B<6sj<1;~iRrXs}{T(}Z~2 zMxOKfX)2`E>k4%GX&x*w1;z*~ zh+Hu6D4>bZ=%C-vN!frIX|u`LWTCta!&oe|!E4E9OpGPZlt(cpplRA@F&K>|w1~j+ zEG4pNfrwsb)aesLD!>5}&K&>aH1fi%%j75FG#En(%6!K+-z`T5t`{Z7j%Bm^a&I?= z)SqM!JG1gTR@)}q}*7^Of zwcVr1S&-?R_W81-YoEGT+Enwysh0TRxqz`6&9&rM#w)_(Z(sjt&$mp=lXvbLJaWFT z=Zyn9wwe34jU@25#f0bnGPkU3`7exIFjlzOLbphWxF2T7SFd^!ZIkvbz3xd5}z6vOjZb{0_~x z-70tB=)7?H;W<`WMd~HT$_7p*?3!oE zOxjx9Z5m>-Z<&ZiB?j}I={ZSRWf_~#ja+?Br_Cs+BKop5*BXAmJ<&mWuX79IinUi% zFE03g#?{W}=RekTuwS>;t{xqzSah*;=bt*7Tig0CK4`7E&spYg`Xc$?{=N^c-}89N()R`zy<77cab<~97anqa zaHBVU{^*GQ^x+fI%n#p;o3dBQFG5A^0c_R<_9{xhcAR2M_r+UNfIf-o|9t(sClEb5 zUQxT{w+mwnW^XzaYQ;`vD-2$PMJ>D;C(($`{u*j8wsNP?_ozetcUJ26Ae&)j&6{m zAy!24XR%YT7=iSrL$fntB})edh80#xloUpSs6Z5i%4m1x64FoRIc#mxV{Mfdo+OKk zfJGdJ=4&HKvcgqK`bZA2AA!RMQ;y1Ybe@Z^H&~;d(wbWiqkgKK6sK=~uCj4fN1d_7Ru>GBf~(d5XRXBWG|2E{zOafN6MMTH!}186U&v#u ziPqOuhP(zi4$>ybl1Ses2S!nJqsYimih8Qnyv|c6^ZoLy93}_3u0pY$M6}I~gBOcw z9#0#~n>_{;JH!`Jk7HUw7L1)Ar~;=Ha;j9$3zArGOxvG^ZxZ+iS-wFY2*~&hz{Uk# zNp|!g1^qsb;p+esB_T{p+8;@2excC<0GkW=v>}0waKW%xIDV223j!OECd_exreL9F zL!l+qveC(Hy2>opDVl3&6J?^v!Y1(*wqI8T5JQ`8fF7D`*4t!SZS%&WU!j7 z`4)rKyj;sr5+xg^?!bn{K}^s^%w-r+z!fN0luHn*O*A8TVL)hWP<#Xi_(O1%m*Y7p z`j8eP#cCKx_X!ihwgCKAnz_(J+9rw@SAjN?H$D*k=SRBDrWdO@i;YKAt)?)8K?75f$JQbnA z^5|$4NJ43iV6wu~$}|zhPXbyXj_5<)0jP*XjGa;@2z05&f5l?oG>!Zq0P`PMArp_2 zAEemZ^OFx#%3Qq7Vm#7#9QOfDMHd)B{4h#jfbH1JyBzhFB!zSTWX{x{WQBviu?X(! rBn@K@r7*@gnreKW&dHpVmoVo6%u%7^Ll86V7#7HB+uhrV|K0xu@ZdEI