Skip to content

Commit ae21735

Browse files
MiguelCompanymergify[bot]
authored andcommitted
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
1 parent 4ee6ecf commit ae21735

15 files changed

Lines changed: 1268 additions & 2550 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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ find_package(fastdds 3 REQUIRED)
4141

4242
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
4343

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-
5144
#Create library for C++ types
5245
add_library(${PROJECT_NAME} SHARED
5346
calculatorTypeObjectSupport.cxx

fastdds_python_examples/RPCExample/generated_code/calculator.hpp

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@
2323
#define FAST_DDS_GENERATED__CALCULATOR_HPP
2424

2525
#include <cstdint>
26-
#include <memory>
2726
#include <string>
2827
#include <utility>
2928
#include <fastcdr/cdr/fixed_size_string.hpp>
3029
#include <fastcdr/xcdr/optional.hpp>
3130
#include <fastdds/dds/rpc/exceptions/RpcOperationError.hpp>
32-
#include <fastdds/dds/rpc/interfaces/RpcClientReader.hpp>
33-
#include <fastdds/dds/rpc/interfaces/RpcClientWriter.hpp>
3431
#include <fastdds/dds/rpc/interfaces/RpcFuture.hpp>
3532

3633

@@ -155,30 +152,32 @@ class eProsima_user_DllExport Subtractor
155152

156153

157154

155+
} // namespace calculator_base
156+
158157
namespace detail {
159158

160-
struct BasicCalculator_representation_limits_Out;
159+
struct Calculator_representation_limits_Out;
161160

162161
} // namespace detail
163162

164163
/*!
165-
* @brief This class represents the interface BasicCalculator defined by the user in the IDL file.
164+
* @brief This class represents the interface Calculator defined by the user in the IDL file.
166165
* @ingroup calculator
167166
*/
168-
class eProsima_user_DllExport BasicCalculator : public calculator_base::Adder, public calculator_base::Subtractor
167+
class eProsima_user_DllExport Calculator : public calculator_base::Adder, public calculator_base::Subtractor
169168
{
170169
public:
171-
virtual ~BasicCalculator() = default;
170+
virtual ~Calculator() = default;
172171

173172

174-
virtual eprosima::fastdds::dds::rpc::RpcFuture<calculator_base::detail::BasicCalculator_representation_limits_Out> representation_limits(
173+
virtual eprosima::fastdds::dds::rpc::RpcFuture<detail::Calculator_representation_limits_Out> representation_limits(
175174
) = 0;
176175

177176
};
178177

179178
namespace detail {
180179

181-
struct BasicCalculator_representation_limits_Out
180+
struct Calculator_representation_limits_Out
182181
{
183182
int32_t min_value;
184183
int32_t max_value;
@@ -188,33 +187,6 @@ struct BasicCalculator_representation_limits_Out
188187
} // namespace detail
189188

190189

191-
} // namespace calculator_base
192-
193-
/*!
194-
* @brief This class represents the interface Calculator defined by the user in the IDL file.
195-
* @ingroup calculator
196-
*/
197-
class eProsima_user_DllExport Calculator : public calculator_base::BasicCalculator
198-
{
199-
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;
213-
214-
};
215-
216-
217-
218190
#endif // _FAST_DDS_GENERATED_CALCULATOR_HPP_
219191

220192

fastdds_python_examples/RPCExample/generated_code/calculator.i

Lines changed: 7 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -94,33 +94,6 @@
9494
}
9595
}
9696

