Fast DDS
Version 3.6.1.0
Fast DDS
Toggle main menu visibility
Loading...
Searching...
No Matches
UserAllocatedSequence.hpp
1
// Copyright 2021 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_DDS_CORE__USERALLOCATEDSEQUENCE_HPP
20
#define FASTDDS_DDS_CORE__USERALLOCATEDSEQUENCE_HPP
21
22
#include <cassert>
23
#include <cstdint>
24
#include <stdexcept>
25
26
#include <fastdds/dds/core/LoanableCollection.hpp>
27
28
namespace
eprosima
{
29
namespace
fastdds
{
30
namespace
dds
{
31
40
struct
UserAllocatedSequence
:
public
LoanableCollection
41
{
42
using
size_type
=
LoanableCollection::size_type
;
43
using
element_type
=
LoanableCollection::element_type
;
44
56
UserAllocatedSequence
(
57
element_type
* items,
58
size_type
num_items)
59
{
60
has_ownership_
=
true
;
61
maximum_
= num_items;
62
length_
= 0;
63
elements_
= items;
64
}
65
66
~UserAllocatedSequence
() =
default
;
67
68
// Non-copyable
69
UserAllocatedSequence
(
70
const
UserAllocatedSequence
&) =
delete
;
71
UserAllocatedSequence
&
operator =
(
72
const
UserAllocatedSequence
&) =
delete
;
73
74
// Non-moveable
75
UserAllocatedSequence
(
76
UserAllocatedSequence
&&) =
delete
;
77
UserAllocatedSequence
&
operator =
(
78
UserAllocatedSequence
&&) =
delete
;
79
80
protected
:
81
82
using
LoanableCollection::maximum_
;
83
using
LoanableCollection::length_
;
84
using
LoanableCollection::elements_
;
85
using
LoanableCollection::has_ownership_
;
86
87
void
resize
(
88
size_type
new_length)
override
89
{
90
// This kind of collection cannot grow above its stack-allocated size
91
if
(new_length >
maximum_
)
92
{
93
throw
std::bad_alloc();
94
}
95
}
96
97
};
98
99
}
// namespace dds
100
}
// namespace fastdds
101
}
// namespace eprosima
102
103
#endif
// FASTDDS_DDS_CORE__USERALLOCATEDSEQUENCE_HPP
eprosima::fastdds::dds::LoanableCollection::has_ownership_
bool has_ownership_
Definition
LoanableCollection.hpp:243
eprosima::fastdds::dds::LoanableCollection::LoanableCollection
LoanableCollection()=default
Default constructor.
eprosima::fastdds::dds::LoanableCollection::maximum_
size_type maximum_
Definition
LoanableCollection.hpp:240
eprosima::fastdds::dds::LoanableCollection::size_type
int32_t size_type
Definition
LoanableCollection.hpp:37
eprosima::fastdds::dds::LoanableCollection::length_
size_type length_
Definition
LoanableCollection.hpp:241
eprosima::fastdds::dds::LoanableCollection::elements_
element_type * elements_
Definition
LoanableCollection.hpp:242
eprosima::fastdds::dds::LoanableCollection::element_type
void * element_type
Definition
LoanableCollection.hpp:38
eprosima::fastdds::dds
Definition
BuiltinTopicKey.hpp:26
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::dds::UserAllocatedSequence::UserAllocatedSequence
UserAllocatedSequence(const UserAllocatedSequence &)=delete
eprosima::fastdds::dds::UserAllocatedSequence::UserAllocatedSequence
UserAllocatedSequence(element_type *items, size_type num_items)
Construct a UserAllocatedSequence.
Definition
UserAllocatedSequence.hpp:56
eprosima::fastdds::dds::UserAllocatedSequence::has_ownership_
bool has_ownership_
Definition
LoanableCollection.hpp:243
eprosima::fastdds::dds::UserAllocatedSequence::maximum_
size_type maximum_
Definition
LoanableCollection.hpp:240
eprosima::fastdds::dds::UserAllocatedSequence::resize
void resize(size_type new_length) override
Definition
UserAllocatedSequence.hpp:87
eprosima::fastdds::dds::UserAllocatedSequence::length_
size_type length_
Definition
LoanableCollection.hpp:241
eprosima::fastdds::dds::UserAllocatedSequence::UserAllocatedSequence
UserAllocatedSequence(UserAllocatedSequence &&)=delete
eprosima::fastdds::dds::UserAllocatedSequence::element_type
LoanableCollection::element_type element_type
Definition
UserAllocatedSequence.hpp:43
eprosima::fastdds::dds::UserAllocatedSequence::elements_
element_type * elements_
Definition
LoanableCollection.hpp:242
eprosima::fastdds::dds::UserAllocatedSequence::size_type
LoanableCollection::size_type size_type
Definition
UserAllocatedSequence.hpp:42
eprosima::fastdds::dds::UserAllocatedSequence::operator=
UserAllocatedSequence & operator=(const UserAllocatedSequence &)=delete
eprosima::fastdds::dds::UserAllocatedSequence::~UserAllocatedSequence
~UserAllocatedSequence()=default
include
fastdds
dds
core
UserAllocatedSequence.hpp
Generated on
for