iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
resizable_memory_publish_subscribe.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_PUBLISH_SUBSCRIBE_HPP
14#define IOX2_RESIZABLE_MEMORY_PUBLISH_SUBSCRIBE_HPP
15
16#include "iox2/iceoryx2_cxx_deployment.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>
27class Publisher;
28
29namespace internal {
31template <ServiceType Service>
32class ResizableMemoryPublishSubscribe : public flatbuffers::Allocator {
33 public:
34 ResizableMemoryPublishSubscribe(const ResizableMemoryPublishSubscribe&) = delete;
35 ResizableMemoryPublishSubscribe(ResizableMemoryPublishSubscribe&&) noexcept;
36 ~ResizableMemoryPublishSubscribe() override;
37
38 auto operator=(const ResizableMemoryPublishSubscribe&) noexcept -> ResizableMemoryPublishSubscribe& = delete;
39 auto operator=(ResizableMemoryPublishSubscribe&&) noexcept -> ResizableMemoryPublishSubscribe&;
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>
54 friend class iox2::Publisher;
55
56 explicit ResizableMemoryPublishSubscribe(iox2_resizable_memory_publish_subscribe_h handle);
57 void drop();
58
59 iox2_resizable_memory_publish_subscribe_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_PUBLISH_SUBSCRIBE_HPP