iceoryx_posh 2.0.5
Loading...
Searching...
No Matches
memory_block.hpp
1// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
2// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16// SPDX-License-Identifier: Apache-2.0
17#ifndef IOX_POSH_ROUDI_MEMORY_MEMORY_BLOCK_HPP
18#define IOX_POSH_ROUDI_MEMORY_MEMORY_BLOCK_HPP
19
20#include "iceoryx_hoofs/cxx/helplets.hpp"
21#include "iceoryx_hoofs/cxx/optional.hpp"
22
23#include <cstdint>
24
25namespace iox
26{
27namespace roudi
28{
34{
35 friend class MemoryProvider;
36
37 public:
38 MemoryBlock() noexcept = default;
39 virtual ~MemoryBlock() noexcept = default;
40
43 MemoryBlock(const MemoryBlock&) = delete;
44 MemoryBlock(MemoryBlock&&) = delete;
45 MemoryBlock& operator=(const MemoryBlock&) = delete;
46 MemoryBlock& operator=(MemoryBlock&&) = delete;
47
51 virtual uint64_t size() const noexcept = 0;
52
56 virtual uint64_t alignment() const noexcept = 0;
57
61 cxx::optional<void*> memory() const noexcept;
62
63 protected:
66 virtual void destroy() noexcept = 0;
67
71 virtual void onMemoryAvailable(cxx::not_null<void*> memory) noexcept;
72
73 private:
74 void* m_memory{nullptr};
75};
76
77} // namespace roudi
78} // namespace iox
79
80#endif // IOX_POSH_ROUDI_MEMORY_MEMORY_BLOCK_HPP
The MemoryBlock is a container for general purpose memory. It is used to request some memory from a M...
Definition memory_block.hpp:34
virtual uint64_t size() const noexcept=0
This function provides the size of the required memory for the underlying data. It is needed for the ...
cxx::optional< void * > memory() const noexcept
This function provides the pointer to the requested memory.
virtual void destroy() noexcept=0
The MemoryProvider calls this either when MemoryProvider::destroy is called or in its destructor.
MemoryBlock(const MemoryBlock &)=delete
virtual uint64_t alignment() const noexcept=0
This function provides the alignment of the memory for the underlying data. This information is neede...
virtual void onMemoryAvailable(cxx::not_null< void * > memory) noexcept
This function is called once the memory is available and is therefore the earliest possibility to use...
This class creates memory which is requested by the MemoryBlocks. Once the memory is available,...
Definition memory_provider.hpp:69