diff --git a/.github/actions/fetch-shapesdemo-repos/action.yml b/.github/actions/fetch-shapesdemo-repos/action.yml new file mode 100644 index 0000000..26f87c9 --- /dev/null +++ b/.github/actions/fetch-shapesdemo-repos/action.yml @@ -0,0 +1,23 @@ +name: 'fetch-shapesdemo-repos' +description: 'Fetch Shapes Demo dependencies' +inputs: + foonathan-memory-vendor-branch: + description: 'foonathan_memory_vendor branch to be used' + required: true + fastcdr-branch: + description: 'Fast-CDR branch to be used' + required: true + fastdds-branch: + description: 'Fast-DDS branch to be used' + required: true +runs: + using: "composite" + steps: + - id: fetch-shapesdemo-repos + shell: bash + run: | + cd src + git clone https://github.com/eProsima/foonathan_memory_vendor.git --branch ${{ inputs.foonathan-memory-vendor-branch }} + git clone https://github.com/eProsima/Fast-CDR.git --branch ${{ inputs.fastcdr-branch }} + git clone https://github.com/eProsima/Fast-DDS.git --branch ${{ inputs.fastdds-branch }} + cd .. diff --git a/.github/workflows/build.meta b/.github/workflows/build.meta new file mode 100644 index 0000000..5acb71d --- /dev/null +++ b/.github/workflows/build.meta @@ -0,0 +1,12 @@ +{ + "names": + { + "fastrtps" : + { + "cmake-args": [ + "-DNO_TLS=ON", + "-DSECURITY=OFF" + ] + } + } +} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..672b559 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,151 @@ +name: build + +on: + workflow_dispatch: + inputs: + foonathan_memory_vendor_branch: + description: 'foonathan_memory_vendor branch to be used' + required: false + default: 'master' + fastcdr_versions: + description: 'Fast-CDR branches to be used' + required: false + default: '["1.1.x", "master"]' + fastdds_branch: + description: 'Fast-DDS branch to be used' + required: false + default: 'master' + pull_request: + push: + branches: + - master + schedule: + - cron: '0 0 * * *' + +jobs: + windows-build-test: + runs-on: windows-2019 + strategy: + matrix: + fastcdr_version: ${{ fromJson(github.event.inputs.fastcdr_versions || '["1.1.x", "master"]') }} + + env: + CXXFLAGS: /MP + + steps: + + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: '5.15.2' + arch: 'win64_msvc2019_64' + cache: true + + - name: Install Asio and TinyXML2 + shell: pwsh + run: | + mkdir "$pwdpath/choco_packages" + Invoke-WebRequest -Uri https://github.com/ros2/choco-packages/releases/download/2020-02-24/asio.1.12.1.nupkg -OutFile "$pwdpath/choco_packages/asio.1.12.1.nupkg" + Invoke-WebRequest -Uri https://github.com/ros2/choco-packages/releases/download/2020-02-24/tinyxml2.6.0.0.nupkg -OutFile "$pwdpath/choco_packages/tinyxml2.6.0.0.nupkg" + choco install -y -s "$pwdpath/choco_packages" asio tinyxml2 + Set-Item -Force -Path "env:PATH" -Value "C:\ProgramData\chocolatey\lib\asio;C:\ProgramData\chocolatey\lib\tinyxml2;C:\ProgramData\chocolatey\lib\tinyxml2\lib;$env:PATH" + echo "PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + + - uses: eProsima/eProsima-CI/multiplatform/install_colcon@v0 + + - uses: eProsima/eProsima-CI/external/checkout@v0 + with: + path: src/shapesdemo + + - uses: ./src/shapesdemo/.github/actions/fetch-shapesdemo-repos + with: + foonathan-memory-vendor-branch: ${{ github.event.inputs.foonathan_memory_vendor_branch || 'master' }} + fastcdr-branch: ${{ matrix.fastcdr_version }} + fastdds-branch: ${{ github.event.inputs.fastdds_branch || 'master' }} + + - uses: eProsima/eProsima-CI/external/get-cmake@v0 + with: + cmakeVersion: 3.22.6 + + - name: Setting ninja + id: ninja + if: github.event.schedule == '' + shell: pwsh + run: | + echo "cmake_generator=ninja" >> $Env:GITHUB_OUTPUT + + - name: Setup ccache + uses: eProsima/eProsima-CI/external/setup-ccache-action@v0 + with: + windows_compile_environment: msvc + + - name: Build workspace + shell: pwsh + run: | + $installpath = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise" + $modulepath = "$installpath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Import-Module $modulepath + Enter-VsDevShell -SetDefaultWindowTitle -InstallPath $installpath ` + -StartInPath (pwd) -DevCmdArguments '/arch=x64 /host_arch=x64'; + cmake --version + colcon build --executor parallel --event-handlers console_direct+ desktop_notification- ` + --metas ./src/shapesdemo/.github/workflows/build.meta ` + --mixin rel-with-deb-info ccache ${{ steps.ninja.outputs.cmake_generator }} + + - name: Upload Logs + uses: actions/upload-artifact@v1 + with: + name: colcon-logs-windows + path: log/ + if: always() + + ubuntu-build-test: + runs-on: ubuntu-22.04 + strategy: + matrix: + fastcdr_version: ${{ fromJson(github.event.inputs.fastcdr_versions || '["1.1.x", "master"]') }} + + steps: + - uses: eProsima/eProsima-CI/external/checkout@v0 + with: + path: src/shapesdemo + + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: '5.15.2' + + - name: Install apt packages + uses: eProsima/eProsima-CI/ubuntu/install_apt_packages@v0 + with: + packages: libasio-dev libtinyxml2-dev + + - uses: eProsima/eProsima-CI/multiplatform/install_colcon@v0 + + - uses: ./src/shapesdemo/.github/actions/fetch-shapesdemo-repos + with: + foonathan-memory-vendor-branch: ${{ github.event.inputs.foonathan_memory_vendor_branch || 'master' }} + fastcdr-branch: ${{ matrix.fastcdr_version }} + fastdds-branch: ${{ github.event.inputs.fastdds_branch || 'master' }} + + - uses: eProsima/eProsima-CI/external/get-cmake@v0 + with: + cmakeVersion: 3.22.6 + + - name: Setup ccache + uses: eProsima/eProsima-CI/external/setup-ccache-action@v0 + + - name: Build workspace + run: | + cmake --version + colcon build \ + --event-handlers=console_direct+ \ + --metas ./src/shapesdemo/.github/workflows/build.meta \ + --mixin rel-with-deb-info ccache + + - name: Upload Logs + uses: actions/upload-artifact@v1 + with: + name: colcon-logs-ubuntu + path: log/ + if: always() diff --git a/CMakeLists.txt b/CMakeLists.txt index c317d2b..be6f5b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,10 +123,9 @@ option(EPROSIMA_BUILD "Activate internal building" OFF) ############################################################################### # Load external eProsima projects. ############################################################################### -set(FASTDDS_MIN_VERSION "2.12.0") -set(FASTCDR_MIN_VERSION "2.0.0") +set(FASTDDS_MIN_VERSION "2.12.1") -find_package(fastcdr ${FASTCDR_MIN_VERSION} REQUIRED) +find_package(fastcdr REQUIRED) find_package(fastrtps ${FASTDDS_MIN_VERSION} REQUIRED) # If ROS environment is not set, disable ROS features. If there's no TypeSupport for the ROS 2 type, disable them as well. @@ -200,6 +199,7 @@ set( SHAPESDEMO_SOURCES src/shapesdemo/ShapesDemo.cpp src/shapesdemo/ShapeSubscriber.cpp types/Shape.cxx + types/Shapev1.cxx types/ShapePubSubTypes.cxx types/ShapeTypeObject.cxx ) @@ -207,6 +207,7 @@ set( SHAPESDEMO_SOURCES if(BUILD_ROS_COMPONENTS) list( APPEND SHAPESDEMO_SOURCES types/KeylessShapeType.cxx + types/KeylessShapeTypev1.cxx types/KeylessShapeTypePubSubTypes.cxx types/KeylessShapeTypeTypeObject.cxx ) diff --git a/ShapesDemo.pro b/ShapesDemo.pro index 6d0cfe4..fb0dce4 100644 --- a/ShapesDemo.pro +++ b/ShapesDemo.pro @@ -98,6 +98,7 @@ SOURCES += \ src/qt/ContentFilterSelector.cpp \ src/shapesdemo/ShapeHistory.cpp \ src/shapesdemo/Shape.cxx \ + src/shapesdemo/Shapev1.cxx \ src/shapesdemo/ShapePubSubTypes.cxx diff --git a/shapes-demo-ros2.repos b/shapes-demo-ros2.repos index b03371d..06267b6 100644 --- a/shapes-demo-ros2.repos +++ b/shapes-demo-ros2.repos @@ -6,11 +6,11 @@ repositories: fastcdr: type: git url: https://github.com/eProsima/Fast-CDR.git - version: v2.0.0 + version: v2.1.0 fastdds: type: git url: https://github.com/eProsima/Fast-DDS.git - version: v2.12.0 + version: v2.12.1 shapes-demo-typesupport: type: git url: https://github.com/eProsima/ShapesDemo-TypeSupport.git @@ -18,4 +18,4 @@ repositories: shapes-demo: type: git url: https://github.com/eProsima/ShapesDemo.git - version: v2.12.0 + version: v2.12.1 diff --git a/shapes-demo.repos b/shapes-demo.repos index 06ec6ff..836c946 100644 --- a/shapes-demo.repos +++ b/shapes-demo.repos @@ -6,12 +6,12 @@ repositories: fastcdr: type: git url: https://github.com/eProsima/Fast-CDR.git - version: v2.0.0 + version: v2.1.0 fastdds: type: git url: https://github.com/eProsima/Fast-DDS.git - version: v2.12.0 + version: v2.12.1 shapes-demo: type: git url: https://github.com/eProsima/ShapesDemo.git - version: v2.12.0 + version: v2.12.1 diff --git a/types/KeylessShapeType.cxx b/types/KeylessShapeType.cxx index 4f85df4..f8e7708 100644 --- a/types/KeylessShapeType.cxx +++ b/types/KeylessShapeType.cxx @@ -27,7 +27,8 @@ char dummy; #endif // _WIN32 #include "KeylessShapeType.h" -#include "KeylessShapeTypeTypeObject.h" + +#if FASTCDR_VERSION_MAJOR > 1 #include <fastcdr/Cdr.h> @@ -38,18 +39,21 @@ using namespace eprosima::fastcdr::exception; #include <utility> -shapes_demo_typesupport::idl::KeylessShapeType::KeylessShapeType() -{ +namespace shapes_demo_typesupport { + +namespace idl { - // Just to register all known types - registerKeylessShapeTypeTypes(); + + +KeylessShapeType::KeylessShapeType() +{ } -shapes_demo_typesupport::idl::KeylessShapeType::~KeylessShapeType() +KeylessShapeType::~KeylessShapeType() { } -shapes_demo_typesupport::idl::KeylessShapeType::KeylessShapeType( +KeylessShapeType::KeylessShapeType( const KeylessShapeType& x) { m_color = x.m_color; @@ -58,7 +62,7 @@ shapes_demo_typesupport::idl::KeylessShapeType::KeylessShapeType( m_shapesize = x.m_shapesize; } -shapes_demo_typesupport::idl::KeylessShapeType::KeylessShapeType( +KeylessShapeType::KeylessShapeType( KeylessShapeType&& x) noexcept { m_color = std::move(x.m_color); @@ -67,7 +71,7 @@ shapes_demo_typesupport::idl::KeylessShapeType::KeylessShapeType( m_shapesize = x.m_shapesize; } -shapes_demo_typesupport::idl::KeylessShapeType& shapes_demo_typesupport::idl::KeylessShapeType::operator =( +KeylessShapeType& KeylessShapeType::operator =( const KeylessShapeType& x) { @@ -75,11 +79,10 @@ shapes_demo_typesupport::idl::KeylessShapeType& shapes_demo_typesupport::idl::Ke m_x = x.m_x; m_y = x.m_y; m_shapesize = x.m_shapesize; - return *this; } -shapes_demo_typesupport::idl::KeylessShapeType& shapes_demo_typesupport::idl::KeylessShapeType::operator =( +KeylessShapeType& KeylessShapeType::operator =( KeylessShapeType&& x) noexcept { @@ -87,11 +90,10 @@ shapes_demo_typesupport::idl::KeylessShapeType& shapes_demo_typesupport::idl::Ke m_x = x.m_x; m_y = x.m_y; m_shapesize = x.m_shapesize; - return *this; } -bool shapes_demo_typesupport::idl::KeylessShapeType::operator ==( +bool KeylessShapeType::operator ==( const KeylessShapeType& x) const { return (m_color == x.m_color && @@ -100,7 +102,7 @@ bool shapes_demo_typesupport::idl::KeylessShapeType::operator ==( m_shapesize == x.m_shapesize); } -bool shapes_demo_typesupport::idl::KeylessShapeType::operator !=( +bool KeylessShapeType::operator !=( const KeylessShapeType& x) const { return !(*this == x); @@ -110,7 +112,7 @@ bool shapes_demo_typesupport::idl::KeylessShapeType::operator !=( * @brief This function copies the value in member color * @param _color New value to be copied in member color */ -void shapes_demo_typesupport::idl::KeylessShapeType::color( +void KeylessShapeType::color( const std::string& _color) { m_color = _color; @@ -120,7 +122,7 @@ void shapes_demo_typesupport::idl::KeylessShapeType::color( * @brief This function moves the value in member color * @param _color New value to be moved in member color */ -void shapes_demo_typesupport::idl::KeylessShapeType::color( +void KeylessShapeType::color( std::string&& _color) { m_color = std::move(_color); @@ -130,7 +132,7 @@ void shapes_demo_typesupport::idl::KeylessShapeType::color( * @brief This function returns a constant reference to member color * @return Constant reference to member color */ -const std::string& shapes_demo_typesupport::idl::KeylessShapeType::color() const +const std::string& KeylessShapeType::color() const { return m_color; } @@ -139,7 +141,7 @@ const std::string& shapes_demo_typesupport::idl::KeylessShapeType::color() const * @brief This function returns a reference to member color * @return Reference to member color */ -std::string& shapes_demo_typesupport::idl::KeylessShapeType::color() +std::string& KeylessShapeType::color() { return m_color; } @@ -149,7 +151,7 @@ std::string& shapes_demo_typesupport::idl::KeylessShapeType::color() * @brief This function sets a value in member x * @param _x New value for member x */ -void shapes_demo_typesupport::idl::KeylessShapeType::x( +void KeylessShapeType::x( int32_t _x) { m_x = _x; @@ -159,7 +161,7 @@ void shapes_demo_typesupport::idl::KeylessShapeType::x( * @brief This function returns the value of member x * @return Value of member x */ -int32_t shapes_demo_typesupport::idl::KeylessShapeType::x() const +int32_t KeylessShapeType::x() const { return m_x; } @@ -168,7 +170,7 @@ int32_t shapes_demo_typesupport::idl::KeylessShapeType::x() const * @brief This function returns a reference to member x * @return Reference to member x */ -int32_t& shapes_demo_typesupport::idl::KeylessShapeType::x() +int32_t& KeylessShapeType::x() { return m_x; } @@ -178,7 +180,7 @@ int32_t& shapes_demo_typesupport::idl::KeylessShapeType::x() * @brief This function sets a value in member y * @param _y New value for member y */ -void shapes_demo_typesupport::idl::KeylessShapeType::y( +void KeylessShapeType::y( int32_t _y) { m_y = _y; @@ -188,7 +190,7 @@ void shapes_demo_typesupport::idl::KeylessShapeType::y( * @brief This function returns the value of member y * @return Value of member y */ -int32_t shapes_demo_typesupport::idl::KeylessShapeType::y() const +int32_t KeylessShapeType::y() const { return m_y; } @@ -197,7 +199,7 @@ int32_t shapes_demo_typesupport::idl::KeylessShapeType::y() const * @brief This function returns a reference to member y * @return Reference to member y */ -int32_t& shapes_demo_typesupport::idl::KeylessShapeType::y() +int32_t& KeylessShapeType::y() { return m_y; } @@ -207,7 +209,7 @@ int32_t& shapes_demo_typesupport::idl::KeylessShapeType::y() * @brief This function sets a value in member shapesize * @param _shapesize New value for member shapesize */ -void shapes_demo_typesupport::idl::KeylessShapeType::shapesize( +void KeylessShapeType::shapesize( int32_t _shapesize) { m_shapesize = _shapesize; @@ -217,7 +219,7 @@ void shapes_demo_typesupport::idl::KeylessShapeType::shapesize( * @brief This function returns the value of member shapesize * @return Value of member shapesize */ -int32_t shapes_demo_typesupport::idl::KeylessShapeType::shapesize() const +int32_t KeylessShapeType::shapesize() const { return m_shapesize; } @@ -226,7 +228,7 @@ int32_t shapes_demo_typesupport::idl::KeylessShapeType::shapesize() const * @brief This function returns a reference to member shapesize * @return Reference to member shapesize */ -int32_t& shapes_demo_typesupport::idl::KeylessShapeType::shapesize() +int32_t& KeylessShapeType::shapesize() { return m_shapesize; } @@ -234,5 +236,11 @@ int32_t& shapes_demo_typesupport::idl::KeylessShapeType::shapesize() +} // namespace idl + + +} // namespace shapes_demo_typesupport // Include auxiliary functions like for serializing/deserializing. #include "KeylessShapeTypeCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/types/KeylessShapeType.h b/types/KeylessShapeType.h index 8dab5b7..c7ce7a1 100644 --- a/types/KeylessShapeType.h +++ b/types/KeylessShapeType.h @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include <fastcdr/config.h> +#include "KeylessShapeTypev1.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_SHAPES_DEMO_TYPESUPPORT_IDL_KEYLESSSHAPETYPE_H_ #define _FAST_DDS_GENERATED_SHAPES_DEMO_TYPESUPPORT_IDL_KEYLESSSHAPETYPE_H_ @@ -30,6 +35,7 @@ #include <vector> #include <fastcdr/cdr/fixed_size_string.hpp> +#include <fastcdr/xcdr/external.hpp> #include <fastcdr/xcdr/optional.hpp> @@ -68,163 +74,172 @@ class CdrSizeCalculator; namespace shapes_demo_typesupport { - namespace idl { - /*! - * @brief This class represents the structure KeylessShapeType defined by the user in the IDL file. - * @ingroup KeylessShapeType - */ - class KeylessShapeType - { - public: - - /*! - * @brief Default constructor. - */ - eProsima_user_DllExport KeylessShapeType(); - - /*! - * @brief Default destructor. - */ - eProsima_user_DllExport ~KeylessShapeType(); - - /*! - * @brief Copy constructor. - * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. - */ - eProsima_user_DllExport KeylessShapeType( - const KeylessShapeType& x); - - /*! - * @brief Move constructor. - * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. - */ - eProsima_user_DllExport KeylessShapeType( - KeylessShapeType&& x) noexcept; - - /*! - * @brief Copy assignment. - * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. - */ - eProsima_user_DllExport KeylessShapeType& operator =( - const KeylessShapeType& x); - - /*! - * @brief Move assignment. - * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. - */ - eProsima_user_DllExport KeylessShapeType& operator =( - KeylessShapeType&& x) noexcept; - - /*! - * @brief Comparison operator. - * @param x shapes_demo_typesupport::idl::KeylessShapeType object to compare. - */ - eProsima_user_DllExport bool operator ==( - const KeylessShapeType& x) const; - - /*! - * @brief Comparison operator. - * @param x shapes_demo_typesupport::idl::KeylessShapeType object to compare. - */ - eProsima_user_DllExport bool operator !=( - const KeylessShapeType& x) const; - - /*! - * @brief This function copies the value in member color - * @param _color New value to be copied in member color - */ - eProsima_user_DllExport void color( - const std::string& _color); - - /*! - * @brief This function moves the value in member color - * @param _color New value to be moved in member color - */ - eProsima_user_DllExport void color( - std::string&& _color); - - /*! - * @brief This function returns a constant reference to member color - * @return Constant reference to member color - */ - eProsima_user_DllExport const std::string& color() const; - - /*! - * @brief This function returns a reference to member color - * @return Reference to member color - */ - eProsima_user_DllExport std::string& color(); - - - /*! - * @brief This function sets a value in member x - * @param _x New value for member x - */ - eProsima_user_DllExport void x( - int32_t _x); - - /*! - * @brief This function returns the value of member x - * @return Value of member x - */ - eProsima_user_DllExport int32_t x() const; - - /*! - * @brief This function returns a reference to member x - * @return Reference to member x - */ - eProsima_user_DllExport int32_t& x(); - - - /*! - * @brief This function sets a value in member y - * @param _y New value for member y - */ - eProsima_user_DllExport void y( - int32_t _y); - - /*! - * @brief This function returns the value of member y - * @return Value of member y - */ - eProsima_user_DllExport int32_t y() const; - - /*! - * @brief This function returns a reference to member y - * @return Reference to member y - */ - eProsima_user_DllExport int32_t& y(); - - - /*! - * @brief This function sets a value in member shapesize - * @param _shapesize New value for member shapesize - */ - eProsima_user_DllExport void shapesize( - int32_t _shapesize); - - /*! - * @brief This function returns the value of member shapesize - * @return Value of member shapesize - */ - eProsima_user_DllExport int32_t shapesize() const; - - /*! - * @brief This function returns a reference to member shapesize - * @return Reference to member shapesize - */ - eProsima_user_DllExport int32_t& shapesize(); - - private: - - std::string m_color; - int32_t m_x{0}; - int32_t m_y{0}; - int32_t m_shapesize{0}; - - }; - } // namespace idl + +namespace idl { + + + +/*! + * @brief This class represents the structure KeylessShapeType defined by the user in the IDL file. + * @ingroup KeylessShapeType + */ +class KeylessShapeType +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport KeylessShapeType(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~KeylessShapeType(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. + */ + eProsima_user_DllExport KeylessShapeType( + const KeylessShapeType& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. + */ + eProsima_user_DllExport KeylessShapeType( + KeylessShapeType&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. + */ + eProsima_user_DllExport KeylessShapeType& operator =( + const KeylessShapeType& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. + */ + eProsima_user_DllExport KeylessShapeType& operator =( + KeylessShapeType&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x shapes_demo_typesupport::idl::KeylessShapeType object to compare. + */ + eProsima_user_DllExport bool operator ==( + const KeylessShapeType& x) const; + + /*! + * @brief Comparison operator. + * @param x shapes_demo_typesupport::idl::KeylessShapeType object to compare. + */ + eProsima_user_DllExport bool operator !=( + const KeylessShapeType& x) const; + + /*! + * @brief This function copies the value in member color + * @param _color New value to be copied in member color + */ + eProsima_user_DllExport void color( + const std::string& _color); + + /*! + * @brief This function moves the value in member color + * @param _color New value to be moved in member color + */ + eProsima_user_DllExport void color( + std::string&& _color); + + /*! + * @brief This function returns a constant reference to member color + * @return Constant reference to member color + */ + eProsima_user_DllExport const std::string& color() const; + + /*! + * @brief This function returns a reference to member color + * @return Reference to member color + */ + eProsima_user_DllExport std::string& color(); + + + /*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ + eProsima_user_DllExport void x( + int32_t _x); + + /*! + * @brief This function returns the value of member x + * @return Value of member x + */ + eProsima_user_DllExport int32_t x() const; + + /*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ + eProsima_user_DllExport int32_t& x(); + + + /*! + * @brief This function sets a value in member y + * @param _y New value for member y + */ + eProsima_user_DllExport void y( + int32_t _y); + + /*! + * @brief This function returns the value of member y + * @return Value of member y + */ + eProsima_user_DllExport int32_t y() const; + + /*! + * @brief This function returns a reference to member y + * @return Reference to member y + */ + eProsima_user_DllExport int32_t& y(); + + + /*! + * @brief This function sets a value in member shapesize + * @param _shapesize New value for member shapesize + */ + eProsima_user_DllExport void shapesize( + int32_t _shapesize); + + /*! + * @brief This function returns the value of member shapesize + * @return Value of member shapesize + */ + eProsima_user_DllExport int32_t shapesize() const; + + /*! + * @brief This function returns a reference to member shapesize + * @return Reference to member shapesize + */ + eProsima_user_DllExport int32_t& shapesize(); + +private: + + std::string m_color; + int32_t m_x{0}; + int32_t m_y{0}; + int32_t m_shapesize{0}; + +}; + +} // namespace idl + } // namespace shapes_demo_typesupport #endif // _FAST_DDS_GENERATED_SHAPES_DEMO_TYPESUPPORT_IDL_KEYLESSSHAPETYPE_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/types/KeylessShapeTypeCdrAux.hpp b/types/KeylessShapeTypeCdrAux.hpp index b44286b..16b2998 100644 --- a/types/KeylessShapeTypeCdrAux.hpp +++ b/types/KeylessShapeTypeCdrAux.hpp @@ -34,6 +34,8 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const shapes_demo_typesupport::idl::KeylessShapeType& data); diff --git a/types/KeylessShapeTypeCdrAux.ipp b/types/KeylessShapeTypeCdrAux.ipp index ba4b492..de5960d 100644 --- a/types/KeylessShapeTypeCdrAux.ipp +++ b/types/KeylessShapeTypeCdrAux.ipp @@ -34,12 +34,16 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, const shapes_demo_typesupport::idl::KeylessShapeType& data, size_t& current_alignment) { + using namespace shapes_demo_typesupport::idl; + static_cast<void>(data); eprosima::fastcdr::EncodingAlgorithmFlag previous_encoding = calculator.get_encoding(); @@ -73,6 +77,8 @@ eProsima_user_DllExport void serialize( eprosima::fastcdr::Cdr& scdr, const shapes_demo_typesupport::idl::KeylessShapeType& data) { + using namespace shapes_demo_typesupport::idl; + eprosima::fastcdr::Cdr::state current_state(scdr); scdr.begin_serialize_type(current_state, eprosima::fastcdr::CdrVersion::XCDRv2 == scdr.get_cdr_version() ? @@ -85,7 +91,6 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(2) << data.y() << eprosima::fastcdr::MemberId(3) << data.shapesize() ; - scdr.end_serialize_type(current_state); } @@ -94,6 +99,8 @@ eProsima_user_DllExport void deserialize( eprosima::fastcdr::Cdr& cdr, shapes_demo_typesupport::idl::KeylessShapeType& data) { + using namespace shapes_demo_typesupport::idl; + cdr.deserialize_type(eprosima::fastcdr::CdrVersion::XCDRv2 == cdr.get_cdr_version() ? eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2 : eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR, @@ -130,6 +137,8 @@ void serialize_key( eprosima::fastcdr::Cdr& scdr, const shapes_demo_typesupport::idl::KeylessShapeType& data) { + using namespace shapes_demo_typesupport::idl; + static_cast<void>(scdr); static_cast<void>(data); } diff --git a/types/KeylessShapeTypePubSubTypes.cxx b/types/KeylessShapeTypePubSubTypes.cxx index 6848206..0d2a597 100644 --- a/types/KeylessShapeTypePubSubTypes.cxx +++ b/types/KeylessShapeTypePubSubTypes.cxx @@ -20,9 +20,7 @@ */ -#include <fastcdr/FastBuffer.h> -#include <fastcdr/Cdr.h> -#include <fastcdr/CdrSizeCalculator.hpp> +#include <fastdds/rtps/common/CdrSerialization.hpp> #include "KeylessShapeTypePubSubTypes.h" #include "KeylessShapeTypeCdrAux.hpp" @@ -33,10 +31,17 @@ using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; namespace shapes_demo_typesupport { namespace idl { + + KeylessShapeTypePubSubType::KeylessShapeTypePubSubType() { - setName("shapes_demo_typesupport::idl::dds_::KeylessShapeType_"); - uint32_t type_size = shapes_demo_typesupport_idl_KeylessShapeType_max_cdr_typesize; + setName("shapes_demo_typesupport::idl::KeylessShapeType"); + uint32_t type_size = + #if FASTCDR_VERSION_MAJOR == 1 + KeylessShapeType::getMaxCdrSerializedSize(); + #else + shapes_demo_typesupport_idl_KeylessShapeType_max_cdr_typesize; + #endif type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = false; @@ -67,10 +72,12 @@ namespace shapes_demo_typesupport { data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; + #if FASTCDR_VERSION_MAJOR > 1 ser.set_encoding_flag( data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); + #endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -85,7 +92,11 @@ namespace shapes_demo_typesupport { } // Get the serialized length + #if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast<uint32_t>(ser.getSerializedDataLength()); + #else payload->length = static_cast<uint32_t>(ser.get_serialized_data_length()); + #endif // FASTCDR_VERSION_MAJOR == 1 return true; } @@ -102,7 +113,11 @@ namespace shapes_demo_typesupport { eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN + #if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR + #endif // FASTCDR_VERSION_MAJOR == 1 + ); // Deserialize encapsulation. deser.read_encapsulation(); @@ -125,13 +140,25 @@ namespace shapes_demo_typesupport { { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast<uint32_t>(calculator.calculate_serialized_size( - *static_cast<KeylessShapeType*>(data), current_alignment)) + - 4u /*encapsulation*/; + #if FASTCDR_VERSION_MAJOR == 1 + return static_cast<uint32_t>(type::getCdrSerializedSize(*static_cast<KeylessShapeType*>(data))) + + 4u /*encapsulation*/; + #else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast<uint32_t>(calculator.calculate_serialized_size( + *static_cast<KeylessShapeType*>(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } + #endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -163,12 +190,20 @@ namespace shapes_demo_typesupport { shapes_demo_typesupport_idl_KeylessShapeType_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); + #if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); + #else eprosima::fastcdr::serialize_key(ser, *p_type); + #endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || shapes_demo_typesupport_idl_KeylessShapeType_max_key_cdr_typesize > 16) { m_md5.init(); + #if FASTCDR_VERSION_MAJOR == 1 + m_md5.update(m_keyBuffer, static_cast<unsigned int>(ser.getSerializedDataLength())); + #else m_md5.update(m_keyBuffer, static_cast<unsigned int>(ser.get_serialized_data_length())); + #endif // FASTCDR_VERSION_MAJOR == 1 m_md5.finalize(); for (uint8_t i = 0; i < 16; ++i) { diff --git a/types/KeylessShapeTypePubSubTypes.h b/types/KeylessShapeTypePubSubTypes.h index dd9c9ab..ed0d598 100644 --- a/types/KeylessShapeTypePubSubTypes.h +++ b/types/KeylessShapeTypePubSubTypes.h @@ -42,6 +42,8 @@ namespace shapes_demo_typesupport namespace idl { + + /*! * @brief This class represents the TopicDataType of the type KeylessShapeType defined by the user in the IDL file. * @ingroup KeylessShapeType diff --git a/types/KeylessShapeTypeTypeObject.cxx b/types/KeylessShapeTypeTypeObject.cxx index 3a742e4..2463406 100644 --- a/types/KeylessShapeTypeTypeObject.cxx +++ b/types/KeylessShapeTypeTypeObject.cxx @@ -29,14 +29,12 @@ namespace { char dummy; } #include <mutex> #include <utility> #include <sstream> +#include <fastdds/rtps/common/CdrSerialization.hpp> #include <fastrtps/rtps/common/SerializedPayload.h> #include <fastrtps/utils/md5.h> #include <fastrtps/types/TypeObjectFactory.h> #include <fastrtps/types/TypeNamesGenerator.h> #include <fastrtps/types/AnnotationParameterValue.h> -#include <fastcdr/FastBuffer.h> -#include <fastcdr/Cdr.h> -#include <fastcdr/CdrSizeCalculator.hpp> using namespace eprosima::fastrtps::rtps; @@ -46,9 +44,9 @@ void registerKeylessShapeTypeTypes() std::call_once(once_flag, []() { TypeObjectFactory *factory = TypeObjectFactory::get_instance(); - factory->add_type_object("shapes_demo_typesupport::idl::dds_::KeylessShapeType_", shapes_demo_typesupport::idl::GetKeylessShapeTypeIdentifier(true), + factory->add_type_object("shapes_demo_typesupport::idl::KeylessShapeType", shapes_demo_typesupport::idl::GetKeylessShapeTypeIdentifier(true), shapes_demo_typesupport::idl::GetKeylessShapeTypeObject(true)); - factory->add_type_object("shapes_demo_typesupport::idl::dds_::KeylessShapeType_", shapes_demo_typesupport::idl::GetKeylessShapeTypeIdentifier(false), + factory->add_type_object("shapes_demo_typesupport::idl::KeylessShapeType", shapes_demo_typesupport::idl::GetKeylessShapeTypeIdentifier(false), shapes_demo_typesupport::idl::GetKeylessShapeTypeObject(false)); @@ -200,7 +198,11 @@ namespace shapes_demo_typesupport { payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; ser << *type_object; + #if FASTCDR_VERSION_MAJOR == 1 + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + #else payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length + #endif // FASTCDR_VERSION_MAJOR == 1 MD5 objectHash; objectHash.update((char*)payload.data, payload.length); objectHash.finalize(); @@ -316,7 +318,11 @@ namespace shapes_demo_typesupport { payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; ser << *type_object; + #if FASTCDR_VERSION_MAJOR == 1 + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length + #else payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length + #endif // FASTCDR_VERSION_MAJOR == 1 MD5 objectHash; objectHash.update((char*)payload.data, payload.length); objectHash.finalize(); diff --git a/types/KeylessShapeTypev1.cxx b/types/KeylessShapeTypev1.cxx new file mode 100644 index 0000000..ecf58ea --- /dev/null +++ b/types/KeylessShapeTypev1.cxx @@ -0,0 +1,402 @@ +// 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 KeylessShapeType.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "KeylessShapeType.h" + +#if FASTCDR_VERSION_MAJOR == 1 + +#include <fastcdr/Cdr.h> + + +#include <fastcdr/exceptions/BadParamException.h> +using namespace eprosima::fastcdr::exception; + +#include <utility> + +namespace helper { namespace internal { + +enum class Size { + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size(int s) { + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template<Size s> +struct FindTypeH; + +template<> +struct FindTypeH<Size::UInt8> { + using type = std::uint8_t; +}; + +template<> +struct FindTypeH<Size::UInt16> { + using type = std::uint16_t; +}; + +template<> +struct FindTypeH<Size::UInt32> { + using type = std::uint32_t; +}; + +template<> +struct FindTypeH<Size::UInt64> { + using type = std::uint64_t; +}; +} + +template<int S> +struct FindType { + using type = typename internal::FindTypeH<internal::get_size(S)>::type; +}; +} + +#define shapes_demo_typesupport_idl_KeylessShapeType_max_cdr_typesize 276ULL; + + +namespace shapes_demo_typesupport { + +namespace idl { + + + +KeylessShapeType::KeylessShapeType() +{ + // /type_d() m_color + + // long m_x + m_x = 0; + // long m_y + m_y = 0; + // long m_shapesize + m_shapesize = 0; + +} + +KeylessShapeType::~KeylessShapeType() +{ +} + +KeylessShapeType::KeylessShapeType( + const KeylessShapeType& x) +{ + m_color = x.m_color; + + + m_x = x.m_x; + + + m_y = x.m_y; + + + m_shapesize = x.m_shapesize; + +} + +KeylessShapeType::KeylessShapeType( + KeylessShapeType&& x) noexcept +{ + m_color = std::move(x.m_color); + + + m_x = x.m_x; + + + m_y = x.m_y; + + + m_shapesize = x.m_shapesize; + +} + +KeylessShapeType& KeylessShapeType::operator =( + const KeylessShapeType& x) +{ + m_color = x.m_color; + + + m_x = x.m_x; + + + m_y = x.m_y; + + + m_shapesize = x.m_shapesize; + + return *this; +} + +KeylessShapeType& KeylessShapeType::operator =( + KeylessShapeType&& x) noexcept +{ + m_color = std::move(x.m_color); + + + m_x = x.m_x; + + + m_y = x.m_y; + + + m_shapesize = x.m_shapesize; + + return *this; +} + +bool KeylessShapeType::operator ==( + const KeylessShapeType& x) const +{ + return (m_color == x.m_color && + m_x == x.m_x && + m_y == x.m_y && + m_shapesize == x.m_shapesize); +} + +bool KeylessShapeType::operator !=( + const KeylessShapeType& x) const +{ + return !(*this == x); +} + +size_t KeylessShapeType::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast<void>(current_alignment); + return shapes_demo_typesupport_idl_KeylessShapeType_max_cdr_typesize; +} + +size_t KeylessShapeType::getCdrSerializedSize( + const KeylessShapeType& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.color().size() + 1; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + return current_alignment - initial_alignment; +} + + +void KeylessShapeType::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_color.c_str(); + + scdr << m_x; + + scdr << m_y; + + scdr << m_shapesize; + +} + +void KeylessShapeType::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_color; + + + + dcdr >> m_x; + + + + dcdr >> m_y; + + + + dcdr >> m_shapesize; + + +} + + +bool KeylessShapeType::isKeyDefined() +{ + return false; +} + +void KeylessShapeType::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; +} + +/*! + * @brief This function copies the value in member color + * @param _color New value to be copied in member color + */ +void KeylessShapeType::color( + const std::string& _color) +{ + m_color = _color; +} + +/*! + * @brief This function moves the value in member color + * @param _color New value to be moved in member color + */ +void KeylessShapeType::color( + std::string&& _color) +{ + m_color = std::move(_color); +} + +/*! + * @brief This function returns a constant reference to member color + * @return Constant reference to member color + */ +const std::string& KeylessShapeType::color() const +{ + return m_color; +} + +/*! + * @brief This function returns a reference to member color + * @return Reference to member color + */ +std::string& KeylessShapeType::color() +{ + return m_color; +} + + +/*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ +void KeylessShapeType::x( + int32_t _x) +{ + m_x = _x; +} + +/*! + * @brief This function returns the value of member x + * @return Value of member x + */ +int32_t KeylessShapeType::x() const +{ + return m_x; +} + +/*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ +int32_t& KeylessShapeType::x() +{ + return m_x; +} + + +/*! + * @brief This function sets a value in member y + * @param _y New value for member y + */ +void KeylessShapeType::y( + int32_t _y) +{ + m_y = _y; +} + +/*! + * @brief This function returns the value of member y + * @return Value of member y + */ +int32_t KeylessShapeType::y() const +{ + return m_y; +} + +/*! + * @brief This function returns a reference to member y + * @return Reference to member y + */ +int32_t& KeylessShapeType::y() +{ + return m_y; +} + + +/*! + * @brief This function sets a value in member shapesize + * @param _shapesize New value for member shapesize + */ +void KeylessShapeType::shapesize( + int32_t _shapesize) +{ + m_shapesize = _shapesize; +} + +/*! + * @brief This function returns the value of member shapesize + * @return Value of member shapesize + */ +int32_t KeylessShapeType::shapesize() const +{ + return m_shapesize; +} + +/*! + * @brief This function returns a reference to member shapesize + * @return Reference to member shapesize + */ +int32_t& KeylessShapeType::shapesize() +{ + return m_shapesize; +} + + + + + +} // namespace idl + + +} // namespace shapes_demo_typesupport + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/types/KeylessShapeTypev1.h b/types/KeylessShapeTypev1.h new file mode 100644 index 0000000..8cebcdc --- /dev/null +++ b/types/KeylessShapeTypev1.h @@ -0,0 +1,289 @@ +// 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 KeylessShapeType.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include <fastcdr/config.h> + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_SHAPES_DEMO_TYPESUPPORT_IDL_KEYLESSSHAPETYPE_H_ +#define _FAST_DDS_GENERATED_SHAPES_DEMO_TYPESUPPORT_IDL_KEYLESSSHAPETYPE_H_ + + +#include <fastrtps/utils/fixed_size_string.hpp> + +#include <stdint.h> +#include <array> +#include <string> +#include <vector> +#include <map> +#include <bitset> + +#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(KEYLESSSHAPETYPE_SOURCE) +#define KEYLESSSHAPETYPE_DllAPI __declspec( dllexport ) +#else +#define KEYLESSSHAPETYPE_DllAPI __declspec( dllimport ) +#endif // KEYLESSSHAPETYPE_SOURCE +#else +#define KEYLESSSHAPETYPE_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define KEYLESSSHAPETYPE_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + +namespace shapes_demo_typesupport { + namespace idl { + + + /*! + * @brief This class represents the structure KeylessShapeType defined by the user in the IDL file. + * @ingroup KeylessShapeType + */ + class KeylessShapeType + { + public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport KeylessShapeType(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~KeylessShapeType(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. + */ + eProsima_user_DllExport KeylessShapeType( + const KeylessShapeType& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. + */ + eProsima_user_DllExport KeylessShapeType( + KeylessShapeType&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. + */ + eProsima_user_DllExport KeylessShapeType& operator =( + const KeylessShapeType& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object shapes_demo_typesupport::idl::KeylessShapeType that will be copied. + */ + eProsima_user_DllExport KeylessShapeType& operator =( + KeylessShapeType&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x shapes_demo_typesupport::idl::KeylessShapeType object to compare. + */ + eProsima_user_DllExport bool operator ==( + const KeylessShapeType& x) const; + + /*! + * @brief Comparison operator. + * @param x shapes_demo_typesupport::idl::KeylessShapeType object to compare. + */ + eProsima_user_DllExport bool operator !=( + const KeylessShapeType& x) const; + + /*! + * @brief This function copies the value in member color + * @param _color New value to be copied in member color + */ + eProsima_user_DllExport void color( + const std::string& _color); + + /*! + * @brief This function moves the value in member color + * @param _color New value to be moved in member color + */ + eProsima_user_DllExport void color( + std::string&& _color); + + /*! + * @brief This function returns a constant reference to member color + * @return Constant reference to member color + */ + eProsima_user_DllExport const std::string& color() const; + + /*! + * @brief This function returns a reference to member color + * @return Reference to member color + */ + eProsima_user_DllExport std::string& color(); + + + /*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ + eProsima_user_DllExport void x( + int32_t _x); + + /*! + * @brief This function returns the value of member x + * @return Value of member x + */ + eProsima_user_DllExport int32_t x() const; + + /*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ + eProsima_user_DllExport int32_t& x(); + + + /*! + * @brief This function sets a value in member y + * @param _y New value for member y + */ + eProsima_user_DllExport void y( + int32_t _y); + + /*! + * @brief This function returns the value of member y + * @return Value of member y + */ + eProsima_user_DllExport int32_t y() const; + + /*! + * @brief This function returns a reference to member y + * @return Reference to member y + */ + eProsima_user_DllExport int32_t& y(); + + + /*! + * @brief This function sets a value in member shapesize + * @param _shapesize New value for member shapesize + */ + eProsima_user_DllExport void shapesize( + int32_t _shapesize); + + /*! + * @brief This function returns the value of member shapesize + * @return Value of member shapesize + */ + eProsima_user_DllExport int32_t shapesize() const; + + /*! + * @brief This function returns a reference to member shapesize + * @return Reference to member shapesize + */ + eProsima_user_DllExport int32_t& shapesize(); + + + /*! + * @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 shapes_demo_typesupport::idl::KeylessShapeType& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + + private: + + std::string m_color; + int32_t m_x; + int32_t m_y; + int32_t m_shapesize; + + }; + + } // namespace idl +} // namespace shapes_demo_typesupport + +#endif // _FAST_DDS_GENERATED_SHAPES_DEMO_TYPESUPPORT_IDL_KEYLESSSHAPETYPE_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/types/Shape.cxx b/types/Shape.cxx index f566345..7c2a0ef 100644 --- a/types/Shape.cxx +++ b/types/Shape.cxx @@ -27,7 +27,8 @@ char dummy; #endif // _WIN32 #include "Shape.h" -#include "ShapeTypeObject.h" + +#if FASTCDR_VERSION_MAJOR > 1 #include <fastcdr/Cdr.h> @@ -38,11 +39,10 @@ using namespace eprosima::fastcdr::exception; #include <utility> + + ShapeType::ShapeType() { - - // Just to register all known types - registerShapeTypes(); } ShapeType::~ShapeType() @@ -75,7 +75,6 @@ ShapeType& ShapeType::operator =( m_x = x.m_x; m_y = x.m_y; m_shapesize = x.m_shapesize; - return *this; } @@ -87,7 +86,6 @@ ShapeType& ShapeType::operator =( m_x = x.m_x; m_y = x.m_y; m_shapesize = x.m_shapesize; - return *this; } @@ -234,3 +232,5 @@ int32_t& ShapeType::shapesize() // Include auxiliary functions like for serializing/deserializing. #include "ShapeCdrAux.ipp" + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/types/Shape.h b/types/Shape.h index 1dffcbd..2334735 100644 --- a/types/Shape.h +++ b/types/Shape.h @@ -19,6 +19,11 @@ * This file was generated by the tool fastddsgen. */ +#include <fastcdr/config.h> +#include "Shapev1.h" + +#if FASTCDR_VERSION_MAJOR > 1 + #ifndef _FAST_DDS_GENERATED_SHAPE_H_ #define _FAST_DDS_GENERATED_SHAPE_H_ @@ -30,6 +35,7 @@ #include <vector> #include <fastcdr/cdr/fixed_size_string.hpp> +#include <fastcdr/xcdr/external.hpp> #include <fastcdr/xcdr/optional.hpp> @@ -67,6 +73,8 @@ class CdrSizeCalculator; + + /*! * @brief This class represents the structure ShapeType defined by the user in the IDL file. * @ingroup Shape @@ -224,3 +232,6 @@ class ShapeType #endif // _FAST_DDS_GENERATED_SHAPE_H_ + + +#endif // FASTCDR_VERSION_MAJOR > 1 diff --git a/types/ShapeCdrAux.hpp b/types/ShapeCdrAux.hpp index be3ee1c..e02428f 100644 --- a/types/ShapeCdrAux.hpp +++ b/types/ShapeCdrAux.hpp @@ -34,6 +34,8 @@ namespace fastcdr { class Cdr; class CdrSizeCalculator; + + eProsima_user_DllExport void serialize_key( eprosima::fastcdr::Cdr& scdr, const ShapeType& data); diff --git a/types/ShapeCdrAux.ipp b/types/ShapeCdrAux.ipp index 564a065..cfb85fd 100644 --- a/types/ShapeCdrAux.ipp +++ b/types/ShapeCdrAux.ipp @@ -34,6 +34,8 @@ using namespace eprosima::fastcdr::exception; namespace eprosima { namespace fastcdr { + + template<> eProsima_user_DllExport size_t calculate_serialized_size( eprosima::fastcdr::CdrSizeCalculator& calculator, @@ -85,7 +87,6 @@ eProsima_user_DllExport void serialize( << eprosima::fastcdr::MemberId(2) << data.y() << eprosima::fastcdr::MemberId(3) << data.shapesize() ; - scdr.end_serialize_type(current_state); } diff --git a/types/ShapePubSubTypes.cxx b/types/ShapePubSubTypes.cxx index 6850392..1d83aad 100644 --- a/types/ShapePubSubTypes.cxx +++ b/types/ShapePubSubTypes.cxx @@ -20,9 +20,7 @@ */ -#include <fastcdr/FastBuffer.h> -#include <fastcdr/Cdr.h> -#include <fastcdr/CdrSizeCalculator.hpp> +#include <fastdds/rtps/common/CdrSerialization.hpp> #include "ShapePubSubTypes.h" #include "ShapeCdrAux.hpp" @@ -31,10 +29,17 @@ using SerializedPayload_t = eprosima::fastrtps::rtps::SerializedPayload_t; using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t; using DataRepresentationId_t = eprosima::fastdds::dds::DataRepresentationId_t; + + ShapeTypePubSubType::ShapeTypePubSubType() { setName("ShapeType"); - uint32_t type_size = ShapeType_max_cdr_typesize; + uint32_t type_size = +#if FASTCDR_VERSION_MAJOR == 1 + ShapeType::getMaxCdrSerializedSize(); +#else + ShapeType_max_cdr_typesize; +#endif type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */ m_typeSize = type_size + 4; /*encapsulation*/ m_isGetKeyDefined = true; @@ -65,10 +70,12 @@ bool ShapeTypePubSubType::serialize( data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2); payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; +#if FASTCDR_VERSION_MAJOR > 1 ser.set_encoding_flag( data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR : eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2); +#endif // FASTCDR_VERSION_MAJOR > 1 try { @@ -83,7 +90,11 @@ bool ShapeTypePubSubType::serialize( } // Get the serialized length +#if FASTCDR_VERSION_MAJOR == 1 + payload->length = static_cast<uint32_t>(ser.getSerializedDataLength()); +#else payload->length = static_cast<uint32_t>(ser.get_serialized_data_length()); +#endif // FASTCDR_VERSION_MAJOR == 1 return true; } @@ -100,7 +111,11 @@ bool ShapeTypePubSubType::deserialize( eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->length); // Object that deserializes the data. - eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN); + eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN +#if FASTCDR_VERSION_MAJOR == 1 + , eprosima::fastcdr::Cdr::CdrType::DDS_CDR +#endif // FASTCDR_VERSION_MAJOR == 1 + ); // Deserialize encapsulation. deser.read_encapsulation(); @@ -123,13 +138,25 @@ std::function<uint32_t()> ShapeTypePubSubType::getSerializedSizeProvider( { return [data, data_representation]() -> uint32_t { - eprosima::fastcdr::CdrSizeCalculator calculator( - data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? - eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); - size_t current_alignment {0}; - return static_cast<uint32_t>(calculator.calculate_serialized_size( - *static_cast<ShapeType*>(data), current_alignment)) + - 4u /*encapsulation*/; +#if FASTCDR_VERSION_MAJOR == 1 + return static_cast<uint32_t>(type::getCdrSerializedSize(*static_cast<ShapeType*>(data))) + + 4u /*encapsulation*/; +#else + try + { + eprosima::fastcdr::CdrSizeCalculator calculator( + data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ? + eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2); + size_t current_alignment {0}; + return static_cast<uint32_t>(calculator.calculate_serialized_size( + *static_cast<ShapeType*>(data), current_alignment)) + + 4u /*encapsulation*/; + } + catch (eprosima::fastcdr::exception::Exception& /*exception*/) + { + return 0; + } +#endif // FASTCDR_VERSION_MAJOR == 1 }; } @@ -161,12 +188,20 @@ bool ShapeTypePubSubType::getKey( ShapeType_max_key_cdr_typesize); // Object that serializes the data. - eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS); + eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1); +#if FASTCDR_VERSION_MAJOR == 1 + p_type->serializeKey(ser); +#else eprosima::fastcdr::serialize_key(ser, *p_type); +#endif // FASTCDR_VERSION_MAJOR == 1 if (force_md5 || ShapeType_max_key_cdr_typesize > 16) { m_md5.init(); +#if FASTCDR_VERSION_MAJOR == 1 + m_md5.update(m_keyBuffer, static_cast<unsigned int>(ser.getSerializedDataLength())); +#else m_md5.update(m_keyBuffer, static_cast<unsigned int>(ser.get_serialized_data_length())); +#endif // FASTCDR_VERSION_MAJOR == 1 m_md5.finalize(); for (uint8_t i = 0; i < 16; ++i) { diff --git a/types/ShapePubSubTypes.h b/types/ShapePubSubTypes.h index 3978bd1..d3f47ae 100644 --- a/types/ShapePubSubTypes.h +++ b/types/ShapePubSubTypes.h @@ -38,6 +38,8 @@ #endif // GEN_API_VER + + /*! * @brief This class represents the TopicDataType of the type ShapeType defined by the user in the IDL file. * @ingroup Shape diff --git a/types/ShapeTypeObject.cxx b/types/ShapeTypeObject.cxx index f65232a..3e0b92c 100644 --- a/types/ShapeTypeObject.cxx +++ b/types/ShapeTypeObject.cxx @@ -29,14 +29,12 @@ namespace { char dummy; } #include <mutex> #include <utility> #include <sstream> +#include <fastdds/rtps/common/CdrSerialization.hpp> #include <fastrtps/rtps/common/SerializedPayload.h> #include <fastrtps/utils/md5.h> #include <fastrtps/types/TypeObjectFactory.h> #include <fastrtps/types/TypeNamesGenerator.h> #include <fastrtps/types/AnnotationParameterValue.h> -#include <fastcdr/FastBuffer.h> -#include <fastcdr/Cdr.h> -#include <fastcdr/CdrSizeCalculator.hpp> using namespace eprosima::fastrtps::rtps; @@ -196,7 +194,11 @@ const TypeObject* GetMinimalShapeTypeObject() payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; ser << *type_object; +#if FASTCDR_VERSION_MAJOR == 1 + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length +#else payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length +#endif // FASTCDR_VERSION_MAJOR == 1 MD5 objectHash; objectHash.update((char*)payload.data, payload.length); objectHash.finalize(); @@ -334,7 +336,11 @@ const TypeObject* GetCompleteShapeTypeObject() payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE; ser << *type_object; +#if FASTCDR_VERSION_MAJOR == 1 + payload.length = (uint32_t)ser.getSerializedDataLength(); //Get the serialized length +#else payload.length = (uint32_t)ser.get_serialized_data_length(); //Get the serialized length +#endif // FASTCDR_VERSION_MAJOR == 1 MD5 objectHash; objectHash.update((char*)payload.data, payload.length); objectHash.finalize(); diff --git a/types/Shapev1.cxx b/types/Shapev1.cxx new file mode 100644 index 0000000..11159b4 --- /dev/null +++ b/types/Shapev1.cxx @@ -0,0 +1,398 @@ +// 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 Shape.cpp + * This source file contains the implementation of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#ifdef _WIN32 +// Remove linker warning LNK4221 on Visual Studio +namespace { +char dummy; +} // namespace +#endif // _WIN32 + +#include "Shape.h" + +#if FASTCDR_VERSION_MAJOR == 1 + +#include <fastcdr/Cdr.h> + + +#include <fastcdr/exceptions/BadParamException.h> +using namespace eprosima::fastcdr::exception; + +#include <utility> + +namespace helper { namespace internal { + +enum class Size { + UInt8, + UInt16, + UInt32, + UInt64, +}; + +constexpr Size get_size(int s) { + return (s <= 8 ) ? Size::UInt8: + (s <= 16) ? Size::UInt16: + (s <= 32) ? Size::UInt32: Size::UInt64; +} + +template<Size s> +struct FindTypeH; + +template<> +struct FindTypeH<Size::UInt8> { + using type = std::uint8_t; +}; + +template<> +struct FindTypeH<Size::UInt16> { + using type = std::uint16_t; +}; + +template<> +struct FindTypeH<Size::UInt32> { + using type = std::uint32_t; +}; + +template<> +struct FindTypeH<Size::UInt64> { + using type = std::uint64_t; +}; +} + +template<int S> +struct FindType { + using type = typename internal::FindTypeH<internal::get_size(S)>::type; +}; +} + +#define ShapeType_max_cdr_typesize 276ULL; + + + + +ShapeType::ShapeType() +{ + // /type_d() m_color + + // long m_x + m_x = 0; + // long m_y + m_y = 0; + // long m_shapesize + m_shapesize = 0; + +} + +ShapeType::~ShapeType() +{ +} + +ShapeType::ShapeType( + const ShapeType& x) +{ + m_color = x.m_color; + + + m_x = x.m_x; + + + m_y = x.m_y; + + + m_shapesize = x.m_shapesize; + +} + +ShapeType::ShapeType( + ShapeType&& x) noexcept +{ + m_color = std::move(x.m_color); + + + m_x = x.m_x; + + + m_y = x.m_y; + + + m_shapesize = x.m_shapesize; + +} + +ShapeType& ShapeType::operator =( + const ShapeType& x) +{ + m_color = x.m_color; + + + m_x = x.m_x; + + + m_y = x.m_y; + + + m_shapesize = x.m_shapesize; + + return *this; +} + +ShapeType& ShapeType::operator =( + ShapeType&& x) noexcept +{ + m_color = std::move(x.m_color); + + + m_x = x.m_x; + + + m_y = x.m_y; + + + m_shapesize = x.m_shapesize; + + return *this; +} + +bool ShapeType::operator ==( + const ShapeType& x) const +{ + return (m_color == x.m_color && + m_x == x.m_x && + m_y == x.m_y && + m_shapesize == x.m_shapesize); +} + +bool ShapeType::operator !=( + const ShapeType& x) const +{ + return !(*this == x); +} + +size_t ShapeType::getMaxCdrSerializedSize( + size_t current_alignment) +{ + static_cast<void>(current_alignment); + return ShapeType_max_cdr_typesize; +} + +size_t ShapeType::getCdrSerializedSize( + const ShapeType& data, + size_t current_alignment) +{ + (void)data; + size_t initial_alignment = current_alignment; + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4) + data.color().size() + 1; + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4); + + + return current_alignment - initial_alignment; +} + + +void ShapeType::serialize( + eprosima::fastcdr::Cdr& scdr) const +{ + scdr << m_color.c_str(); + + scdr << m_x; + + scdr << m_y; + + scdr << m_shapesize; + +} + +void ShapeType::deserialize( + eprosima::fastcdr::Cdr& dcdr) +{ + dcdr >> m_color; + + + + dcdr >> m_x; + + + + dcdr >> m_y; + + + + dcdr >> m_shapesize; + + +} + + +bool ShapeType::isKeyDefined() +{ + return true; +} + +void ShapeType::serializeKey( + eprosima::fastcdr::Cdr& scdr) const +{ + (void) scdr; + + scdr << m_color.c_str(); + + + + +} + +/*! + * @brief This function copies the value in member color + * @param _color New value to be copied in member color + */ +void ShapeType::color( + const std::string& _color) +{ + m_color = _color; +} + +/*! + * @brief This function moves the value in member color + * @param _color New value to be moved in member color + */ +void ShapeType::color( + std::string&& _color) +{ + m_color = std::move(_color); +} + +/*! + * @brief This function returns a constant reference to member color + * @return Constant reference to member color + */ +const std::string& ShapeType::color() const +{ + return m_color; +} + +/*! + * @brief This function returns a reference to member color + * @return Reference to member color + */ +std::string& ShapeType::color() +{ + return m_color; +} + + +/*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ +void ShapeType::x( + int32_t _x) +{ + m_x = _x; +} + +/*! + * @brief This function returns the value of member x + * @return Value of member x + */ +int32_t ShapeType::x() const +{ + return m_x; +} + +/*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ +int32_t& ShapeType::x() +{ + return m_x; +} + + +/*! + * @brief This function sets a value in member y + * @param _y New value for member y + */ +void ShapeType::y( + int32_t _y) +{ + m_y = _y; +} + +/*! + * @brief This function returns the value of member y + * @return Value of member y + */ +int32_t ShapeType::y() const +{ + return m_y; +} + +/*! + * @brief This function returns a reference to member y + * @return Reference to member y + */ +int32_t& ShapeType::y() +{ + return m_y; +} + + +/*! + * @brief This function sets a value in member shapesize + * @param _shapesize New value for member shapesize + */ +void ShapeType::shapesize( + int32_t _shapesize) +{ + m_shapesize = _shapesize; +} + +/*! + * @brief This function returns the value of member shapesize + * @return Value of member shapesize + */ +int32_t ShapeType::shapesize() const +{ + return m_shapesize; +} + +/*! + * @brief This function returns a reference to member shapesize + * @return Reference to member shapesize + */ +int32_t& ShapeType::shapesize() +{ + return m_shapesize; +} + + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/types/Shapev1.h b/types/Shapev1.h new file mode 100644 index 0000000..e6dc782 --- /dev/null +++ b/types/Shapev1.h @@ -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 Shape.h + * This header file contains the declaration of the described types in the IDL file. + * + * This file was generated by the tool fastddsgen. + */ + +#include <fastcdr/config.h> + +#if FASTCDR_VERSION_MAJOR == 1 + +#ifndef _FAST_DDS_GENERATED_SHAPE_H_ +#define _FAST_DDS_GENERATED_SHAPE_H_ + + +#include <fastrtps/utils/fixed_size_string.hpp> + +#include <stdint.h> +#include <array> +#include <string> +#include <vector> +#include <map> +#include <bitset> + +#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(SHAPE_SOURCE) +#define SHAPE_DllAPI __declspec( dllexport ) +#else +#define SHAPE_DllAPI __declspec( dllimport ) +#endif // SHAPE_SOURCE +#else +#define SHAPE_DllAPI +#endif // EPROSIMA_USER_DLL_EXPORT +#else +#define SHAPE_DllAPI +#endif // _WIN32 + +namespace eprosima { +namespace fastcdr { +class Cdr; +} // namespace fastcdr +} // namespace eprosima + + + + + +/*! + * @brief This class represents the structure ShapeType defined by the user in the IDL file. + * @ingroup Shape + */ +class ShapeType +{ +public: + + /*! + * @brief Default constructor. + */ + eProsima_user_DllExport ShapeType(); + + /*! + * @brief Default destructor. + */ + eProsima_user_DllExport ~ShapeType(); + + /*! + * @brief Copy constructor. + * @param x Reference to the object ShapeType that will be copied. + */ + eProsima_user_DllExport ShapeType( + const ShapeType& x); + + /*! + * @brief Move constructor. + * @param x Reference to the object ShapeType that will be copied. + */ + eProsima_user_DllExport ShapeType( + ShapeType&& x) noexcept; + + /*! + * @brief Copy assignment. + * @param x Reference to the object ShapeType that will be copied. + */ + eProsima_user_DllExport ShapeType& operator =( + const ShapeType& x); + + /*! + * @brief Move assignment. + * @param x Reference to the object ShapeType that will be copied. + */ + eProsima_user_DllExport ShapeType& operator =( + ShapeType&& x) noexcept; + + /*! + * @brief Comparison operator. + * @param x ShapeType object to compare. + */ + eProsima_user_DllExport bool operator ==( + const ShapeType& x) const; + + /*! + * @brief Comparison operator. + * @param x ShapeType object to compare. + */ + eProsima_user_DllExport bool operator !=( + const ShapeType& x) const; + + /*! + * @brief This function copies the value in member color + * @param _color New value to be copied in member color + */ + eProsima_user_DllExport void color( + const std::string& _color); + + /*! + * @brief This function moves the value in member color + * @param _color New value to be moved in member color + */ + eProsima_user_DllExport void color( + std::string&& _color); + + /*! + * @brief This function returns a constant reference to member color + * @return Constant reference to member color + */ + eProsima_user_DllExport const std::string& color() const; + + /*! + * @brief This function returns a reference to member color + * @return Reference to member color + */ + eProsima_user_DllExport std::string& color(); + + + /*! + * @brief This function sets a value in member x + * @param _x New value for member x + */ + eProsima_user_DllExport void x( + int32_t _x); + + /*! + * @brief This function returns the value of member x + * @return Value of member x + */ + eProsima_user_DllExport int32_t x() const; + + /*! + * @brief This function returns a reference to member x + * @return Reference to member x + */ + eProsima_user_DllExport int32_t& x(); + + + /*! + * @brief This function sets a value in member y + * @param _y New value for member y + */ + eProsima_user_DllExport void y( + int32_t _y); + + /*! + * @brief This function returns the value of member y + * @return Value of member y + */ + eProsima_user_DllExport int32_t y() const; + + /*! + * @brief This function returns a reference to member y + * @return Reference to member y + */ + eProsima_user_DllExport int32_t& y(); + + + /*! + * @brief This function sets a value in member shapesize + * @param _shapesize New value for member shapesize + */ + eProsima_user_DllExport void shapesize( + int32_t _shapesize); + + /*! + * @brief This function returns the value of member shapesize + * @return Value of member shapesize + */ + eProsima_user_DllExport int32_t shapesize() const; + + /*! + * @brief This function returns a reference to member shapesize + * @return Reference to member shapesize + */ + eProsima_user_DllExport int32_t& shapesize(); + + + /*! + * @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 ShapeType& data, + size_t current_alignment = 0); + + + + /*! + * @brief This function serializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serialize( + eprosima::fastcdr::Cdr& cdr) const; + + /*! + * @brief This function deserializes an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void deserialize( + eprosima::fastcdr::Cdr& cdr); + + + + + /*! + * @brief This function tells you if the Key has been defined for this type + */ + eProsima_user_DllExport static bool isKeyDefined(); + + /*! + * @brief This function serializes the key members of an object using CDR serialization. + * @param cdr CDR serialization object. + */ + eProsima_user_DllExport void serializeKey( + eprosima::fastcdr::Cdr& cdr) const; + + +private: + + std::string m_color; + int32_t m_x; + int32_t m_y; + int32_t m_shapesize; + +}; + + +#endif // _FAST_DDS_GENERATED_SHAPE_H_ + + + +#endif // FASTCDR_VERSION_MAJOR == 1 diff --git a/version.pri b/version.pri index ee28220..4910f38 100644 --- a/version.pri +++ b/version.pri @@ -1,2 +1,2 @@ -SHAPESVERSION="2.12.0" +SHAPESVERSION="2.12.1"