Skip to content

Commit ee382e4

Browse files
committed
Refs #21349. Regenerate source code
Signed-off-by: Ricardo González Moreno <ricardo@richiware.dev>
1 parent 9644d44 commit ee382e4

File tree

4 files changed

+156
-206
lines changed

4 files changed

+156
-206
lines changed

types/KeylessShapeTypePubSubTypes.cxx

Lines changed: 62 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -35,49 +35,42 @@ namespace shapes_demo_typesupport {
3535
namespace idl {
3636
KeylessShapeTypePubSubType::KeylessShapeTypePubSubType()
3737
{
38-
setName("shapes_demo_typesupport::idl::KeylessShapeType");
39-
uint32_t type_size =
40-
#if FASTCDR_VERSION_MAJOR == 1
41-
static_cast<uint32_t>(KeylessShapeType::getMaxCdrSerializedSize());
42-
#else
43-
shapes_demo_typesupport_idl_KeylessShapeType_max_cdr_typesize;
44-
#endif
38+
set_name("shapes_demo_typesupport::idl::KeylessShapeType");
39+
uint32_t type_size = shapes_demo_typesupport_idl_KeylessShapeType_max_cdr_typesize;
4540
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
46-
m_typeSize = type_size + 4; /*encapsulation*/
47-
m_isGetKeyDefined = false;
48-
uint32_t keyLength = shapes_demo_typesupport_idl_KeylessShapeType_max_key_cdr_typesize > 16 ? shapes_demo_typesupport_idl_KeylessShapeType_max_key_cdr_typesize : 16;
49-
m_keyBuffer = reinterpret_cast<unsigned char*>(malloc(keyLength));
50-
memset(m_keyBuffer, 0, keyLength);
41+
max_serialized_type_size = type_size + 4; /*encapsulation*/
42+
is_compute_key_provided = false;
43+
uint32_t key_length = shapes_demo_typesupport_idl_KeylessShapeType_max_key_cdr_typesize > 16 ? shapes_demo_typesupport_idl_KeylessShapeType_max_key_cdr_typesize : 16;
44+
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
45+
memset(key_buffer_, 0, key_length);
5146
}
5247

5348
KeylessShapeTypePubSubType::~KeylessShapeTypePubSubType()
5449
{
55-
if (m_keyBuffer != nullptr)
50+
if (key_buffer_ != nullptr)
5651
{
57-
free(m_keyBuffer);
52+
free(key_buffer_);
5853
}
5954
}
6055

6156
bool KeylessShapeTypePubSubType::serialize(
6257
const void* const data,
63-
SerializedPayload_t* payload,
58+
SerializedPayload_t& payload,
6459
DataRepresentationId_t data_representation)
6560
{
6661
const KeylessShapeType* p_type = static_cast<const KeylessShapeType*>(data);
6762

6863
// Object that manages the raw buffer.
69-
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->max_size);
64+
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
7065
// Object that serializes the data.
7166
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
7267
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
7368
eprosima::fastcdr::CdrVersion::XCDRv1 : eprosima::fastcdr::CdrVersion::XCDRv2);
74-
payload->encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
75-
#if FASTCDR_VERSION_MAJOR > 1
69+
payload.encapsulation = ser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
7670
ser.set_encoding_flag(
7771
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
7872
eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR :
7973
eprosima::fastcdr::EncodingAlgorithmFlag::DELIMIT_CDR2);
80-
#endif // FASTCDR_VERSION_MAJOR > 1
8174

8275
try
8376
{
@@ -92,16 +85,12 @@ namespace shapes_demo_typesupport {
9285
}
9386

9487
// Get the serialized length
95-
#if FASTCDR_VERSION_MAJOR == 1
96-
payload->length = static_cast<uint32_t>(ser.getSerializedDataLength());
97-
#else
98-
payload->length = static_cast<uint32_t>(ser.get_serialized_data_length());
99-
#endif // FASTCDR_VERSION_MAJOR == 1
88+
payload.length = static_cast<uint32_t>(ser.get_serialized_data_length());
10089
return true;
10190
}
10291

10392
bool KeylessShapeTypePubSubType::deserialize(
104-
SerializedPayload_t* payload,
93+
SerializedPayload_t& payload,
10594
void* data)
10695
{
10796
try
@@ -110,18 +99,14 @@ namespace shapes_demo_typesupport {
11099
KeylessShapeType* p_type = static_cast<KeylessShapeType*>(data);
111100

112101
// Object that manages the raw buffer.
113-
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload->data), payload->length);
102+
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
114103

115104
// Object that deserializes the data.
116-
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN
117-
#if FASTCDR_VERSION_MAJOR == 1
118-
, eprosima::fastcdr::Cdr::CdrType::DDS_CDR
119-
#endif // FASTCDR_VERSION_MAJOR == 1
120-
);
105+
eprosima::fastcdr::Cdr deser(fastbuffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN);
121106

