iceoryx2
C++ Bindings
Loading...
Searching...
No Matches
resizable_memory_response.hpp
Go to the documentation of this file.
1// Copyright (c) 2026 Contributors to the Eclipse Foundation
2//
3// See the NOTICE file(s) distributed with this work for additional
4// information regarding copyright ownership.
5//
6// This program and the accompanying materials are made available under the
7// terms of the Apache Software License 2.0 which is available at
8// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9// which is available at https://opensource.org/licenses/MIT.
10//
11// SPDX-License-Identifier: Apache-2.0 OR MIT
12
13#ifndef IOX2_RESIZABLE_MEMORY_RESPONSE_HPP
14#define IOX2_RESIZABLE_MEMORY_RESPONSE_HPP
15
16#include "iox2/deployment/iceoryx2_cxx_feature_flags.hpp"
17
18#if IOX2_FEATURE_FLATBUFFERS
19
20#include <flatbuffers/allocator.h>
21
23#include "iox2/service_type.hpp"
24
25namespace iox2 {
26template <ServiceType, typename, typename, typename, typename>
27class ActiveRequest;
28
29namespace internal {
31template <ServiceType Service>
32class ResizableMemoryResponse : public flatbuffers::Allocator {
33 public:
37
38 auto operator=(const ResizableMemoryResponse&) noexcept -> ResizableMemoryResponse& = delete;
39 auto operator=(ResizableMemoryResponse&&) noexcept -> ResizableMemoryResponse&;
40
41 auto allocate(size_t size) -> uint8_t* override;
42
43 void deallocate(uint8_t* ptr, size_t size) override;
44
45 auto reallocate_downward(uint8_t* old_p, size_t old_size, size_t new_size, size_t in_use_back, size_t in_use_front)
46 -> uint8_t* override;
47
48 auto len() const -> size_t;
49 auto reserved_header_len() const -> size_t;
50 auto as_ptr() const -> const uint8_t*;
51
52 private:
53 template <ServiceType, typename, typename, typename, typename>
54 friend class iox2::ActiveRequest;
55
56 explicit ResizableMemoryResponse(iox2_resizable_memory_response_h handle);
57 void drop();
58
59 iox2_resizable_memory_response_h m_handle = nullptr;
60 bool m_has_allocated = false;
61 uint8_t* m_ptr = nullptr;
62};
63} // namespace internal
64} // namespace iox2
65
66#endif // IOX2_FEATURE_FLATBUFFERS
67
68#endif // IOX2_RESIZABLE_MEMORY_RESPONSE_HPP
Internal helper class to handle dynamic memory allocations used in e.g. flatbuffers.
ResizableMemoryResponse(const ResizableMemoryResponse &)=delete
void deallocate(uint8_t *ptr, size_t size) override
ResizableMemoryResponse(ResizableMemoryResponse &&) noexcept
auto reallocate_downward(uint8_t *old_p, size_t old_size, size_t new_size, size_t in_use_back, size_t in_use_front) -> uint8_t *override
auto reserved_header_len() const -> size_t
auto allocate(size_t size) -> uint8_t *override
auto as_ptr() const -> const uint8_t *