Skip to content

Commit

Permalink
final → override (cpp:S1990)[https://sonarcloud.io/organizations/open…
Browse files Browse the repository at this point in the history
  • Loading branch information
serges147 committed May 8, 2024
1 parent 69f5a58 commit a7062bd
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 67 deletions.
6 changes: 3 additions & 3 deletions include/libcyphal/transport/can/delegate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class TransportDelegate
}
CanardMemory(const CanardMemory&) = delete;

~CanardMemory() final
~CanardMemory() override
{
if (buffer_ != nullptr)
{
Expand All @@ -82,14 +82,14 @@ class TransportDelegate

// MARK: ScatteredBuffer::IStorage

CETL_NODISCARD std::size_t size() const noexcept final
CETL_NODISCARD std::size_t size() const noexcept override
{
return payload_size_;
}

CETL_NODISCARD std::size_t copy(const std::size_t offset_bytes,
void* const destination,
const std::size_t length_bytes) const final
const std::size_t length_bytes) const override
{
CETL_DEBUG_ASSERT((destination != nullptr) || (length_bytes == 0),
"Destination could be null only with zero bytes ask.");
Expand Down
12 changes: 6 additions & 6 deletions include/libcyphal/transport/can/msg_rx_session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class MessageRxSession final : public IMessageRxSession, private IRxSessionDeleg
MessageRxSession& operator=(const MessageRxSession&) = delete;
MessageRxSession& operator=(MessageRxSession&&) noexcept = delete;

~MessageRxSession() final
~MessageRxSession() override
{
const int8_t result = ::canardRxUnsubscribe(&delegate_.canard_instance(),
CanardTransferKindMessage,
Expand All @@ -110,12 +110,12 @@ class MessageRxSession final : public IMessageRxSession, private IRxSessionDeleg
private:
// MARK: IMessageRxSession

CETL_NODISCARD MessageRxParams getParams() const noexcept final
CETL_NODISCARD MessageRxParams getParams() const noexcept override
{
return params_;
}

CETL_NODISCARD cetl::optional<MessageRxTransfer> receive() final
CETL_NODISCARD cetl::optional<MessageRxTransfer> receive() override
{
cetl::optional<MessageRxTransfer> result{};
result.swap(last_rx_transfer_);
Expand All @@ -124,7 +124,7 @@ class MessageRxSession final : public IMessageRxSession, private IRxSessionDeleg

// MARK: IRxSession

void setTransferIdTimeout(const Duration timeout) final
void setTransferIdTimeout(const Duration timeout) override
{
const auto timeout_us = std::chrono::duration_cast<std::chrono::microseconds>(timeout);
if (timeout_us.count() > 0)
Expand All @@ -135,14 +135,14 @@ class MessageRxSession final : public IMessageRxSession, private IRxSessionDeleg

// MARK: IRunnable

void run(const TimePoint) final
void run(const TimePoint) override
{
// Nothing to do here currently.
}

// MARK: IRxSessionDelegate

void acceptRxTransfer(const CanardRxTransfer& transfer) final
void acceptRxTransfer(const CanardRxTransfer& transfer) override
{
const auto priority = static_cast<Priority>(transfer.metadata.priority);
const auto transfer_id = static_cast<TransferId>(transfer.metadata.transfer_id);
Expand Down
8 changes: 4 additions & 4 deletions include/libcyphal/transport/can/msg_tx_session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ class MessageTxSession final : public IMessageTxSession
private:
// MARK: ITxSession

void setSendTimeout(const Duration timeout) final
void setSendTimeout(const Duration timeout) override
{
send_timeout_ = timeout;
}

// MARK: IMessageTxSession

CETL_NODISCARD MessageTxParams getParams() const noexcept final
CETL_NODISCARD MessageTxParams getParams() const noexcept override
{
return params_;
}

CETL_NODISCARD cetl::optional<AnyError> send(const TransferMetadata& metadata,
const PayloadFragments payload_fragments) final
const PayloadFragments payload_fragments) override
{
const auto canard_metadata = CanardTransferMetadata{static_cast<CanardPriority>(metadata.priority),
CanardTransferKindMessage,
Expand All @@ -98,7 +98,7 @@ class MessageTxSession final : public IMessageTxSession

// MARK: IRunnable

void run(const TimePoint) final
void run(const TimePoint) override
{
// Nothing to do here currently.
}
Expand Down
12 changes: 6 additions & 6 deletions include/libcyphal/transport/can/svc_rx_sessions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class SvcRxSession final : public Interface_, private IRxSessionDelegate
SvcRxSession& operator=(const SvcRxSession&) = delete;
SvcRxSession& operator=(SvcRxSession&&) noexcept = delete;

~SvcRxSession() final
~SvcRxSession() override
{
const int8_t result = ::canardRxUnsubscribe(&delegate_.canard_instance(),
TransferKind,
Expand All @@ -118,12 +118,12 @@ class SvcRxSession final : public Interface_, private IRxSessionDelegate
private:
// MARK: Interface

CETL_NODISCARD Params getParams() const noexcept final
CETL_NODISCARD Params getParams() const noexcept override
{
return params_;
}

CETL_NODISCARD cetl::optional<ServiceRxTransfer> receive() final
CETL_NODISCARD cetl::optional<ServiceRxTransfer> receive() override
{
cetl::optional<ServiceRxTransfer> result{};
result.swap(last_rx_transfer_);
Expand All @@ -132,7 +132,7 @@ class SvcRxSession final : public Interface_, private IRxSessionDelegate

// MARK: IRxSession

void setTransferIdTimeout(const Duration timeout) final
void setTransferIdTimeout(const Duration timeout) override
{
const auto timeout_us = std::chrono::duration_cast<std::chrono::microseconds>(timeout);
if (timeout_us.count() > 0)
Expand All @@ -143,14 +143,14 @@ class SvcRxSession final : public Interface_, private IRxSessionDelegate

// MARK: IRunnable

void run(const TimePoint) final
void run(const TimePoint) override
{
// Nothing to do here currently.
}

// MARK: IRxSessionDelegate

void acceptRxTransfer(const CanardRxTransfer& transfer) final
void acceptRxTransfer(const CanardRxTransfer& transfer) override
{
const auto priority = static_cast<Priority>(transfer.metadata.priority);
const auto remote_node_id = static_cast<NodeId>(transfer.metadata.remote_node_id);
Expand Down
16 changes: 8 additions & 8 deletions include/libcyphal/transport/can/svc_tx_sessions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@ class SvcRequestTxSession final : public IRequestTxSession
private:
// MARK: ITxSession

void setSendTimeout(const Duration timeout) final
void setSendTimeout(const Duration timeout) override
{
send_timeout_ = timeout;
}

// MARK: IRequestTxSession

CETL_NODISCARD RequestTxParams getParams() const noexcept final
CETL_NODISCARD RequestTxParams getParams() const noexcept override
{
return params_;
}

CETL_NODISCARD cetl::optional<AnyError> send(const TransferMetadata& metadata,
const PayloadFragments payload_fragments) final
const PayloadFragments payload_fragments) override
{
// Before delegating to transport it makes sense to do some sanity checks.
// Otherwise, transport may do some work (like possible payload allocation/copying,
Expand All @@ -110,7 +110,7 @@ class SvcRequestTxSession final : public IRequestTxSession

// MARK: IRunnable

void run(const TimePoint) final
void run(const TimePoint) override
{
// Nothing to do here currently.
}
Expand Down Expand Up @@ -169,20 +169,20 @@ class SvcResponseTxSession final : public IResponseTxSession
private:
// MARK: ITxSession

void setSendTimeout(const Duration timeout) final
void setSendTimeout(const Duration timeout) override
{
send_timeout_ = timeout;
}

// MARK: IResponseTxSession

CETL_NODISCARD ResponseTxParams getParams() const noexcept final
CETL_NODISCARD ResponseTxParams getParams() const noexcept override
{
return params_;
}

CETL_NODISCARD cetl::optional<AnyError> send(const ServiceTransferMetadata& metadata,
const PayloadFragments payload_fragments) final
const PayloadFragments payload_fragments) override
{
// Before delegating to transport it makes sense to do some sanity checks.
// Otherwise, transport may do some work (like possible payload allocation/copying,
Expand All @@ -205,7 +205,7 @@ class SvcResponseTxSession final : public IResponseTxSession

// MARK: IRunnable

void run(const TimePoint) final
void run(const TimePoint) override
{
// Nothing to do here currently.
}
Expand Down
24 changes: 12 additions & 12 deletions include/libcyphal/transport/can/transport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class TransportImpl final : public ICanTransport, private TransportDelegate
TransportImpl& operator=(const TransportImpl&) = delete;
TransportImpl& operator=(TransportImpl&&) noexcept = delete;

~TransportImpl() final
~TransportImpl() override
{
for (Media& media : media_array_)
{
Expand All @@ -181,7 +181,7 @@ class TransportImpl final : public ICanTransport, private TransportDelegate
private:
// MARK: ITransport

CETL_NODISCARD cetl::optional<NodeId> getLocalNodeId() const noexcept final
CETL_NODISCARD cetl::optional<NodeId> getLocalNodeId() const noexcept override
{
if (canard_instance().node_id > CANARD_NODE_ID_MAX)
{
Expand All @@ -191,7 +191,7 @@ class TransportImpl final : public ICanTransport, private TransportDelegate
return cetl::make_optional(static_cast<NodeId>(canard_instance().node_id));
}

CETL_NODISCARD cetl::optional<ArgumentError> setLocalNodeId(const NodeId node_id) noexcept final
CETL_NODISCARD cetl::optional<ArgumentError> setLocalNodeId(const NodeId node_id) noexcept override
{
if (node_id > CANARD_NODE_ID_MAX)
{
Expand Down Expand Up @@ -239,7 +239,7 @@ class TransportImpl final : public ICanTransport, private TransportDelegate
}

CETL_NODISCARD Expected<UniquePtr<IMessageRxSession>, AnyError> makeMessageRxSession(
const MessageRxParams& params) final
const MessageRxParams& params) override
{
const cetl::optional<AnyError> any_error = ensureNewSessionFor(CanardTransferKindMessage, params.subject_id);
if (any_error.has_value())
Expand All @@ -251,13 +251,13 @@ class TransportImpl final : public ICanTransport, private TransportDelegate
}

CETL_NODISCARD Expected<UniquePtr<IMessageTxSession>, AnyError> makeMessageTxSession(
const MessageTxParams& params) final
const MessageTxParams& params) override
{
return MessageTxSession::make(asDelegate(), params);
}

CETL_NODISCARD Expected<UniquePtr<IRequestRxSession>, AnyError> makeRequestRxSession(
const RequestRxParams& params) final
const RequestRxParams& params) override
{
const cetl::optional<AnyError> any_error = ensureNewSessionFor(CanardTransferKindRequest, params.service_id);
if (any_error.has_value())
Expand All @@ -269,13 +269,13 @@ class TransportImpl final : public ICanTransport, private TransportDelegate
}

CETL_NODISCARD Expected<UniquePtr<IRequestTxSession>, AnyError> makeRequestTxSession(
const RequestTxParams& params) final
const RequestTxParams& params) override
{
return SvcRequestTxSession::make(asDelegate(), params);
}

CETL_NODISCARD Expected<UniquePtr<IResponseRxSession>, AnyError> makeResponseRxSession(
const ResponseRxParams& params) final
const ResponseRxParams& params) override
{
const cetl::optional<AnyError> any_error = ensureNewSessionFor(CanardTransferKindResponse, params.service_id);
if (any_error.has_value())
Expand All @@ -287,14 +287,14 @@ class TransportImpl final : public ICanTransport, private TransportDelegate
}

CETL_NODISCARD Expected<UniquePtr<IResponseTxSession>, AnyError> makeResponseTxSession(
const ResponseTxParams& params) final
const ResponseTxParams& params) override
{
return SvcResponseTxSession::make(asDelegate(), params);
}

// MARK: IRunnable

void run(const TimePoint now) final
void run(const TimePoint now) override
{
runMediaTransmit(now);
runMediaReceive();
Expand All @@ -310,7 +310,7 @@ class TransportImpl final : public ICanTransport, private TransportDelegate

CETL_NODISCARD cetl::optional<AnyError> sendTransfer(const TimePoint deadline,
const CanardTransferMetadata& metadata,
const PayloadFragments payload_fragments) final
const PayloadFragments payload_fragments) override
{
// libcanard currently does not support fragmented payloads (at `canardTxPush`).
// so we need to concatenate them when there are more than one non-empty fragment.
Expand Down Expand Up @@ -348,7 +348,7 @@ class TransportImpl final : public ICanTransport, private TransportDelegate
return maybe_error;
}

void triggerUpdateOfFilters(const FiltersUpdateCondition condition) noexcept final
void triggerUpdateOfFilters(const FiltersUpdateCondition condition) noexcept override
{
switch (condition)
{
Expand Down
24 changes: 14 additions & 10 deletions include/libcyphal/transport/udp/transport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ class TransportImpl final : public IUdpTransport
private:
// MARK: ITransport

CETL_NODISCARD cetl::optional<NodeId> getLocalNodeId() const noexcept final
CETL_NODISCARD cetl::optional<NodeId> getLocalNodeId() const noexcept override
{
return cetl::nullopt;
}

CETL_NODISCARD cetl::optional<ArgumentError> setLocalNodeId(const NodeId node_id) noexcept final
CETL_NODISCARD cetl::optional<ArgumentError> setLocalNodeId(const NodeId node_id) noexcept override
{
if (node_id > UDPARD_NODE_ID_MAX)
{
Expand All @@ -85,41 +85,45 @@ class TransportImpl final : public IUdpTransport
return ArgumentError{};
}

CETL_NODISCARD ProtocolParams getProtocolParams() const noexcept final
CETL_NODISCARD ProtocolParams getProtocolParams() const noexcept override
{
return ProtocolParams{};
}

CETL_NODISCARD Expected<UniquePtr<IMessageRxSession>, AnyError> makeMessageRxSession(const MessageRxParams&) final
CETL_NODISCARD Expected<UniquePtr<IMessageRxSession>, AnyError> makeMessageRxSession(
const MessageRxParams&) override
{
return NotImplementedError{};
}
CETL_NODISCARD Expected<UniquePtr<IMessageTxSession>, AnyError> makeMessageTxSession(const MessageTxParams&) final
CETL_NODISCARD Expected<UniquePtr<IMessageTxSession>, AnyError> makeMessageTxSession(
const MessageTxParams&) override
{
return NotImplementedError{};
}
CETL_NODISCARD Expected<UniquePtr<IRequestRxSession>, AnyError> makeRequestRxSession(const RequestRxParams&) final
CETL_NODISCARD Expected<UniquePtr<IRequestRxSession>, AnyError> makeRequestRxSession(
const RequestRxParams&) override
{
return NotImplementedError{};
}
CETL_NODISCARD Expected<UniquePtr<IRequestTxSession>, AnyError> makeRequestTxSession(const RequestTxParams&) final
CETL_NODISCARD Expected<UniquePtr<IRequestTxSession>, AnyError> makeRequestTxSession(
const RequestTxParams&) override
{
return NotImplementedError{};
}
CETL_NODISCARD Expected<UniquePtr<IResponseRxSession>, AnyError> makeResponseRxSession(
const ResponseRxParams&) final
const ResponseRxParams&) override
{
return NotImplementedError{};
}
CETL_NODISCARD Expected<UniquePtr<IResponseTxSession>, AnyError> makeResponseTxSession(
const ResponseTxParams&) final
const ResponseTxParams&) override
{
return NotImplementedError{};
}

// MARK: IRunnable

void run(const TimePoint) final {}
void run(const TimePoint) override {}

}; // TransportImpl

Expand Down
Loading

0 comments on commit a7062bd

Please sign in to comment.