diff --git a/controller/controller_tool/CMakeLists.txt b/controller/controller_tool/CMakeLists.txt index 59b6b73a9..31b5f3af4 100644 --- a/controller/controller_tool/CMakeLists.txt +++ b/controller/controller_tool/CMakeLists.txt @@ -52,8 +52,17 @@ if (BUILD_DDSRECORDER_CONTROLLER) ############################################################################### # Build and install types ############################################################################### - add_subdirectory(ddstypes/DdsRecorderCommand) - add_subdirectory(ddstypes/DdsRecorderStatus) + + # 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) ############################################################################### # Install Tool diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/CMakeLists.txt b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/CMakeLists.txt new file mode 100644 index 000000000..765948b4c --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/CMakeLists.txt @@ -0,0 +1,112 @@ + +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 new file mode 100644 index 000000000..5a176add0 --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.cxx @@ -0,0 +1,234 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..51dcd1769 --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.h @@ -0,0 +1,241 @@ +// 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 new file mode 100644 index 000000000..6f612586e --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.i @@ -0,0 +1,99 @@ +// 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/DdsRecorderCommand/DdsRecorderCommand.idl b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.idl similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.idl rename to controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommand.idl diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx new file mode 100644 index 000000000..720747c92 --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..b10231ffc --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..463d59e4b --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i @@ -0,0 +1,30 @@ +// 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 new file mode 100644 index 000000000..ac4942397 --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/CMakeLists.txt @@ -0,0 +1,112 @@ + +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 new file mode 100644 index 000000000..17f5f32aa --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.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 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 new file mode 100644 index 000000000..ef7f75e20 --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.h @@ -0,0 +1,267 @@ +// 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 new file mode 100644 index 000000000..b00372401 --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.i @@ -0,0 +1,107 @@ +// 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/DdsRecorderStatus/DdsRecorderStatus.idl b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.idl similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.idl rename to controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatus.idl diff --git a/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx new file mode 100644 index 000000000..ce6ce75ae --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..a6a6d3ae3 --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..9577a3232 --- /dev/null +++ b/controller/controller_tool/ddstypes/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i @@ -0,0 +1,30 @@ +// 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/DdsRecorderCommand/CMakeLists.txt b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/CMakeLists.txt similarity index 99% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/CMakeLists.txt rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/CMakeLists.txt index 95749dc5f..e210a12e9 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/CMakeLists.txt +++ b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/CMakeLists.txt @@ -118,4 +118,3 @@ install(TARGETS ${PROJECT_NAME} 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/DdsRecorderCommand/DdsRecorderCommand.cxx b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.cxx similarity index 99% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.cxx rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.cxx index bdcfa67fa..4b67e14f1 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.cxx +++ b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.cxx @@ -13,7 +13,7 @@ // limitations under the License. /*! - * @file DdsRecorderCommand.cpp + * @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. diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.h b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.h similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.h rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.h diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.i b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.i similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommand.i rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.i diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.idl b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.idl similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.idl rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommand.idl diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx similarity index 99% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx index 4348a59db..fa2c15f39 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx +++ b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -13,7 +13,7 @@ // limitations under the License. /*! - * @file DdsRecorderCommandPubSubTypes.cpp + * @file DdsRecorderCommandPubSubTypes.cxx * This header file contains the implementation of the serialization functions. * * This file was generated by the tool fastddsgen. diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.i diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.cxx b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx similarity index 99% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.cxx rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx index 4b3bfeebb..41e51e300 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.cxx +++ b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx @@ -13,7 +13,7 @@ // limitations under the License. /*! - * @file DdsRecorderCommand.cpp + * @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. diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.h b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.h similarity index 99% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.h rename to controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.h index ae03d6c94..1da59383c 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.h +++ b/controller/controller_tool/ddstypes/v2/DdsRecorderCommand/DdsRecorderCommandv1.h @@ -13,7 +13,7 @@ // limitations under the License. /*! - * @file DdsRecorderCommand.h + * @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. diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/CMakeLists.txt b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/CMakeLists.txt similarity index 99% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/CMakeLists.txt rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/CMakeLists.txt index 36661fb64..13b7aa19f 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/CMakeLists.txt +++ b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/CMakeLists.txt @@ -118,4 +118,3 @@ install(TARGETS ${PROJECT_NAME} 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/DdsRecorderStatus/DdsRecorderStatus.cxx b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.cxx similarity index 99% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.cxx rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.cxx index bd04b23f2..6e32de2b6 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.cxx +++ b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.cxx @@ -13,7 +13,7 @@ // limitations under the License. /*! - * @file DdsRecorderStatus.cpp + * @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. diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.h b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.h similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.h rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.h diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.i b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.i similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatus.i rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.i diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.idl b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.idl similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.idl rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatus.idl diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx similarity index 99% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx index 7efd35fc1..5d7506b0b 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx +++ b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -13,7 +13,7 @@ // limitations under the License. /*! - * @file DdsRecorderStatusPubSubTypes.cpp + * @file DdsRecorderStatusPubSubTypes.cxx * This header file contains the implementation of the serialization functions. * * This file was generated by the tool fastddsgen. diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.i diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.cxx b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx similarity index 99% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.cxx rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx index 6bfb99a8c..8e94280a8 100644 --- a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.cxx +++ b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx @@ -13,7 +13,7 @@ // limitations under the License. /*! - * @file DdsRecorderStatus.cpp + * @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. diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.h b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.h similarity index 99% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.h rename to controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.h index 11acbbe91..6b6d9b6c5 100644 --- a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.h +++ b/controller/controller_tool/ddstypes/v2/DdsRecorderStatus/DdsRecorderStatusv1.h @@ -13,7 +13,7 @@ // limitations under the License. /*! - * @file DdsRecorderStatus.h + * @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. diff --git a/ddsrecorder/CMakeLists.txt b/ddsrecorder/CMakeLists.txt index ef257c170..2945d4e23 100644 --- a/ddsrecorder/CMakeLists.txt +++ b/ddsrecorder/CMakeLists.txt @@ -60,18 +60,28 @@ project( # - Configure log depending on LOG_INFO flag and CMake type configure_project_cpp() -# Compile C++ library +# 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" + ) + compile_tool( - "${PROJECT_SOURCE_DIR}/src/cpp" # Source directory + "${PROJECT_SOURCE_DIR}/src/cpp/" # Source directory + "${SOURCES_FILES}" ) -############################################################################### -# Test -############################################################################### -# Compile tests if CMake options requires it -compile_test_tool( - "${PROJECT_SOURCE_DIR}/test" # Test directory -) +compile_test_tool("${PROJECT_SOURCE_DIR}/test/") ############################################################################### # Packaging diff --git a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp index 3b41a14cd..a8f37d5d0 100644 --- a/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp +++ b/ddsrecorder/src/cpp/command_receiver/CommandReceiver.hpp @@ -35,10 +35,17 @@ #include #include -#include "types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h" -#include "types/DdsRecorderCommand/DdsRecorderCommandTypeObject.h" -#include "types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h" -#include "types/DdsRecorderStatus/DdsRecorderStatusTypeObject.h" +#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 namespace eprosima { namespace ddsrecorder { diff --git a/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.cxx b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.cxx new file mode 100644 index 000000000..7b0cc0ecf --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.cxx @@ -0,0 +1,234 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..51dcd1769 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.h @@ -0,0 +1,241 @@ +// 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 new file mode 100644 index 000000000..001fd4b2e --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommand.idl @@ -0,0 +1,5 @@ +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 new file mode 100644 index 000000000..2f92b59be --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..b10231ffc --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..9bea321d5 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx @@ -0,0 +1,255 @@ +// 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 new file mode 100644 index 000000000..7158aaa66 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderCommand/DdsRecorderCommandTypeObject.h @@ -0,0 +1,65 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..a8bf3c9f4 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.cxx @@ -0,0 +1,285 @@ +// 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 new file mode 100644 index 000000000..ef7f75e20 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.h @@ -0,0 +1,267 @@ +// 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 new file mode 100644 index 000000000..cee55f14f --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatus.idl @@ -0,0 +1,6 @@ +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 new file mode 100644 index 000000000..b89abb8f5 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..a6a6d3ae3 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..65fd9310c --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx @@ -0,0 +1,285 @@ +// 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 new file mode 100644 index 000000000..759aad885 --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v1/DdsRecorderStatus/DdsRecorderStatusTypeObject.h @@ -0,0 +1,65 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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/DdsRecorderCommand/DdsRecorderCommand.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.cxx similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.cxx rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.cxx diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.h similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommand.h rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.h diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.idl b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.idl new file mode 100644 index 000000000..001fd4b2e --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommand.idl @@ -0,0 +1,5 @@ +struct DdsRecorderCommand +{ + string command; + string args; +}; diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.hpp diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandCdrAux.ipp diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.cxx diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandPubSubTypes.h diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.cxx diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObject.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.h similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandTypeObject.h rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandTypeObject.h diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderCommand/DdsRecorderCommandv1.cxx rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.cxx diff --git a/controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.h similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderCommand/DdsRecorderCommandv1.h rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderCommand/DdsRecorderCommandv1.h diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.cxx similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.cxx rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.cxx diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.h similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatus.h rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.h diff --git a/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.idl b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.idl new file mode 100644 index 000000000..cee55f14f --- /dev/null +++ b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatus.idl @@ -0,0 +1,6 @@ +struct DdsRecorderStatus +{ + string previous; + string current; + string info; +}; diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.hpp diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusCdrAux.ipp diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.cxx diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusPubSubTypes.h diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.cxx diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.h similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusTypeObject.h rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusTypeObject.h diff --git a/ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.cxx b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx similarity index 100% rename from ddsrecorder/src/cpp/command_receiver/types/DdsRecorderStatus/DdsRecorderStatusv1.cxx rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.cxx diff --git a/controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.h b/ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.h similarity index 100% rename from controller/controller_tool/ddstypes/DdsRecorderStatus/DdsRecorderStatusv1.h rename to ddsrecorder/src/cpp/command_receiver/types/v2/DdsRecorderStatus/DdsRecorderStatusv1.h diff --git a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt index 63be9a945..10d52cc92 100644 --- a/ddsrecorder/test/blackbox/mcap/CMakeLists.txt +++ b/ddsrecorder/test/blackbox/mcap/CMakeLists.txt @@ -18,12 +18,27 @@ set(TEST_NAME McapFileCreationTest) +# 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_LIBRARY_SOURCES + "${PROJECT_SOURCE_DIR}/src/cpp/tool/*.cpp" + "${PROJECT_SOURCE_DIR}/src/cpp/user_interface/*.cpp" + "${PROJECT_SOURCE_DIR}/src/cpp/command_receiver/Command*.cpp" + "${PROJECT_SOURCE_DIR}/src/cpp/*/*/${DDS_TYPES_VERSION}/*/*.cxx" + ) + set(TEST_SOURCES McapFileCreationTest.cpp - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/hello_world/HelloWorld.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/hello_world/HelloWorldv1.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/${DDS_TYPES_VERSION}/hello_world/HelloWorld.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/${DDS_TYPES_VERSION}/hello_world/HelloWorldPubSubTypes.cxx + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/${DDS_TYPES_VERSION}/hello_world/HelloWorldTypeObject.cxx + $<$:${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/v2/hello_world/HelloWorldv1.cxx> ) set(TEST_LIST @@ -59,8 +74,8 @@ set(TEST_NEEDED_SOURCES ) set(TEST_EXTRA_HEADERS - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/hello_world - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types) + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/${DDS_TYPES_VERSION}/hello_world + ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/types/${DDS_TYPES_VERSION}) add_blackbox_executable( "${TEST_NAME}" @@ -68,4 +83,5 @@ add_blackbox_executable( "${TEST_LIST}" "${TEST_NEEDED_SOURCES}" "${TEST_EXTRA_HEADERS}" + "${TEST_LIBRARY_SOURCES}" ) diff --git a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp index b0c327ce8..6f80d9119 100644 --- a/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp +++ b/ddsrecorder/test/blackbox/mcap/McapFileCreationTest.cpp @@ -33,8 +33,13 @@ #include -#include "types/hello_world/HelloWorldTypeObject.h" -#include "types/hello_world/HelloWorldPubSubTypes.h" +#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 + #include "types/v1/hello_world/HelloWorldTypeObject.h" + #include "types/v1/hello_world/HelloWorldPubSubTypes.h" +#else + #include "types/v2/hello_world/HelloWorldTypeObject.h" + #include "types/v2/hello_world/HelloWorldPubSubTypes.h" +#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13 #include #include diff --git a/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorld.cxx b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorld.cxx new file mode 100644 index 000000000..08543a477 --- /dev/null +++ b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorld.cxx @@ -0,0 +1,239 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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/blackbox/mcap/types/v1/hello_world/HelloWorld.h b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorld.h new file mode 100644 index 000000000..cb7885b35 --- /dev/null +++ b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorld.h @@ -0,0 +1,234 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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/blackbox/mcap/types/hello_world/HelloWorld.idl b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorld.idl similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.idl rename to ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorld.idl diff --git a/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorldPubSubTypes.cxx b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorldPubSubTypes.cxx new file mode 100644 index 000000000..1159fb042 --- /dev/null +++ b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorldPubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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/blackbox/mcap/types/v1/hello_world/HelloWorldPubSubTypes.h b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorldPubSubTypes.h new file mode 100644 index 000000000..3ec5efa14 --- /dev/null +++ b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorldPubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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/blackbox/mcap/types/v1/hello_world/HelloWorldTypeObject.cxx b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorldTypeObject.cxx new file mode 100644 index 000000000..e4cd82ed3 --- /dev/null +++ b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorldTypeObject.cxx @@ -0,0 +1,248 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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; } +#endif + +#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/blackbox/mcap/types/v1/hello_world/HelloWorldTypeObject.h b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorldTypeObject.h new file mode 100644 index 000000000..37639c165 --- /dev/null +++ b/ddsrecorder/test/blackbox/mcap/types/v1/hello_world/HelloWorldTypeObject.h @@ -0,0 +1,65 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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/blackbox/mcap/types/hello_world/HelloWorld.cxx b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorld.cxx similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.cxx rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorld.cxx diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.h b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorld.h similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorld.h rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorld.h diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorld.idl b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorld.idl similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorld.idl rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorld.idl diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.hpp b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldCdrAux.hpp similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.hpp rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldCdrAux.hpp diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.ipp b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldCdrAux.ipp similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldCdrAux.ipp rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldCdrAux.ipp diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.cxx b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldPubSubTypes.cxx similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.cxx rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldPubSubTypes.cxx diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.h b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldPubSubTypes.h similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldPubSubTypes.h rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldPubSubTypes.h diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.cxx b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldTypeObject.cxx similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.cxx rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldTypeObject.cxx diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.h b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldTypeObject.h similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldTypeObject.h rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldTypeObject.h diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.cxx b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldv1.cxx similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.cxx rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldv1.cxx diff --git a/ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.h b/ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldv1.h similarity index 100% rename from ddsrecorder/test/blackbox/mcap/types/hello_world/HelloWorldv1.h rename to ddsrecorder/test/blackbox/mcap/types/v2/hello_world/HelloWorldv1.h diff --git a/ddsrecorder_participants/CMakeLists.txt b/ddsrecorder_participants/CMakeLists.txt index 035b6ed38..a43c8bb58 100644 --- a/ddsrecorder_participants/CMakeLists.txt +++ b/ddsrecorder_participants/CMakeLists.txt @@ -60,10 +60,34 @@ 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/replayer/*.cpp" + "${PROJECT_SOURCE_DIR}/src/cpp/recorder/**/*.cpp" + "${PROJECT_SOURCE_DIR}/src/cpp/**/**${DDS_TYPES_VERSION}*.cpp" + ) + +file( + GLOB_RECURSE HEADERS_FILES + ${PROJECT_SOURCE_DIR}/include/constants.hpp + ${PROJECT_SOURCE_DIR}/include/replayer/*.hpp + ${PROJECT_SOURCE_DIR}/include/recorder/**/*.hpp + ${PROJECT_SOURCE_DIR}/include/**/**${DDS_TYPES_VERSION}*.hpp + ) + # Compile C++ library compile_library( "${PROJECT_SOURCE_DIR}/src/cpp" # Source directory "${PROJECT_SOURCE_DIR}/include" # Include directory + "${SOURCES_FILES}" + "${HEADERS_FILES}" ) ############################################################################### diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/v1/DynamicTypesCollection.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/v1/DynamicTypesCollection.hpp new file mode 100644 index 000000000..457ce1788 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/v1/DynamicTypesCollection.hpp @@ -0,0 +1,414 @@ +// 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/v1/DynamicTypesCollectionPubSubTypes.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/v1/DynamicTypesCollectionPubSubTypes.hpp new file mode 100644 index 000000000..9bc634847 --- /dev/null +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/v1/DynamicTypesCollectionPubSubTypes.hpp @@ -0,0 +1,174 @@ +// 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/DynamicTypesCollection.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/v2/DynamicTypesCollection.hpp similarity index 100% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollection.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/v2/DynamicTypesCollection.hpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionPubSubTypes.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/v2/DynamicTypesCollectionPubSubTypes.hpp similarity index 98% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionPubSubTypes.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/v2/DynamicTypesCollectionPubSubTypes.hpp index b4e3aaee5..29d6d628e 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionPubSubTypes.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/v2/DynamicTypesCollectionPubSubTypes.hpp @@ -29,7 +29,7 @@ #include #include -#include +#include #if !defined(GEN_API_VER) || (GEN_API_VER != 2) @@ -227,4 +227,3 @@ class DynamicTypesCollectionPubSubType : public eprosima::fastdds::dds::TopicDat } // namespace eprosima #endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTION_PUBSUBTYPES_H_ - diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionv1.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/common/types/v2/DynamicTypesCollectionv1.hpp similarity index 100% rename from ddsrecorder_participants/include/ddsrecorder_participants/common/types/DynamicTypesCollectionv1.hpp rename to ddsrecorder_participants/include/ddsrecorder_participants/common/types/v2/DynamicTypesCollectionv1.hpp diff --git a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp index c1bc87f83..374f66e95 100644 --- a/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp +++ b/ddsrecorder_participants/include/ddsrecorder_participants/recorder/mcap/McapHandler.hpp @@ -38,7 +38,12 @@ #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 { diff --git a/ddsrecorder_participants/src/cpp/common/types/v1/DynamicTypesCollection.cpp b/ddsrecorder_participants/src/cpp/common/types/v1/DynamicTypesCollection.cpp new file mode 100644 index 000000000..80890be01 --- /dev/null +++ b/ddsrecorder_participants/src/cpp/common/types/v1/DynamicTypesCollection.cpp @@ -0,0 +1,422 @@ +// 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/v1/DynamicTypesCollectionPubSubTypes.cpp b/ddsrecorder_participants/src/cpp/common/types/v1/DynamicTypesCollectionPubSubTypes.cpp new file mode 100644 index 000000000..481f0c85f --- /dev/null +++ b/ddsrecorder_participants/src/cpp/common/types/v1/DynamicTypesCollectionPubSubTypes.cpp @@ -0,0 +1,319 @@ +// 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/DynamicTypesCollection.cpp b/ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollection.cpp similarity index 98% rename from ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollection.cpp rename to ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollection.cpp index 0ccdb83b5..a1239bcc1 100644 --- a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollection.cpp +++ b/ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollection.cpp @@ -26,7 +26,7 @@ char dummy; } // namespace #endif // _WIN32 -#include +#include #if FASTCDR_VERSION_MAJOR > 1 diff --git a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollection.idl b/ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollection.idl similarity index 100% rename from ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollection.idl rename to ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollection.idl diff --git a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.hpp b/ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionCdrAux.hpp similarity index 96% rename from ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.hpp rename to ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionCdrAux.hpp index 94e976e6a..911336610 100644 --- a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.hpp +++ b/ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionCdrAux.hpp @@ -22,7 +22,7 @@ #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_key_cdr_typesize {0UL}; @@ -59,4 +59,3 @@ eProsima_user_DllExport void serialize_key( } // namespace eprosima #endif // _FAST_DDS_GENERATED_EPROSIMA_DDSRECORDER_PARTICIPANTS_DYNAMICTYPESCOLLECTIONCDRAUX_HPP_ - diff --git a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.ipp b/ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionCdrAux.ipp similarity index 100% rename from ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionCdrAux.ipp rename to ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionCdrAux.ipp diff --git a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionPubSubTypes.cpp b/ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionPubSubTypes.cpp similarity index 99% rename from ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionPubSubTypes.cpp rename to ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionPubSubTypes.cpp index c56adf3c7..a41f3154f 100644 --- a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionPubSubTypes.cpp +++ b/ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionPubSubTypes.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include "DynamicTypesCollectionCdrAux.hpp" using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; @@ -419,4 +419,3 @@ bool DynamicTypesCollectionPubSubType::getKey( } //End of namespace eprosima - diff --git a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionv1.cpp b/ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionv1.cpp similarity index 99% rename from ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionv1.cpp rename to ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionv1.cpp index 6f8559a41..9fc802f73 100644 --- a/ddsrecorder_participants/src/cpp/common/types/DynamicTypesCollectionv1.cpp +++ b/ddsrecorder_participants/src/cpp/common/types/v2/DynamicTypesCollectionv1.cpp @@ -26,7 +26,7 @@ char dummy; } // namespace #endif // _WIN32 -#include +#include #if FASTCDR_VERSION_MAJOR == 1 diff --git a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp index 7e9eb16a4..caca39dbe 100644 --- a/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp +++ b/ddsrecorder_participants/src/cpp/recorder/mcap/McapHandler.cpp @@ -31,15 +31,24 @@ #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 @@ -1118,8 +1127,13 @@ std::string McapHandler::serialize_type_identifier_( eprosima::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; // Serialize @@ -1171,8 +1185,12 @@ std::string McapHandler::serialize_type_object_( eprosima::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; // Serialize diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp index 43c8f3dff..f29d60f90 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.cpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.cpp @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -34,10 +33,24 @@ #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 +#if FASTRTPS_VERSION_MINOR < 13 + #include + #include + #include +#else + #include +#endif // if FASTRTPS_VERSION_MINOR < 13 + #include "DdsReplayer.hpp" namespace eprosima { @@ -488,7 +501,11 @@ fastrtps::types::TypeIdentifier DdsReplayer::deserialize_type_identifier_( fastrtps::rtps::CDRMessage::readData(cdr_message, payload.data, 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 payload.encapsulation = deser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize @@ -526,7 +543,11 @@ fastrtps::types::TypeObject DdsReplayer::deserialize_type_object_( fastrtps::rtps::CDRMessage::readData(cdr_message, payload.data, 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 payload.encapsulation = deser.endianness() == fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; // Deserialize diff --git a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp index a7c84eb06..efc06a6d0 100644 --- a/ddsreplayer/src/cpp/tool/DdsReplayer.hpp +++ b/ddsreplayer/src/cpp/tool/DdsReplayer.hpp @@ -33,7 +33,13 @@ #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 + + #include #include diff --git a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt index 041e99cab..b7eabc386 100644 --- a/ddsreplayer/test/blackbox/mcap/CMakeLists.txt +++ b/ddsreplayer/test/blackbox/mcap/CMakeLists.txt @@ -18,13 +18,20 @@ 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/hello_world/HelloWorld.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx - ${PROJECT_SOURCE_DIR}/test/blackbox/mcap/dds/HelloWorldSubscriber.cpp - ) + 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/HelloWorldSubscriber.cpp +) set(TEST_LIST trivial diff --git a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h b/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h index f01da79e4..ecf4dc2f7 100644 --- a/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h +++ b/ddsreplayer/test/blackbox/mcap/dds/HelloWorldSubscriber.h @@ -24,7 +24,11 @@ #include #include -#include "types/hello_world/HelloWorldPubSubTypes.h" +#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 struct DataToCheck { 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 new file mode 100644 index 000000000..6a3b213cd --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.cxx @@ -0,0 +1,236 @@ +// 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 new file mode 100644 index 000000000..cb7885b35 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.h @@ -0,0 +1,234 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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/hello_world/HelloWorld.idl b/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.idl similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.idl rename to ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorld.idl 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 new file mode 100644 index 000000000..1159fb042 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorldPubSubTypes.cxx @@ -0,0 +1,169 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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 new file mode 100644 index 000000000..3ec5efa14 --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/v1/hello_world/HelloWorldPubSubTypes.h @@ -0,0 +1,101 @@ +// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/*! + * @file 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/hello_world/HelloWorld.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.cxx similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.cxx rename to ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.cxx diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.h b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.h similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorld.h rename to ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.h diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.idl b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.idl new file mode 100644 index 000000000..0fd2c355a --- /dev/null +++ b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorld.idl @@ -0,0 +1,5 @@ +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/v2/hello_world/HelloWorldCdrAux.hpp similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.hpp rename to ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldCdrAux.hpp diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldCdrAux.ipp similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldCdrAux.ipp rename to ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldCdrAux.ipp diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldPubSubTypes.cxx similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.cxx rename to ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldPubSubTypes.cxx diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldPubSubTypes.h similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldPubSubTypes.h rename to ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldPubSubTypes.h diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.cxx b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.cxx similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.cxx rename to ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.cxx diff --git a/ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.h b/ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.h similarity index 100% rename from ddsreplayer/test/blackbox/mcap/dds/types/hello_world/HelloWorldv1.h rename to ddsreplayer/test/blackbox/mcap/dds/types/v2/hello_world/HelloWorldv1.h diff --git a/docs/rst/tutorials/dynamic_types.rst b/docs/rst/tutorials/dynamic_types.rst index a0277d721..e6db0fbd7 100644 --- a/docs/rst/tutorials/dynamic_types.rst +++ b/docs/rst/tutorials/dynamic_types.rst @@ -70,11 +70,11 @@ At the moment, there are two data types that can be used: * `HelloWorld.idl `_ -.. literalinclude:: ../../../resources/dds/TypeLookupService/types/hello_world/HelloWorld.idl +.. literalinclude:: ../../../resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.idl * `Complete.idl `_ -.. literalinclude:: ../../../resources/dds/TypeLookupService/types/complete/Complete.idl +.. literalinclude:: ../../../resources/dds/TypeLookupService/types/v2/complete/Complete.idl Examining the code ================== diff --git a/resources/dds/TypeLookupService/types/complete/Complete.cxx b/resources/dds/TypeLookupService/types/v2/complete/Complete.cxx similarity index 100% rename from resources/dds/TypeLookupService/types/complete/Complete.cxx rename to resources/dds/TypeLookupService/types/v2/complete/Complete.cxx diff --git a/resources/dds/TypeLookupService/types/complete/Complete.h b/resources/dds/TypeLookupService/types/v2/complete/Complete.h similarity index 100% rename from resources/dds/TypeLookupService/types/complete/Complete.h rename to resources/dds/TypeLookupService/types/v2/complete/Complete.h diff --git a/resources/dds/TypeLookupService/types/complete/Complete.idl b/resources/dds/TypeLookupService/types/v2/complete/Complete.idl similarity index 100% rename from resources/dds/TypeLookupService/types/complete/Complete.idl rename to resources/dds/TypeLookupService/types/v2/complete/Complete.idl diff --git a/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp b/resources/dds/TypeLookupService/types/v2/complete/CompleteCdrAux.hpp similarity index 100% rename from resources/dds/TypeLookupService/types/complete/CompleteCdrAux.hpp rename to resources/dds/TypeLookupService/types/v2/complete/CompleteCdrAux.hpp diff --git a/resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp b/resources/dds/TypeLookupService/types/v2/complete/CompleteCdrAux.ipp similarity index 100% rename from resources/dds/TypeLookupService/types/complete/CompleteCdrAux.ipp rename to resources/dds/TypeLookupService/types/v2/complete/CompleteCdrAux.ipp diff --git a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx b/resources/dds/TypeLookupService/types/v2/complete/CompletePubSubTypes.cxx similarity index 100% rename from resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.cxx rename to resources/dds/TypeLookupService/types/v2/complete/CompletePubSubTypes.cxx diff --git a/resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h b/resources/dds/TypeLookupService/types/v2/complete/CompletePubSubTypes.h similarity index 100% rename from resources/dds/TypeLookupService/types/complete/CompletePubSubTypes.h rename to resources/dds/TypeLookupService/types/v2/complete/CompletePubSubTypes.h diff --git a/resources/dds/TypeLookupService/types/complete/CompleteTypeObject.cxx b/resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.cxx similarity index 100% rename from resources/dds/TypeLookupService/types/complete/CompleteTypeObject.cxx rename to resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.cxx diff --git a/resources/dds/TypeLookupService/types/complete/CompleteTypeObject.h b/resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.h similarity index 100% rename from resources/dds/TypeLookupService/types/complete/CompleteTypeObject.h rename to resources/dds/TypeLookupService/types/v2/complete/CompleteTypeObject.h diff --git a/resources/dds/TypeLookupService/types/complete/Completev1.cxx b/resources/dds/TypeLookupService/types/v2/complete/Completev1.cxx similarity index 100% rename from resources/dds/TypeLookupService/types/complete/Completev1.cxx rename to resources/dds/TypeLookupService/types/v2/complete/Completev1.cxx diff --git a/resources/dds/TypeLookupService/types/complete/Completev1.h b/resources/dds/TypeLookupService/types/v2/complete/Completev1.h similarity index 100% rename from resources/dds/TypeLookupService/types/complete/Completev1.h rename to resources/dds/TypeLookupService/types/v2/complete/Completev1.h diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorld.cxx b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.cxx similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorld.cxx rename to resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.cxx diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorld.h b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.h similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorld.h rename to resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.h diff --git a/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.idl b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.idl new file mode 100644 index 000000000..6bf0e2fb8 --- /dev/null +++ b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorld.idl @@ -0,0 +1,5 @@ +struct HelloWorld +{ + unsigned long index; + string message; +}; diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldCdrAux.hpp similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.hpp rename to resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldCdrAux.hpp diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldCdrAux.ipp similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorldCdrAux.ipp rename to resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldCdrAux.ipp diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldPubSubTypes.cxx similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.cxx rename to resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldPubSubTypes.cxx diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldPubSubTypes.h similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorldPubSubTypes.h rename to resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldPubSubTypes.h diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.cxx b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.cxx similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.cxx rename to resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.cxx diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.h b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.h similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorldTypeObject.h rename to resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldTypeObject.h diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.cxx b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.cxx similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.cxx rename to resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.cxx diff --git a/resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.h b/resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.h similarity index 100% rename from resources/dds/TypeLookupService/types/hello_world/HelloWorldv1.h rename to resources/dds/TypeLookupService/types/v2/hello_world/HelloWorldv1.h