Skip to content

Commit 37cd876

Browse files
committed
Adapt to new FastDdsGen
Signed-off-by: Iker Luengo <ikerluengo@eprosima.com>
1 parent 867fdf8 commit 37cd876

25 files changed

Lines changed: 421 additions & 388 deletions

test/HelloWorld.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../build/fastdds_python/test/types/HelloWorld.py

test/_HelloWorldWrapper.so

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../build/fastdds_python/test/types/_HelloWorldWrapper.so

test/libHelloWorld.a

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../build/fastdds_python/test/types/libHelloWorld.a

test/test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fastdds_wrapper
2-
import topic_types
2+
import HelloWorld
33

44
class Reader:
55
def __init__(self, domain):
@@ -8,7 +8,7 @@ def __init__(self, domain):
88
factory.get_default_participant_qos(self.participant_qos)
99
self.participant = factory.create_participant(5, self.participant_qos)
1010

11-
self.topic_data_type = topic_types.HelloWorldTopicDataType()
11+
self.topic_data_type = HelloWorld.HelloWorldPubSubType()
1212
self.topic_data_type.setName("HelloWorldDataType")
1313
self.type_support = fastdds_wrapper.TypeSupport(self.topic_data_type)
1414
self.participant.register_type(self.type_support)
@@ -27,10 +27,10 @@ def __init__(self, domain):
2727

2828
def read(self):
2929
info = fastdds_wrapper.SampleInfo()
30-
data = topic_types.HelloWorld()
30+
data = HelloWorld.HelloWorld()
3131
self.reader.take_next_sample(data, info)
3232

33-
print("Received {message} : {index}".format(message=data.get_message(), index=data.get_index()))
33+
print("Received {message} : {index}".format(message=data.message(), index=data.index()))
3434

3535

3636
class Writer:
@@ -40,7 +40,7 @@ def __init__(self, domain):
4040
factory.get_default_participant_qos(self.participant_qos)
4141
self.participant = factory.create_participant(5, self.participant_qos)
4242

43-
self.topic_data_type = topic_types.HelloWorldTopicDataType()
43+
self.topic_data_type = HelloWorld.HelloWorldPubSubType()
4444
self.topic_data_type.setName("HelloWorldDataType")
4545
self.type_support = fastdds_wrapper.TypeSupport(self.topic_data_type)
4646
self.participant.register_type(self.type_support)
@@ -60,10 +60,10 @@ def __init__(self, domain):
6060
self.index = 0
6161

6262
def write(self):
63-
data = topic_types.HelloWorld()
64-
data.set_message("Hello World")
65-
data.set_index(self.index)
63+
data = HelloWorld.HelloWorld()
64+
data.message("Hello World")
65+
data.index(self.index)
6666
self.writer.write(data)
67-
print("Sending {message} : {index}".format(message=data.get_message(), index=data.get_index()))
67+
print("Sending {message} : {index}".format(message=data.message(), index=data.index()))
6868
self.index = self.index + 1
6969

test/topic_types.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/types/CMakeLists.txt

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
cmake_minimum_required(VERSION 2.8.12)
23

34
if(NOT CMAKE_VERSION VERSION_LESS 3.0)
@@ -14,25 +15,71 @@ if(POLICY CMP0086)
1415
cmake_policy(SET CMP0086 NEW)
1516
endif()
1617

17-
project(FastDdsTypesPythonWrapper)
18+
###############################################################################
19+
# Library for types defined in HelloWorld IDL
20+
###############################################################################
21+
22+
message(STATUS "Configuring python wrapper for types in HelloWorld...")
1823

1924
###############################################################################
20-
# Dependencies
25+
# Type library on C++
26+
27+
project(HelloWorld)
28+
29+
FIND_PACKAGE(fastcdr REQUIRED)
30+
FIND_PACKAGE(fastrtps REQUIRED)
31+
32+
33+
set(${PROJECT_NAME}_FILES
34+
HelloWorld.cxx
35+
HelloWorldPubSubTypes.cxx
36+
)
37+
38+
INCLUDE_DIRECTORIES()
39+
40+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
41+
42+
#Create library for C++ types
43+
add_library(${PROJECT_NAME} ${${PROJECT_NAME}_FILES})
44+
target_link_libraries(${PROJECT_NAME} PUBLIC fastcdr fastrtps)
45+
2146
###############################################################################
47+
# Python bindings for type
48+
49+
project(HelloWorldWrapper)
2250

