| Fast DDS Version 3.3.0 Fast DDS

Loading...
Searching...
No Matches
DynamicPubSubType.hpp
1// Copyright 2023 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#ifndef FASTDDS_DDS_XTYPES_DYNAMIC_TYPES__DYNAMICPUBSUBTYPE_HPP
16#define FASTDDS_DDS_XTYPES_DYNAMIC_TYPES__DYNAMICPUBSUBTYPE_HPP
17
18#include <fastdds/dds/core/ReturnCode.hpp>
19#include <fastdds/dds/topic/TopicDataType.hpp>
20#include <fastdds/dds/xtypes/dynamic_types/Types.hpp>
21#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
22#include <fastdds/rtps/common/InstanceHandle.hpp>
23#include <fastdds/rtps/common/SerializedPayload.hpp>
24#include <fastdds/utils/md5.hpp>
25
26 namespace eprosima {
27 namespace fastdds {
28 namespace dds {
29
30 class DynamicType;
31 class DynamicData;
32
33 class DynamicPubSubType : public virtual eprosima::fastdds::dds::TopicDataType
34{
35 traits<DynamicType>::ref_type dynamic_type_;
36
37 unsigned char* key_buffer_ {nullptr};
38
39 MD5 md5_;
40
41 public:
42
43 //{{{ Public functions
44
45 FASTDDS_EXPORTED_API DynamicPubSubType() = default;
46
54 FASTDDS_EXPORTED_API DynamicPubSubType(
55 traits<DynamicType>::ref_type type);
56
73 FASTDDS_EXPORTED_API DynamicPubSubType(
74 traits<DynamicType>::ref_type type,
75 const xtypes::TypeInformation& type_information);
76
77 FASTDDS_EXPORTED_API virtual ~DynamicPubSubType();
78
86 FASTDDS_EXPORTED_API void* create_data() override;
87
95 FASTDDS_EXPORTED_API void delete_data(
96 void* data) override;
97
106 FASTDDS_EXPORTED_API bool deserialize(
107 eprosima::fastdds::rtps::SerializedPayload_t& payload,
108 void* data) override;
109
115 FASTDDS_EXPORTED_API traits<DynamicType>::ref_type get_dynamic_type() const noexcept;
116
126 FASTDDS_EXPORTED_API bool compute_key(
127 eprosima::fastdds::rtps::SerializedPayload_t& payload,
128 eprosima::fastdds::rtps::InstanceHandle_t& ihandle,
129 bool force_md5 = false) override;
130
140 FASTDDS_EXPORTED_API bool compute_key(
141 const void* const data,
142 eprosima::fastdds::rtps::InstanceHandle_t& ihandle,
143 bool force_md5 = false) override;
144
153 FASTDDS_EXPORTED_API uint32_t calculate_serialized_size(
154 const void* const data,
155 DataRepresentationId_t data_representation) override;
156
166 FASTDDS_EXPORTED_API bool serialize(
167 const void* const data,
168 eprosima::fastdds::rtps::SerializedPayload_t& payload,
169 fastdds::dds::DataRepresentationId_t data_representation) override;
170
180 FASTDDS_EXPORTED_API ReturnCode_t set_dynamic_type(
181 traits<DynamicType>::ref_type type);
182
184 FASTDDS_EXPORTED_API void register_type_object_representation() override;
185
186 //}}}
187
188private:
189
190 void update_dynamic_type();
191};
192
193} // namespace dds
194} // namespace fastdds
195} // namespace eprosima
196
197#endif // FASTDDS_DDS_XTYPES_DYNAMIC_TYPES__DYNAMICPUBSUBTYPE_HPP
eprosima::fastdds::MD5
Class MD5, for calculating MD5 hashes of strings or byte arrays it is not meant to be fast or secure.
Definition md5.hpp:63
eprosima::fastdds::dds::DynamicData
Definition DynamicData.hpp:32
eprosima::fastdds::dds::DynamicPubSubType::deserialize
FASTDDS_EXPORTED_API bool deserialize(eprosima::fastdds::rtps::SerializedPayload_t &payload, void *data) override
Deserialize an object from the given payload.
eprosima::fastdds::dds::DynamicPubSubType::DynamicPubSubType
FASTDDS_EXPORTED_API DynamicPubSubType(traits< DynamicType >::ref_type type, const xtypes::TypeInformation &type_information)
Constructs a DynamicPubSubType from a DynamicType and a TypeInformation.
eprosima::fastdds::dds::DynamicPubSubType::create_data
FASTDDS_EXPORTED_API void * create_data() override
Create a new data object of the specified type.
eprosima::fastdds::dds::DynamicPubSubType::~DynamicPubSubType
virtual FASTDDS_EXPORTED_API ~DynamicPubSubType()
eprosima::fastdds::dds::DynamicPubSubType::serialize
FASTDDS_EXPORTED_API bool serialize(const void *const data, eprosima::fastdds::rtps::SerializedPayload_t &payload, fastdds::dds::DataRepresentationId_t data_representation) override
Serialize an object into a given payload.
eprosima::fastdds::dds::DynamicPubSubType::compute_key
FASTDDS_EXPORTED_API bool compute_key(eprosima::fastdds::rtps::SerializedPayload_t &payload, eprosima::fastdds::rtps::InstanceHandle_t &ihandle, bool force_md5=false) override
Calculate the key associated to a given object.
eprosima::fastdds::dds::DynamicPubSubType::get_dynamic_type
FASTDDS_EXPORTED_API traits< DynamicType >::ref_type get_dynamic_type() const noexcept
Returns a copy of the internal DynamicType object.
eprosima::fastdds::dds::DynamicPubSubType::register_type_object_representation
FASTDDS_EXPORTED_API void register_type_object_representation() override
Register TypeObject representation in Fast DDS TypeObjectRegistry.
eprosima::fastdds::dds::DynamicPubSubType::delete_data
FASTDDS_EXPORTED_API void delete_data(void *data) override
Deletes an object previously allocated via create_data.
eprosima::fastdds::dds::DynamicPubSubType::set_dynamic_type
FASTDDS_EXPORTED_API ReturnCode_t set_dynamic_type(traits< DynamicType >::ref_type type)
Sets up the internal DynamicType object.
eprosima::fastdds::dds::DynamicPubSubType::calculate_serialized_size
FASTDDS_EXPORTED_API uint32_t calculate_serialized_size(const void *const data, DataRepresentationId_t data_representation) override
Provide a functor that calculates a specified object serialized size.
eprosima::fastdds::dds::DynamicPubSubType::DynamicPubSubType
FASTDDS_EXPORTED_API DynamicPubSubType()=default
eprosima::fastdds::dds::DynamicPubSubType::DynamicPubSubType
FASTDDS_EXPORTED_API DynamicPubSubType(traits< DynamicType >::ref_type type)
Constructs a DynamicPubSubType from a DynamicType.
eprosima::fastdds::dds::DynamicType
Definition DynamicType.hpp:33
eprosima::fastdds::dds::TopicDataType
Class TopicDataType used to provide the DomainRTPSParticipant with the methods to serialize,...
Definition TopicDataType.hpp:61
eprosima::fastdds::dds::xtypes::TypeInformation
This class represents the structure TypeInformation defined by the user in the IDL file.
Definition dds_xtypes_typeobject.hpp:24606
dds
Definition DomainParticipant.hpp:46
eprosima::fastdds::dds
Definition BuiltinTopicKey.hpp:26
eprosima::fastdds::dds::InstanceHandle_t
eprosima::fastdds::rtps::InstanceHandle_t InstanceHandle_t
Definition InstanceHandle.hpp:31
eprosima::fastdds::dds::DataRepresentationId_t
enum eprosima::fastdds::dds::DataRepresentationId DataRepresentationId_t
Enum DataRepresentationId, different kinds of topic data representation.
eprosima::fastdds::dds::ReturnCode_t
int32_t ReturnCode_t
Definition DDSReturnCode.hpp:59
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::dds::traits
Definition type_traits.hpp:28
eprosima::fastdds::dds::traits::ref_type
typename ::std::shared_ptr< T > ref_type
Definition type_traits.hpp:29
eprosima::fastdds::rtps::SerializedPayload_t
Structure SerializedPayload_t.
Definition SerializedPayload.hpp:59