Skip to content

iox::rp::BaseRelocatablePointer🔗

pointer class to use when pointer and pointee are located in the same shared memory segment We can have the following scenario: Pointer p points to object X of type T and both are stored in shared memory segment S. More...

#include <base_relocatable_pointer.hpp>

Inherited by iox::rp::RelocatablePointer< T >

Public Types🔗

Name
using std::ptrdiff_t offset_t

Public Functions🔗

Name
BaseRelocatablePointer()
default constructs a logical nullptr
BaseRelocatablePointer(const void * ptr)
creates a relocatable pointer pointing to the same pointee as ptr
BaseRelocatablePointer(const BaseRelocatablePointer & other)
copy constructor
BaseRelocatablePointer(BaseRelocatablePointer && other)
move constructor
BaseRelocatablePointer & operator=(const BaseRelocatablePointer & other)
copy assignment
BaseRelocatablePointer & operator=(const void * rawPtr)
assign BaseRelocatablePointer to point to the same pointee as rawPtr
BaseRelocatablePointer & operator=(BaseRelocatablePointer && other)
move assignment
const void * operator*() const
read-only access to the underlying object in shared memory
operator bool() const
checks if this is not a logical nullptr
bool operator!() const
checks if this is a logical nullptr
const void * get() const
access to the underlying object in shared memory
offset_t getOffset() const
returns the offset

Protected Functions🔗

Name
offset_t computeOffset(const void * ptr) const
void * computeRawPtr() const

Public Attributes🔗

Name
constexpr offset_t NULL_POINTER_OFFSET

Protected Attributes🔗

Name
offset_t m_offset

Friends🔗

Name
class RelocatablePointer

Detailed Description🔗

class iox::rp::BaseRelocatablePointer;

pointer class to use when pointer and pointee are located in the same shared memory segment We can have the following scenario: Pointer p points to object X of type T and both are stored in shared memory segment S.

Shared Memory S: p X |______^ App1 a1 b1 c1 App2 a2 b2 c2

Let a1, b1, c1 be the addresses of segment S, pointer p and object X in application 1 and similarly a2, b2, and c2 in application 2. If application 2 maps the memory differently they will be shifted by some common offset d depending on the individual memory mapping: a2=a1+d, b2=b1+d, c2=c1+d This is why storing a raw pointer to X will not be sufficient, the value of c1 will not point to X in application 2. However, storing the difference between the location of p and X will work since it is an invariant in both address spaces.

Public Types Documentation🔗

using offset_t🔗

using iox::rp::BaseRelocatablePointer::offset_t =  std::ptrdiff_t;

Public Functions Documentation🔗

function BaseRelocatablePointer🔗

BaseRelocatablePointer()

default constructs a logical nullptr

function BaseRelocatablePointer🔗

explicit BaseRelocatablePointer(
    const void * ptr
)

creates a relocatable pointer pointing to the same pointee as ptr

Parameters:

  • ptr the pointer whose pointee shall be the same for this

function BaseRelocatablePointer🔗

BaseRelocatablePointer(
    const BaseRelocatablePointer & other
)

copy constructor

Parameters:

  • other is the copy origin

function BaseRelocatablePointer🔗

BaseRelocatablePointer(
    BaseRelocatablePointer && other
)

move constructor

Parameters:

  • other is the move origin

function operator=🔗

BaseRelocatablePointer & operator=(
    const BaseRelocatablePointer & other
)

copy assignment

Parameters:

  • other is the copy origin

Return: reference to self

function operator=🔗

BaseRelocatablePointer & operator=(
    const void * rawPtr
)

assign BaseRelocatablePointer to point to the same pointee as rawPtr

Parameters:

  • rawPtr the pointer whose pointee shall be the same for this

Return: reference to self

function operator=🔗

BaseRelocatablePointer & operator=(
    BaseRelocatablePointer && other
)

move assignment

Parameters:

  • other is the move origin

Return: reference to self

function operator*🔗

const void * operator*() const

read-only access to the underlying object in shared memory

Return: a const pointer to the underlying object

function operator bool🔗

operator bool() const

checks if this is not a logical nullptr

Return: true if this is not a logical nullptr, otherwise false

function operator!🔗

bool operator!() const

checks if this is a logical nullptr

Return: true if this is a logical nullptr, otherwise false

function get🔗

const void * get() const

access to the underlying object in shared memory

Return: a pointer to the underlying object

function getOffset🔗

offset_t getOffset() const

returns the offset

Return: offset

Protected Functions Documentation🔗

function computeOffset🔗

offset_t computeOffset(
    const void * ptr
) const

function computeRawPtr🔗

void * computeRawPtr() const

Public Attributes Documentation🔗

variable NULL_POINTER_OFFSET🔗

static constexpr offset_t NULL_POINTER_OFFSET = std::numeric_limits<offset_t>::max();

Protected Attributes Documentation🔗

variable m_offset🔗

offset_t m_offset {NULL_POINTER_OFFSET};

Friends🔗

friend RelocatablePointer🔗

friend class RelocatablePointer;

Updated on 31 May 2022 at 15:29:15 CEST