2351
FIND_PACKAGE(SWIG REQUIRED)
2452
INCLUDE(${SWIG_USE_FILE})
2553
SET(CMAKE_SWIG_FLAGS "")
2654

27-
FIND_PACKAGE(PythonLibs)
55+
FIND_PACKAGE(PythonLibs REQUIRED)
2856
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
2957

58+
FIND_PACKAGE(fastcdr REQUIRED)
3059
FIND_PACKAGE(fastrtps REQUIRED)
3160

32-
###############################################################################
33-
# Project subdirectories
34-
###############################################################################
61+
set(${PROJECT_NAME}_FILES
62+
HelloWorld.i
63+
)
64+
65+
SET_SOURCE_FILES_PROPERTIES(
66+
${${PROJECT_NAME}_FILES}
67+
PROPERTIES CPLUSPLUS ON
68+
USE_TARGET_INCLUDE_DIRECTORIES TRUE
69+
)
70+
71+
INCLUDE_DIRECTORIES(
72+
${PROJECT_SOURCE_DIR}
73+
)
74+
75+
SWIG_ADD_LIBRARY(${PROJECT_NAME}
76+
TYPE SHARED
77+
LANGUAGE python
78+
SOURCES ${${PROJECT_NAME}_FILES})
3579

36-
add_subdirectory(src/cpp)
37-
add_subdirectory(src/swig)
80+
SWIG_LINK_LIBRARIES(${PROJECT_NAME}
81+
${PYTHON_LIBRARIES}
82+
fastrtps
83+
HelloWorld
84+
)
3885

test/types/src/cpp/HelloWorld/HelloWorld.cxx renamed to test/types/HelloWorld.cxx

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222
#ifdef _WIN32
2323
// Remove linker warning LNK4221 on Visual Studio
24-
namespace { char dummy; }
25-
#endif
24+
namespace {
25+
char dummy;
26+
} // namespace
27+
#endif // _WIN32
2628

2729
#include "HelloWorld.h"
2830
#include <fastcdr/Cdr.h>
@@ -34,9 +36,9 @@ using namespace eprosima::fastcdr::exception;
3436

3537
HelloWorld::HelloWorld()
3638
{
37-
// m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@1622f1b
39+
// m_index com.eprosima.idl.parser.typecode.PrimitiveTypeCode@32eebfca
3840
m_index = 0;
39-
// m_message com.eprosima.idl.parser.typecode.StringTypeCode@70e8f8e
41+
// m_message com.eprosima.idl.parser.typecode.StringTypeCode@543c6f6d
4042
m_message ="";
4143

4244
}
@@ -47,19 +49,22 @@ HelloWorld::~HelloWorld()
4749

4850
}
4951

50-
HelloWorld::HelloWorld(const HelloWorld &x)
52+
HelloWorld::HelloWorld(
53+
const HelloWorld& x)
5154
{
5255
m_index = x.m_index;
5356
m_message = x.m_message;
5457
}
5558

56-
HelloWorld::HelloWorld(HelloWorld &&x)
59+
HelloWorld::HelloWorld(
60+
HelloWorld&& x)
5761
{
5862
m_index = x.m_index;
5963
m_message = std::move(x.m_message);
6064
}
6165

62-
HelloWorld& HelloWorld::operator=(const HelloWorld &x)
66+
HelloWorld& HelloWorld::operator =(
67+
const HelloWorld& x)
6368
{
6469

6570
m_index = x.m_index;
@@ -68,7 +73,8 @@ HelloWorld& HelloWorld::operator=(const HelloWorld &x)
6873
return *this;
6974
}
7075

