Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/xtypes/HelloWorld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @file HelloWorld.hpp
* This header file contains the declaration of the described types in the IDL file.
*
* This file was generated by the tool fastddsgen (version: 4.0.5).
* This file was generated by the tool fastddsgen (version: 4.0.6).
*/

#ifndef FAST_DDS_GENERATED__HELLOWORLD_HPP
Expand Down
2 changes: 1 addition & 1 deletion resources/xtypes/HelloWorldCdrAux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @file HelloWorldCdrAux.hpp
* This source file contains some definitions of CDR related functions.
*
* This file was generated by the tool fastddsgen (version: 4.0.5).
* This file was generated by the tool fastddsgen (version: 4.0.6).
*/

#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_HPP
Expand Down
2 changes: 1 addition & 1 deletion resources/xtypes/HelloWorldCdrAux.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @file HelloWorldCdrAux.ipp
* This source file contains some declarations of CDR related functions.
*
* This file was generated by the tool fastddsgen (version: 4.0.5).
* This file was generated by the tool fastddsgen (version: 4.0.6).
*/

#ifndef FAST_DDS_GENERATED__HELLOWORLDCDRAUX_IPP
Expand Down
72 changes: 17 additions & 55 deletions resources/xtypes/HelloWorldPubSubTypes.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
* @file HelloWorldPubSubTypes.cpp
* This header file contains the implementation of the serialization functions.
*
* This file was generated by the tool fastddsgen (version: 4.0.5).
* This file was generated by the tool fastddsgen (version: 4.0.6).
*/

#include "HelloWorldPubSubTypes.hpp"

#include <algorithm>
#include <mutex>

#include <fastdds/dds/log/Log.hpp>
#include <fastdds/rtps/common/CdrSerialization.hpp>

Expand All @@ -36,25 +39,19 @@ HelloWorldPubSubType::HelloWorldPubSubType()
type_size += static_cast<uint32_t>(eprosima::fastcdr::Cdr::alignment(type_size, 4)); /* possible submessage alignment */
max_serialized_type_size = type_size + 4; /*encapsulation*/
is_compute_key_provided = false;
uint32_t key_length = HelloWorld_max_key_cdr_typesize > 16 ? HelloWorld_max_key_cdr_typesize : 16;
key_buffer_ = reinterpret_cast<unsigned char*>(malloc(key_length));
memset(key_buffer_, 0, key_length);
}

HelloWorldPubSubType::~HelloWorldPubSubType()
{
if (key_buffer_ != nullptr)
{
free(key_buffer_);
}
}

bool HelloWorldPubSubType::serialize(
const void* const data,
SerializedPayload_t& payload,
DataRepresentationId_t data_representation)
{
const HelloWorld* p_type = static_cast<const HelloWorld*>(data);
const HelloWorld* p_type =
static_cast<const HelloWorld*>(data);

// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.max_size);
Expand All @@ -74,7 +71,7 @@ bool HelloWorldPubSubType::serialize(
ser.serialize_encapsulation();
// Serialize the object.
ser << *p_type;
ser.set_dds_cdr_options({0,0});
ser.set_dds_cdr_options({0, 0});
}
catch (eprosima::fastcdr::exception::Exception& /*exception*/)
{
Expand All @@ -93,7 +90,8 @@ bool HelloWorldPubSubType::deserialize(
try
{
// Convert DATA to pointer of your type
HelloWorld* p_type = static_cast<HelloWorld*>(data);
HelloWorld* p_type =
static_cast<HelloWorld*>(data);

// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(payload.data), payload.length);
Expand Down Expand Up @@ -152,16 +150,9 @@ bool HelloWorldPubSubType::compute_key(
InstanceHandle_t& handle,
bool force_md5)
{
if (!is_compute_key_provided)
{
return false;
}

HelloWorld data;
if (deserialize(payload, static_cast<void*>(&data)))
{
return compute_key(static_cast<void*>(&data), handle, force_md5);
}
static_cast<void>(payload);
static_cast<void>(handle);
static_cast<void>(force_md5);

return false;
}
Expand All @@ -171,47 +162,18 @@ bool HelloWorldPubSubType::compute_key(
InstanceHandle_t& handle,
bool force_md5)
{
if (!is_compute_key_provided)
{
return false;
}
static_cast<void>(data);
static_cast<void>(handle);
static_cast<void>(force_md5);

const HelloWorld* p_type = static_cast<const HelloWorld*>(data);

// Object that manages the raw buffer.
eprosima::fastcdr::FastBuffer fastbuffer(reinterpret_cast<char*>(key_buffer_),
HelloWorld_max_key_cdr_typesize);

// Object that serializes the data.
eprosima::fastcdr::Cdr ser(fastbuffer, eprosima::fastcdr::Cdr::BIG_ENDIANNESS, eprosima::fastcdr::CdrVersion::XCDRv2);
ser.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR2);
eprosima::fastcdr::serialize_key(ser, *p_type);
if (force_md5 || HelloWorld_max_key_cdr_typesize > 16)
{
md5_.init();
md5_.update(key_buffer_, static_cast<unsigned int>(ser.get_serialized_data_length()));
md5_.finalize();
for (uint8_t i = 0; i < 16; ++i)
{
handle.value[i] = md5_.digest[i];
}
}
else
{
for (uint8_t i = 0; i < 16; ++i)
{
handle.value[i] = key_buffer_[i];
}
}
return true;
return false;
}

void HelloWorldPubSubType::register_type_object_representation()
{
EPROSIMA_LOG_WARNING(XTYPES_TYPE_REPRESENTATION,
"TypeObject type representation support disabled in generated code");
"TypeObject type representation support disabled in generated code");
}


// Include auxiliary functions like for serializing/deserializing.
#include "HelloWorldCdrAux.ipp"
7 changes: 3 additions & 4 deletions resources/xtypes/HelloWorldPubSubTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
* @file HelloWorldPubSubTypes.hpp
* This header file contains the declaration of the serialization functions.
*
* This file was generated by the tool fastddsgen (version: 4.0.5).
* This file was generated by the tool fastddsgen (version: 4.0.6).
*/


#ifndef FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP
#define FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP

#include <mutex>

#include <fastdds/dds/core/policy/QosPolicies.hpp>
#include <fastdds/dds/topic/TopicDataType.hpp>
#include <fastdds/rtps/common/InstanceHandle.hpp>
Expand Down Expand Up @@ -114,9 +116,6 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType

private:

eprosima::fastdds::MD5 md5_;
unsigned char* key_buffer_;

};

#endif // FAST_DDS_GENERATED__HELLOWORLD_PUBSUBTYPES_HPP
Expand Down
Loading