iceoryx_doc  1.0.1
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
iox::rp::BaseRelocatablePointer Class Reference

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>

Inheritance diagram for iox::rp::BaseRelocatablePointer:
Inheritance graph
[legend]

Public Types

using offset_t = std::ptrdiff_t
 

Public Member Functions

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

Static Public Attributes

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

Protected Member Functions

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

Protected Attributes

offset_t m_offset {NULL_POINTER_OFFSET}
 

Friends

template<typename T >
class RelocatablePointer
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ BaseRelocatablePointer() [1/3]

iox::rp::BaseRelocatablePointer::BaseRelocatablePointer ( const void *  ptr)
explicitnoexcept

creates a relocatable pointer pointing to the same pointee as ptr

Parameters
[in]ptrthe pointer whose pointee shall be the same for this

◆ BaseRelocatablePointer() [2/3]

iox::rp::BaseRelocatablePointer::BaseRelocatablePointer ( const BaseRelocatablePointer other)
noexcept

copy constructor

Parameters
[in]otheris the copy origin

◆ BaseRelocatablePointer() [3/3]

iox::rp::BaseRelocatablePointer::BaseRelocatablePointer ( BaseRelocatablePointer &&  other)
noexcept

move constructor

Parameters
[in]otheris the move origin

Member Function Documentation

◆ get()

const void* iox::rp::BaseRelocatablePointer::get ( ) const
noexcept

access to the underlying object in shared memory

Returns
a pointer to the underlying object

◆ getOffset()

offset_t iox::rp::BaseRelocatablePointer::getOffset ( ) const
noexcept

returns the offset

Returns
offset

◆ operator bool()

iox::rp::BaseRelocatablePointer::operator bool ( ) const
noexcept

checks if this is not a logical nullptr

Returns
true if this is not a logical nullptr, otherwise false

◆ operator!()

bool iox::rp::BaseRelocatablePointer::operator! ( ) const
noexcept

checks if this is a logical nullptr

Returns
true if this is a logical nullptr, otherwise false

◆ operator*()

const void* iox::rp::BaseRelocatablePointer::operator* ( ) const
noexcept

read-only access to the underlying object in shared memory

Returns
a const pointer to the underlying object

◆ operator=() [1/3]

BaseRelocatablePointer& iox::rp::BaseRelocatablePointer::operator= ( BaseRelocatablePointer &&  other)
noexcept

move assignment

Parameters
[in]otheris the move origin
Returns
reference to self

◆ operator=() [2/3]

BaseRelocatablePointer& iox::rp::BaseRelocatablePointer::operator= ( const BaseRelocatablePointer other)
noexcept

copy assignment

Parameters
[in]otheris the copy origin
Returns
reference to self

◆ operator=() [3/3]

BaseRelocatablePointer& iox::rp::BaseRelocatablePointer::operator= ( const void *  rawPtr)
noexcept

assign BaseRelocatablePointer to point to the same pointee as rawPtr

Parameters
[in]rawPtrthe pointer whose pointee shall be the same for this
Returns
reference to self

The documentation for this class was generated from the following file: