Skip to content

iox::rp::PointerRepository🔗

Allows registration of memory segments with their start pointers and size. This class is used to resolve relative pointers in the corresponding address space of the application. Up to CAPACITY segments can be registered with MIN_ID = 1 to MAX_ID = CAPACITY - 1 id 0 is reserved and allows relative pointers to behave like normal pointers (which is equivalent to measure the offset relative to 0). More...

#include <pointer_repository.hpp>

Public Functions🔗

Name
PointerRepository()
default constructor
bool registerPtr(id_t id, ptr_t ptr, uint64_t size)
registers the start pointer of the segment in another application with a specific id
id_t registerPtr(const ptr_t ptr, uint64_t size =0U)
registers the start pointer of a segment with a specific size
bool unregisterPtr(id_t id)
unregisters the id
void unregisterAll()
unregisters all ids
ptr_t getBasePtr(id_t id) const
gets the base pointer, i.e. the starting address, associated with id
id_t searchId(ptr_t ptr) const
returns the id for a given pointer ptr
bool isValid(id_t id) const
checks if given id is valid
void print() const
prints the ids and their associated base pointers

Public Attributes🔗

Name
constexpr id_t INVALID_ID

Detailed Description🔗

template <typename id_t ,
typename ptr_t ,
uint64_t CAPACITY =10000U>
class iox::rp::PointerRepository;

Allows registration of memory segments with their start pointers and size. This class is used to resolve relative pointers in the corresponding address space of the application. Up to CAPACITY segments can be registered with MIN_ID = 1 to MAX_ID = CAPACITY - 1 id 0 is reserved and allows relative pointers to behave like normal pointers (which is equivalent to measure the offset relative to 0).

Public Functions Documentation🔗

function PointerRepository🔗

inline PointerRepository()

default constructor

function registerPtr🔗

inline bool registerPtr(
    id_t id,
    ptr_t ptr,
    uint64_t size
)

registers the start pointer of the segment in another application with a specific id

Parameters:

  • id identifies the segment
  • ptr is the start pointer of the segment
  • size is the size of the segment

Return: true if the registration was successful, otherwise false

function registerPtr🔗

inline id_t registerPtr(
    const ptr_t ptr,
    uint64_t size =0U
)

registers the start pointer of a segment with a specific size

Parameters:

  • ptr is the start pointer of the segment
  • size is the size of the segment

Return: the id that identifies the segment

function unregisterPtr🔗

inline bool unregisterPtr(
    id_t id
)

unregisters the id

Parameters:

  • id is the id to be unregistered

Return: true if successful, otherwise false

Attention: the relative pointers corresponding to this id become unsafe to use

do not search for next lower registered index but we could do it here

function unregisterAll🔗

inline void unregisterAll()

unregisters all ids

Attention: the relative pointers corresponding to this id become unsafe to use

function getBasePtr🔗

inline ptr_t getBasePtr(
    id_t id
) const

gets the base pointer, i.e. the starting address, associated with id

Parameters:

  • id is the segment id

Return: the base pointer associated with the id

for id 0 nullptr is returned, meaning we will later interpret a relative pointer by casting the offset into a pointer (i.e. we measure relative to 0)

we cannot distinguish between not registered and nullptr registered, but we do not need to

function searchId🔗

inline id_t searchId(
    ptr_t ptr
) const

returns the id for a given pointer ptr

Parameters:

  • ptr is the pointer whose corresponding id is searched for

Return: the id the pointer was registered to

implicitly interpret the pointer as a regular pointer if not found by setting id to 0 rationale: test cases work without registered shared memory and require this at the moment to avoid fundamental changes

function isValid🔗

inline bool isValid(
    id_t id
) const

checks if given id is valid

Parameters:

  • id is the id to be checked

Return: true if id is valid, otherwise false

function print🔗

inline void print() const

prints the ids and their associated base pointers

Public Attributes Documentation🔗

variable INVALID_ID🔗

static constexpr id_t INVALID_ID = std::numeric_limits<id_t>::max();

Updated on 17 June 2021 at 11:15:26 CEST