Skip to content

Commit

Permalink
Merge pull request #21 from orecham/rmw-iox2-16-organize-codebase
Browse files Browse the repository at this point in the history
[#16] Reorganization and refactoring
  • Loading branch information
orecham authored Dec 21, 2024
2 parents f94d87b + 81d5040 commit cda4d68
Show file tree
Hide file tree
Showing 67 changed files with 924 additions and 915 deletions.
2 changes: 2 additions & 0 deletions doc/release-notes/unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
conflicts when merging.
-->

* Organize code base to separate rmw api and implementation details [#16](https://github.com/ekxide/rmw_iceoryx2/issues/16)

### Workflow

<!--
Expand Down
37 changes: 19 additions & 18 deletions rmw_iceoryx2_cxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,17 @@ endforeach()
# ----------------------------------------------------------------------------

add_library(${PROJECT_NAME} SHARED
src/iox2/context_impl.cpp
src/iox2/guard_condition_impl.cpp
src/iox2/iceoryx2.cpp
src/iox2/names.cpp
src/iox2/node_impl.cpp
src/iox2/publisher_impl.cpp
src/iox2/subscriber_impl.cpp
src/iox2/waitset_impl.cpp
src/message/introspect.cpp
src/message/serialize.cpp
src/impl/common/names.cpp
src/impl/message/introspection.cpp
src/impl/message/serialization.cpp
src/impl/middleware/iceoryx2.cpp
src/impl/runtime/context.cpp
src/impl/runtime/guard_condition.cpp
src/impl/runtime/node.cpp
src/impl/runtime/publisher.cpp
src/impl/runtime/subscriber.cpp
src/impl/runtime/waitset.cpp

src/rmw/client.cpp
src/rmw/event.cpp
src/rmw/feature.cpp
Expand Down Expand Up @@ -149,14 +150,14 @@ if(BUILD_TESTING)

ament_add_gtest(test_rmw_iceoryx2_cxx
test/testing/base.cpp
test/test_iox2_context_impl.cpp
test/test_iox2_guard_condition_impl.cpp
test/test_iox2_message_introspection.cpp
test/test_iox2_node_impl.cpp
test/test_iox2_publisher_impl.cpp
test/test_iox2_sample_registry.cpp
test/test_iox2_subscriber_impl.cpp
test/test_iox2_waitset_impl.cpp
test/test_impl_context.cpp
test/test_impl_guard_condition.cpp
test/test_impl_message_introspection.cpp
test/test_impl_node.cpp
test/test_impl_publisher.cpp
test/test_impl_sample_registry.cpp
test/test_impl_subscriber.cpp
test/test_impl_waitset.cpp
test/test_rmw_allocator.cpp
test/test_rmw_gid.cpp
test/test_rmw_graph.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_ALLOCATOR_HELPERS_HPP_
#define RMW_IOX2_ALLOCATOR_HELPERS_HPP_
#ifndef RMW_IOX2_COMMON_ALLOCATOR_HPP_
#define RMW_IOX2_COMMON_ALLOCATOR_HPP_

#include "iox/expected.hpp"
#include "rmw/allocators.h"
#include "rmw/visibility_control.h"
#include "rmw_iceoryx2_cxx/error.hpp"
#include "rmw_iceoryx2_cxx/error_message.hpp"
#include "rmw_iceoryx2_cxx/impl/common/error.hpp"
#include "rmw_iceoryx2_cxx/impl/common/error_message.hpp"

#include <cstring>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_CREATE_HPP_
#define RMW_IOX2_CREATE_HPP_
#ifndef RMW_IOX2_COMMON_CREATE_HPP_
#define RMW_IOX2_COMMON_CREATE_HPP_

#include "iox/expected.hpp"
#include "iox/optional.hpp"
#include "iox2/service_builder_publish_subscribe_error.hpp"
#include "rmw/visibility_control.h"
#include "rmw_iceoryx2_cxx/creation_lock.hpp"
#include "rmw_iceoryx2_cxx/error.hpp"
#include "rmw_iceoryx2_cxx/error_message.hpp"
#include "rmw_iceoryx2_cxx/impl/common/creation_lock.hpp"
#include "rmw_iceoryx2_cxx/impl/common/error.hpp"
#include "rmw_iceoryx2_cxx/impl/common/error_message.hpp"

namespace rmw::iox2
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_CREATION_LOCK_HPP_
#define RMW_IOX2_CREATION_LOCK_HPP_
#ifndef RMW_IOX2_COMMON_CREATION_LOCK_HPP_
#define RMW_IOX2_COMMON_CREATION_LOCK_HPP_

#include "iox/expected.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include "rcutils/types/string_array.h"

#ifndef RMW_IOX2_DEFAULTS_HPP_
#define RMW_IOX2_DEFAULTS_HPP_
#ifndef RMW_IOX2_COMMON_DEFAULTS_HPP_
#define RMW_IOX2_COMMON_DEFAULTS_HPP_

constexpr rcutils_string_array_t RCUTILS_STRING_ARRAY_ZERO = {
0, // size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_ENSURE_HPP_
#define RMW_IOX2_ENSURE_HPP_
#ifndef RMW_IOX2_COMMON_ENSURE_HPP_
#define RMW_IOX2_COMMON_ENSURE_HPP_

#include "rmw_iceoryx2_cxx/defaults.hpp"
#include "rmw_iceoryx2_cxx/error_message.hpp"
#include "rmw_iceoryx2_cxx/message/typesupport.hpp"
#include "rmw_iceoryx2_cxx/impl/common/defaults.hpp"
#include "rmw_iceoryx2_cxx/impl/common/error_message.hpp"
#include "rmw_iceoryx2_cxx/impl/message/typesupport.hpp"

#define RMW_IOX2_ENSURE_VALID_ALLOCATOR(allocator, return_value) RCUTILS_CHECK_ALLOCATOR(allocator, return return_value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_ERROR_HPP_
#define RMW_IOX2_ERROR_HPP_
#ifndef RMW_IOX2_COMMON_ERROR_HPP_
#define RMW_IOX2_COMMON_ERROR_HPP_

#include <cstdint>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_ERROR_HANDLING_HPP_
#define RMW_IOX2_ERROR_HANDLING_HPP_
#ifndef RMW_IOX2_COMMON_ERROR_MESSAGE_HPP_
#define RMW_IOX2_COMMON_ERROR_MESSAGE_HPP_

#include "rmw/allocators.h"
#include "rmw/error_handling.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_LOG_HPP_
#define RMW_IOX2_LOG_HPP_
#ifndef RMW_IOX2_COMMON_LOG_HPP_
#define RMW_IOX2_COMMON_LOG_HPP_

#include "rcutils/logging_macros.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_TYPESUPPORT_HPP_
#define RMW_IOX2_TYPESUPPORT_HPP_
#ifndef RMW_IOX2_MESSAGE_TYPESUPPORT_HPP_
#define RMW_IOX2_MESSAGE_TYPESUPPORT_HPP_

#include "rosidl_typesupport_fastrtps_c/identifier.h"
#include "rosidl_typesupport_fastrtps_cpp/identifier.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_HANDLE_HPP_
#define RMW_IOX2_HANDLE_HPP_
#ifndef RMW_IOX2_MIDDLEWARE_ICEORYX2_HPP_
#define RMW_IOX2_MIDDLEWARE_ICEORYX2_HPP_

#include "iox2/listener.hpp"
#include "iox2/node.hpp"
Expand All @@ -23,8 +23,8 @@
#include "iox2/subscriber.hpp"
#include "iox2/waitset.hpp"
#include "rmw/visibility_control.h"
#include "rmw_iceoryx2_cxx/creation_lock.hpp"
#include "rmw_iceoryx2_cxx/error.hpp"
#include "rmw_iceoryx2_cxx/impl/common/creation_lock.hpp"
#include "rmw_iceoryx2_cxx/impl/common/error.hpp"

#include <string>

Expand All @@ -34,7 +34,7 @@ namespace rmw::iox2
class Iceoryx2;

template <>
struct Error<Iceoryx2>
struct Error<::rmw::iox2::Iceoryx2>
{
using Type = HandleError;
};
Expand All @@ -55,6 +55,10 @@ struct Error<Iceoryx2>
///
class RMW_PUBLIC Iceoryx2
{
template <typename T>
using Error = ::rmw::iox2::Error<T>;
using CreationLock = ::rmw::iox2::CreationLock;

public:
// In iceoryx2, a node is an instance of iceoryx2 with its own lifetime management.
using InstanceName = ::iox2::NodeName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_CONTEXT_IMPL_HPP_
#define RMW_IOX2_CONTEXT_IMPL_HPP_
#ifndef RMW_IOX2_RUNTIME_CONTEXT_HPP_
#define RMW_IOX2_RUNTIME_CONTEXT_HPP_

#include "iox/optional.hpp"
#include "rmw/visibility_control.h"
#include "rmw_iceoryx2_cxx/creation_lock.hpp"
#include "rmw_iceoryx2_cxx/error.hpp"
#include "rmw_iceoryx2_cxx/iox2/iceoryx2.hpp"
#include "rmw_iceoryx2_cxx/impl/common/creation_lock.hpp"
#include "rmw_iceoryx2_cxx/impl/common/error.hpp"
#include "rmw_iceoryx2_cxx/impl/middleware/iceoryx2.hpp"

#include <atomic>

Expand Down Expand Up @@ -81,7 +81,7 @@ namespace rmw::iox2
{

// Used throughout implementation to indicate it is C++
using ContextImpl = rmw_context_impl_s;
using Context = rmw_context_impl_s;

} // namespace rmw::iox2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_GUARD_CONDITION_IMPL_HPP_
#define RMW_IOX2_GUARD_CONDITION_IMPL_HPP_
#ifndef RMW_IOX2_RUNTIME_GUARD_CONDITION_HPP_
#define RMW_IOX2_RUNTIME_GUARD_CONDITION_HPP_

#include "iox/optional.hpp"
#include "iox2/unique_port_id.hpp"
#include "rmw/visibility_control.h"
#include "rmw_iceoryx2_cxx/creation_lock.hpp"
#include "rmw_iceoryx2_cxx/error.hpp"
#include "rmw_iceoryx2_cxx/iox2/context_impl.hpp"
#include "rmw_iceoryx2_cxx/iox2/iceoryx2.hpp"
#include "rmw_iceoryx2_cxx/impl/common/creation_lock.hpp"
#include "rmw_iceoryx2_cxx/impl/common/error.hpp"
#include "rmw_iceoryx2_cxx/impl/middleware/iceoryx2.hpp"
#include "rmw_iceoryx2_cxx/impl/runtime/context.hpp"

namespace rmw::iox2
{

class NodeImpl;
class GuardConditionImpl;
class Node;
class GuardCondition;

template <>
struct Error<GuardConditionImpl>
struct Error<GuardCondition>
{
using Type = GuardConditionError;
};
Expand All @@ -35,21 +35,21 @@ struct Error<GuardConditionImpl>
/// wake up a waiting thread. It is used in ROS 2 to signal events between
/// different parts of the system. This implementation uses an iceoryx2
/// notifier to implement the guard condition functionality.
class RMW_PUBLIC GuardConditionImpl
class RMW_PUBLIC GuardCondition
{
using RawIdType = ::iox2::RawIdType;
using IdType = ::iox2::UniquePublisherId;
using Notifier = Iceoryx2::Local::Notifier;
using IceoryxNotifier = Iceoryx2::Local::Notifier;

public:
using ErrorType = Error<GuardConditionImpl>::Type;
using ErrorType = Error<GuardCondition>::Type;

public:
/// @brief Creates a new guard condition
/// @param[in] lock Creation lock to restrict construction to creation functions
/// @param[out] error Optional error that is set if construction fails
/// @param[in] context The context to associate the guard condition with
GuardConditionImpl(CreationLock, iox::optional<ErrorType>& error, ContextImpl& context);
GuardCondition(CreationLock, iox::optional<ErrorType>& error, Context& context);

/// @brief Get the unique id of the guard condition
/// @return The unique id or empty optional if failing to retrieve it from iceoryx2
Expand All @@ -72,7 +72,7 @@ class RMW_PUBLIC GuardConditionImpl
const std::string m_service_name;

iox::optional<IdType> m_iox2_unique_id;
iox::optional<Notifier> m_iox2_notifier;
iox::optional<IceoryxNotifier> m_iox2_notifier;
};

} // namespace rmw::iox2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
//
// SPDX-License-Identifier: Apache-2.0 OR MIT

#ifndef RMW_IOX2_NODE_IMPL_HPP_
#define RMW_IOX2_NODE_IMPL_HPP_
#ifndef RMW_IOX2_RUNTIME_NODE_HPP_
#define RMW_IOX2_RUNTIME_NODE_HPP_

#include "iox/optional.hpp"
#include "rmw/visibility_control.h"
#include "rmw_iceoryx2_cxx/creation_lock.hpp"
#include "rmw_iceoryx2_cxx/error.hpp"
#include "rmw_iceoryx2_cxx/iox2/context_impl.hpp"
#include "rmw_iceoryx2_cxx/iox2/guard_condition_impl.hpp"
#include "rmw_iceoryx2_cxx/iox2/iceoryx2.hpp"
#include "rmw_iceoryx2_cxx/impl/common/creation_lock.hpp"
#include "rmw_iceoryx2_cxx/impl/common/error.hpp"
#include "rmw_iceoryx2_cxx/impl/middleware/iceoryx2.hpp"
#include "rmw_iceoryx2_cxx/impl/runtime/context.hpp"
#include "rmw_iceoryx2_cxx/impl/runtime/guard_condition.hpp"

namespace rmw::iox2
{

class NodeImpl;
class Node;

template <>
struct Error<NodeImpl>
struct Error<Node>
{
using Type = NodeError;
};
Expand All @@ -36,10 +36,10 @@ struct Error<NodeImpl>
/// The graph data structure is managed by iceoryx2 directly, related operations can be achived via the handle to
/// iceoryx2.
///
class RMW_PUBLIC NodeImpl
class RMW_PUBLIC Node
{
public:
using ErrorType = Error<NodeImpl>::Type;
using ErrorType = Error<Node>::Type;

public:
/// @brief Constructor for the iceoryx2 implementation of an RMW node
Expand All @@ -48,7 +48,7 @@ class RMW_PUBLIC NodeImpl
/// @param[in] context The context which this node will belong to
/// @param[in] name The name of the node
/// @param[in] ns The namespace of the node
NodeImpl(CreationLock, iox::optional<ErrorType>& error, ContextImpl& context, const char* name, const char* ns);
Node(CreationLock, iox::optional<ErrorType>& error, Context& context, const char* name, const char* ns);

/// @brief Get the name of the node
/// @return The name of the node
Expand All @@ -60,12 +60,12 @@ class RMW_PUBLIC NodeImpl

/// @brief Get the guard condition for notifying of graph events
/// @return The guard condition for graph events
auto graph_guard_condition() -> GuardConditionImpl&;
auto graph_guard_condition() -> GuardCondition&;

private:
const std::string m_name;
iox::optional<Iceoryx2> m_iox2;
iox::optional<GuardConditionImpl> m_graph_guard_condition;
iox::optional<GuardCondition> m_graph_guard_condition;
};

} // namespace rmw::iox2
Expand Down
Loading

0 comments on commit cda4d68

Please sign in to comment.