Skip to content

Commit 4f2af4f

Browse files
authored
Add support for FastDDS versions earlier than 2.13 (#67)
Signed-off-by: Irene Bandera <[email protected]>
1 parent 3b76649 commit 4f2af4f

17 files changed

+815
-8
lines changed

fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationPublisher.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@
2828
#include <fastdds/dds/publisher/DataWriterListener.hpp>
2929
#include <fastdds/dds/topic/TypeSupport.hpp>
3030

31-
#include "HelloWorldPubSubTypes.h"
31+
#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13
32+
#include "types/v1/HelloWorldPubSubTypes.h"
33+
#else
34+
#include "types/v2/HelloWorldPubSubTypes.h"
35+
#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13
36+
3237
#include "types.hpp"
3338

3439
/**

fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/AdvancedConfigurationSubscriber.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@
2828
#include <fastdds/dds/domain/DomainParticipant.hpp>
2929
#include <fastdds/dds/subscriber/DataReaderListener.hpp>
3030

31-
#include "HelloWorldPubSubTypes.h"
31+
#if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13
32+
#include "types/v1/HelloWorldPubSubTypes.h"
33+
#else
34+
#include "types/v2/HelloWorldPubSubTypes.h"
35+
#endif // if FASTRTPS_VERSION_MAJOR <= 2 && FASTRTPS_VERSION_MINOR < 13
36+
3237
#include "types.hpp"
3338

3439
/**

fastddsspy_tool/test/application/dds/AdvancedConfigurationExample/CMakeLists.txt

+19-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ project(AdvancedConfigurationExample VERSION 1 LANGUAGES CXX)
1818

1919
# Find requirements
2020
if(NOT fastcdr_FOUND)
21-
find_package(fastcdr 2 REQUIRED)
21+
find_package(fastcdr REQUIRED)
2222
endif()
2323

2424
if(NOT fastrtps_FOUND)
25-
find_package(fastrtps 2.12 REQUIRED)
25+
find_package(fastrtps REQUIRED)
2626
endif()
2727

2828
#Check C++11
@@ -35,9 +35,24 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
3535
endif()
3636
endif()
3737

38+
# Determine Fast DDS version
39+
if ("${fastrtps_VERSION}" VERSION_LESS 2.13)
40+
set(DDS_TYPES_VERSION "v1")
41+
else()
42+
set(DDS_TYPES_VERSION "v2")
43+
endif()
44+
3845
message(STATUS "Configuring AdvancedConfiguration example...")
39-
file(GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX "*.cxx")
40-
file(GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP "*.cpp")
46+
file(
47+
GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX
48+
"*.cxx"
49+
"types/${DDS_TYPES_VERSION}/*.cxx"
50+
)
51+
file(
52+
GLOB ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP
53+
"*.cpp"
54+
"types/${DDS_TYPES_VERSION}/*.cpp"
55+
)
4156

4257
add_executable(${PROJECT_NAME} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CXX} ${ADVANCED_CONFIG_EXAMPLE_SOURCES_CPP})
4358
target_compile_definitions(${PROJECT_NAME} PRIVATE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
// Copyright 2016 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+
/*!
16+
* @file HelloWorld.cpp
17+
* This source file contains the definition of the described types in the IDL file.
18+
*
19+
* This file was generated by the tool gen.
20+
*/
21+
22+
#ifdef _WIN32
23+
// Remove linker warning LNK4221 on Visual Studio
24+
namespace {
25+
char dummy;
26+
} // namespace
27+
#endif // _WIN32
28+
29+
#include "HelloWorld.h"
30+
#include <fastcdr/Cdr.h>
31+
32+
#include <fastcdr/exceptions/BadParamException.h>
33+
using namespace eprosima::fastcdr::exception;
34+
35+
#include <utility>
36+
37+
#define HelloWorld_max_cdr_typesize 24ULL;
38+
#define HelloWorld_max_key_cdr_typesize 0ULL;
39+
40+
HelloWorld::HelloWorld()
41+
{
42+
// unsigned long m_index
43+
m_index = 0;
44+
// char m_message
45+
memset(&m_message, 0, (20) * 1);
46+
47+
}
48+
49+
HelloWorld::~HelloWorld()
50+
{
51+
52+
53+
}
54+
55+
HelloWorld::HelloWorld(
56+
const HelloWorld& x)
57+
{
58+
m_index = x.m_index;
59+
m_message = x.m_message;
60+
}
61+
62+
HelloWorld::HelloWorld(
63+
HelloWorld&& x) noexcept
64+
{
65+
m_index = x.m_index;
66+
m_message = std::move(x.m_message);
67+
}
68+
69+
HelloWorld& HelloWorld::operator =(
70+
const HelloWorld& x)
71+
{
72+
73+
m_index = x.m_index;
74+
m_message = x.m_message;
75+
76+
return *this;
77+
}
78+
79+
HelloWorld& HelloWorld::operator =(
80+
HelloWorld&& x) noexcept
81+
{
82+
83+
m_index = x.m_index;
84+
m_message = std::move(x.m_message);
85+
86+
return *this;
87+
}
88+
89+
bool HelloWorld::operator ==(
90+
const HelloWorld& x) const
91+
{
92+
93+
return (m_index == x.m_index && m_message == x.m_message);
94+
}
95+
96+
bool HelloWorld::operator !=(
97+
const HelloWorld& x) const
98+
{
99+
return !(*this == x);
100+
}
101+
102+
size_t HelloWorld::getMaxCdrSerializedSize(
103+
size_t current_alignment)
104+
{
105+
static_cast<void>(current_alignment);
106+
return HelloWorld_max_cdr_typesize;
107+
}
108+
109+
size_t HelloWorld::getCdrSerializedSize(
110+
const HelloWorld& data,
111+
size_t current_alignment)
112+
{
113+
(void)data;
114+
size_t initial_alignment = current_alignment;
115+
116+
117+
current_alignment += 4 + eprosima::fastcdr::Cdr::alignment(current_alignment, 4);
118+
119+
120+
current_alignment += ((20) * 1) + eprosima::fastcdr::Cdr::alignment(current_alignment, 1);
121+
122+
123+
return current_alignment - initial_alignment;
124+
}
125+
126+
void HelloWorld::serialize(
127+
eprosima::fastcdr::Cdr& scdr) const
128+
{
129+
130+
scdr << m_index;
131+
scdr << m_message;
132+
133+
134+
}
135+
136+
void HelloWorld::deserialize(
137+
eprosima::fastcdr::Cdr& dcdr)
138+
{
139+
140+
dcdr >> m_index;
141+
dcdr >> m_message;
142+
143+
}
144+
145+
/*!
146+
* @brief This function sets a value in member index
147+
* @param _index New value for member index
148+
*/
149+
void HelloWorld::index(
150+
uint32_t _index)
151+
{
152+
m_index = _index;
153+
}
154+
155+
/*!
156+
* @brief This function returns the value of member index
157+
* @return Value of member index
158+
*/
159+
uint32_t HelloWorld::index() const
160+
{
161+
return m_index;
162+
}
163+
164+
/*!
165+
* @brief This function returns a reference to member index
166+
* @return Reference to member index
167+
*/
168+
uint32_t& HelloWorld::index()
169+
{
170+
return m_index;
171+
}
172+
173+
/*!
174+
* @brief This function copies the value in member message
175+
* @param _message New value to be copied in member message
176+
*/
177+
void HelloWorld::message(
178+
const std::array<char, 20>& _message)
179+
{
180+
m_message = _message;
181+
}
182+
183+
/*!
184+
* @brief This function moves the value in member message
185+
* @param _message New value to be moved in member message
186+
*/
187+
void HelloWorld::message(
188+
std::array<char, 20>&& _message)
189+
{
190+
m_message = std::move(_message);
191+
}
192+
193+
/*!
194+
* @brief This function returns a constant reference to member message
195+
* @return Constant reference to member message
196+
*/
197+
const std::array<char, 20>& HelloWorld::message() const
198+
{
199+
return m_message;
200+
}
201+
202+
/*!
203+
* @brief This function returns a reference to member message
204+
* @return Reference to member message
205+
*/
206+
std::array<char, 20>& HelloWorld::message()
207+
{
208+
return m_message;
209+
}
210+
211+
size_t HelloWorld::getKeyMaxCdrSerializedSize(
212+
size_t current_alignment)
213+
{
214+
static_cast<void>(current_alignment);
215+
return HelloWorld_max_key_cdr_typesize;
216+
}
217+
218+
bool HelloWorld::isKeyDefined()
219+
{
220+
return false;
221+
}
222+
223+
void HelloWorld::serializeKey(
224+
eprosima::fastcdr::Cdr& scdr) const
225+
{
226+
(void) scdr;
227+
}

0 commit comments

Comments
 (0)