iceoryx_doc  1.0.1
Classes | Public Member Functions | Static Public Attributes | List of all members
iox::rp::PointerRepository< id_t, ptr_t, CAPACITY > Class Template Reference

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 Member Functions

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

Static Public Attributes

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

Detailed Description

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

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).

Member Function Documentation

◆ getBasePtr()

template<typename id_t , typename ptr_t , uint64_t CAPACITY>
ptr_t iox::rp::PointerRepository< id_t, ptr_t, CAPACITY >::getBasePtr ( id_t  id) const
inlinenoexcept

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

Parameters
[in]idis the segment id
Returns
the base pointer associated with the id
Note
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

◆ isValid()

template<typename id_t , typename ptr_t , uint64_t CAPACITY>
bool iox::rp::PointerRepository< id_t, ptr_t, CAPACITY >::isValid ( id_t  id) const
inlinenoexcept

checks if given id is valid

Parameters
[in]idis the id to be checked
Returns
true if id is valid, otherwise false

◆ registerPtr() [1/2]

template<typename id_t , typename ptr_t , uint64_t CAPACITY>
id_t iox::rp::PointerRepository< id_t, ptr_t, CAPACITY >::registerPtr ( const ptr_t  ptr,
uint64_t  size = 0U 
)
inlinenoexcept

registers the start pointer of a segment with a specific size

Parameters
[in]ptris the start pointer of the segment
[in]sizeis the size of the segment
Returns
the id that identifies the segment

◆ registerPtr() [2/2]

template<typename id_t , typename ptr_t , uint64_t CAPACITY>
bool iox::rp::PointerRepository< id_t, ptr_t, CAPACITY >::registerPtr ( id_t  id,
ptr_t  ptr,
uint64_t  size 
)
inlinenoexcept

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

Parameters
[in]ididentifies the segment
[in]ptris the start pointer of the segment
[in]sizeis the size of the segment
Returns
true if the registration was successful, otherwise false

◆ searchId()

template<typename id_t , typename ptr_t , uint64_t CAPACITY>
id_t iox::rp::PointerRepository< id_t, ptr_t, CAPACITY >::searchId ( ptr_t  ptr) const
inlinenoexcept

returns the id for a given pointer ptr

Parameters
[in]ptris the pointer whose corresponding id is searched for
Returns
the id the pointer was registered to
Note
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

◆ unregisterAll()

template<typename id_t , typename ptr_t , uint64_t CAPACITY>
void iox::rp::PointerRepository< id_t, ptr_t, CAPACITY >::unregisterAll
inlinenoexcept

unregisters all ids

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

◆ unregisterPtr()

template<typename id_t , typename ptr_t , uint64_t CAPACITY>
bool iox::rp::PointerRepository< id_t, ptr_t, CAPACITY >::unregisterPtr ( id_t  id)
inlinenoexcept

unregisters the id

Parameters
[in]idis the id to be unregistered
Returns
true if successful, otherwise false
Attention
the relative pointers corresponding to this id become unsafe to use
Note
do not search for next lower registered index but we could do it here

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