Skip to content

Commit 8d703cd

Browse files
Add RPC Client/Server examples documentation (#1064)
* Refs #23031: Add fastddsgen documentation Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Add examples source code Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Clear block separator comments in source code files Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Regenerate types in basic example. Delete ping_server method and PENDING status Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Add examples and refactor request/reply section Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Fix workspace name Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Update examples Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Update documentation Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Fix spelling, typos and executable names Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Add tests Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Fix @feed icon Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Move code_blocks code to src Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Delete KEEP_ALL manual configuration and update internal api docs Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Review - Remove indentation in RPC internal API examples Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Review - Update RPC internal API image Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Add data streaming sections and refactor request-reply section Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Review - Update examples Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Fix request reply subsections order Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Review - Separate with toctrees Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Fix spelling Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Add br Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Fix typo Signed-off-by: Carlosespicur <carlosespicur@proton.me> * Refs #23031: Update docs and regenerate types Signed-off-by: Carlosespicur <carlosespicur@proton.me> --------- Signed-off-by: Carlosespicur <carlosespicur@proton.me>
1 parent 54caf46 commit 8d703cd

91 files changed

Lines changed: 14646 additions & 42 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

code/CMakeLists.txt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ else()
4242
endif()
4343

4444
####################################################################################################
45-
# Compile getting started tutorial
45+
# Compile examples
4646
####################################################################################################
4747
add_subdirectory(Examples/C++/DDSHelloWorld)
48+
add_subdirectory(Examples/C++/RpcClientServerBasic)
49+
add_subdirectory(Examples/C++/RpcClientServerFeed)
4850

4951
####################################################################################################
5052
# Compile test applications
@@ -98,6 +100,12 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/StaticTester.xml
98100
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/helloworld_test.py
99101
${CMAKE_CURRENT_BINARY_DIR}/helloworld_test.py COPYONLY)
100102

103+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rpc_calculator_basic_test.py
104+
${CMAKE_CURRENT_BINARY_DIR}/rpc_calculator_basic_test.py COPYONLY)
105+
106+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rpc_calculator_feed_test.py
107+
${CMAKE_CURRENT_BINARY_DIR}/rpc_calculator_feed_test.py COPYONLY)
108+
101109
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/grep.py
102110
${CMAKE_CURRENT_BINARY_DIR}/grep.py COPYONLY)
103111

@@ -132,14 +140,26 @@ add_test(NAME xml.fastdds_permissions_test
132140
# Check validity of Static discovery XML file
133141
add_test(NAME xml.static_discovery COMMAND dds-doctest StaticTester.xml)
134142

135-
# Check that the helloworld example runs as expected
143+
# Check that the helloworld and RPC calculator examples run as expected
136144
find_package(Python3 COMPONENTS Interpreter Development)
137145
if(${Python3_FOUND} AND (${Python3_VERSION} VERSION_GREATER "3.6"))
138146
add_test(NAME helloworld COMMAND ${Python3_EXECUTABLE} helloworld_test.py)
139147
set_property(TEST helloworld
140148
APPEND PROPERTY ENVIRONMENT "HELLOWORLD_PUB_TEST_BIN=$<TARGET_FILE:DDSHelloWorldPublisher>")
141149
set_property(TEST helloworld
142150
APPEND PROPERTY ENVIRONMENT "HELLOWORLD_SUB_TEST_BIN=$<TARGET_FILE:DDSHelloWorldSubscriber>")
151+
152+
add_test(NAME calculator_basic COMMAND ${Python3_EXECUTABLE} rpc_calculator_basic_test.py)
153+
set_property(TEST calculator_basic
154+
APPEND PROPERTY ENVIRONMENT "CLIENT_TEST_BIN=$<TARGET_FILE:basic_client>")
155+
set_property(TEST calculator_basic
156+
APPEND PROPERTY ENVIRONMENT "SERVER_TEST_BIN=$<TARGET_FILE:basic_server>")
157+
158+
add_test(NAME calculator_feed COMMAND ${Python3_EXECUTABLE} rpc_calculator_feed_test.py)
159+
set_property(TEST calculator_feed
160+
APPEND PROPERTY ENVIRONMENT "CLIENT_TEST_BIN=$<TARGET_FILE:feed_client>")
161+
set_property(TEST calculator_feed
162+
APPEND PROPERTY ENVIRONMENT "SERVER_TEST_BIN=$<TARGET_FILE:feed_server>")
143163
endif()
144164

145165
# Check docs style

code/DDSCodeTester.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <thread>
55

66
#include <fastcdr/Cdr.h>
7+
#include <fastcdr/xcdr/optional.hpp>
78

89
#include <fastdds/dds/builtin/topic/ParticipantBuiltinTopicData.hpp>
910
#include <fastdds/dds/core/condition/GuardCondition.hpp>
@@ -24,6 +25,9 @@
2425
#include <fastdds/dds/publisher/PublisherListener.hpp>
2526
#include <fastdds/dds/publisher/qos/DataWriterQos.hpp>
2627
#include <fastdds/dds/publisher/qos/PublisherQos.hpp>
28+
#include <fastdds/dds/rpc/exceptions.hpp>
29+
#include <fastdds/dds/rpc/interfaces.hpp>
30+
#include <fastdds/dds/rpc/RemoteExceptionCode_t.hpp>
2731
#include <fastdds/dds/rpc/Replier.hpp>
2832
#include <fastdds/dds/rpc/Requester.hpp>
2933
#include <fastdds/dds/rpc/RequestInfo.hpp>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2025 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+
cmake_minimum_required(VERSION 3.20)
16+
17+
project(RpcClientServerBasic)
18+
19+
# Find requirements
20+
if(NOT fastcdr_FOUND)
21+
find_package(fastcdr 2 REQUIRED)
22+
endif()
23+
24+
if(NOT fastdds_FOUND)
25+
find_package(fastdds 3.2.0 REQUIRED)
26+
endif()
27+
28+
# Set C++11
29+
include(CheckCXXCompilerFlag)
30+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
31+
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
32+
check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11)
33+
if(SUPPORTS_CXX11)
34+
add_compile_options(-std=c++11)
35+
else()
36+
message(FATAL_ERROR "Compiler doesn't support C++11")
37+
endif()
38+
endif()
39+
40+
message(STATUS "Configuring client server basic example...")
41+
file(GLOB CLIENT_SERVER_BASIC_TYPES_SOURCES_CXX "src/types/*.cxx")
42+
file(GLOB CLIENT_SERVER_BASIC_TYPES_SOURCES_IPP "src/types/*.ipp")
43+
44+
add_executable(basic_client src/CalculatorClient.cpp
45+
${CLIENT_SERVER_BASIC_TYPES_SOURCES_CXX}
46+
${CLIENT_SERVER_BASIC_TYPES_SOURCES_IPP}
47+
)
48+
49+
target_link_libraries(basic_client fastdds fastcdr)
50+
51+
add_executable(basic_server src/CalculatorServer.cpp
52+
${CLIENT_SERVER_BASIC_TYPES_SOURCES_CXX}
53+
${CLIENT_SERVER_BASIC_TYPES_SOURCES_IPP}
54+
)
55+
56+
target_link_libraries(basic_server fastdds fastcdr)

0 commit comments

Comments
 (0)