Skip to content

Commit

Permalink
[#500] Make bytes() method const
Browse files Browse the repository at this point in the history
  • Loading branch information
orecham committed Nov 18, 2024
1 parent 2b22f5e commit 30f7d25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions iceoryx2-ffi/cxx/include/iox2/unique_port_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class UniquePublisherId {
auto operator=(UniquePublisherId&& rhs) noexcept -> UniquePublisherId&;
~UniquePublisherId();

auto bytes() -> const iox::optional<RawIdType>&;
auto bytes() const -> const iox::optional<RawIdType>&;

private:
template <ServiceType, typename, typename>
Expand All @@ -44,7 +44,7 @@ class UniquePublisherId {
void drop();

iox2_unique_publisher_id_h m_handle = nullptr;
iox::optional<RawIdType> m_raw_id;
mutable iox::optional<RawIdType> m_raw_id;
};

/// The system-wide unique id of a [`Subscriber`].
Expand All @@ -56,7 +56,7 @@ class UniqueSubscriberId {
auto operator=(UniqueSubscriberId&& rhs) noexcept -> UniqueSubscriberId&;
~UniqueSubscriberId();

auto bytes() -> const iox::optional<RawIdType>&;
auto bytes() const -> const iox::optional<RawIdType>&;

private:
template <ServiceType, typename, typename>
Expand All @@ -68,7 +68,7 @@ class UniqueSubscriberId {
void drop();

iox2_unique_subscriber_id_h m_handle = nullptr;
iox::optional<RawIdType> m_raw_id;
mutable iox::optional<RawIdType> m_raw_id;
};

/// The system-wide unique id of a [`Notifier`].
Expand All @@ -80,7 +80,7 @@ class UniqueNotifierId {
auto operator=(UniqueNotifierId&& rhs) noexcept -> UniqueNotifierId&;
~UniqueNotifierId();

auto bytes() -> const iox::optional<RawIdType>&;
auto bytes() const -> const iox::optional<RawIdType>&;

private:
template <ServiceType>
Expand All @@ -92,7 +92,7 @@ class UniqueNotifierId {
void drop();

iox2_unique_notifier_id_h m_handle = nullptr;
iox::optional<RawIdType> m_raw_id;
mutable iox::optional<RawIdType> m_raw_id;
};

/// The system-wide unique id of a [`Listener`].
Expand All @@ -104,7 +104,7 @@ class UniqueListenerId {
auto operator=(UniqueListenerId&& rhs) noexcept -> UniqueListenerId&;
~UniqueListenerId();

auto bytes() -> const iox::optional<RawIdType>&;
auto bytes() const -> const iox::optional<RawIdType>&;

private:
template <ServiceType>
Expand All @@ -116,7 +116,7 @@ class UniqueListenerId {
void drop();

iox2_unique_listener_id_h m_handle = nullptr;
iox::optional<RawIdType> m_raw_id;
mutable iox::optional<RawIdType> m_raw_id;
};

auto operator==(const UniquePublisherId& lhs, const UniquePublisherId& rhs) -> bool;
Expand Down
8 changes: 4 additions & 4 deletions iceoryx2-ffi/cxx/src/unique_port_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ UniquePublisherId::UniquePublisherId(iox2_unique_publisher_id_h handle)
: m_handle { handle } {
}

auto UniquePublisherId::bytes() -> const iox::optional<RawIdType>& {
auto UniquePublisherId::bytes() const -> const iox::optional<RawIdType>& {
if (!m_raw_id.has_value() && m_handle != nullptr) {
RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 };
iox2_unique_publisher_id_value(m_handle, bytes.data(), bytes.size());
Expand Down Expand Up @@ -90,7 +90,7 @@ UniqueSubscriberId::UniqueSubscriberId(iox2_unique_subscriber_id_h handle)
: m_handle { handle } {
}

auto UniqueSubscriberId::bytes() -> const iox::optional<RawIdType>& {
auto UniqueSubscriberId::bytes() const -> const iox::optional<RawIdType>& {
if (!m_raw_id.has_value() && m_handle != nullptr) {
RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 };
iox2_unique_subscriber_id_value(m_handle, bytes.data(), bytes.size());
Expand Down Expand Up @@ -136,7 +136,7 @@ UniqueNotifierId::UniqueNotifierId(iox2_unique_notifier_id_h handle)
: m_handle { handle } {
}

auto UniqueNotifierId::bytes() -> const iox::optional<RawIdType>& {
auto UniqueNotifierId::bytes() const -> const iox::optional<RawIdType>& {
if (!m_raw_id.has_value() && m_handle != nullptr) {
RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 };
iox2_unique_notifier_id_value(m_handle, bytes.data(), bytes.size());
Expand Down Expand Up @@ -182,7 +182,7 @@ UniqueListenerId::UniqueListenerId(iox2_unique_listener_id_h handle)
: m_handle { handle } {
}

auto UniqueListenerId::bytes() -> const iox::optional<RawIdType>& {
auto UniqueListenerId::bytes() const -> const iox::optional<RawIdType>& {
if (!m_raw_id.has_value() && m_handle != nullptr) {
RawIdType bytes { UNIQUE_PORT_ID_LENGTH, 0 };
iox2_unique_listener_id_value(m_handle, bytes.data(), bytes.size());
Expand Down

0 comments on commit 30f7d25

Please sign in to comment.