-
Notifications
You must be signed in to change notification settings - Fork 24
[23079] Add RPC interfaces, exceptions, and example #233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5de871b
Refs #23079. Add rpc interfaces to python bindings.
MiguelCompany a8288c6
Refs #23079. Add rpc exceptions to python bindings.
MiguelCompany 36c2f59
Refs #23079. Add calculator IDL and example python code.
MiguelCompany eca25d9
Refs #23079. Generate code with fastddsgen.
MiguelCompany 1542e36
Refs #23079. Build new example.
MiguelCompany f1132c7
Refs #23079. Add new example to regeneration script.
MiguelCompany a0faaa4
Refs #23079. Move generated code to a different folder.
MiguelCompany 038929a
Refs #23079. Add readme for RPC example.
MiguelCompany 3110a62
Refs #23079. Move HelloWorld generated code to a different folder.
MiguelCompany File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| %{ | ||
| #include "fastdds/dds/rpc/exceptions.hpp" | ||
| %} | ||
|
|
||
| // Base class should be included first | ||
| %include "fastdds/dds/rpc/exceptions/RpcException.hpp" | ||
| // Include first level inheritance | ||
| %include "fastdds/dds/rpc/exceptions/RpcBrokenPipeException.hpp" | ||
| %include "fastdds/dds/rpc/exceptions/RpcFeedCancelledException.hpp" | ||
| %include "fastdds/dds/rpc/exceptions/RpcOperationError.hpp" | ||
| %include "fastdds/dds/rpc/exceptions/RpcTimeoutException.hpp" | ||
| // This is the base class for second level inheritance | ||
| %include "fastdds/dds/rpc/RemoteExceptionCode_t.hpp" | ||
| %include "fastdds/dds/rpc/exceptions/RpcRemoteException.hpp" | ||
| // Include second level inheritance | ||
| %include "fastdds/dds/rpc/exceptions/RemoteInvalidArgumentError.hpp" | ||
| %include "fastdds/dds/rpc/exceptions/RemoteOutOfResourcesError.hpp" | ||
| %include "fastdds/dds/rpc/exceptions/RemoteUnknownExceptionError.hpp" | ||
| %include "fastdds/dds/rpc/exceptions/RemoteUnknownOperationError.hpp" | ||
| %include "fastdds/dds/rpc/exceptions/RemoteUnsupportedError.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| %{ | ||
| #include "fastdds/dds/rpc/interfaces.hpp" | ||
| %} | ||
|
|
||
| %include "fastdds/dds/rpc/interfaces/RpcStatusCode.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
|
|
||
| cmake_minimum_required(VERSION 3.20) | ||
|
|
||
| # 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 calculator IDL | ||
| ############################################################################### | ||
|
|
||
| message(STATUS "Configuring python wrapper for types in calculator...") | ||
|
|
||
| ############################################################################### | ||
| # Type library on C++ | ||
|
|
||
| project(calculator) | ||
|
|
||
| find_package(fastcdr REQUIRED) | ||
| find_package(fastdds 3 REQUIRED) | ||
|
|
||
| set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
|
||
| #Create library for C++ types | ||
| add_library(${PROJECT_NAME} SHARED | ||
| calculatorTypeObjectSupport.cxx | ||
| calculatorPubSubTypes.cxx | ||
| calculatorClient.cxx | ||
| calculatorServer.cxx | ||
| ) | ||
| if(WIN32) | ||
| target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT) | ||
| endif(WIN32) | ||
| 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 | ||
| fastdds | ||
| ) | ||
|
|
||
| ############################################################################### | ||
| # Python bindings for type | ||
|
|
||
| find_package(SWIG) | ||
| if (NOT SWIG_FOUND) | ||
| # Trick to find swig4.1 in Ubuntu noble. | ||
| find_program(SWIG_EXECUTABLE NAMES swig4.1 swig) | ||
| find_package(SWIG REQUIRED) | ||
| endif() | ||
| 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 | ||
| calculatorWrapper | ||
| ) | ||
|
|
||
| set(${PROJECT_NAME}_MODULE_FILES | ||
| calculator.i | ||
| ) | ||
|
|
||
| SET_SOURCE_FILES_PROPERTIES( | ||
| ${${PROJECT_NAME}_MODULE_FILES} | ||
| PROPERTIES CPLUSPLUS ON | ||
| USE_TARGET_INCLUDE_DIRECTORIES TRUE | ||
| ) | ||
|
|
||
| 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() | ||
|
|
||
| target_link_libraries(${${PROJECT_NAME}_MODULE} | ||
| Python3::Module | ||
| fastdds | ||
| ${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}/${PROJECT_NAME} | ||
| ) | ||
|
|
||
| # 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} RENAME __init__.py) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.