iox::rp::RelativePointerData🔗
This are the data for a relative pointer. To be able so safely be used in the shared memory and prevent torn writes/reads, the class must not be larger than 64 bits and trivially copy-able.
#include <relative_pointer_data.hpp>
Public Types🔗
Name | |
---|---|
using uint16_t | id_t |
using uint64_t | offset_t |
Public Functions🔗
Name | |
---|---|
constexpr | RelativePointerData() =default Default constructed RelativePointerData which is logically equal to a nullptr. |
constexpr | RelativePointerData(id_t id, offset_t offset) constructs a RelativePointerData from a given offset and segment id |
id_t | id() const Getter for the id which identifies the segment. |
offset_t | offset() const Getter for the offset within the segment. |
void | reset() Resets the pointer to a logically nullptr. |
bool | isLogicalNullptr() const Checks if the pointer is logically a nullptr. |
Public Attributes🔗
Name | |
---|---|
constexpr id_t | ID_RANGE |
constexpr id_t | NULL_POINTER_ID |
constexpr id_t | MAX_VALID_ID |
constexpr offset_t | OFFSET_RANGE id_t is 16 bit and the offset consumes the remaining 48 bits -> offset range is 2^48 - 1 |
constexpr offset_t | NULL_POINTER_OFFSET |
constexpr offset_t | MAX_VALID_OFFSET |
constexpr offset_t | LOGICAL_NULLPTR |
Public Types Documentation🔗
using id_t🔗
using iox::rp::RelativePointerData::id_t = uint16_t;
using offset_t🔗
using iox::rp::RelativePointerData::offset_t = uint64_t;
Public Functions Documentation🔗
function RelativePointerData🔗
constexpr RelativePointerData() =default
Default constructed RelativePointerData which is logically equal to a nullptr.
function RelativePointerData🔗
constexpr RelativePointerData(
id_t id,
offset_t offset
)
constructs a RelativePointerData from a given offset and segment id
Parameters:
- id is the unique id of the segment
- offset is the offset within the segment
function id🔗
id_t id() const
Getter for the id which identifies the segment.
Return: the id which identifies the segment
function offset🔗
offset_t offset() const
Getter for the offset within the segment.
Return: the offset
function reset🔗
void reset()
Resets the pointer to a logically nullptr.
function isLogicalNullptr🔗
bool isLogicalNullptr() const
Checks if the pointer is logically a nullptr.
Return: true if logically a nullptr otherwise false
Public Attributes Documentation🔗
variable ID_RANGE🔗
static constexpr id_t ID_RANGE {std::numeric_limits<id_t>::max()};
Note: the maximum number of available ids
variable NULL_POINTER_ID🔗
static constexpr id_t NULL_POINTER_ID {[ID_RANGE](/v1.0.3/API-reference/utils/Classes/classiox_1_1rp_1_1RelativePointerData/#variable-id_range)};
Note: this represents the id of a logically nullptr
variable MAX_VALID_ID🔗
static constexpr id_t MAX_VALID_ID {[ID_RANGE](/v1.0.3/API-reference/utils/Classes/classiox_1_1rp_1_1RelativePointerData/#variable-id_range) - 1U};
Note: the maximum number of valid ids
variable OFFSET_RANGE🔗
static constexpr offset_t OFFSET_RANGE {(1ULL << 48U) - 1U};
id_t is 16 bit and the offset consumes the remaining 48 bits -> offset range is 2^48 - 1
variable NULL_POINTER_OFFSET🔗
static constexpr offset_t NULL_POINTER_OFFSET {[OFFSET_RANGE](/v1.0.3/API-reference/utils/Classes/classiox_1_1rp_1_1RelativePointerData/#variable-offset_range)};
Note: this represents the offset of a logically nullptr;
variable MAX_VALID_OFFSET🔗
static constexpr offset_t MAX_VALID_OFFSET {[OFFSET_RANGE](/v1.0.3/API-reference/utils/Classes/classiox_1_1rp_1_1RelativePointerData/#variable-offset_range) - 1U};
Note: the maximum offset which can be represented
variable LOGICAL_NULLPTR🔗
static constexpr offset_t LOGICAL_NULLPTR {[NULL_POINTER_OFFSET](/v1.0.3/API-reference/utils/Classes/classiox_1_1rp_1_1RelativePointerData/#variable-null_pointer_offset) << 16 | [NULL_POINTER_ID](/v1.0.3/API-reference/utils/Classes/classiox_1_1rp_1_1RelativePointerData/#variable-null_pointer_id)};
Note: internal representation of a nullptr
Updated on 31 May 2022 at 15:29:15 CEST