Skip to content

Commit 5b3253b

Browse files
committed
Refs #23079. Generate code with fastddsgen.
Signed-off-by: Miguel Company <miguelcompany@eprosima.com>
1 parent 8939292 commit 5b3253b

16 files changed

Lines changed: 8048 additions & 0 deletions
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
2+
cmake_minimum_required(VERSION 3.20)
3+
4+
# SWIG: use standard target name.
5+
if(POLICY CMP0078)
6+
cmake_policy(SET CMP0078 NEW)
7+
endif()
8+
9+
# SWIG: use SWIG_MODULE_NAME property.
10+
if(POLICY CMP0086)
11+
cmake_policy(SET CMP0086 NEW)
12+
endif()
13+
14+
###############################################################################
15+
# Library for types defined in calculator IDL
16+
###############################################################################
17+
18+
message(STATUS "Configuring python wrapper for types in calculator...")
19+
20+
###############################################################################
21+
# Type library on C++
22+
23+
project(calculator)
24+
25+
find_package(fastcdr REQUIRED)
26+
find_package(fastdds 3 REQUIRED)
27+
28+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
29+
30+
#Create library for C++ types
31+
add_library(${PROJECT_NAME} SHARED
32+
calculatorTypeObjectSupport.cxx
33+
calculatorPubSubTypes.cxx
34+
calculatorClient.cxx
35+
calculatorServer.cxx
36+
)
37+
if(WIN32)
38+
target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT)
39+
endif(WIN32)
40+
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11)
41+
target_include_directories(${PROJECT_NAME} PUBLIC
42+
${PROJECT_SOURCE_DIR}
43+
)
44+
target_link_libraries(${PROJECT_NAME}
45+
PUBLIC
46+
fastcdr
47+
fastdds
48+
)
49+
50+
###############################################################################
51+
# Python bindings for type
52+
53+
find_package(SWIG)
54+
if (NOT SWIG_FOUND)
55+
# Trick to find swig4.1 in Ubuntu noble.
56+
find_program(SWIG_EXECUTABLE NAMES swig4.1 swig)
57+
find_package(SWIG REQUIRED)
58+
endif()
59+
include(${SWIG_USE_FILE})
60+
set(CMAKE_SWIG_FLAGS "")
61+
62+
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
63+
set(PYTHON_INCLUDE_PATH ${Python3_INCLUDE_DIRS})
64+
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
65+
set(PYTHON_LIBRARIES ${Python3_LIBRARIES})
66+
67+
include_directories(${PYTHON_INCLUDE_PATH})
68+
69+
set(${PROJECT_NAME}_MODULE
70+
calculatorWrapper
71+
)
72+
73+
set(${PROJECT_NAME}_MODULE_FILES
74+
calculator.i
75+
)
76+
77+
SET_SOURCE_FILES_PROPERTIES(
78+
${${PROJECT_NAME}_MODULE_FILES}
79+
PROPERTIES CPLUSPLUS ON
80+
USE_TARGET_INCLUDE_DIRECTORIES TRUE
81+
)
82+
83+
SWIG_ADD_LIBRARY(${${PROJECT_NAME}_MODULE}
84+
TYPE SHARED
85+
LANGUAGE python
86+
SOURCES ${${PROJECT_NAME}_MODULE_FILES})
87+
88+
set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY CXX_STANDARD 11)
89+
if(UNIX AND CMAKE_SIZEOF_VOID_P EQUAL 8)
90+
set_property(TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_COMPILE_DEFINITIONS SWIGWORDSIZE64)
91+
endif()
92+
93+
target_link_libraries(${${PROJECT_NAME}_MODULE}
94+
Python3::Module
95+
fastdds
96+
${PROJECT_NAME}
97+
)
98+
99+
# Find the installation path
100+
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))"
101+
OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH
102+
OUTPUT_STRIP_TRAILING_WHITESPACE
103+
)
104+
105+
get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE)
106+
file (RELATIVE_PATH _REL_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH})
107+
SET (PYTHON_MODULE_PATH
108+
${_REL_PYTHON_MODULE_PATH}/${PROJECT_NAME}
109+
)
110+
111+
# Install
112+
install(TARGETS ${PROJECT_NAME}
113+
RUNTIME DESTINATION bin/
114+
LIBRARY DESTINATION lib/
115+
ARCHIVE DESTINATION lib/
116+
)
117+
install(TARGETS ${${PROJECT_NAME}_MODULE} DESTINATION ${PYTHON_MODULE_PATH})
118+
get_property(support_files TARGET ${${PROJECT_NAME}_MODULE} PROPERTY SWIG_SUPPORT_FILES)
119+
install(FILES ${support_files} DESTINATION ${PYTHON_MODULE_PATH} RENAME __init__.py)
120+
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
/*!
16+
* @file calculator.hpp
17+
* This header file contains the declaration of the described types in the IDL file.
18+
*
19+
* This file was generated by the tool fastddsgen (version: 4.1.0).
20+
*/
21+
22+
#ifndef FAST_DDS_GENERATED__CALCULATOR_HPP
23+
#define FAST_DDS_GENERATED__CALCULATOR_HPP
24+
25+
#include <cstdint>
26+
#include <memory>
27+
#include <string>
28+
#include <utility>
29+
#include <fastcdr/cdr/fixed_size_string.hpp>
30+
#include <fastcdr/xcdr/optional.hpp>
31+
#include <fastdds/dds/rpc/exceptions/RpcOperationError.hpp>
32+
#include <fastdds/dds/rpc/interfaces/RpcClientReader.hpp>
33+
#include <fastdds/dds/rpc/interfaces/RpcClientWriter.hpp>
34+
#include <fastdds/dds/rpc/interfaces/RpcFuture.hpp>
35+
36+
37+
#if defined(_WIN32)
38+
#if defined(EPROSIMA_USER_DLL_EXPORT)
39+
#define eProsima_user_DllExport __declspec( dllexport )
40+
#else
41+
#define eProsima_user_DllExport
42+
#endif // EPROSIMA_USER_DLL_EXPORT
43+
#else
44+
#define eProsima_user_DllExport
45+
#endif // _WIN32
46+
47+
#if defined(_WIN32)
48+
#if defined(EPROSIMA_USER_DLL_EXPORT)
49+
#if defined(CALCULATOR_SOURCE)
50+
#define CALCULATOR_DllAPI __declspec( dllexport )
51+
#else
52+
#define CALCULATOR_DllAPI __declspec( dllimport )
53+
#endif // CALCULATOR_SOURCE
54+
#else
55+
#define CALCULATOR_DllAPI
56+
#endif // EPROSIMA_USER_DLL_EXPORT
57+
#else
58+
#define CALCULATOR_DllAPI
59+
#endif // _WIN32
60+
61+
namespace calculator_base {
62+
63+
/*!
64+
* @brief This class implements the user exception calculator_base::OverflowException
65+
* @ingroup calculator
66+
*/
67+
class eProsima_user_DllExport OverflowException : public eprosima::fastdds::dds::rpc::RpcOperationError
68+
{
69+
public:
70+
71+
/**
72+
* Default constructor.
73+
*/
74+
OverflowException()
75+
: OverflowException("OverflowException")
76+
{
77+
}
78+
79+
/**
80+
* Constructor.
81+
*/
82+
OverflowException(
83+
const std::string& message)
84+
: eprosima::fastdds::dds::rpc::RpcOperationError(message)
85+
{
86+
}
87+
88+
/**
89+
* Constructor.
90+
*/
91+
OverflowException(
92+
const char* message)
93+
: eprosima::fastdds::dds::rpc::RpcOperationError(message)
94+
{
95+
}
96+
97+
/**
98+
* Copy constructor.
99+
*/
100+
OverflowException(
101+
const OverflowException& other) noexcept = default;
102+
103+
/**
104+
* Copy assignment.
105+
*/
106+
OverflowException& operator =(
107+
const OverflowException& other) noexcept = default;
108+
109+
/**
110+
* Destructor.
111+
*/
112+
virtual ~OverflowException() noexcept = default;
113+
114+
115+
116+
private:
117+
118+
119+
};
120+
121+
/*!
122+
* @brief This class represents the interface Adder defined by the user in the IDL file.
123+
* @ingroup calculator
124+
*/
125+
class eProsima_user_DllExport Adder
126+
{
127+
public:
128+
virtual ~Adder() = default;
129+
130+
virtual eprosima::fastdds::dds::rpc::RpcFuture<int32_t> addition(
131+
/*in*/ int32_t value1,
132+
/*in*/ int32_t value2) = 0;
133+
134+
};
135+
/*!
136+
* @brief This class represents the interface Subtractor defined by the user in the IDL file.
137+
* @ingroup calculator
138+
*/
139+
class eProsima_user_DllExport Subtractor
140+
{
141+
public:
142+
virtual ~Subtractor() = default;
143+
144+
virtual eprosima::fastdds::dds::rpc::RpcFuture<int32_t> subtraction(
145+
/*in*/ int32_t value1,
146+
/*in*/ int32_t value2) = 0;
147+
148+
};
149+
/*!
150+
* @brief This class represents the interface BasicCalculator defined by the user in the IDL file.
151+
* @ingroup calculator
152+
*/
153+
class eProsima_user_DllExport BasicCalculator : public calculator_base::Adder, public calculator_base::Subtractor
154+
{
155+
public:
156+
virtual ~BasicCalculator() = default;
157+
158+
virtual eprosima::fastdds::dds::rpc::RpcFuture<void> representation_limits(
159+
/*out*/ int32_t& min_value,
160+
/*out*/ int32_t& max_value) = 0;
161+
162+
};
163+
164+
} // namespace calculator_base
165+
/*!
166+
* @brief This class represents the interface Calculator defined by the user in the IDL file.
167+
* @ingroup calculator
168+
*/
169+
class eProsima_user_DllExport Calculator : public calculator_base::BasicCalculator
170+
{
171+
public:
172+
virtual ~Calculator() = default;
173+
174+
virtual std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientReader<int32_t> > fibonacci_seq(
175+
/*in*/ uint32_t n_results) = 0;
176+
177+
virtual eprosima::fastdds::dds::rpc::RpcFuture<int32_t> sum_all(
178+
/*in*/ std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientWriter<int32_t>>& value) = 0;
179+
180+
virtual std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientReader<int32_t> > accumulator(
181+
/*in*/ std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientWriter<int32_t>>& value) = 0;
182+
183+
};
184+
185+
#endif // _FAST_DDS_GENERATED_CALCULATOR_HPP_
186+
187+

0 commit comments

Comments
 (0)