Skip to content

Commit

Permalink
Support both fastcdr v1 and v2 (#96)
Browse files Browse the repository at this point in the history
* Refs #19760. Coexist fastcdr v1 and v2

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #19760. Coexist fastcdr v1 and v2 [new approach]

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Refs #19760. Fix

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>

* Uncrustify

Signed-off-by: tempate <danieldiaz@eprosima.com>

---------

Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
Signed-off-by: tempate <danieldiaz@eprosima.com>
Co-authored-by: tempate <danieldiaz@eprosima.com>
  • Loading branch information
richiware and Tempate committed Dec 29, 2023
1 parent 7b8e279 commit 824e664
Show file tree
Hide file tree
Showing 93 changed files with 12,138 additions and 3,019 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,26 @@ 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})
add_library(${PROJECT_NAME} SHARED
DdsRecorderCommand.cxx
DdsRecorderCommandv1.cxx
DdsRecorderCommandPubSubTypes.cxx
)
if(WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT)
endif(WIN32)
target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr fastrtps)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
target_include_directories(${PROJECT_NAME} PUBLIC
${PROJECT_SOURCE_DIR}
)
target_link_libraries(${PROJECT_NAME}
PUBLIC
fastcdr
fastrtps
)

###############################################################################
# Python bindings for type
Expand Down Expand Up @@ -70,25 +74,29 @@ SET_SOURCE_FILES_PROPERTIES(
USE_TARGET_INCLUDE_DIRECTORIES TRUE
)

include_directories(
${PROJECT_SOURCE_DIR}
)
set_property(SOURCE ${PROJECT_NAME}.i PROPERTY OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/")

SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE}
TYPE SHARED
LANGUAGE python
SOURCES ${${PROJECT_NAME}_MODULE_FILES})

set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY CXX_STANDARD 11)
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}
target_link_libraries(${${PROJECT_NAME}_MODULE}
Python3::Module
fastrtps
${PROJECT_NAME}
)

set_target_properties(${${PROJECT_NAME}_MODULE}
PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
)


# 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
Expand All @@ -107,7 +115,7 @@ install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib/
ARCHIVE DESTINATION lib/
)
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH})
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})
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH}/)

Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

/*!
* @file DdsRecorderCommand.cpp
* This source file contains the definition of the described types in the IDL file.
* This source file contains the implementation of the described types in the IDL file.
*
* This file was generated by the tool gen.
* This file was generated by the tool fastddsgen.
*/

#ifdef _WIN32
Expand All @@ -27,29 +27,26 @@ char dummy;
#endif // _WIN32

#include "DdsRecorderCommand.h"

#if FASTCDR_VERSION_MAJOR > 1

#include <fastcdr/Cdr.h>


#include <fastcdr/exceptions/BadParamException.h>
using namespace eprosima::fastcdr::exception;

#include <utility>

#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(
Expand All @@ -60,7 +57,7 @@ DdsRecorderCommand::DdsRecorderCommand(
}

DdsRecorderCommand::DdsRecorderCommand(
DdsRecorderCommand&& x) noexcept
DdsRecorderCommand&& x) noexcept
{
m_command = std::move(x.m_command);
m_args = std::move(x.m_args);
Expand All @@ -72,7 +69,6 @@ DdsRecorderCommand& DdsRecorderCommand::operator =(

m_command = x.m_command;
m_args = x.m_args;

return *this;
}

Expand All @@ -82,15 +78,14 @@ DdsRecorderCommand& DdsRecorderCommand::operator =(

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);
return (m_command == x.m_command &&
m_args == x.m_args);
}

bool DdsRecorderCommand::operator !=(
Expand All @@ -99,46 +94,6 @@ bool DdsRecorderCommand::operator !=(
return !(*this == x);
}

size_t DdsRecorderCommand::getMaxCdrSerializedSize(
size_t current_alignment)
{
static_cast<void>(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
Expand Down Expand Up @@ -176,6 +131,7 @@ 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
Expand Down Expand Up @@ -214,21 +170,7 @@ std::string& DdsRecorderCommand::args()
return m_args;
}

// Include auxiliary functions like for serializing/deserializing.
#include "DdsRecorderCommandCdrAux.ipp"

size_t DdsRecorderCommand::getKeyMaxCdrSerializedSize(
size_t current_alignment)
{
static_cast<void>(current_alignment);
return DdsRecorderCommand_max_key_cdr_typesize;
}

bool DdsRecorderCommand::isKeyDefined()
{
return false;
}

void DdsRecorderCommand::serializeKey(
eprosima::fastcdr::Cdr& scdr) const
{
(void) scdr;
}
#endif // FASTCDR_VERSION_MAJOR > 1

0 comments on commit 824e664

Please sign in to comment.