Skip to content

Commit

Permalink
[#264] Add documentation and fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
elfenpiff committed Dec 19, 2024
1 parent 6468504 commit 0190c25
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 70 deletions.
113 changes: 65 additions & 48 deletions iceoryx2-ffi/cxx/include/iox2/enum_translation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ constexpr auto from<int, iox2::SemanticStringError>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::SemanticStringError, iox2_semantic_string_error_e>(
const iox2::SemanticStringError value) noexcept -> iox2_semantic_string_error_e {
constexpr auto
from<iox2::SemanticStringError, iox2_semantic_string_error_e>(const iox2::SemanticStringError value) noexcept
-> iox2_semantic_string_error_e {
switch (value) {
case iox2::SemanticStringError::InvalidContent:
return iox2_semantic_string_error_e_INVALID_CONTENT;
Expand Down Expand Up @@ -85,8 +86,8 @@ constexpr auto from<int, iox2::ServiceType>(const int value) noexcept -> iox2::S
}

template <>
constexpr auto
from<iox2::ServiceType, iox2_service_type_e>(const iox2::ServiceType value) noexcept -> iox2_service_type_e {
constexpr auto from<iox2::ServiceType, iox2_service_type_e>(const iox2::ServiceType value) noexcept
-> iox2_service_type_e {
switch (value) {
case iox2::ServiceType::Ipc:
return iox2_service_type_e_IPC;
Expand All @@ -111,8 +112,9 @@ constexpr auto from<int, iox2::NodeCreationFailure>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::NodeCreationFailure, iox2_node_creation_failure_e>(
const iox2::NodeCreationFailure value) noexcept -> iox2_node_creation_failure_e {
constexpr auto
from<iox2::NodeCreationFailure, iox2_node_creation_failure_e>(const iox2::NodeCreationFailure value) noexcept
-> iox2_node_creation_failure_e {
switch (value) {
case iox2::NodeCreationFailure::InsufficientPermissions:
return iox2_node_creation_failure_e_INSUFFICIENT_PERMISSIONS;
Expand Down Expand Up @@ -143,8 +145,9 @@ constexpr auto from<int, iox2::CallbackProgression>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::CallbackProgression, iox2_callback_progression_e>(
const iox2::CallbackProgression value) noexcept -> iox2_callback_progression_e {
constexpr auto
from<iox2::CallbackProgression, iox2_callback_progression_e>(const iox2::CallbackProgression value) noexcept
-> iox2_callback_progression_e {
switch (value) {
case iox2::CallbackProgression::Continue:
return iox2_callback_progression_e_CONTINUE;
Expand Down Expand Up @@ -258,8 +261,9 @@ constexpr auto from<int, iox2::ServiceDetailsError>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::ServiceDetailsError, iox2_service_details_error_e>(
const iox2::ServiceDetailsError value) noexcept -> iox2_service_details_error_e {
constexpr auto
from<iox2::ServiceDetailsError, iox2_service_details_error_e>(const iox2::ServiceDetailsError value) noexcept
-> iox2_service_details_error_e {
switch (value) {
case iox2::ServiceDetailsError::FailedToOpenStaticServiceInfo:
return iox2_service_details_error_e_FAILED_TO_OPEN_STATIC_SERVICE_INFO;
Expand Down Expand Up @@ -337,8 +341,9 @@ constexpr auto from<int, iox2::EventOpenOrCreateError>(const int value) noexcept
}

template <>
constexpr auto from<iox2::EventOpenOrCreateError, iox2_event_open_or_create_error_e>(
const iox2::EventOpenOrCreateError value) noexcept -> iox2_event_open_or_create_error_e {
constexpr auto
from<iox2::EventOpenOrCreateError, iox2_event_open_or_create_error_e>(const iox2::EventOpenOrCreateError value) noexcept
-> iox2_event_open_or_create_error_e {
switch (value) {
case iox2::EventOpenOrCreateError::OpenDoesNotExist:
return iox2_event_open_or_create_error_e_O_DOES_NOT_EXIST;
Expand Down Expand Up @@ -489,8 +494,9 @@ constexpr auto from<int, iox2::EventCreateError>(const int value) noexcept -> io
}

template <>
constexpr auto from<iox2::EventCreateError, iox2_event_open_or_create_error_e>(
const iox2::EventCreateError value) noexcept -> iox2_event_open_or_create_error_e {
constexpr auto
from<iox2::EventCreateError, iox2_event_open_or_create_error_e>(const iox2::EventCreateError value) noexcept
-> iox2_event_open_or_create_error_e {
switch (value) {
case iox2::EventCreateError::InsufficientPermissions:
return iox2_event_open_or_create_error_e_C_INSUFFICIENT_PERMISSIONS;
Expand Down Expand Up @@ -664,15 +670,14 @@ constexpr auto from<iox2::PublishSubscribeOpenError, iox2_pub_sub_open_or_create
}

template <>
inline auto
from<iox2::PublishSubscribeOpenError, const char*>(const iox2::PublishSubscribeOpenError value) noexcept -> const
char* {
inline auto from<iox2::PublishSubscribeOpenError, const char*>(const iox2::PublishSubscribeOpenError value) noexcept
-> const char* {
return iox2_pub_sub_open_or_create_error_string(iox::into<iox2_pub_sub_open_or_create_error_e>(value));
}

template <>
constexpr auto
from<int, iox2::PublishSubscribeCreateError>(const int value) noexcept -> iox2::PublishSubscribeCreateError {
constexpr auto from<int, iox2::PublishSubscribeCreateError>(const int value) noexcept
-> iox2::PublishSubscribeCreateError {
const auto error = static_cast<iox2_pub_sub_open_or_create_error_e>(value);
switch (error) {
case iox2_pub_sub_open_or_create_error_e_C_SERVICE_IN_CORRUPTED_STATE:
Expand Down Expand Up @@ -718,9 +723,8 @@ constexpr auto from<iox2::PublishSubscribeCreateError, iox2_pub_sub_open_or_crea
}

template <>
inline auto
from<iox2::PublishSubscribeCreateError, const char*>(const iox2::PublishSubscribeCreateError value) noexcept -> const
char* {
inline auto from<iox2::PublishSubscribeCreateError, const char*>(const iox2::PublishSubscribeCreateError value) noexcept
-> const char* {
return iox2_pub_sub_open_or_create_error_string(iox::into<iox2_pub_sub_open_or_create_error_e>(value));
}

Expand Down Expand Up @@ -784,8 +788,9 @@ constexpr auto from<iox2::PublishSubscribeOpenOrCreateError, iox2_pub_sub_open_o
}

template <>
inline auto from<iox2::PublishSubscribeOpenOrCreateError, const char*>(
const iox2::PublishSubscribeOpenOrCreateError value) noexcept -> const char* {
inline auto
from<iox2::PublishSubscribeOpenOrCreateError, const char*>(const iox2::PublishSubscribeOpenOrCreateError value) noexcept
-> const char* {
return iox2_pub_sub_open_or_create_error_string(iox::into<iox2_pub_sub_open_or_create_error_e>(value));
}

Expand All @@ -801,8 +806,9 @@ constexpr auto from<int, iox2::NotifierCreateError>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::NotifierCreateError, iox2_notifier_create_error_e>(
const iox2::NotifierCreateError value) noexcept -> iox2_notifier_create_error_e {
constexpr auto
from<iox2::NotifierCreateError, iox2_notifier_create_error_e>(const iox2::NotifierCreateError value) noexcept
-> iox2_notifier_create_error_e {
switch (value) {
case iox2::NotifierCreateError::ExceedsMaxSupportedNotifiers:
return iox2_notifier_create_error_e_EXCEEDS_MAX_SUPPORTED_NOTIFIERS;
Expand Down Expand Up @@ -831,8 +837,9 @@ constexpr auto from<int, iox2::ListenerCreateError>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::ListenerCreateError, iox2_listener_create_error_e>(
const iox2::ListenerCreateError value) noexcept -> iox2_listener_create_error_e {
constexpr auto
from<iox2::ListenerCreateError, iox2_listener_create_error_e>(const iox2::ListenerCreateError value) noexcept
-> iox2_listener_create_error_e {
switch (value) {
case iox2::ListenerCreateError::ExceedsMaxSupportedListeners:
return iox2_listener_create_error_e_EXCEEDS_MAX_SUPPORTED_LISTENERS;
Expand Down Expand Up @@ -861,8 +868,9 @@ constexpr auto from<int, iox2::NotifierNotifyError>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::NotifierNotifyError, iox2_notifier_notify_error_e>(
const iox2::NotifierNotifyError value) noexcept -> iox2_notifier_notify_error_e {
constexpr auto
from<iox2::NotifierNotifyError, iox2_notifier_notify_error_e>(const iox2::NotifierNotifyError value) noexcept
-> iox2_notifier_notify_error_e {
switch (value) {
case iox2::NotifierNotifyError::EventIdOutOfBounds:
return iox2_notifier_notify_error_e_EVENT_ID_OUT_OF_BOUNDS;
Expand Down Expand Up @@ -926,8 +934,9 @@ constexpr auto from<int, iox2::PublisherCreateError>(const int value) noexcept -
}

template <>
constexpr auto from<iox2::PublisherCreateError, iox2_publisher_create_error_e>(
const iox2::PublisherCreateError value) noexcept -> iox2_publisher_create_error_e {
constexpr auto
from<iox2::PublisherCreateError, iox2_publisher_create_error_e>(const iox2::PublisherCreateError value) noexcept
-> iox2_publisher_create_error_e {
switch (value) {
case iox2::PublisherCreateError::ExceedsMaxSupportedPublishers:
return iox2_publisher_create_error_e_EXCEEDS_MAX_SUPPORTED_PUBLISHERS;
Expand Down Expand Up @@ -958,8 +967,9 @@ constexpr auto from<int, iox2::SubscriberCreateError>(const int value) noexcept
}

template <>
constexpr auto from<iox2::SubscriberCreateError, iox2_subscriber_create_error_e>(
const iox2::SubscriberCreateError value) noexcept -> iox2_subscriber_create_error_e {
constexpr auto
from<iox2::SubscriberCreateError, iox2_subscriber_create_error_e>(const iox2::SubscriberCreateError value) noexcept
-> iox2_subscriber_create_error_e {
switch (value) {
case iox2::SubscriberCreateError::BufferSizeExceedsMaxSupportedBufferSizeOfService:
return iox2_subscriber_create_error_e_BUFFER_SIZE_EXCEEDS_MAX_SUPPORTED_BUFFER_SIZE_OF_SERVICE;
Expand Down Expand Up @@ -1000,8 +1010,9 @@ constexpr auto from<int, iox2::PublisherSendError>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::PublisherSendError, iox2_publisher_send_error_e>(
const iox2::PublisherSendError value) noexcept -> iox2_publisher_send_error_e {
constexpr auto
from<iox2::PublisherSendError, iox2_publisher_send_error_e>(const iox2::PublisherSendError value) noexcept
-> iox2_publisher_send_error_e {
switch (value) {
case iox2::PublisherSendError::ConnectionBrokenSincePublisherNoLongerExists:
return iox2_publisher_send_error_e_CONNECTION_BROKEN_SINCE_PUBLISHER_NO_LONGER_EXISTS;
Expand Down Expand Up @@ -1043,8 +1054,9 @@ constexpr auto from<int, iox2::SubscriberReceiveError>(const int value) noexcept
}

template <>
constexpr auto from<iox2::SubscriberReceiveError, iox2_subscriber_receive_error_e>(
const iox2::SubscriberReceiveError value) noexcept -> iox2_subscriber_receive_error_e {
constexpr auto
from<iox2::SubscriberReceiveError, iox2_subscriber_receive_error_e>(const iox2::SubscriberReceiveError value) noexcept
-> iox2_subscriber_receive_error_e {
switch (value) {
case iox2::SubscriberReceiveError::FailedToEstablishConnection:
return iox2_subscriber_receive_error_e_FAILED_TO_ESTABLISH_CONNECTION;
Expand Down Expand Up @@ -1081,8 +1093,9 @@ constexpr auto from<int, iox2::PublisherLoanError>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::PublisherLoanError, iox2_publisher_loan_error_e>(
const iox2::PublisherLoanError value) noexcept -> iox2_publisher_loan_error_e {
constexpr auto
from<iox2::PublisherLoanError, iox2_publisher_loan_error_e>(const iox2::PublisherLoanError value) noexcept
-> iox2_publisher_loan_error_e {
switch (value) {
case iox2::PublisherLoanError::ExceedsMaxLoanedSamples:
return iox2_publisher_loan_error_e_EXCEEDS_MAX_LOANED_SAMPLES;
Expand Down Expand Up @@ -1234,8 +1247,9 @@ constexpr auto from<int, iox2::ConfigCreationError>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::ConfigCreationError, iox2_config_creation_error_e>(
const iox2::ConfigCreationError value) noexcept -> iox2_config_creation_error_e {
constexpr auto
from<iox2::ConfigCreationError, iox2_config_creation_error_e>(const iox2::ConfigCreationError value) noexcept
-> iox2_config_creation_error_e {
switch (value) {
case iox2::ConfigCreationError::FailedToOpenConfigFile:
return iox2_config_creation_error_e_FAILED_TO_OPEN_CONFIG_FILE;
Expand Down Expand Up @@ -1306,8 +1320,9 @@ constexpr auto from<int, iox2::WaitSetCreateError>(const int value) noexcept ->
}

template <>
constexpr auto from<iox2::WaitSetCreateError, iox2_waitset_create_error_e>(
const iox2::WaitSetCreateError value) noexcept -> iox2_waitset_create_error_e {
constexpr auto
from<iox2::WaitSetCreateError, iox2_waitset_create_error_e>(const iox2::WaitSetCreateError value) noexcept
-> iox2_waitset_create_error_e {
switch (value) {
case iox2::WaitSetCreateError::InternalError:
return iox2_waitset_create_error_e_INTERNAL_ERROR;
Expand Down Expand Up @@ -1371,8 +1386,9 @@ constexpr auto from<int, iox2::WaitSetAttachmentError>(const int value) noexcept
}

template <>
constexpr auto from<iox2::WaitSetAttachmentError, iox2_waitset_attachment_error_e>(
const iox2::WaitSetAttachmentError value) noexcept -> iox2_waitset_attachment_error_e {
constexpr auto
from<iox2::WaitSetAttachmentError, iox2_waitset_attachment_error_e>(const iox2::WaitSetAttachmentError value) noexcept
-> iox2_waitset_attachment_error_e {
switch (value) {
case iox2::WaitSetAttachmentError::AlreadyAttached:
return iox2_waitset_attachment_error_e_ALREADY_ATTACHED;
Expand Down Expand Up @@ -1435,8 +1451,9 @@ inline auto from<iox2::WaitSetRunError, const char*>(const iox2::WaitSetRunError
}

template <>
constexpr auto from<iox2::SignalHandlingMode, iox2_signal_handling_mode_e>(
const iox2::SignalHandlingMode value) noexcept -> iox2_signal_handling_mode_e {
constexpr auto
from<iox2::SignalHandlingMode, iox2_signal_handling_mode_e>(const iox2::SignalHandlingMode value) noexcept
-> iox2_signal_handling_mode_e {
switch (value) {
case iox2::SignalHandlingMode::Disabled:
return iox2_signal_handling_mode_e_DISABLED;
Expand Down
2 changes: 2 additions & 0 deletions iceoryx2-ffi/cxx/include/iox2/node_failure_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ enum class NodeCreationFailure : uint8_t {
InternalError
};

/// Failures of [`DeadNodeView::remove_stale_resources()`] that occur when the stale resources of
/// a dead [`Node`] are removed.
enum class NodeCleanupFailure : uint8_t {
/// The process received an interrupt signal while cleaning up all stale resources of a dead [`Node`].
Interrupt,
Expand Down
14 changes: 6 additions & 8 deletions iceoryx2-ffi/cxx/include/iox2/node_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <iostream>

namespace iox2 {
/// The system-wide unique id of a [`Node`]
class NodeId {
public:
NodeId(const NodeId& rhs);
Expand All @@ -29,10 +30,10 @@ class NodeId {
auto operator=(NodeId&& rhs) noexcept -> NodeId&;
~NodeId();

/// Returns high bits of the underlying value of the [`NodeId`].
/// Returns the high bits of the underlying value of the [`NodeId`].
auto value_high() const -> uint64_t;

/// Returns low bits of the underlying value of the [`NodeId`].
/// Returns the low bits of the underlying value of the [`NodeId`].
auto value_low() const -> uint64_t;

/// Returns the [`ProcessId`] of the process that owns the [`Node`].
Expand All @@ -47,12 +48,9 @@ class NodeId {
template <ServiceType>
friend class DeadNodeView;
template <ServiceType>
friend auto list_callback(iox2_node_state_e,
iox2_node_id_ptr,
const char*,
iox2_node_name_ptr,
iox2_config_ptr,
iox2_callback_context) -> iox2_callback_progression_e;
friend auto list_callback(
iox2_node_state_e, iox2_node_id_ptr, const char*, iox2_node_name_ptr, iox2_config_ptr, iox2_callback_context)
-> iox2_callback_progression_e;


explicit NodeId(iox2_node_id_h handle);
Expand Down
10 changes: 3 additions & 7 deletions iceoryx2-ffi/cxx/include/iox2/node_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,9 @@ class NodeState {

private:
template <ServiceType>
// NOLINTBEGIN(readability-function-size)
friend auto list_callback(iox2_node_state_e,
iox2_node_id_ptr,
const char*,
iox2_node_name_ptr,
iox2_config_ptr,
iox2_callback_context) -> iox2_callback_progression_e;
friend auto list_callback(
iox2_node_state_e, iox2_node_id_ptr, const char*, iox2_node_name_ptr, iox2_config_ptr, iox2_callback_context)
-> iox2_callback_progression_e;

explicit NodeState(const AliveNodeView<T>& view);
explicit NodeState(const DeadNodeView<T>& view);
Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-ffi/cxx/src/node_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ auto NodeId::creation_time() const -> timespec {
uint32_t nanoseconds = 0;
iox2_node_id_creation_time(&m_handle, &seconds, &nanoseconds);

return { static_cast<time_t>(seconds), nanoseconds };
return { static_cast<decltype(timespec::tv_sec)>(seconds), static_cast<decltype(timespec::tv_nsec)>(nanoseconds) };
}

auto operator<<(std::ostream& stream, const NodeId& node) -> std::ostream& {
Expand Down
2 changes: 1 addition & 1 deletion iceoryx2-ffi/cxx/tests/src/node_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ TYPED_TEST(NodeTest, created_nodes_can_be_listed) {
}

uint64_t counter = 0;
auto result = Node<SERVICE_TYPE>::list(Config::global_config(), [&](auto node_state) {
auto result = Node<SERVICE_TYPE>::list(Config::global_config(), [&](const auto& node_state) {
counter++;
return CallbackProgression::Continue;
});
Expand Down
Loading

0 comments on commit 0190c25

Please sign in to comment.