Skip to content

Commit eb71379

Browse files
Remove @feed operations from example (#256) (#260)
* Remove `@feed` operations from example (#256) * Refs #23701. Remove feed operations from example. Signed-off-by: Miguel Company <miguelcompany@eprosima.com> * Refs #23703. Apply suggestion. Signed-off-by: Miguel Company <miguelcompany@eprosima.com> --------- Signed-off-by: Miguel Company <miguelcompany@eprosima.com> (cherry picked from commit e143c3b) # Conflicts: # fastdds_python_examples/RPCExample/generated_code/calculator.i # fastdds_python_examples/RPCExample/generated_code/calculatorClient.cxx # fastdds_python_examples/RPCExample/generated_code/calculatorPubSubTypes.cxx # fastdds_python_examples/RPCExample/generated_code/calculatorServer.cxx # fastdds_python_examples/RPCExample/generated_code/calculatorServer.hpp # fastdds_python_examples/RPCExample/generated_code/calculatorServerImpl.hpp # fastdds_python_examples/RPCExample/generated_code/calculatorTypeObjectSupport.cxx * Fix conflicts. Signed-off-by: Miguel Company <miguelcompany@eprosima.com> --------- Signed-off-by: Miguel Company <miguelcompany@eprosima.com> Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
1 parent 4ee6ecf commit eb71379

16 files changed

Lines changed: 206 additions & 4754 deletions

fastdds_python_examples/RPCExample/CalculatorExample.py

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -50,38 +50,6 @@ def representation_limits(self, info):
5050
ret_val.max_value = 2147483647
5151
return ret_val
5252

53-
def fibonacci_seq(self, info, n_results, result_writer):
54-
self.operation_call_print(info, "fibonacci_seq")
55-
a = 1
56-
b = 1
57-
c = 0
58-
59-
while n_results > 0:
60-
n_results = n_results - 1
61-
62-
result_writer.write(a)
63-
c = a + b
64-
a = b
65-
b = c
66-
67-
def sum_all(self, info, value):
68-
self.operation_call_print(info, "sum_all")
69-
ret = 0
70-
has_value, n = value.read()
71-
while has_value:
72-
ret = ret + n
73-
has_value, n = value.read()
74-
return ret
75-
76-
def accumulator(self, info, value, result_writer):
77-
self.operation_call_print(info, "accumulator")
78-
ret = 0
79-
has_value, n = value.read()
80-
while has_value:
81-
ret = ret + n
82-
result_writer.write(ret)
83-
has_value, n = value.read()
84-
8553
### Server application ###
8654

8755
def run_server(server):
@@ -134,9 +102,6 @@ def run(self):
134102
self.perform_addition()
135103
self.perform_subtraction()
136104
self.perform_representation_limits()
137-
self.perform_fibonacci_seq()
138-
self.perform_sum_all()
139-
self.perform_accumulator()
140105

141106
def perform_addition(self):
142107
try:
@@ -180,51 +145,6 @@ def perform_representation_limits(self):
180145
print("Exception: {}".format(type(e).__name__))
181146
print("Exception message: {}".format(e))
182147

183-
def perform_fibonacci_seq(self):
184-
try:
185-
print("Performing fibonacci_seq(10)")
186-
result = self.client.fibonacci_seq(10)
187-
has_value, n = result.read()
188-
while has_value:
189-
print("Result: {}".format(n))
190-
has_value, n = result.read()
191-
except Exception as e:
192-
print("Exception: {}".format(type(e).__name__))
193-
print("Exception message: {}".format(e))
194-
195-
def perform_sum_all(self):
196-
try:
197-
print("Performing sum_all([1, 2, 3, 4, 5])")
198-
result, value = self.client.sum_all()
199-
value.write(1)
200-
value.write(2)
201-
value.write(3)
202-
value.write(4)
203-
value.write(5)
204-
value.finish()
205-
print("Result: {}".format(result.get()))
206-
except Exception as e:
207-
print("Exception: {}".format(type(e).__name__))
208-
print("Exception message: {}".format(e))
209-
210-
def perform_accumulator(self):
211-
try:
212-
print("Performing accumulator([1, 2, 3, 4, 5])")
213-
result, value = self.client.accumulator()
214-
value.write(1)
215-
value.write(2)
216-
value.write(3)
217-
value.write(4)
218-
value.write(5)
219-
value.finish()
220-
has_value, n = result.read()
221-
while has_value:
222-
print("Result: {}".format(n))
223-
has_value, n = result.read()
224-
except Exception as e:
225-
print("Exception: {}".format(type(e).__name__))
226-
print("Exception message: {}".format(e))
227-
228148
def parse_options():
229149
""""
230150
Parse arguments.

fastdds_python_examples/RPCExample/calculator.idl

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,10 @@ module calculator_base
3232
// Returns the result of value1 - value2
3333
long subtraction(in long value1, in long value2) raises(OverflowException);
3434
};
35-
36-
interface BasicCalculator : Adder, Subtractor
37-
{
38-
// Returns the minimum and maximum representable values
39-
void representation_limits(out long min_value, out long max_value);
40-
};
4135
};
4236

43-
interface Calculator : calculator_base::BasicCalculator
37+
interface Calculator : calculator_base::Adder, calculator_base::Subtractor
4438
{
45-
// Returns a feed of results with the n_results first elements of the Fibonacci sequence
46-
// E.g. for an input of 5, returns a feed with {1, 1, 2, 3, 5}
47-
@feed long fibonacci_seq(in unsigned long n_results) raises (calculator_base::OverflowException);
48-
49-
// Waits for an input feed to finish and returns the sum of all the received values
50-
// E.g. for an input of {1, 2, 3, 4, 5} returns 15
51-
long sum_all(@feed in long value) raises (calculator_base::OverflowException);
52-
53-
// Returns a feed of results with the sum of all received values
54-
// E.g. for an input of {1, 2, 3, 4, 5}, returns a feed with {1, 3, 6, 10, 15}
55-
@feed long accumulator(@feed in long value) raises (calculator_base::OverflowException);
39+
// Returns the minimum and maximum representable values
40+
void representation_limits(out long min_value, out long max_value);
5641
};

fastdds_python_examples/RPCExample/generated_code/CMakeLists.txt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
11

2-
# Copyright 2025 Proyectos y Sistemas de Mantenimiento SL (eProsima).
3-
#
4-
# Licensed under the Apache License, Version 2.0 (the "License");
5-
# you may not use this file except in compliance with the License.
6-
# You may obtain a copy of the License at
7-
#
8-
# http://www.apache.org/licenses/LICENSE-2.0
9-
#
10-
# Unless required by applicable law or agreed to in writing, software
11-
# distributed under the License is distributed on an "AS IS" BASIS,
12-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
# See the License for the specific language governing permissions and
14-
# limitations under the License.
15-
162
cmake_minimum_required(VERSION 3.20)
173

184
# SWIG: use standard target name.
@@ -41,19 +27,9 @@ find_package(fastdds 3 REQUIRED)
4127

4228
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
4329

44-
if(NOT WIN32)
45-
# Default values for shared library suffix in MacOS
46-
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
47-
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
48-
endif()
49-
endif()
50-
5130
#Create library for C++ types
5231
add_library(${PROJECT_NAME} SHARED
5332
calculatorTypeObjectSupport.cxx
54-
calculatorPubSubTypes.cxx
55-
calculatorClient.cxx
56-
calculatorServer.cxx
5733
)
5834
if(WIN32)
5935
target_compile_definitions(${PROJECT_NAME} PRIVATE EPROSIMA_USER_DLL_EXPORT)

fastdds_python_examples/RPCExample/generated_code/calculator.hpp

Lines changed: 4 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,14 @@
1616
* @file calculator.hpp
1717
* This header file contains the declaration of the described types in the IDL file.
1818
*
19-
* This file was generated by the tool fastddsgen (version: 4.1.0).
19+
* This file was generated by the tool fastddsgen (version: 4.0.4).
2020
*/
2121

2222
#ifndef FAST_DDS_GENERATED__CALCULATOR_HPP
2323
#define FAST_DDS_GENERATED__CALCULATOR_HPP
2424

2525
#include <cstdint>
26-
#include <memory>
27-
#include <string>
2826
#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-
3627

3728
#if defined(_WIN32)
3829
#if defined(EPROSIMA_USER_DLL_EXPORT)
@@ -60,161 +51,36 @@
6051

6152
namespace calculator_base {
6253

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-
12254
/*!
12355
* @brief This class represents the interface Adder defined by the user in the IDL file.
12456
* @ingroup calculator
12557
*/
126-
class eProsima_user_DllExport Adder
58+
class CALCULATOR_DllAPI Adder
12759
{
12860
public:
129-
virtual ~Adder() = default;
130-
131-
132-
virtual eprosima::fastdds::dds::rpc::RpcFuture<int32_t> addition(
133-
/*in*/ int32_t value1,
134-
/*in*/ int32_t value2) = 0;
13561

13662
};
137-
138-
139-
14063
/*!
14164
* @brief This class represents the interface Subtractor defined by the user in the IDL file.
14265
* @ingroup calculator
14366
*/
144-
class eProsima_user_DllExport Subtractor
145-
{
146-
public:
147-
virtual ~Subtractor() = default;
148-
149-
150-
virtual eprosima::fastdds::dds::rpc::RpcFuture<int32_t> subtraction(
151-
/*in*/ int32_t value1,
152-
/*in*/ int32_t value2) = 0;
153-
154-
};
155-
156-
157-
158-
namespace detail {
159-
160-
struct BasicCalculator_representation_limits_Out;
161-
162-
} // namespace detail
163-
164-
/*!
165-
* @brief This class represents the interface BasicCalculator defined by the user in the IDL file.
166-
* @ingroup calculator
167-
*/
168-
class eProsima_user_DllExport BasicCalculator : public calculator_base::Adder, public calculator_base::Subtractor
67+
class CALCULATOR_DllAPI Subtractor
16968
{
17069
public:
171-
virtual ~BasicCalculator() = default;
172-
173-
174-
virtual eprosima::fastdds::dds::rpc::RpcFuture<calculator_base::detail::BasicCalculator_representation_limits_Out> representation_limits(
175-
) = 0;
17670

17771
};
17872

179-
namespace detail {
180-
181-
struct BasicCalculator_representation_limits_Out
182-
{
183-
int32_t min_value;
184-
int32_t max_value;
185-
};
186-
187-
188-
} // namespace detail
189-
190-
19173
} // namespace calculator_base
192-
19374
/*!
19475
* @brief This class represents the interface Calculator defined by the user in the IDL file.
19576
* @ingroup calculator
19677
*/
197-
class eProsima_user_DllExport Calculator : public calculator_base::BasicCalculator
78+
class CALCULATOR_DllAPI Calculator : public calculator_base::Adder, public calculator_base::Subtractor
19879
{
19980
public:
200-
virtual ~Calculator() = default;
201-
202-
203-
virtual std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientReader<int32_t> > fibonacci_seq(
204-
/*in*/ uint32_t n_results) = 0;
205-
206-
207-
virtual eprosima::fastdds::dds::rpc::RpcFuture<int32_t> sum_all(
208-
/*in*/ std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientWriter<int32_t>>& value) = 0;
209-
210-
211-
virtual std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientReader<int32_t> > accumulator(
212-
/*in*/ std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientWriter<int32_t>>& value) = 0;
21381

21482
};
21583

216-
217-
21884
#endif // _FAST_DDS_GENERATED_CALCULATOR_HPP_
21985

22086

0 commit comments

Comments
 (0)