| Fast DDS Version 3.3.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
18
19#ifndef FASTDDS_DDS_CORE__LOANABLEARRAY_HPP
20#define FASTDDS_DDS_CORE__LOANABLEARRAY_HPP
21
22#include <cstdint>
23#include <array>
24
25 namespace eprosima {
26 namespace fastdds {
27 namespace dds {
28
33 template<typename T, std::size_t num_items>
34 struct LoanableArray : public std::array<T, num_items>
35{
36 LoanableArray()
37 {
38 for (std::size_t n = 0; n < num_items; ++n)
39 {
40 buffer_[n] = &((*this)[n]);
41 }
42 }
43
44 // Non-copyable
45 LoanableArray(
46 const LoanableArray&) = delete;
47 LoanableArray& operator = (
48 const LoanableArray&) = delete;
49
50 // Non-moveable
51 LoanableArray(
52 LoanableArray&&) = delete;
53 LoanableArray& operator = (
54 LoanableArray&&) = delete;
55
61 void** buffer_for_loans() const
62 {
63 return (void**) buffer_;
64 }
65
66 private:
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
eprosima::fastdds::dds
Definition BuiltinTopicKey.hpp:26
eprosima::fastdds
eprosima
eProsima namespace.
eprosima::fastdds::dds::LoanableArray::LoanableArray
LoanableArray(const LoanableArray &)=delete
eprosima::fastdds::dds::LoanableArray::buffer_for_loans
void ** buffer_for_loans() const
Get a buffer pointer that could be used on loan.
Definition LoanableArray.hpp:61
eprosima::fastdds::dds::LoanableArray::LoanableArray
LoanableArray(LoanableArray &&)=delete
eprosima::fastdds::dds::LoanableArray::LoanableArray
LoanableArray()
Definition LoanableArray.hpp:36
eprosima::fastdds::dds::LoanableArray::operator=
LoanableArray & operator=(const LoanableArray &)=delete