97-
%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcServerWriter.hpp"
98-
%ignore eprosima::fastdds::dds::rpc::RpcClientReader::read(T&);
99-
%ignore eprosima::fastdds::dds::rpc::RpcClientReader::read(T&,eprosima::fastdds::dds::Duration_t&);
100-
%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcClientReader.hpp"
101-
%extend eprosima::fastdds::dds::rpc::RpcClientReader {
102-
std::pair<bool, T> read(
103-
const eprosima::fastdds::dds::Duration_t& timeout = eprosima::fastdds::dds::c_TimeInfinite)
104-
{
105-
std::pair<bool, T> ret_val{};
106-
if (eprosima::fastdds::dds::c_TimeInfinite == timeout)
107-
{
108-
ret_val.first = self->read(ret_val.second);
109-
}
110-
else
111-
{
112-
ret_val.first = self->read(ret_val.second, timeout);
113-
}
114-
return ret_val;
115-
}
116-
}
117-
118-
%shared_ptr(eprosima::fastdds::dds::rpc::RpcClientReader<int32_t>);
119-
%template(int32_t_client_reader_result) std::pair<bool, int32_t>;
120-
%template(int32_t_client_reader) eprosima::fastdds::dds::rpc::RpcClientReader<int32_t>;
121-
122-
%template(int32_t_server_writer) eprosima::fastdds::dds::rpc::RpcServerWriter<int32_t>;
123-
12497
// Code for std::future taken from https://github.com/swig/swig/issues/1828#issuecomment-648449092
12598
namespace eprosima::fastdds::dds::rpc
12699
{
@@ -151,12 +124,12 @@ class RpcFuture {
151124

152125
}
153126

154-
%shared_ptr(eprosima::fastdds::dds::rpc::RpcFuture<calculator_base::detail::BasicCalculator_representation_limits_Out>);
155-
%template(calculator_base_detail_BasicCalculator_representation_limits_Out_rpc_future) eprosima::fastdds::dds::rpc::RpcFuture<calculator_base::detail::BasicCalculator_representation_limits_Out>;
127+
%shared_ptr(eprosima::fastdds::dds::rpc::RpcFuture<detail::Calculator_representation_limits_Out>);
128+
%template(detail_Calculator_representation_limits_Out_rpc_future) eprosima::fastdds::dds::rpc::RpcFuture<detail::Calculator_representation_limits_Out>;
156129

157-
%typemap(out, optimal="1") eprosima::fastdds::dds::rpc::RpcFuture<calculator_base::detail::BasicCalculator_representation_limits_Out> {
130+
%typemap(out, optimal="1") eprosima::fastdds::dds::rpc::RpcFuture<detail::Calculator_representation_limits_Out> {
158131
std::shared_ptr<$1_ltype> *smartresult = new std::shared_ptr<$1_ltype>(new $1_ltype($1));
159-
$result = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), $descriptor(std::shared_ptr< eprosima::fastdds::dds::rpc::RpcFuture<calculator_base::detail::BasicCalculator_representation_limits_Out>> *), SWIG_POINTER_OWN);
132+
$result = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), $descriptor(std::shared_ptr< eprosima::fastdds::dds::rpc::RpcFuture<detail::Calculator_representation_limits_Out>> *), SWIG_POINTER_OWN);
160133
}
161134

162135
%shared_ptr(eprosima::fastdds::dds::rpc::RpcFuture<int32_t>);
@@ -167,42 +140,6 @@ class RpcFuture {
167140
$result = SWIG_NewPointerObj(SWIG_as_voidptr(smartresult), $descriptor(std::shared_ptr< eprosima::fastdds::dds::rpc::RpcFuture<int32_t>> *), SWIG_POINTER_OWN);
168141
}
169142

170-
%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcClientWriter.hpp"
171-
%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcStatusCode.hpp"
172-
173-
%ignore eprosima::fastdds::dds::rpc::RpcServerReader::read(T&);
174-
%ignore eprosima::fastdds::dds::rpc::RpcServerReader::read(T&,eprosima::fastdds::dds::Duration_t&);
175-
%import(module="fastdds") "fastdds/dds/rpc/interfaces/RpcServerReader.hpp"
176-
%extend eprosima::fastdds::dds::rpc::RpcServerReader {
177-
std::pair<bool, T> read(
178-
const eprosima::fastdds::dds::Duration_t& timeout = eprosima::fastdds::dds::c_TimeInfinite)
179-
{
180-
std::pair<bool, T> ret_val{};
181-
if (eprosima::fastdds::dds::c_TimeInfinite == timeout)
182-
{
183-
ret_val.first = self->read(ret_val.second);
184-
}
185-
else
186-
{
187-
ret_val.first = self->read(ret_val.second, timeout);
188-
}
189-
return ret_val;
190-
}
191-
}
192-
193-
%template(int32_t_server_reader_result) std::pair<bool, int32_t>;
194-
%template(int32_t_server_reader) eprosima::fastdds::dds::rpc::RpcServerReader<int32_t>;
195-
196-
%shared_ptr(eprosima::fastdds::dds::rpc::RpcClientWriter<int32_t>);
197-
%template(int32_t_rpc_client_writer) eprosima::fastdds::dds::rpc::RpcClientWriter<int32_t>;
198-
%typemap(in,numinputs=0) std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientWriter<int32_t>>& %{
199-
$1 = new std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientWriter<int32_t>>();
200-
%}
201-
%typemap(argout) std::shared_ptr<eprosima::fastdds::dds::rpc::RpcClientWriter<int32_t>>& (PyObject* tmp) %{
202-
tmp = SWIG_NewPointerObj($1, $1_descriptor, SWIG_POINTER_OWN);
203-
$result = SWIG_Python_AppendOutput($result, tmp);
204-
%}
205-
206143
%exception;
207144

208145
%define %traits_penumn(Type...)
@@ -227,6 +164,7 @@ namespace swig {
227164

228165

229166

167+
<<<<<<< HEAD
230168
%shared_ptr(calculator_base::BasicCalculator);
231169
%shared_ptr(calculator_base::BasicCalculatorServer);
232170
%extend calculator_base::BasicCalculatorServer
@@ -245,6 +183,8 @@ namespace swig {
245183

246184

247185

186+
=======
187+
>>>>>>> e143c3b (Remove `@feed` operations from example (#256))
248188
%shared_ptr(Calculator);
249189
%shared_ptr(CalculatorServer);
250190
%extend CalculatorServer

0 commit comments

Comments
 (0)