iceoryx_doc
1.0.1
|
pointer class to use when pointer and pointee are located in different shared memory segments We can have the following scenario: Pointer p is stored in segment S1 and points to object X of type T in segment S2. More...
#include <base_relative_pointer.hpp>
Public Types | |
using | id_t = uint64_t |
using | ptr_t = void * |
using | const_ptr_t = const void *const |
using | offset_t = std::uintptr_t |
Public Member Functions | |
BaseRelativePointer (ptr_t ptr, id_t id) noexcept | |
constructs a BaseRelativePointer pointing to the same pointee as ptr in a segment identified by id More... | |
BaseRelativePointer (offset_t offset, id_t id) noexcept | |
constructs a BaseRelativePointer from a given offset and segment id More... | |
BaseRelativePointer (ptr_t ptr=nullptr) noexcept | |
constructs a BaseRelativePointer pointing to the same pointer as ptr More... | |
BaseRelativePointer (const BaseRelativePointer &other) noexcept | |
copy constructor More... | |
BaseRelativePointer (BaseRelativePointer &&other) noexcept | |
move constructor More... | |
BaseRelativePointer & | operator= (const BaseRelativePointer &other) noexcept |
copy assignment More... | |
BaseRelativePointer & | operator= (void *ptr) noexcept |
assigns the BaseRelativePointer to point to the same pointee as ptr More... | |
BaseRelativePointer & | operator= (BaseRelativePointer &&other) noexcept |
move assignment More... | |
ptr_t | get () const noexcept |
access to the underlying object More... | |
id_t | getId () const noexcept |
returns the id which identifies the segment More... | |
offset_t | getOffset () const noexcept |
returns the offset More... | |
ptr_t | getBasePtr () const noexcept |
get the base pointer associated with this' id More... | |
offset_t | computeOffset (ptr_t ptr) const noexcept |
get the offset from the start address of the segment and ptr More... | |
ptr_t | computeRawPtr () const noexcept |
get the pointer from stored id and offset More... | |
Static Public Member Functions | |
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 More... | |
static bool | registerPtr (const id_t id, const ptr_t ptr, uint64_t size=0U) noexcept |
tries to register a memory segment with a given size starting at ptr to a given id More... | |
static bool | unregisterPtr (const id_t id) noexcept |
unregisters ptr with given id More... | |
static ptr_t | getBasePtr (const id_t id) noexcept |
get the base ptr associated with the given id More... | |
static void | unregisterAll () noexcept |
unregisters all ptr id pairs (leads to initial state) | |
static offset_t | getOffset (const id_t id, const_ptr_t ptr) noexcept |
get the offset from id and ptr More... | |
static ptr_t | getPtr (const id_t id, const offset_t offset) noexcept |
get the pointer from id and offset ("inverse" to getOffset) More... | |
static id_t | searchId (ptr_t ptr) noexcept |
get the id for a given ptr More... | |
static bool | isValid (id_t id) noexcept |
checks if given id is valid More... | |
static PointerRepository< id_t, ptr_t > & | getRepository () noexcept |
returns the pointer repository More... | |
Static Public Attributes | |
static constexpr id_t | NULL_POINTER_ID = std::numeric_limits<id_t>::max() |
static constexpr offset_t | NULL_POINTER_OFFSET = std::numeric_limits<offset_t>::max() |
Protected Attributes | |
id_t | m_id {NULL_POINTER_ID} |
offset_t | m_offset {NULL_POINTER_OFFSET} |
pointer class to use when pointer and pointee are located in different shared memory segments We can have the following scenario: Pointer p is stored in segment S1 and points to object X of type T in segment S2.
Shared Memory S1: p S2: X |___________________^ App1 a1 b1 c1 d1 App2 a2 b2 c2 d2
Now it is no longer true in general that both segments will be offset by the same difference in App2 and therefore relocatable pointers are no longer sufficient. Relative pointers solve this problem by incorporating the information from where they need to measure differences (i.e. relative to the given address). This requires an additional registration mechanism to be used by all applications where the start addresses and the size of all segments to be used are registered. Since these start address may differ between applications, each segment is identified by a unique id, which can be provided upon registration by the first application. In the figure, this means that the starting addresses of both segments(a1, a2 and c1, c2) would have to be registered in both applications. Once this registration is done, relative pointers can be constructed from raw pointers similar to relocatable pointers.
|
noexcept |
constructs a BaseRelativePointer pointing to the same pointee as ptr in a segment identified by id
[in] | ptr | the pointer whose pointee shall be the same for this |
[in] | id | is the unique id of the segment |
|
noexcept |
constructs a BaseRelativePointer from a given offset and segment id
[in] | offset | is the offset |
[in] | id | is the unique id of the segment |
|
noexcept |
constructs a BaseRelativePointer pointing to the same pointer as ptr
[in] | ptr | the pointer whose pointee shall be the same for this |
|
noexcept |
copy constructor
[in] | other | is the copy origin |
|
noexcept |
move constructor
[in] | other | is the move origin |
|
noexcept |
get the offset from the start address of the segment and ptr
[in] | ptr | is the pointer whose offset should be calculated |
|
noexcept |
get the pointer from stored id and offset
|
noexcept |
access to the underlying object
|
noexcept |
get the base pointer associated with this' id
|
staticnoexcept |
get the base ptr associated with the given id
[in] | id | is the id of the segment |
|
noexcept |
returns the id which identifies the segment
|
noexcept |
returns the offset
|
staticnoexcept |
get the offset from id and ptr
[in] | id | is the id of the segment and is used to get the base pointer |
[in] | ptr | is the pointer whose offset should be calculated |
|
staticnoexcept |
get the pointer from id and offset ("inverse" to getOffset)
[in] | id | is the id of the segment and is used to get the base pointer |
[in] | offset | is the offset for which the pointer should be calculated |
|
staticnoexcept |
returns the pointer repository
|
staticnoexcept |
checks if given id is valid
[in] | id | is the id to be checked |
|
noexcept |
move assignment
[in] | other | is the move origin |
|
noexcept |
copy assignment
[in] | other | is the copy origin |
|
noexcept |
assigns the BaseRelativePointer to point to the same pointee as ptr
[in] | ptr | the pointer whose pointee shall be the same for this |
|
staticnoexcept |
tries to register a memory segment with a given size starting at ptr to a given id
[in] | id | is the id of the segment |
[in] | ptr | starting address of the segment to be registered |
[in] | size | is the size of the segment |
|
staticnoexcept |
registers a memory segment at ptr with size of a new id
[in] | ptr | starting address of the segment to be registered |
[in] | size | is the size of the segment |
|
staticnoexcept |
get the id for a given ptr
[in] | ptr | the pointer whose corresponding id is searched for |
|
staticnoexcept |
unregisters ptr with given id
[in] | id | is the id of the segment |