Fast DDS
Version 3.6.1.0
Fast DDS
Toggle main menu visibility
Loading...
Searching...
No Matches
LoanableTypedCollection.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__LOANABLETYPEDCOLLECTION_HPP
20
#define FASTDDS_DDS_CORE__LOANABLETYPEDCOLLECTION_HPP
21
22
#include <cassert>
23
#include <cstdint>
24
#include <stdexcept>
25
#include <type_traits>
26
27
#include <fastdds/dds/core/LoanableCollection.hpp>
28
29
namespace
eprosima
{
30
namespace
fastdds
{
31
namespace
dds
{
32
38
template
<
typename
T,
typename
_NonConstEnabler = std::true_type>
39
class
LoanableTypedCollection
:
public
LoanableCollection
40
{
41
public
:
42
58
template
<
typename
Enabler = _NonConstEnabler>
59
typename
std::enable_if<Enabler::value, T>::type&
operator []
(
60
size_type
n)
61
{
62
if
(n >=
length_
)
63
{
64
throw
std::out_of_range(
""
);
65
}
66
67
return
*
static_cast<
T*
>
(
elements_
[n]);
68
}
69
84
const
T&
operator []
(
85
size_type
n)
const
86
{
87
if
(n >=
length_
)
88
{
89
throw
std::out_of_range(
""
);
90
}
91
92
return
*
static_cast<
const
T*
>
(
elements_
[n]);
93
}
94
95
};
96
97
}
// namespace dds
98
}
// namespace fastdds
99
}
// namespace eprosima
100
101
#endif
// FASTDDS_DDS_CORE__LOANABLETYPEDCOLLECTION_HPP
eprosima::fastdds::dds::LoanableCollection::LoanableCollection
LoanableCollection()=default
Default constructor.
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::LoanableTypedCollection
A type-safe accessible collection of generic opaque pointers that can receive the buffer from outside...
Definition
LoanableTypedCollection.hpp:40
eprosima::fastdds::dds::LoanableTypedCollection::operator[]
std::enable_if< Enabler::value, T >::type & operator[](size_type n)
Set an element of the sequence.
Definition
LoanableTypedCollection.hpp:59
eprosima::fastdds::dds
Definition
BuiltinTopicKey.hpp:26
eprosima::fastdds
eprosima
eProsima namespace.
include
fastdds
dds
core
LoanableTypedCollection.hpp
Generated on
for