Template Class PointerRepository

Nested Relationships

Nested Types

Class Documentation

template<typename id_t, typename ptr_t, uint64_t CAPACITY = 10000U>
class 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

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

Parameters:
  • id[in] identifies the segment

  • ptr[in] is the start pointer of the segment

  • size[in] is the size of the segment

Returns:

true if the registration was successful, otherwise false

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

registers the start pointer of a segment with a specific size

Parameters:
  • ptr[in] is the start pointer of the segment

  • size[in] is the size of the segment

Returns:

the id that identifies the segment

bool unregisterPtr(id_t id) noexcept

unregisters the id

Attention

the relative pointers corresponding to this id become unsafe to use

Parameters:

id[in] is the id to be unregistered

Returns:

true if successful, otherwise false

void unregisterAll() noexcept

unregisters all ids

Attention

the relative pointers corresponding to this id become unsafe to use

ptr_t getBasePtr(id_t id) const noexcept

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

Parameters:

id[in] is the segment id

Returns:

the base pointer associated with the id

id_t searchId(ptr_t ptr) const noexcept

returns the id for a given pointer ptr

Parameters:

ptr[in] is the pointer whose corresponding id is searched for

Returns:

the id the pointer was registered to

bool isValid(id_t id) const noexcept

checks if given id is valid

Parameters:

id[in] is the id to be checked

Returns:

true if id is valid, otherwise false

void print() const noexcept

prints the ids and their associated base pointers

Public Static Attributes

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