71-
HelloWorld& HelloWorld::operator=(HelloWorld &&x)
76+
HelloWorld& HelloWorld::operator =(
77+
HelloWorld&& x)
7278
{
7379

7480
m_index = x.m_index;
@@ -77,7 +83,8 @@ HelloWorld& HelloWorld::operator=(HelloWorld &&x)
7783
return *this;
7884
}
7985

80-
size_t HelloWorld::getMaxCdrSerializedSize(size_t current_alignment)
86+
size_t HelloWorld::getMaxCdrSerializedSize(
87+
size_t current_alignment)
8188
{
8289
size_t initial_alignment = current_alignment;
8390

@@ -91,7 +98,9 @@ size_t HelloWorld::getMaxCdrSerializedSize(size_t current_alignment)
9198
return current_alignment - initial_alignment;
9299
}
93100

94-
size_t HelloWorld::getCdrSerializedSize(const HelloWorld& data, size_t current_alignment)
101+
size_t HelloWorld::getCdrSerializedSize(
102+
const HelloWorld& data,
103+
size_t current_alignment)
95104
{
96105
(void)data;
97106
size_t initial_alignment = current_alignment;
@@ -106,14 +115,17 @@ size_t HelloWorld::getCdrSerializedSize(const HelloWorld& data, size_t current_a
106115
return current_alignment - initial_alignment;
107116
}
108117

109-
void HelloWorld::serialize(eprosima::fastcdr::Cdr &scdr) const
118+
void HelloWorld::serialize(
119+
eprosima::fastcdr::Cdr& scdr) const
110120
{
111121

112122
scdr << m_index;
113123
scdr << m_message;
124+
114125
}
115126

116-
void HelloWorld::deserialize(eprosima::fastcdr::Cdr &dcdr)
127+
void HelloWorld::deserialize(
128+
eprosima::fastcdr::Cdr& dcdr)
117129
{
118130

119131
dcdr >> m_index;
@@ -124,9 +136,10 @@ void HelloWorld::deserialize(eprosima::fastcdr::Cdr &dcdr)
124136
* @brief This function sets a value in member index
125137
* @param _index New value for member index
126138
*/
127-
void HelloWorld::index(uint32_t _index)
139+
void HelloWorld::index(
140+
uint32_t _index)
128141
{
129-
m_index = _index;
142+
m_index = _index;
130143
}
131144

132145
/*!
@@ -151,18 +164,20 @@ uint32_t& HelloWorld::index()
151164
* @brief This function copies the value in member message
152165
* @param _message New value to be copied in member message
153166
*/
154-
void HelloWorld::message(const std::string &_message)
167+
void HelloWorld::message(
168+
const std::string& _message)
155169
{
156-
m_message = _message;
170+
m_message = _message;
157171
}
158172

159173
/*!
160174
* @brief This function moves the value in member message
161175
* @param _message New value to be moved in member message
162176
*/
163-
void HelloWorld::message(std::string &&_message)
177+
void HelloWorld::message(
178+
std::string&& _message)
164179
{
165-
m_message = std::move(_message);
180+
m_message = std::move(_message);
166181
}
167182

168183
/*!
@@ -183,7 +198,8 @@ std::string& HelloWorld::message()
183198
return m_message;
184199
}
185200

186-
size_t HelloWorld::getKeyMaxCdrSerializedSize(size_t current_alignment)
201+
size_t HelloWorld::getKeyMaxCdrSerializedSize(
202+
size_t current_alignment)
187203
{
188204
size_t current_align = current_alignment;
189205

@@ -196,13 +212,12 @@ size_t HelloWorld::getKeyMaxCdrSerializedSize(size_t current_alignment)
196212

197213
bool HelloWorld::isKeyDefined()
198214
{
199-
return false;
215+
return false;
200216
}
201217

202-
void HelloWorld::serializeKey(eprosima::fastcdr::Cdr &scdr) const
218+
void HelloWorld::serializeKey(
219+
eprosima::fastcdr::Cdr& scdr) const
203220
{
204221
(void) scdr;
205-
206-
222+
207223
}
208-

0 commit comments

Comments
 (0)