Fast DDS  Version 3.0.0
Fast DDS
Loading...
Searching...
No Matches
LoanableArray.hpp
1// Copyright 2020 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
19#ifndef FASTDDS_DDS_CORE__LOANABLEARRAY_HPP
20#define FASTDDS_DDS_CORE__LOANABLEARRAY_HPP
21
22#include <cstdint>
23#include <array>
24
25namespace eprosima {
26namespace fastdds {
27namespace dds {
28
33template<typename T, std::size_t num_items>
34struct LoanableArray : public std::array<T, num_items>
35{
37 {
38 for (std::size_t n = 0; n < num_items; ++n)
39 {
40 buffer_[n] = &((*this)[n]);
41 }
42 }
43
44 // Non-copyable
46 const LoanableArray&) = delete;
48 const LoanableArray&) = delete;
49
50 // Non-moveable
52 LoanableArray&&) = delete;
54 LoanableArray&&) = delete;
55
61 void** buffer_for_loans() const
62 {
63 return (void**) buffer_;
64 }
65
66private:
67
68 void* buffer_[num_items];
69};
70
71} // namespace dds
72} // namespace fastdds
73} // namespace eprosima
74
75#endif // FASTDDS_DDS_CORE__LOANABLEARRAY_HPP
Definition DomainParticipant.hpp:45
eProsima namespace.
A type-safe, ordered collection of elements allocated on the stack, which can be loaned to a Loanable...
Definition LoanableArray.hpp:35
LoanableArray(const LoanableArray &)=delete
void ** buffer_for_loans() const
Get a buffer pointer that could be used on LoanableCollection::loan.
Definition LoanableArray.hpp:61
LoanableArray(LoanableArray &&)=delete
LoanableArray()
Definition LoanableArray.hpp:36
LoanableArray & operator=(const LoanableArray &)=delete