122107
// Deserialize encapsulation.
123108
deser.read_encapsulation();
124-
payload->encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
109+
payload.encapsulation = deser.endianness() == eprosima::fastcdr::Cdr::BIG_ENDIANNESS ? CDR_BE : CDR_LE;
125110

126111
// Deserialize the object.
127112
deser >> *p_type;
@@ -134,88 +119,90 @@ namespace shapes_demo_typesupport {
134119
return true;
135120
}
136121

137-
std::function<uint32_t()> KeylessShapeTypePubSubType::getSerializedSizeProvider(
122+
uint32_t KeylessShapeTypePubSubType::calculate_serialized_size(
138123
const void* const data,
139124
DataRepresentationId_t data_representation)
140125
{
141-
return [data, data_representation]() -> uint32_t
142-
{
143-
#if FASTCDR_VERSION_MAJOR == 1
144-
static_cast<void>(data_representation);
145-
return static_cast<uint32_t>(type::getCdrSerializedSize(*static_cast<KeylessShapeType*>(data))) +
146-
4u /*encapsulation*/;
147-
#else
148-
try
149-
{
150-
eprosima::fastcdr::CdrSizeCalculator calculator(
151-
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
152-
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
153-
size_t current_alignment {0};
154-
return static_cast<uint32_t>(calculator.calculate_serialized_size(
155-
*static_cast<const KeylessShapeType*>(data), current_alignment)) +
156-
4u /*encapsulation*/;
157-
}
158-
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
159-
{
160-
return 0;
161-
}
162-
#endif // FASTCDR_VERSION_MAJOR == 1
163-
};
126+
try
127+
{
128+
eprosima::fastcdr::CdrSizeCalculator calculator(
129+
data_representation == DataRepresentationId_t::XCDR_DATA_REPRESENTATION ?
130+
eprosima::fastcdr::CdrVersion::XCDRv1 :eprosima::fastcdr::CdrVersion::XCDRv2);
131+
size_t current_alignment {0};
132+
return static_cast<uint32_t>(calculator.calculate_serialized_size(
133+
*static_cast<const KeylessShapeType*>(data), current_alignment)) +
134+
4u /*encapsulation*/;
135+
}
136+
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
137+
{
138+
return 0;
139+
}
164140
}
165141

166-
void* KeylessShapeTypePubSubType::createData()
142+
void* KeylessShapeTypePubSubType::create_data()
167143
{
168144
return reinterpret_cast<void*>(new KeylessShapeType());
169145
}
170146

171-
void KeylessShapeTypePubSubType::deleteData(
147+
void KeylessShapeTypePubSubType::delete_data(
172148
void* data)
173149
{
174150
delete(reinterpret_cast<KeylessShapeType*>(data));
175151
}
176152

177-
bool KeylessShapeTypePubSubType::getKey(
153+
bool KeylessShapeTypePubSubType::compute_key(
154+
SerializedPayload_t& payload,
155+
InstanceHandle_t& handle,
156+
bool force_md5)
157+
{
158+
if (!is_compute_key_provided)
159+
{
160+
return false;
161+
}
162+
163+
KeylessShapeType data;
164+
if (deserialize(payload, static_cast<void*>(&data)))
165+
{
166+
return compute_key(static_cast<void*>(&data), handle, force_md5);
167+
}
168+
169+
return false;
170+
}
171+
172+
bool KeylessShapeTypePubSubType::compute_key(
178173
const void* const data,
179-
InstanceHandle_t* handle,
174+
InstanceHandle_t& handle,
180175
bool force_md5)
181176
{
182-
if (!m_isGetKeyDefined)
177+
if (!is_compute_key_provided)
183178
{
184179
return false;
185180
}
186181

187182
const KeylessShapeType* p_type = static_cast<const KeylessShapeType*>(data);
188183

189184
// Object that manages the raw buffer.
190-
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(m_keyBuffer),
185+
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
191186
shapes_demo_typesupport_idl_KeylessShapeType_max_key_cdr_typesize);
192187

193188
// Object that serializes the data.
194189
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv1);
195-
#if FASTCDR_VERSION_MAJOR == 1
196-
p_type->serializeKey(ser);
197-
#else
198190
eprosima::fastcdr::serialize_key(ser, *p_type);
199-
#endif // FASTCDR_VERSION_MAJOR == 1
200191
if (force_md5 || shapes_demo_typesupport_idl_KeylessShapeType_max_key_cdr_typesize > 16)
201192
{
202-
m_md5.init();
203-
#if FASTCDR_VERSION_MAJOR == 1
204-
m_md5.update(m_keyBuffer, static_cast<unsigned int>(ser.getSerializedDataLength()));
205-
#else
206-
m_md5.update(m_keyBuffer, static_cast<unsigned int>(ser.get_serialized_data_length()));
207-
#endif // FASTCDR_VERSION_MAJOR == 1
208-
m_md5.finalize();
193+
md5_.init();
194+
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
195+
md5_.finalize();
209196
for (uint8_t i = 0; i < 16; ++i)
210197
{
211-
handle->value[i] = m_md5.digest[i];
198+
handle.value[i] = md5_.digest[i];
212199
}
213200
}
214201
else
215202
{
216203
for (uint8_t i = 0; i < 16; ++i)
217204
{
218-
handle->value[i] = m_keyBuffer[i];
205+
handle.value[i] = key_buffer_[i];
219206
}
220207
}
221208
return true;

types/KeylessShapeTypePubSubTypes.hpp

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
#include "KeylessShapeType.hpp"
3333

3434

35-
#if !defined(GEN_API_VER) || (GEN_API_VER != 2)
35+
#if !defined(FASTDDS_GEN_API_VER) || (FASTDDS_GEN_API_VER != 3)
3636
#error \
3737
Generated KeylessShapeType is not compatible with current installed Fast DDS. Please, regenerate it with fastddsgen.
38-
#endif // GEN_API_VER
38+
#endif // FASTDDS_GEN_API_VER
3939

4040
namespace shapes_demo_typesupport
4141
{
@@ -58,38 +58,30 @@ namespace shapes_demo_typesupport
5858

5959
eProsima_user_DllExport bool serialize(
6060
const void* const data,
61-
eprosima::fastdds::rtps::SerializedPayload_t* payload) override
62-
{
63-
return serialize(data, payload, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION);
64-
}
65-
66-
eProsima_user_DllExport bool serialize(
67-
const void* const data,
68-
eprosima::fastdds::rtps::SerializedPayload_t* payload,
61+
eprosima::fastdds::rtps::SerializedPayload_t& payload,
6962
eprosima::fastdds::dds::DataRepresentationId_t data_representation) override;
7063

7164
eProsima_user_DllExport bool deserialize(
72-
eprosima::fastdds::rtps::SerializedPayload_t* payload,
65+
eprosima::fastdds::rtps::SerializedPayload_t& payload,
7366
void* data) override;
7467

75-
eProsima_user_DllExport std::function<uint32_t()> getSerializedSizeProvider(
76-
const void* const data) override
77-
{
78-
return getSerializedSizeProvider(data, eprosima::fastdds::dds::DEFAULT_DATA_REPRESENTATION);
79-
}
80-
81-
eProsima_user_DllExport std::function<uint32_t()> getSerializedSizeProvider(
68+
eProsima_user_DllExport uint32_t calculate_serialized_size(
8269
const void* const data,
8370
eprosima::fastdds::dds::DataRepresentationId_t data_representation) override;
8471

85-
eProsima_user_DllExport bool getKey(
72+
eProsima_user_DllExport bool compute_key(
73+
eprosima::fastdds::rtps::SerializedPayload_t& payload,
74+
eprosima::fastdds::rtps::InstanceHandle_t& ihandle,
75+
bool force_md5 = false) override;
76+
77+
eProsima_user_DllExport bool compute_key(
8678
const void* const data,
87-
eprosima::fastdds::rtps::InstanceHandle_t* ihandle,
79+
eprosima::fastdds::rtps::InstanceHandle_t& ihandle,
8880
bool force_md5 = false) override;
8981

90-
eProsima_user_DllExport void* createData() override;
82+
eProsima_user_DllExport void* create_data() override;
9183

92-
eProsima_user_DllExport void deleteData(
84+
eProsima_user_DllExport void delete_data(
9385
void* data) override;
9486

9587
//Register TypeObject representation in Fast DDS TypeObjectRegistry
@@ -104,10 +96,6 @@ namespace shapes_demo_typesupport
10496
#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
10597

10698
#ifdef TOPIC_DATA_TYPE_API_HAS_IS_PLAIN
107-
eProsima_user_DllExport inline bool is_plain() const override
108-
{
109-
return false;
110-
}
11199

112100
eProsima_user_DllExport inline bool is_plain(
113101
eprosima::fastdds::dds::DataRepresentationId_t data_representation) const override
@@ -128,8 +116,8 @@ namespace shapes_demo_typesupport
128116

129117
#endif // TOPIC_DATA_TYPE_API_HAS_CONSTRUCT_SAMPLE
130118

131-
eprosima::fastdds::MD5 m_md5;
132-
unsigned char* m_keyBuffer;
119+
eprosima::fastdds::MD5 md5_;
120+
unsigned char* key_buffer_;
133121

134122
};
135123
} // namespace idl

0 commit comments

Comments
 (0)