18 #ifndef IOX_UTILS_RELOCATABLE_POINTER_BASE_RELATIVE_POINTER_HPP
19 #define IOX_UTILS_RELOCATABLE_POINTER_BASE_RELATIVE_POINTER_HPP
21 #include "pointer_repository.hpp"
55 using id_t = uint64_t;
57 using const_ptr_t =
const void*
const;
58 using offset_t = std::uintptr_t;
99 ptr_t
get() const noexcept;
117 static id_t
registerPtr(const ptr_t ptr, uint64_t size = 0U) noexcept;
124 static
bool registerPtr(const id_t
id, const ptr_t ptr, uint64_t size = 0U) noexcept;
143 static offset_t
getOffset(const id_t
id, const_ptr_t ptr) noexcept;
149 static ptr_t
getPtr(const id_t
id, const offset_t offset) noexcept;
174 static constexpr id_t NULL_POINTER_ID = std::numeric_limits<id_t>::max();
175 static constexpr offset_t NULL_POINTER_OFFSET = std::numeric_limits<offset_t>::max();
178 id_t m_id{NULL_POINTER_ID};
179 offset_t m_offset{NULL_POINTER_OFFSET};
pointer class to use when pointer and pointee are located in different shared memory segments We can ...
Definition: base_relative_pointer.hpp:53
static PointerRepository< id_t, ptr_t > & getRepository() noexcept
returns the pointer repository
BaseRelativePointer(offset_t offset, id_t id) noexcept
constructs a BaseRelativePointer from a given offset and segment id
id_t getId() const noexcept
returns the id which identifies the segment
ptr_t computeRawPtr() const noexcept
get the pointer from stored id and offset
BaseRelativePointer(ptr_t ptr=nullptr) noexcept
constructs a BaseRelativePointer pointing to the same pointer as ptr
static bool unregisterPtr(const id_t id) noexcept
unregisters ptr with given id
BaseRelativePointer(ptr_t ptr, id_t id) noexcept
constructs a BaseRelativePointer pointing to the same pointee as ptr in a segment identified by id
ptr_t get() const noexcept
access to the underlying object
static bool isValid(id_t id) noexcept
checks if given id is valid
static void unregisterAll() noexcept
unregisters all ptr id pairs (leads to initial state)
ptr_t getBasePtr() const noexcept
get the base pointer associated with this' id
static id_t registerPtr(const ptr_t ptr, uint64_t size=0U) noexcept
registers a memory segment at ptr with size of a new id
offset_t computeOffset(ptr_t ptr) const noexcept
get the offset from the start address of the segment and ptr
offset_t getOffset() const noexcept
returns the offset
static ptr_t getPtr(const id_t id, const offset_t offset) noexcept
get the pointer from id and offset ("inverse" to getOffset)
static id_t searchId(ptr_t ptr) noexcept
get the id for a given ptr
Allows registration of memory segments with their start pointers and size. This class is used to reso...
Definition: pointer_repository.hpp:38
building block to easily create free function for logging in a library context
Definition: lockfree_queue.hpp:28