Fast DDS
Version 3.6.1.0
Fast DDS
Toggle main menu visibility
Loading...
Searching...
No Matches
SerializedPayload.hpp
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
18
19
#ifndef FASTDDS_RTPS_COMMON__SERIALIZEDPAYLOAD_HPP
20
#define FASTDDS_RTPS_COMMON__SERIALIZEDPAYLOAD_HPP
21
22
#include <cstring>
23
#include <new>
24
#include <stdexcept>
25
#include <cassert>
26
#include <stdint.h>
27
#include <stdlib.h>
28
29
#include <fastdds/fastdds_dll.hpp>
30
#include <fastdds/rtps/common/Types.hpp>
31
#include <fastdds/rtps/history/IPayloadPool.hpp>
32
37
38
namespace
eprosima
{
39
namespace
fastdds
{
40
namespace
rtps
{
41
42
//Pre define data encapsulation schemes
43
#define CDR_BE 0x0000
44
#define CDR_LE 0x0001
45
#define PL_CDR_BE 0x0002
46
#define PL_CDR_LE 0x0003
47
48
#if FASTDDS_IS_BIG_ENDIAN_TARGET
49
#define DEFAULT_ENCAPSULATION CDR_BE
50
#define PL_DEFAULT_ENCAPSULATION PL_CDR_BE
51
#else
52
#define DEFAULT_ENCAPSULATION CDR_LE
53
#define PL_DEFAULT_ENCAPSULATION PL_CDR_LE
54
#endif
// FASTDDS_IS_BIG_ENDIAN_TARGET
55
58
struct
FASTDDS_EXPORTED_API
SerializedPayload_t
59
{
61
static
constexpr
size_t
representation_header_size
= 4u;
62
64
uint16_t
encapsulation
;
66
uint32_t
length
;
68
octet
*
data
;
70
uint32_t
max_size
;
72
uint32_t
pos
;
74
IPayloadPool
*
payload_owner
=
nullptr
;
76
bool
is_serialized_key
=
false
;
77
79
SerializedPayload_t
()
80
:
encapsulation
(CDR_BE)
81
,
length
(0)
82
,
data
(nullptr)
83
,
max_size
(0)
84
,
pos
(0)
85
{
86
}
87
91
explicit
SerializedPayload_t
(
92
uint32_t len)
93
:
SerializedPayload_t
()
94
{
95
this->
reserve
(len);
96
}
97
99
SerializedPayload_t
(
100
const
SerializedPayload_t
& other) =
delete
;
102
SerializedPayload_t
& operator = (
103
const
SerializedPayload_t
& other) =
delete
;
104
106
SerializedPayload_t
(
107
SerializedPayload_t
&& other)
noexcept
108
{
109
*
this
= std::move(other);
110
}
111
113
SerializedPayload_t
& operator = (
114
SerializedPayload_t
&& other)
noexcept
;
115
120
~SerializedPayload_t
();
121
122
bool
operator == (
123
const
SerializedPayload_t
& other)
const
;
124
131
bool
copy
(
132
const
SerializedPayload_t
* serData,
133
bool
with_limit =
true
);
134
140
bool
reserve_fragmented
(
141
SerializedPayload_t
* serData);
142
147
void
empty
();
148
149
void
reserve
(
150
uint32_t new_size);
151
152
};
153
154
}
// namespace rtps
155
}
// namespace fastdds
156
}
// namespace eprosima
157
158
#endif
// FASTDDS_RTPS_COMMON__SERIALIZEDPAYLOAD_HPP
eprosima::fastdds::rtps::IPayloadPool
An interface for classes responsible of serialized payload management.
Definition
IPayloadPool.hpp:35
eprosima::fastdds::rtps
Contains the RTPS protocol implementation.
eprosima::fastdds::rtps::octet
uint8_t octet
Definition
Types.hpp:83
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::rtps::SerializedPayload_t::data
octet * data
Pointer to the data.
Definition
SerializedPayload.hpp:68
eprosima::fastdds::rtps::SerializedPayload_t::copy
bool copy(const SerializedPayload_t *serData, bool with_limit=true)
Copy another structure (including allocating new space for the data).
eprosima::fastdds::rtps::SerializedPayload_t::SerializedPayload_t
SerializedPayload_t(uint32_t len)
Definition
SerializedPayload.hpp:91
eprosima::fastdds::rtps::SerializedPayload_t::encapsulation
uint16_t encapsulation
Encapsulation of the data as suggested in the RTPS 2.1 specification chapter 10.
Definition
SerializedPayload.hpp:64
eprosima::fastdds::rtps::SerializedPayload_t::is_serialized_key
bool is_serialized_key
Whether the payload contains a serialized key, or the whole data.
Definition
SerializedPayload.hpp:76
eprosima::fastdds::rtps::SerializedPayload_t::max_size
uint32_t max_size
Maximum size of the payload.
Definition
SerializedPayload.hpp:70
eprosima::fastdds::rtps::SerializedPayload_t::reserve_fragmented
bool reserve_fragmented(SerializedPayload_t *serData)
Allocate new space for fragmented data.
eprosima::fastdds::rtps::SerializedPayload_t::reserve
void reserve(uint32_t new_size)
eprosima::fastdds::rtps::SerializedPayload_t::SerializedPayload_t
SerializedPayload_t(SerializedPayload_t &&other) noexcept
Move constructor.
Definition
SerializedPayload.hpp:106
eprosima::fastdds::rtps::SerializedPayload_t::SerializedPayload_t
SerializedPayload_t(const SerializedPayload_t &other)=delete
Copy constructor.
eprosima::fastdds::rtps::SerializedPayload_t::empty
void empty()
Empty the payload.
eprosima::fastdds::rtps::SerializedPayload_t::SerializedPayload_t
SerializedPayload_t()
Default constructor.
Definition
SerializedPayload.hpp:79
eprosima::fastdds::rtps::SerializedPayload_t::payload_owner
IPayloadPool * payload_owner
Pool that created the payload.
Definition
SerializedPayload.hpp:74
eprosima::fastdds::rtps::SerializedPayload_t::representation_header_size
static constexpr size_t representation_header_size
Size in bytes of the representation header as specified in the RTPS 2.3 specification chapter 10.
Definition
SerializedPayload.hpp:61
eprosima::fastdds::rtps::SerializedPayload_t::length
uint32_t length
Actual length of the data.
Definition
SerializedPayload.hpp:66
eprosima::fastdds::rtps::SerializedPayload_t::pos
uint32_t pos
Position when reading.
Definition
SerializedPayload.hpp:72
eprosima::fastdds::rtps::SerializedPayload_t::~SerializedPayload_t
~SerializedPayload_t()
Destructor It is expected to release the payload if the payload owner is not nullptr before destructi...
include
fastdds
rtps
common
SerializedPayload.hpp
Generated on
for