From a32de34b41d7a9bb8036a4d2ec6f197516286f11 Mon Sep 17 00:00:00 2001 From: Marika Lehmann Date: Wed, 18 Jan 2023 18:34:43 +0100 Subject: [PATCH 1/7] iox-#1391 Clean up design module Remove unnecessary includes, add missing scheduler to readme Signed-off-by: Marika Lehmann --- iceoryx_hoofs/README.md | 1 + iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp | 2 -- .../include/iceoryx_hoofs/posix_wrapper/posix_call.hpp | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/iceoryx_hoofs/README.md b/iceoryx_hoofs/README.md index 5d591e9c5e..2a901043ff 100644 --- a/iceoryx_hoofs/README.md +++ b/iceoryx_hoofs/README.md @@ -127,6 +127,7 @@ The module structure is a logical grouping. It is replicated for `concurrent` an |`PeriodicTask` | i | Periodically executes a callable specified by the template parameter in a configurable time interval. | |`smart_lock` | i | Creates arbitrary thread-safe constructs which then can be used like smart pointers. If some STL type should be thread safe use the smart_lock to create the thread safe version in one line. Based on some ideas presented in [Wrapping C++ Member Function Calls](https://stroustrup.com/wrapper.pdf) | |`mutex` | i | Mutex interface, see [ManPage pthread_mutex_lock](https://man7.org/linux/man-pages/man3/pthread_mutex_lock.3p.html). | +|`Scheduler` | | Supported schedulers and functions to get their priority range are contained here. | |`UnnamedSemaphore` | | Unamed semaphore interface, see [ManPage sem_overview](https://man7.org/linux/man-pages/man7/sem_overview.7.html) | |`NamedSemaphore` | | Named semaphore interface, see [ManPage sem_overview](https://man7.org/linux/man-pages/man7/sem_overview.7.html) | |`thread` | | Heap-less replacement for `std::thread`. | diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp index d3536ff386..f2feb4e43b 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp @@ -26,8 +26,6 @@ #include "iceoryx_hoofs/internal/cxx/newtype/protected_constructor.hpp" #include "iceoryx_hoofs/internal/cxx/newtype/sortable.hpp" -#include - namespace iox { namespace cxx diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/posix_call.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/posix_call.hpp index ef13c795c0..c79236d3be 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/posix_call.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/posix_call.hpp @@ -20,7 +20,6 @@ #include "iceoryx_hoofs/cxx/attributes.hpp" #include "iox/expected.hpp" #include "iox/string.hpp" -#include "iox/uninitialized_array.hpp" #include #include From 1b4017aca122a29fc6d0f8b70ec72f1a46309c63 Mon Sep 17 00:00:00 2001 From: Marika Lehmann Date: Wed, 18 Jan 2023 20:26:01 +0100 Subject: [PATCH 2/7] iox-#1391 Move newtype files Signed-off-by: Marika Lehmann --- .clang-tidy-diff-scans.txt | 3 + .../release-notes/iceoryx-unreleased.md | 12 ++-- iceoryx_hoofs/BUILD.bazel | 3 +- iceoryx_hoofs/CMakeLists.txt | 2 + .../include/iox/detail}/newtype.inl | 9 +-- .../iox/detail}/newtype/assignment.hpp | 7 +- .../iox/detail}/newtype/comparable.hpp | 9 +-- .../iox/detail}/newtype/constructor.hpp | 7 +- .../iox/detail}/newtype/convertable.hpp | 7 +- .../include/iox/detail}/newtype/internal.hpp | 7 +- .../detail}/newtype/protected_constructor.hpp | 7 +- .../include/iox/detail}/newtype/sortable.hpp | 9 +-- .../cxx => design/include/iox}/newtype.hpp | 33 +++++---- .../iceoryx_hoofs/internal/cxx/unique_id.hpp | 20 +++--- .../iceoryx_hoofs/memory/relative_pointer.hpp | 14 ++-- .../include/iceoryx_hoofs/cxx/newtype.hpp | 66 ++++++++++++++++++ ...xx_newtype.cpp => test_design_newtype.cpp} | 67 +++++-------------- .../popo/building_blocks/unique_port_id.hpp | 20 +++--- .../popo/building_blocks/unique_port_id.cpp | 4 +- 19 files changed, 159 insertions(+), 147 deletions(-) rename iceoryx_hoofs/{include/iceoryx_hoofs/internal/cxx => design/include/iox/detail}/newtype.inl (97%) rename iceoryx_hoofs/{include/iceoryx_hoofs/internal/cxx => design/include/iox/detail}/newtype/assignment.hpp (96%) rename iceoryx_hoofs/{include/iceoryx_hoofs/internal/cxx => design/include/iox/detail}/newtype/comparable.hpp (90%) rename iceoryx_hoofs/{include/iceoryx_hoofs/internal/cxx => design/include/iox/detail}/newtype/constructor.hpp (96%) rename iceoryx_hoofs/{include/iceoryx_hoofs/internal/cxx => design/include/iox/detail}/newtype/convertable.hpp (92%) rename iceoryx_hoofs/{include/iceoryx_hoofs/internal/cxx => design/include/iox/detail}/newtype/internal.hpp (90%) rename iceoryx_hoofs/{include/iceoryx_hoofs/internal/cxx => design/include/iox/detail}/newtype/protected_constructor.hpp (91%) rename iceoryx_hoofs/{include/iceoryx_hoofs/internal/cxx => design/include/iox/detail}/newtype/sortable.hpp (92%) rename iceoryx_hoofs/{include/iceoryx_hoofs/cxx => design/include/iox}/newtype.hpp (89%) create mode 100644 iceoryx_hoofs/legacy/include/iceoryx_hoofs/cxx/newtype.hpp rename iceoryx_hoofs/test/moduletests/{test_cxx_newtype.cpp => test_design_newtype.cpp} (72%) diff --git a/.clang-tidy-diff-scans.txt b/.clang-tidy-diff-scans.txt index 7ed80cb218..cf23a09c75 100644 --- a/.clang-tidy-diff-scans.txt +++ b/.clang-tidy-diff-scans.txt @@ -51,6 +51,9 @@ ./iceoryx_hoofs/vocabulary/**/* ./iceoryx_hoofs/test/moduletests/test_vocabulary_* +./iceoryx_hoofs/design/**/* +./iceoryx_hoofs/test/moduletests/test_design_* + # IMPORTANT: # after the first # everything is considered a comment, add new files and # directories only at the top of this file diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index be18f86d1f..154e1b0cd8 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -229,12 +229,12 @@ 7. It is not possible to delete a class which is derived from `NewType` via a pointer to `NewType` ```cpp - struct Foo : public iox::cxx::NewType + struct Foo : public iox::NewType { using ThisType::ThisType; }; - iox::cxx::NewType* soSmart = new Foo{42}; + iox::NewType* soSmart = new Foo{42}; delete soSmart; // <- not possible anymore ``` @@ -244,17 +244,17 @@ ```cpp // before // for the compiler Foo and Bar are the same type - using Foo = iox::cxx::NewType; - using Bar = iox::cxx::NewType; + using Foo = iox::NewType; + using Bar = iox::NewType; // after // compile time error when Foo and Bar are mixed up - struct Foo : public iox::cxx::NewType + struct Foo : public iox::NewType { using ThisType::ThisType; }; // or with the IOX_NEW_TYPE macro - IOX_NEW_TYPE(Bar, uint64_t, iox::cxx::newtype::ConstructByValueCopy); + IOX_NEW_TYPE(Bar, uint64_t, iox::newtype::ConstructByValueCopy); ``` 9. `FileLock` uses the builder pattern. Path and permissions can now be set. diff --git a/iceoryx_hoofs/BUILD.bazel b/iceoryx_hoofs/BUILD.bazel index c1ccc87dbb..aceae39d9b 100644 --- a/iceoryx_hoofs/BUILD.bazel +++ b/iceoryx_hoofs/BUILD.bazel @@ -35,7 +35,7 @@ cc_library( "source/**/*.hpp", "memory/source/*.cpp", ]), - hdrs = glob(["include/**"]) + glob(["legacy/**"]) + glob(["memory/**"]) + glob(["container/**"]) + glob(["vocabulary/**"]) + glob(["utility/**"]) + glob(["primitives/**"]) + [ + hdrs = glob(["include/**"]) + glob(["legacy/**"]) + glob(["memory/**"]) + glob(["container/**"]) + glob(["vocabulary/**"]) + glob(["utility/**"]) + glob(["primitives/**"]) + glob(["design/**"]) + [ ":iceoryx_hoofs_deployment_hpp", ], includes = [ @@ -46,6 +46,7 @@ cc_library( "primitives/include/", "utility/include/", "vocabulary/include/", + "design/include", ], linkopts = select({ "//iceoryx_platform:linux-clang": [ diff --git a/iceoryx_hoofs/CMakeLists.txt b/iceoryx_hoofs/CMakeLists.txt index a4d632e65b..93cc9c0740 100644 --- a/iceoryx_hoofs/CMakeLists.txt +++ b/iceoryx_hoofs/CMakeLists.txt @@ -53,6 +53,7 @@ iox_add_library( ${PROJECT_SOURCE_DIR}/vocabulary/include ${PROJECT_SOURCE_DIR}/utility/include ${PROJECT_SOURCE_DIR}/primitives/include + ${PROJECT_SOURCE_DIR}/design/include ${CMAKE_BINARY_DIR}/generated/iceoryx_hoofs/include INSTALL_INTERFACE include/${PREFIX} EXPORT_INCLUDE_DIRS include/ @@ -62,6 +63,7 @@ iox_add_library( vocabulary/include/ utility/include/ primitives/include/ + design/include/ FILES source/concurrent/loffli.cpp source/cxx/adaptive_wait.cpp diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype.inl b/iceoryx_hoofs/design/include/iox/detail/newtype.inl similarity index 97% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype.inl rename to iceoryx_hoofs/design/include/iox/detail/newtype.inl index e07a401518..bf3364a805 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype.inl +++ b/iceoryx_hoofs/design/include/iox/detail/newtype.inl @@ -14,15 +14,13 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_NEWTYPE_INL -#define IOX_HOOFS_CXX_NEWTYPE_INL +#ifndef IOX_HOOFS_DESIGN_NEWTYPE_INL +#define IOX_HOOFS_DESIGN_NEWTYPE_INL -#include "iceoryx_hoofs/cxx/newtype.hpp" +#include "iox/newtype.hpp" namespace iox { -namespace cxx -{ template class... Policies> // AXIVION Next Construct AutosarC++19_03-A12.6.1 : m_value is initialized by the default constructor of T; the code // will not compile, if the default constructor of T does not exist or the DefaultConstructable policy is not added @@ -118,7 +116,6 @@ inline NewType::operator T() const noexcept return m_value; } -} // namespace cxx } // namespace iox #endif diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/assignment.hpp b/iceoryx_hoofs/design/include/iox/detail/newtype/assignment.hpp similarity index 96% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/assignment.hpp rename to iceoryx_hoofs/design/include/iox/detail/newtype/assignment.hpp index e889923eb7..bc7f7e7274 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/assignment.hpp +++ b/iceoryx_hoofs/design/include/iox/detail/newtype/assignment.hpp @@ -14,13 +14,11 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_NEWTYPE_ASSIGNMENT_HPP -#define IOX_HOOFS_CXX_NEWTYPE_ASSIGNMENT_HPP +#ifndef IOX_HOOFS_DESIGN_NEWTYPE_ASSIGNMENT_HPP +#define IOX_HOOFS_DESIGN_NEWTYPE_ASSIGNMENT_HPP namespace iox { -namespace cxx -{ namespace newtype { template @@ -76,7 +74,6 @@ struct AssignByValueMove }; } // namespace newtype -} // namespace cxx } // namespace iox #endif diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/comparable.hpp b/iceoryx_hoofs/design/include/iox/detail/newtype/comparable.hpp similarity index 90% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/comparable.hpp rename to iceoryx_hoofs/design/include/iox/detail/newtype/comparable.hpp index af50ab7653..2817d8910c 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/comparable.hpp +++ b/iceoryx_hoofs/design/include/iox/detail/newtype/comparable.hpp @@ -14,14 +14,12 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_NEWTYPE_COMPARABLE_HPP -#define IOX_HOOFS_CXX_NEWTYPE_COMPARABLE_HPP -#include "iceoryx_hoofs/internal/cxx/newtype/internal.hpp" +#ifndef IOX_HOOFS_DESIGN_NEWTYPE_COMPARABLE_HPP +#define IOX_HOOFS_DESIGN_NEWTYPE_COMPARABLE_HPP +#include "internal.hpp" namespace iox { -namespace cxx -{ namespace newtype { template @@ -48,7 +46,6 @@ struct Comparable }; } // namespace newtype -} // namespace cxx } // namespace iox #endif diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/constructor.hpp b/iceoryx_hoofs/design/include/iox/detail/newtype/constructor.hpp similarity index 96% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/constructor.hpp rename to iceoryx_hoofs/design/include/iox/detail/newtype/constructor.hpp index 8b5c3e567a..a36bd40728 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/constructor.hpp +++ b/iceoryx_hoofs/design/include/iox/detail/newtype/constructor.hpp @@ -14,13 +14,11 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_NEWTYPE_CONSTRUCTOR_HPP -#define IOX_HOOFS_CXX_NEWTYPE_CONSTRUCTOR_HPP +#ifndef IOX_HOOFS_DESIGN_NEWTYPE_CONSTRUCTOR_HPP +#define IOX_HOOFS_DESIGN_NEWTYPE_CONSTRUCTOR_HPP namespace iox { -namespace cxx -{ namespace newtype { template @@ -75,7 +73,6 @@ struct DefaultConstructable ~DefaultConstructable() = default; }; } // namespace newtype -} // namespace cxx } // namespace iox #endif diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/convertable.hpp b/iceoryx_hoofs/design/include/iox/detail/newtype/convertable.hpp similarity index 92% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/convertable.hpp rename to iceoryx_hoofs/design/include/iox/detail/newtype/convertable.hpp index 5eacae0a83..59aa6b6d77 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/convertable.hpp +++ b/iceoryx_hoofs/design/include/iox/detail/newtype/convertable.hpp @@ -14,13 +14,11 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_NEWTYPE_CONVERTABLE_HPP -#define IOX_HOOFS_CXX_NEWTYPE_CONVERTABLE_HPP +#ifndef IOX_HOOFS_DESIGN_NEWTYPE_CONVERTABLE_HPP +#define IOX_HOOFS_DESIGN_NEWTYPE_CONVERTABLE_HPP namespace iox { -namespace cxx -{ namespace newtype { template @@ -37,7 +35,6 @@ struct Convertable }; } // namespace newtype -} // namespace cxx } // namespace iox #endif diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/internal.hpp b/iceoryx_hoofs/design/include/iox/detail/newtype/internal.hpp similarity index 90% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/internal.hpp rename to iceoryx_hoofs/design/include/iox/detail/newtype/internal.hpp index 197563d688..78eadb7630 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/internal.hpp +++ b/iceoryx_hoofs/design/include/iox/detail/newtype/internal.hpp @@ -14,15 +14,13 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_NEWTYPE_INTERNAL_HPP -#define IOX_HOOFS_CXX_NEWTYPE_INTERNAL_HPP +#ifndef IOX_HOOFS_DESIGN_NEWTYPE_INTERNAL_HPP +#define IOX_HOOFS_DESIGN_NEWTYPE_INTERNAL_HPP #include namespace iox { -namespace cxx -{ template class...> class NewType; namespace newtype @@ -42,7 +40,6 @@ inline typename T::value_type newTypeAccessor(const T& b) noexcept } } // namespace internal } // namespace newtype -} // namespace cxx } // namespace iox #endif diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/protected_constructor.hpp b/iceoryx_hoofs/design/include/iox/detail/newtype/protected_constructor.hpp similarity index 91% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/protected_constructor.hpp rename to iceoryx_hoofs/design/include/iox/detail/newtype/protected_constructor.hpp index 4c6d0dccd8..51ded5fec0 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/protected_constructor.hpp +++ b/iceoryx_hoofs/design/include/iox/detail/newtype/protected_constructor.hpp @@ -14,13 +14,11 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_NEWTYPE_PROTECTED_CONSTRUCTOR_HPP -#define IOX_HOOFS_CXX_NEWTYPE_PROTECTED_CONSTRUCTOR_HPP +#ifndef IOX_HOOFS_DESIGN_NEWTYPE_PROTECTED_CONSTRUCTOR_HPP +#define IOX_HOOFS_DESIGN_NEWTYPE_PROTECTED_CONSTRUCTOR_HPP namespace iox { -namespace cxx -{ namespace newtype { template @@ -36,7 +34,6 @@ struct ProtectedConstructByValueCopy ~ProtectedConstructByValueCopy() = default; }; } // namespace newtype -} // namespace cxx } // namespace iox #endif diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/sortable.hpp b/iceoryx_hoofs/design/include/iox/detail/newtype/sortable.hpp similarity index 92% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/sortable.hpp rename to iceoryx_hoofs/design/include/iox/detail/newtype/sortable.hpp index 05b2d517d7..3eb8667f02 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/sortable.hpp +++ b/iceoryx_hoofs/design/include/iox/detail/newtype/sortable.hpp @@ -14,14 +14,12 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_NEWTYPE_SORTABLE_HPP -#define IOX_HOOFS_CXX_NEWTYPE_SORTABLE_HPP -#include "iceoryx_hoofs/internal/cxx/newtype/internal.hpp" +#ifndef IOX_HOOFS_DESIGN_NEWTYPE_SORTABLE_HPP +#define IOX_HOOFS_DESIGN_NEWTYPE_SORTABLE_HPP +#include "internal.hpp" namespace iox { -namespace cxx -{ namespace newtype { template @@ -58,7 +56,6 @@ struct Sortable }; } // namespace newtype -} // namespace cxx } // namespace iox diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp b/iceoryx_hoofs/design/include/iox/newtype.hpp similarity index 89% rename from iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp rename to iceoryx_hoofs/design/include/iox/newtype.hpp index f2feb4e43b..47ca92edd2 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/newtype.hpp +++ b/iceoryx_hoofs/design/include/iox/newtype.hpp @@ -14,22 +14,20 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_NEWTYPE_HPP -#define IOX_HOOFS_CXX_NEWTYPE_HPP - +#ifndef IOX_HOOFS_DESIGN_NEWTYPE_HPP +#define IOX_HOOFS_DESIGN_NEWTYPE_HPP + +#include "detail/newtype/assignment.hpp" +#include "detail/newtype/comparable.hpp" +#include "detail/newtype/constructor.hpp" +#include "detail/newtype/convertable.hpp" +#include "detail/newtype/internal.hpp" +#include "detail/newtype/protected_constructor.hpp" +#include "detail/newtype/sortable.hpp" #include "iceoryx_hoofs/cxx/algorithm.hpp" -#include "iceoryx_hoofs/internal/cxx/newtype/assignment.hpp" -#include "iceoryx_hoofs/internal/cxx/newtype/comparable.hpp" -#include "iceoryx_hoofs/internal/cxx/newtype/constructor.hpp" -#include "iceoryx_hoofs/internal/cxx/newtype/convertable.hpp" -#include "iceoryx_hoofs/internal/cxx/newtype/internal.hpp" -#include "iceoryx_hoofs/internal/cxx/newtype/protected_constructor.hpp" -#include "iceoryx_hoofs/internal/cxx/newtype/sortable.hpp" namespace iox { -namespace cxx -{ /// @brief Implementation of the haskell NewType pattern: /// https://wiki.haskell.org/Newtype /// Lets say you would like to have an index which is in the end an integer but @@ -42,7 +40,7 @@ namespace cxx /// inherit from NewType and add your methods. /// For most generic usage, the IOX_NEW_TYPE macro can be used. /// @code -/// #include +/// #include "iox/newtype.hpp" /// /// class Index : public NewType>... T m_value; }; -} // namespace cxx } // namespace iox /// @brief This macro helps to create types with the NewType class. @@ -138,10 +135,10 @@ class NewType : public Policies>... /// @param[in] TypeName is the name of the new type to create /// @param[in] Type is the underlying type of the new type /// @param[in] ... is a variadic list of the policies applied to the new type, -/// e.g. iox::cxx::newtype::ConstructByValueCopy +/// e.g. iox::newtype::ConstructByValueCopy /// /// @code -/// #include +/// #include "iox/newtype.hpp" /// /// IOX_NEW_TYPE(MyType, /// uint64_t, @@ -155,7 +152,7 @@ class NewType : public Policies>... // AXIVION Next Construct AutosarC++19_03-A16.0.1 : macro is used to reduce boilerplate code for 'NewType' /// @NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define IOX_NEW_TYPE(TypeName, Type, ...) \ - struct TypeName : public iox::cxx::NewType \ + struct TypeName : public iox::NewType \ { \ using ThisType::ThisType; \ using ThisType::operator=; \ @@ -167,6 +164,6 @@ class NewType : public Policies>... TypeName& operator=(TypeName&&) noexcept = default; \ } -#include "iceoryx_hoofs/internal/cxx/newtype.inl" +#include "iox/detail/newtype.inl" #endif diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/unique_id.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/unique_id.hpp index 9b779b02d5..44d7a62de2 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/unique_id.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/unique_id.hpp @@ -17,7 +17,7 @@ #ifndef IOX_HOOFS_CXX_UNIQUE_ID_HPP #define IOX_HOOFS_CXX_UNIQUE_ID_HPP -#include "iceoryx_hoofs/cxx/newtype.hpp" +#include "iox/newtype.hpp" #include @@ -28,15 +28,15 @@ namespace cxx /// @brief Unique IDs within a process starting with 1. Monotonic increasing IDs are /// created with each call to the constructor. The IDs are copy/move constructible/assignable, /// comparable, sortable and convertable to the underlying value type. -class UniqueId : public cxx::NewType +class UniqueId : public NewType { public: using ThisType::ThisType; diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/memory/relative_pointer.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/memory/relative_pointer.hpp index fa6709e4a3..9691c14405 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/memory/relative_pointer.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/memory/relative_pointer.hpp @@ -18,8 +18,8 @@ #ifndef IOX_HOOFS_MEMORY_RELATIVE_POINTER_HPP #define IOX_HOOFS_MEMORY_RELATIVE_POINTER_HPP -#include "iceoryx_hoofs/cxx/newtype.hpp" #include "iceoryx_hoofs/internal/memory/pointer_repository.hpp" +#include "iox/newtype.hpp" #include #include @@ -29,12 +29,12 @@ namespace iox { namespace memory { -struct segment_id_t : public cxx::NewType +struct segment_id_t : public NewType { using ThisType::ThisType; }; diff --git a/iceoryx_hoofs/legacy/include/iceoryx_hoofs/cxx/newtype.hpp b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/cxx/newtype.hpp new file mode 100644 index 0000000000..1bf985a600 --- /dev/null +++ b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/cxx/newtype.hpp @@ -0,0 +1,66 @@ +// Copyright (c) 2023 by Apex.AI Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +#ifndef IOX_HOOFS_CXX_NEWTYPE_HPP +#define IOX_HOOFS_CXX_NEWTYPE_HPP + +#include "iox/newtype.hpp" + +namespace iox +{ +/// @todo iox-#1593 Deprecate include +/// [[deprecated("Deprecated in 3.0, removed in 4.0, please include 'iox/newtype.hpp' instead")]] +namespace cxx +{ +/// @deprecated use `iox::NewType` instead of `iox::cxx::NewType` +using iox::NewType; + +namespace newtype +{ +/// @deprecated use `iox::newtype::AssignByValueCopy` instead of `iox::cxx::newtype::AssignByValueCopy` +using iox::newtype::AssignByValueCopy; +/// @deprecated use `iox::newtype::AssignByValueMove` instead of `iox::cxx::newtype::AssignByValueMove` +using iox::newtype::AssignByValueMove; +/// @deprecated use `iox::newtype::Comparable` instead of `iox::cxx::newtype::Comparable` +using iox::newtype::Comparable; +/// @deprecated use `iox::newtype::ConstructByValueCopy` instead of `iox::cxx::newtype::ConstructByValueCopy` +using iox::newtype::ConstructByValueCopy; +/// @deprecated use `iox::newtype::Convertable` instead of `iox::cxx::newtype::Convertable` +using iox::newtype::Convertable; +/// @deprecated use `iox::newtype::CopyAssignable` instead of `iox::cxx::newtype::CopyAssignable` +using iox::newtype::CopyAssignable; +/// @deprecated use `iox::newtype::CopyConstructable` instead of `iox::cxx::newtype::CopyConstructable` +using iox::newtype::CopyConstructable; +/// @deprecated use `iox::newtype::DefaultConstructable` instead of `iox::cxx::newtype::DefaultConstructable` +using iox::newtype::DefaultConstructable; +/// @deprecated use `iox::newtype::MoveAssignable` instead of `iox::cxx::newtype::MoveAssignable` +using iox::newtype::MoveAssignable; +/// @deprecated use `iox::newtype::MoveConstructable` instead of `iox::cxx::newtype::MoveConstructable` +using iox::newtype::MoveConstructable; +/// @deprecated use `iox::newtype::ProtectedConstructByValueCopy` instead of +/// `iox::cxx::newtype::ProtectedConstructByValueCopy` +using iox::newtype::ProtectedConstructByValueCopy; +/// @deprecated use `iox::newtype::Sortable` instead of `iox::cxx::newtype::Sortable` +using iox::newtype::Sortable; + +namespace internal +{ +using iox::newtype::internal::ProtectedConstructor; +} +} // namespace newtype +} // namespace cxx +} // namespace iox + +#endif diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_newtype.cpp b/iceoryx_hoofs/test/moduletests/test_design_newtype.cpp similarity index 72% rename from iceoryx_hoofs/test/moduletests/test_cxx_newtype.cpp rename to iceoryx_hoofs/test/moduletests/test_design_newtype.cpp index 375290477a..62e8ce99ba 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_newtype.cpp +++ b/iceoryx_hoofs/test/moduletests/test_design_newtype.cpp @@ -15,15 +15,14 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_hoofs/cxx/newtype.hpp" #include "iceoryx_hoofs/testing/compile_test.hpp" +#include "iox/newtype.hpp" #include "test.hpp" namespace { using namespace ::testing; using namespace iox; -using namespace iox::cxx; struct ComplexType { @@ -76,48 +75,20 @@ struct Sut : public T Sut& operator=(Sut&&) noexcept = default; }; -CompileTest compileTest(R"( - #include \"iceoryx_hoofs/cxx/newtype.hpp\" - - template - struct Sut : public T - { - using T::T; - using T::operator=; // bring all operator= into scope - }; - - using namespace iox; - using namespace iox::cxx; -)", - {"iceoryx_hoofs/include"}); - - TEST(NewType, ComparableDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "a2c2823b-3593-4d45-845d-fea249362f11"); - using SutType = Sut>; + using SutType = Sut>; SutType a(123); SutType b(456); EXPECT_TRUE(a != b); EXPECT_FALSE(a == b); } -#if !defined(_WIN32) -TEST(NewType, NoComparableDoesNotCompile) -{ - ::testing::Test::RecordProperty("TEST_ID", "17ca57e1-8a9c-4235-91bd-1905e580dbb1"); - const char* p = R"( - Sut> a(123), b(456); - if ( a == b ) {} - )"; - EXPECT_FALSE(compileTest.verify(p)); -} -#endif - TEST(NewType, SortableDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "d58a0838-bad5-4999-b4a5-607b11608f6a"); - using SutType = Sut>; + using SutType = Sut>; SutType a(456); SutType b(789); EXPECT_TRUE(a < b); @@ -129,14 +100,13 @@ TEST(NewType, SortableDoesCompile) TEST(NewType, DefaultConstructableDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "1e6e1d83-36b7-4f9a-9410-438c00a748a9"); - Sut> a; + Sut> a; } TEST(NewType, CopyConstructableDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "177491d2-a940-4584-a362-f973f93b0445"); - using SutType = - Sut>; + using SutType = Sut>; SutType a(91); SutType b(92); // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) copy constructor shall be tested @@ -148,7 +118,7 @@ TEST(NewType, CopyConstructableComplexTypeDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "c73499b8-c8b0-4cc1-b097-44a18f571d34"); using SutType = - Sut>; + Sut>; SutType a(91); SutType b(92); // NOLINTNEXTLINE(performance-unnecessary-copy-initialization) copy constructor shall be tested @@ -159,7 +129,7 @@ TEST(NewType, CopyConstructableComplexTypeDoesCompile) TEST(NewType, CopyAssignableDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "ab690ed0-738e-4e6f-932a-01c9520b5d35"); - using SutType = Sut>; + using SutType = Sut>; SutType a(491); SutType b(492); SutType c(491); @@ -173,7 +143,7 @@ TEST(NewType, CopyAssignableComplexTypeDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "011efe73-7700-41c1-bc12-8aa4e848b0ce"); using SutType = - Sut>; + Sut>; SutType a(491); SutType b(492); SutType c(491); @@ -186,8 +156,7 @@ TEST(NewType, CopyAssignableComplexTypeDoesCompile) TEST(NewType, MoveConstructableDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "635b07e6-0d0d-49b4-ae27-593b870ad45b"); - using SutType = - Sut>; + using SutType = Sut>; SutType b(92); SutType c(92); SutType d(std::move(c)); @@ -198,7 +167,7 @@ TEST(NewType, MoveConstructableComplexTypeDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "7bba277d-5704-4ff7-810d-74bbb851469a"); using SutType = - Sut>; + Sut>; SutType b(92); SutType c(92); SutType d(std::move(c)); @@ -208,7 +177,7 @@ TEST(NewType, MoveConstructableComplexTypeDoesCompile) TEST(NewType, MoveAssignableDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "4d8b1166-94d4-4e4c-8759-04984ce3fbec"); - using SutType = Sut>; + using SutType = Sut>; SutType b(912); SutType c(912); SutType d(123); @@ -220,7 +189,7 @@ TEST(NewType, MoveAssignableComplexTypeDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "c300724e-c7ae-4897-ac99-62b0c4f44fbe"); using SutType = - Sut>; + Sut>; SutType b(912); SutType c(912); SutType d(123); @@ -231,7 +200,7 @@ TEST(NewType, MoveAssignableComplexTypeDoesCompile) TEST(NewType, ConversionDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "6c7cd3e1-1520-43a9-ad45-7269c123b98d"); - using SutType = Sut>; + using SutType = Sut>; SutType a(911); int b = static_cast(a); EXPECT_THAT(b, Eq(911)); @@ -240,8 +209,7 @@ TEST(NewType, ConversionDoesCompile) TEST(NewType, AssignByValueCopyDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "65a6a726-1324-4b81-b12d-7ca89e149aa2"); - using SutType = - Sut>; + using SutType = Sut>; SutType a(8791); SutType b(651); @@ -255,7 +223,7 @@ TEST(NewType, AssignByValueCopyComplexTypeDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "9c341f63-4409-452a-bbe4-d05a42b9bd91"); using SutType = - Sut>; + Sut>; SutType a(8791); SutType b(651); @@ -268,8 +236,7 @@ TEST(NewType, AssignByValueCopyComplexTypeDoesCompile) TEST(NewType, AssignByValueMoveDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "cf62fac7-2d7e-4a70-869b-32a3d29acd10"); - using SutType = - Sut>; + using SutType = Sut>; SutType a(8791); SutType b(651); @@ -284,7 +251,7 @@ TEST(NewType, AssignByValueMoveComplexTypeDoesCompile) { ::testing::Test::RecordProperty("TEST_ID", "dc23e4e2-833b-4cd9-80a1-28f627544836"); using SutType = - Sut>; + Sut>; SutType a(8791); SutType b(651); diff --git a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp index 45e6be2590..cd208d55e6 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp +++ b/iceoryx_posh/include/iceoryx_posh/internal/popo/building_blocks/unique_port_id.hpp @@ -17,8 +17,8 @@ #ifndef IOX_POSH_POPO_BUILDING_BLOCKS_UNIQUE_PORT_ID_HPP #define IOX_POSH_POPO_BUILDING_BLOCKS_UNIQUE_PORT_ID_HPP -#include "iceoryx_hoofs/cxx/newtype.hpp" #include "iceoryx_posh/error_handling/error_handling.hpp" +#include "iox/newtype.hpp" #include #include @@ -38,15 +38,15 @@ constexpr InvalidPortId_t InvalidPortId = InvalidPortId_t(); /// subscriber pattern where samples are exchanged over network via a third party middleware. /// The unique RouDi id must be set manually when RouDi is started and it must be ensured to be unique for a /// given instance for this feature to be used to its full extend. -class UniquePortId : public cxx::NewType +class UniquePortId : public NewType { public: using ThisType::ThisType; diff --git a/iceoryx_posh/source/popo/building_blocks/unique_port_id.cpp b/iceoryx_posh/source/popo/building_blocks/unique_port_id.cpp index 9b5268e1c3..a775a4991c 100644 --- a/iceoryx_posh/source/popo/building_blocks/unique_port_id.cpp +++ b/iceoryx_posh/source/popo/building_blocks/unique_port_id.cpp @@ -28,7 +28,7 @@ std::atomic UniquePortId::uniqueRouDiId{roudi::DEFAULT_UNIQUE_ROUDI_ID std::atomic UniquePortId::globalIDCounter{1U}; UniquePortId::UniquePortId() noexcept - : ThisType(cxx::newtype::internal::ProtectedConstructor, + : ThisType(newtype::internal::ProtectedConstructor, (static_cast(getUniqueRouDiId()) << UNIQUE_ID_BIT_LENGTH) + ((globalIDCounter.fetch_add(1u, std::memory_order_relaxed) << ROUDI_ID_BIT_LENGTH) >> ROUDI_ID_BIT_LENGTH)) @@ -44,7 +44,7 @@ UniquePortId::UniquePortId() noexcept UniquePortId::UniquePortId(InvalidPortId_t) noexcept /// we have to cast INVALID_UNIQUE_ID with static_cast otherwise it will not link /// with gcc-7.x - gcc-10.x. Who knows why?! - : ThisType(cxx::newtype::internal::ProtectedConstructor, static_cast(INVALID_UNIQUE_ID)) + : ThisType(newtype::internal::ProtectedConstructor, static_cast(INVALID_UNIQUE_ID)) { // finalizeSetUniqueRouDiId intentionally not called since the InvalidPortId does not have a unique RouDi ID anyway } From e816c36c4d33cf5ee75c04f4a9ab21d05516a831 Mon Sep 17 00:00:00 2001 From: Marika Lehmann Date: Tue, 31 Jan 2023 17:47:10 +0100 Subject: [PATCH 3/7] iox-#1391 Move builder.hpp to design folder Signed-off-by: Marika Lehmann --- .../release-notes/iceoryx-unreleased.md | 6 ++--- .../include/iox}/builder.hpp | 4 +-- .../internal/posix_wrapper/mutex.hpp | 2 +- .../shared_memory_object/shared_memory.hpp | 2 +- .../iceoryx_hoofs/posix_wrapper/file_lock.hpp | 2 +- .../posix_wrapper/named_semaphore.hpp | 2 +- .../iceoryx_hoofs/posix_wrapper/thread.hpp | 2 +- .../posix_wrapper/unnamed_semaphore.hpp | 2 +- .../iceoryx_hoofs/design_pattern/builder.hpp | 25 +++++++++++++++++++ 9 files changed, 36 insertions(+), 11 deletions(-) rename iceoryx_hoofs/{include/iceoryx_hoofs/design_pattern => design/include/iox}/builder.hpp (97%) create mode 100644 iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index 154e1b0cd8..aac3da58d2 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -77,7 +77,7 @@ - posix wrapper `SharedMemoryObject` is silent on success [\#971](https://github.com/eclipse-iceoryx/iceoryx/issues/971) - Remove creation design pattern class with in place implementation [\#1036](https://github.com/eclipse-iceoryx/iceoryx/issues/1036) - posix wrapper `SharedMemoryObject` uses builder pattern instead of creation - - Builder pattern extracted from `helplets.hpp` into `design_pattern/builder.hpp` + - Builder pattern extracted from `helplets.hpp` into `iox/builder.hpp` - Uninteresting mock function calls in tests [\#1341](https://github.com/eclipse-iceoryx/iceoryx/issues/1341) - `cxx::unique_ptr` owns deleter, remove all deleter classes [\#1143](https://github.com/eclipse-iceoryx/iceoryx/issues/1143) - Remove `iox::posix::Timer` [\#337](https://github.com/eclipse-iceoryx/iceoryx/issues/337) @@ -146,14 +146,14 @@ .create(); ``` -2. Builder pattern extracted from `helplets.hpp` into `design_pattern/builder.hpp` +2. Builder pattern extracted from `helplets.hpp` into `iox/builder.hpp` ```cpp // before #include "iceoryx_hoofs/cxx/helplets.hpp" // after - #include "iceoryx_hoofs/design_pattern/builder.hpp" + #include "iox/builder.hpp" ``` 3. `UnnamedSemaphore` replaces `Semaphore` with `CreateUnnamed*` option diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/design_pattern/builder.hpp b/iceoryx_hoofs/design/include/iox/builder.hpp similarity index 97% rename from iceoryx_hoofs/include/iceoryx_hoofs/design_pattern/builder.hpp rename to iceoryx_hoofs/design/include/iox/builder.hpp index 9282d36155..603d9b3290 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/design_pattern/builder.hpp +++ b/iceoryx_hoofs/design/include/iox/builder.hpp @@ -14,8 +14,8 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_DESIGN_PATTERN_BUILDER_HPP -#define IOX_HOOFS_DESIGN_PATTERN_BUILDER_HPP +#ifndef IOX_HOOFS_DESIGN_BUILDER_HPP +#define IOX_HOOFS_DESIGN_BUILDER_HPP /// @brief Macro which generates a setter method useful for a builder pattern. /// @param[in] type the data type of the parameter diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/mutex.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/mutex.hpp index e4b998ea1d..842460d41c 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/mutex.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/mutex.hpp @@ -17,8 +17,8 @@ #ifndef IOX_HOOFS_POSIX_WRAPPER_MUTEX_HPP #define IOX_HOOFS_POSIX_WRAPPER_MUTEX_HPP -#include "iceoryx_hoofs/design_pattern/builder.hpp" #include "iceoryx_platform/pthread.hpp" +#include "iox/builder.hpp" #include "iox/expected.hpp" #include "iox/optional.hpp" diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/shared_memory.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/shared_memory.hpp index 62ed2cb4ed..22b0706b41 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/shared_memory.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/shared_memory.hpp @@ -18,8 +18,8 @@ #define IOX_HOOFS_POSIX_WRAPPER_SHARED_MEMORY_OBJECT_SHARED_MEMORY_HPP #include "iceoryx_hoofs/cxx/filesystem.hpp" -#include "iceoryx_hoofs/design_pattern/builder.hpp" #include "iceoryx_hoofs/posix_wrapper/types.hpp" +#include "iox/builder.hpp" #include "iox/expected.hpp" #include "iox/optional.hpp" #include "iox/string.hpp" diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/file_lock.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/file_lock.hpp index c70b4bc227..b4dba1848b 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/file_lock.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/file_lock.hpp @@ -17,8 +17,8 @@ #define IOX_HOOFS_POSIX_WRAPPER_FILE_LOCK_HPP #include "iceoryx_hoofs/cxx/filesystem.hpp" -#include "iceoryx_hoofs/design_pattern/builder.hpp" #include "iceoryx_platform/file.hpp" +#include "iox/builder.hpp" #include "iox/expected.hpp" #include "iox/string.hpp" diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_semaphore.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_semaphore.hpp index c3fe1731c8..e39d4e00d8 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_semaphore.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_semaphore.hpp @@ -17,10 +17,10 @@ #define IOX_HOOFS_POSIX_WRAPPER_NAMED_SEMAPHORE_HPP #include "iceoryx_hoofs/cxx/filesystem.hpp" -#include "iceoryx_hoofs/design_pattern/builder.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/semaphore_interface.hpp" #include "iceoryx_hoofs/posix_wrapper/types.hpp" #include "iceoryx_platform/platform_settings.hpp" +#include "iox/builder.hpp" #include "iox/expected.hpp" #include "iox/optional.hpp" #include "iox/string.hpp" diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/thread.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/thread.hpp index baf50fa3aa..488a3411aa 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/thread.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/thread.hpp @@ -17,9 +17,9 @@ #define IOX_HOOFS_POSIX_WRAPPER_PTHREAD_HPP #include "iceoryx_hoofs/cxx/function.hpp" -#include "iceoryx_hoofs/design_pattern/builder.hpp" #include "iceoryx_hoofs/posix_wrapper/posix_call.hpp" #include "iceoryx_platform/pthread.hpp" +#include "iox/builder.hpp" #include "iox/expected.hpp" #include "iox/string.hpp" diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp index 414c286ed9..9bcf9d4818 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/unnamed_semaphore.hpp @@ -16,8 +16,8 @@ #ifndef IOX_HOOFS_POSIX_WRAPPER_UNNAMED_SEMAPHORE_HPP #define IOX_HOOFS_POSIX_WRAPPER_UNNAMED_SEMAPHORE_HPP -#include "iceoryx_hoofs/design_pattern/builder.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/semaphore_interface.hpp" +#include "iox/builder.hpp" #include "iox/expected.hpp" #include "iox/optional.hpp" diff --git a/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp new file mode 100644 index 0000000000..cd8b371920 --- /dev/null +++ b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp @@ -0,0 +1,25 @@ +// Copyright (c) 2023 by Apex.AI Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 + +#ifndef IOX_HOOFS_DESIGN_PATTERN_BUILDER_HPP +#define IOX_HOOFS_DESIGN_PATTERN_BUILDER_HPP + +#include "iox/builder.hpp" +/// @todo iox-#1593 Deprecate include +/// [[deprecated("Deprecated in 3.0, removed in 4.0, please include 'iox/builder.hpp' instead")]] + +#endif + From bff8ee82a246a9bb836d5cddf97d57d2f13b212a Mon Sep 17 00:00:00 2001 From: Marika Lehmann Date: Tue, 31 Jan 2023 19:28:13 +0100 Subject: [PATCH 4/7] iox-#1391 Move functional interface files Signed-off-by: Marika Lehmann --- .../release-notes/iceoryx-unreleased.md | 2 +- iceoryx_hoofs/BUILD.bazel | 1 + iceoryx_hoofs/CMakeLists.txt | 2 +- .../iox/detail}/functional_interface.inl | 17 ++--- .../include/iox}/functional_interface.hpp | 9 +-- .../source}/functional_interface.cpp | 5 +- .../cxx/functional_interface.hpp | 66 +++++++++++++++++++ .../iceoryx_hoofs/design_pattern/builder.hpp | 1 - ..._design_functional_interface_and_then.cpp} | 8 +-- ...st_design_functional_interface_common.cpp} | 6 +- ...st_design_functional_interface_common.hpp} | 14 ++-- ...ional_interface_concat_multiple_calls.cpp} | 8 +-- ...st_design_functional_interface_expect.cpp} | 6 +- ...t_design_functional_interface_or_else.cpp} | 8 +-- ...est_design_functional_interface_types.cpp} | 6 +- ...est_design_functional_interface_types.hpp} | 10 +-- ..._design_functional_interface_value_or.cpp} | 6 +- .../vocabulary/include/iox/expected.hpp | 6 +- .../vocabulary/include/iox/optional.hpp | 4 +- 19 files changed, 121 insertions(+), 64 deletions(-) rename iceoryx_hoofs/{include/iceoryx_hoofs/internal/cxx => design/include/iox/detail}/functional_interface.inl (95%) rename iceoryx_hoofs/{include/iceoryx_hoofs/cxx => design/include/iox}/functional_interface.hpp (99%) rename iceoryx_hoofs/{source/cxx => design/source}/functional_interface.cpp (92%) create mode 100644 iceoryx_hoofs/legacy/include/iceoryx_hoofs/cxx/functional_interface.hpp rename iceoryx_hoofs/test/moduletests/{test_cxx_functional_interface_and_then.cpp => test_design_functional_interface_and_then.cpp} (95%) rename iceoryx_hoofs/test/moduletests/{test_cxx_functional_interface_common.cpp => test_design_functional_interface_common.cpp} (95%) rename iceoryx_hoofs/test/moduletests/{test_cxx_functional_interface_common.hpp => test_design_functional_interface_common.hpp} (85%) rename iceoryx_hoofs/test/moduletests/{test_cxx_functional_interface_concat_multiple_calls.cpp => test_design_functional_interface_concat_multiple_calls.cpp} (96%) rename iceoryx_hoofs/test/moduletests/{test_cxx_functional_interface_expect.cpp => test_design_functional_interface_expect.cpp} (97%) rename iceoryx_hoofs/test/moduletests/{test_cxx_functional_interface_or_else.cpp => test_design_functional_interface_or_else.cpp} (95%) rename iceoryx_hoofs/test/moduletests/{test_cxx_functional_interface_types.cpp => test_design_functional_interface_types.cpp} (97%) rename iceoryx_hoofs/test/moduletests/{test_cxx_functional_interface_types.hpp => test_design_functional_interface_types.hpp} (94%) rename iceoryx_hoofs/test/moduletests/{test_cxx_functional_interface_value_or.cpp => test_design_functional_interface_value_or.cpp} (94%) diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index aac3da58d2..8d9dab81c7 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -220,7 +220,7 @@ via a pointer to `FunctionalInterface` ```cpp - iox::cxx::FunctionalInterface, MyClass, void>* soSmart = + iox::FunctionalInterface, MyClass, void>* soSmart = new iox::optional{}; delete soSmart; // <- not possible anymore diff --git a/iceoryx_hoofs/BUILD.bazel b/iceoryx_hoofs/BUILD.bazel index aceae39d9b..6d20ce0562 100644 --- a/iceoryx_hoofs/BUILD.bazel +++ b/iceoryx_hoofs/BUILD.bazel @@ -34,6 +34,7 @@ cc_library( "vocabulary/source/**/*.cpp", "source/**/*.hpp", "memory/source/*.cpp", + "design/source/*.cpp", ]), hdrs = glob(["include/**"]) + glob(["legacy/**"]) + glob(["memory/**"]) + glob(["container/**"]) + glob(["vocabulary/**"]) + glob(["utility/**"]) + glob(["primitives/**"]) + glob(["design/**"]) + [ ":iceoryx_hoofs_deployment_hpp", diff --git a/iceoryx_hoofs/CMakeLists.txt b/iceoryx_hoofs/CMakeLists.txt index 93cc9c0740..b266291efc 100644 --- a/iceoryx_hoofs/CMakeLists.txt +++ b/iceoryx_hoofs/CMakeLists.txt @@ -69,7 +69,6 @@ iox_add_library( source/cxx/adaptive_wait.cpp source/cxx/deadline_timer.cpp source/cxx/filesystem.cpp - source/cxx/functional_interface.cpp source/cxx/requires.cpp source/cxx/type_traits.cpp source/cxx/unique_id.cpp @@ -97,6 +96,7 @@ iox_add_library( source/units/duration.cpp memory/source/bump_allocator.cpp memory/source/memory.cpp + design/source/functional_interface.cpp ) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/iceoryx_hoofs_deployment.hpp.in" diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/functional_interface.inl b/iceoryx_hoofs/design/include/iox/detail/functional_interface.inl similarity index 95% rename from iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/functional_interface.inl rename to iceoryx_hoofs/design/include/iox/detail/functional_interface.inl index e963c4f681..84fbf91b71 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/functional_interface.inl +++ b/iceoryx_hoofs/design/include/iox/detail/functional_interface.inl @@ -14,16 +14,14 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_FUNCTIONAL_INTERFACE_INL -#define IOX_HOOFS_CXX_FUNCTIONAL_INTERFACE_INL +#ifndef IOX_HOOFS_DESIGN_FUNCTIONAL_INTERFACE_INL +#define IOX_HOOFS_DESIGN_FUNCTIONAL_INTERFACE_INL -#include "iceoryx_hoofs/cxx/functional_interface.hpp" #include "iox/detail/string_type_traits.hpp" +#include "iox/functional_interface.hpp" namespace iox { -namespace cxx -{ namespace internal { /////////////// @@ -33,7 +31,7 @@ template template inline void Expect::expect(const StringType& msg) const noexcept { - static_assert(is_char_array::value || is_cxx_string::value, + static_assert(cxx::is_char_array::value || is_cxx_string::value, "Only char arrays and iox::strings are allowed as message type."); const auto& derivedThis = *static_cast(this); @@ -41,7 +39,7 @@ inline void Expect::expect(const StringType& msg) const noexcept if (!derivedThis) { print_expect_message(&msg[0]); - Ensures(false); + cxx::Ensures(false); } } @@ -49,7 +47,7 @@ template template inline ValueType& ExpectWithValue::expect(const StringType& msg) & noexcept { - static_assert(is_char_array::value || is_cxx_string::value, + static_assert(cxx::is_char_array::value || is_cxx_string::value, "Only char arrays and iox::strings are allowed as message type."); auto& derivedThis = *static_cast(this); @@ -57,7 +55,7 @@ inline ValueType& ExpectWithValue::expect(const StringType& if (!derivedThis) { print_expect_message(&msg[0]); - Ensures(false); + cxx::Ensures(false); } return derivedThis.value(); @@ -312,6 +310,5 @@ inline const Derived&& OrElse::or_else(const or_else_callback_t& callab } // namespace internal -} // namespace cxx } // namespace iox #endif diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/functional_interface.hpp b/iceoryx_hoofs/design/include/iox/functional_interface.hpp similarity index 99% rename from iceoryx_hoofs/include/iceoryx_hoofs/cxx/functional_interface.hpp rename to iceoryx_hoofs/design/include/iox/functional_interface.hpp index 3de1b95ed0..2b80d3da8e 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/cxx/functional_interface.hpp +++ b/iceoryx_hoofs/design/include/iox/functional_interface.hpp @@ -13,8 +13,8 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_CXX_FUNCTIONAL_POLICY_HPP -#define IOX_HOOFS_CXX_FUNCTIONAL_POLICY_HPP +#ifndef IOX_HOOFS_DESIGN_FUNCTIONAL_INTERFACE_HPP +#define IOX_HOOFS_DESIGN_FUNCTIONAL_INTERFACE_HPP #include "iceoryx_hoofs/cxx/function_ref.hpp" #include "iceoryx_hoofs/cxx/type_traits.hpp" @@ -24,8 +24,6 @@ namespace iox { -namespace cxx -{ namespace internal { template @@ -434,9 +432,8 @@ struct FunctionalInterfaceImpl template using FunctionalInterface = internal::FunctionalInterfaceImpl; -} // namespace cxx } // namespace iox -#include "iceoryx_hoofs/internal/cxx/functional_interface.inl" +#include "iox/detail/functional_interface.inl" #endif diff --git a/iceoryx_hoofs/source/cxx/functional_interface.cpp b/iceoryx_hoofs/design/source/functional_interface.cpp similarity index 92% rename from iceoryx_hoofs/source/cxx/functional_interface.cpp rename to iceoryx_hoofs/design/source/functional_interface.cpp index bd2fa1b89e..e0404571dc 100644 --- a/iceoryx_hoofs/source/cxx/functional_interface.cpp +++ b/iceoryx_hoofs/design/source/functional_interface.cpp @@ -14,13 +14,11 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "iceoryx_hoofs/cxx/functional_interface.hpp" +#include "iox/functional_interface.hpp" #include "iceoryx_hoofs/log/logging.hpp" namespace iox { -namespace cxx -{ namespace internal { // AXIVION Next Construct AutosarC++19_03-A3.9.1 : See rational in header @@ -31,5 +29,4 @@ void print_expect_message(const char* message) noexcept IOX_LOG(FATAL) << message; } } // namespace internal -} // namespace cxx } // namespace iox diff --git a/iceoryx_hoofs/legacy/include/iceoryx_hoofs/cxx/functional_interface.hpp b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/cxx/functional_interface.hpp new file mode 100644 index 0000000000..ebcf4c4426 --- /dev/null +++ b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/cxx/functional_interface.hpp @@ -0,0 +1,66 @@ +// Copyright (c) 2023 by Apex.AI Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// SPDX-License-Identifier: Apache-2.0 +#ifndef IOX_HOOFS_CXX_FUNCTIONAL_INTERFACE_HPP +#define IOX_HOOFS_CXX_FUNCTIONAL_INTERFACE_HPP + +#include "iox/functional_interface.hpp" + +namespace iox +{ +/// @todo iox-#1593 Deprecate include +/// [[deprecated("Deprecated in 3.0, removed in 4.0, please include 'iox/functional_interface.hpp' instead")]] +namespace cxx +{ +namespace internal +{ +/// @deprecated use `iox::internal::HasValueMethod` instead of `iox::cxx::internal::HasValueMethod` +using iox::internal::HasValueMethod; + +/// @deprecated use `iox::internal::HasGetErrorMethod` instead of `iox::cxx::internal::HasGetErrorMethod` +using iox::internal::HasGetErrorMethod; + +/// @deprecated use `iox::internal::Expect` instead of `iox::cxx::internal::Expect` +using iox::internal::Expect; + +/// @deprecated use `iox::internal::ExpectWithValue` instead of `iox::cxx::internal::ExpectWithValue` +using iox::internal::ExpectWithValue; + +/// @deprecated use `iox::internal::ValueOr` instead of `iox::cxx::internal::ValueOr` +using iox::internal::ValueOr; + +/// @deprecated use `iox::internal::AndThenWithValue` instead of `iox::cxx::internal::AndThenWithValue` +using iox::internal::AndThenWithValue; + +/// @deprecated use `iox::internal::AndThen` instead of `iox::cxx::internal::AndThen` +using iox::internal::AndThen; + +/// @deprecated use `iox::internal::OrElseWithValue` instead of `iox::cxx::internal::OrElseWithValue` +using iox::internal::OrElseWithValue; + +/// @deprecated use `iox::internal::OrElse` instead of `iox::cxx::internal::OrElse` +using iox::internal::OrElse; + +/// @deprecated use `iox::internal::FunctionalInterfaceImpl` instead of `iox::cxx::internal::FunctionalInterfaceImpl` +using iox::internal::FunctionalInterfaceImpl; +} // namespace internal + +/// @deprecated use `iox::FunctionalInterface` instead of `iox::cxx::FunctionalInterface` +using iox::FunctionalInterface; + +} // namespace cxx +} // namespace iox + +#endif diff --git a/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp index cd8b371920..1e38a75b9b 100644 --- a/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp +++ b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp @@ -22,4 +22,3 @@ /// [[deprecated("Deprecated in 3.0, removed in 4.0, please include 'iox/builder.hpp' instead")]] #endif - diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_and_then.cpp b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_and_then.cpp similarity index 95% rename from iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_and_then.cpp rename to iceoryx_hoofs/test/moduletests/test_design_functional_interface_and_then.cpp index 30e7519928..4040c44671 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_and_then.cpp +++ b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_and_then.cpp @@ -14,18 +14,18 @@ // // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_hoofs/testing/expect_no_death.hpp" -#include "test_cxx_functional_interface_types.hpp" +#include "test_design_functional_interface_types.hpp" namespace { -using namespace test_cxx_functional_interface; +using namespace test_design_functional_interface; using namespace ::testing; TYPED_TEST(FunctionalInterface_test, AndThenHasCorrectSignature) { ::testing::Test::RecordProperty("TEST_ID", "7636fda5-090f-4dd6-b3a0-3d71bdbca787"); using Factory = typename TestFixture::TestFactoryType; - constexpr bool DOES_AND_THEN_HAVE_A_VALUE = iox::cxx::internal::HasValueMethod::value; + constexpr bool DOES_AND_THEN_HAVE_A_VALUE = iox::internal::HasValueMethod::value; EXPECT_THAT(DOES_AND_THEN_HAVE_A_VALUE, Eq(Factory::EXPECT_AND_THEN_WITH_VALUE)); } @@ -36,7 +36,7 @@ TYPED_TEST(FunctionalInterface_test, AndThenHasCorrectSignature) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define IOX_TEST_FUNCTIONAL_INTERFACE(TestName, variationPoint) \ using SutType = typename TestFixture::TestFactoryType::Type; \ - constexpr bool HAS_VALUE_METHOD = iox::cxx::internal::HasValueMethod::value; \ + constexpr bool HAS_VALUE_METHOD = iox::internal::HasValueMethod::value; \ /* NOLINTNEXTLINE(bugprone-macro-parentheses) prevents clang-tidy parsing failures */ \ TestName::template performTest( \ [](auto& sut, auto callback) { (variationPoint).and_then(callback); }) diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_common.cpp b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_common.cpp similarity index 95% rename from iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_common.cpp rename to iceoryx_hoofs/test/moduletests/test_design_functional_interface_common.cpp index 379f2e3b73..3dcde897f8 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_common.cpp +++ b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_common.cpp @@ -14,9 +14,9 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "test_cxx_functional_interface_common.hpp" +#include "test_design_functional_interface_common.hpp" -namespace test_cxx_functional_interface +namespace test_design_functional_interface { // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) only for testing purposes GenericValueError::GenericValueError(const value_t value, const error_t error) noexcept @@ -95,4 +95,4 @@ GenericPlain::operator bool() const noexcept } -} // namespace test_cxx_functional_interface +} // namespace test_design_functional_interface diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_common.hpp b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_common.hpp similarity index 85% rename from iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_common.hpp rename to iceoryx_hoofs/test/moduletests/test_design_functional_interface_common.hpp index 07193e677c..5fb6f49648 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_common.hpp +++ b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_common.hpp @@ -14,13 +14,13 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_MODULETESTS_TEST_CXX_FUNCTIONAL_INTERFACE_COMMON_HPP -#define IOX_HOOFS_MODULETESTS_TEST_CXX_FUNCTIONAL_INTERFACE_COMMON_HPP +#ifndef IOX_HOOFS_MODULETESTS_TEST_DESIGN_FUNCTIONAL_INTERFACE_COMMON_HPP +#define IOX_HOOFS_MODULETESTS_TEST_DESIGN_FUNCTIONAL_INTERFACE_COMMON_HPP -#include "iceoryx_hoofs/cxx/functional_interface.hpp" +#include "iox/functional_interface.hpp" #include "test.hpp" -namespace test_cxx_functional_interface +namespace test_design_functional_interface { /// @brief Every test file uses this as a common base and extends the TYPED_TEST /// for a specific part of the functional interface. @@ -52,7 +52,7 @@ class FunctionalInterface_test : public testing::Test /// @brief This types is used for testing the functional interface in the case /// of a value and a get_error method -struct GenericValueError : public iox::cxx::FunctionalInterface +struct GenericValueError : public iox::FunctionalInterface { using value_t = int; using error_t = int; @@ -80,7 +80,7 @@ struct GenericValueError : public iox::cxx::FunctionalInterface +struct GenericPlain : public iox::FunctionalInterface { static constexpr int VALID_VALUE = 5; static constexpr int INVALID_VALUE = 0; @@ -92,6 +92,6 @@ struct GenericPlain : public iox::cxx::FunctionalInterface::value; \ - constexpr bool HAS_GET_ERROR_METHOD = iox::cxx::internal::HasGetErrorMethod::value; \ + constexpr bool HAS_VALUE_METHOD = iox::internal::HasValueMethod::value; \ + constexpr bool HAS_GET_ERROR_METHOD = iox::internal::HasGetErrorMethod::value; \ /* NOLINTNEXTLINE(bugprone-macro-parentheses) prevents clang-tidy parsing failures */ \ TestName::template performTest( \ [](auto& sut, auto andThenCallback, auto orElseCallback) { \ diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_expect.cpp similarity index 97% rename from iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp rename to iceoryx_hoofs/test/moduletests/test_design_functional_interface_expect.cpp index 208271717a..ae5403acc1 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_expect.cpp +++ b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_expect.cpp @@ -16,11 +16,11 @@ // #include "iceoryx_hoofs/error_handling/error_handling.hpp" #include "iceoryx_hoofs/testing/mocks/error_handler_mock.hpp" -#include "test_cxx_functional_interface_types.hpp" +#include "test_design_functional_interface_types.hpp" namespace { -using namespace test_cxx_functional_interface; +using namespace test_design_functional_interface; using namespace ::testing; // the macro is used as code generator to make the tests more readable. because of the @@ -153,7 +153,7 @@ struct ExpectReturnsValueWhenValid // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define IOX_TEST_FUNCTIONAL_INTERFACE(TestName, variationPoint) \ using SutType = typename TestFixture::TestFactoryType::Type; \ - constexpr bool HAS_VALUE_METHOD = iox::cxx::internal::HasValueMethod::value; \ + constexpr bool HAS_VALUE_METHOD = iox::internal::HasValueMethod::value; \ /* NOLINTNEXTLINE(bugprone-macro-parentheses) prevents clang-tidy parsing failures */ \ TestName::template performTest([](auto& sut) { \ return (variationPoint) \ diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_or_else.cpp b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_or_else.cpp similarity index 95% rename from iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_or_else.cpp rename to iceoryx_hoofs/test/moduletests/test_design_functional_interface_or_else.cpp index 431a01b5ba..9cc9e82c31 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_or_else.cpp +++ b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_or_else.cpp @@ -14,18 +14,18 @@ // // SPDX-License-Identifier: Apache-2.0 #include "iceoryx_hoofs/testing/expect_no_death.hpp" -#include "test_cxx_functional_interface_types.hpp" +#include "test_design_functional_interface_types.hpp" namespace { -using namespace test_cxx_functional_interface; +using namespace test_design_functional_interface; using namespace ::testing; TYPED_TEST(FunctionalInterface_test, OrElseHasCorrectSignature) { ::testing::Test::RecordProperty("TEST_ID", "ede81b23-cd69-45a4-86aa-b81baa8e281b"); using Factory = typename TestFixture::TestFactoryType; - constexpr bool DOES_OR_ELSE_HAVE_A_VALUE = iox::cxx::internal::HasGetErrorMethod::value; + constexpr bool DOES_OR_ELSE_HAVE_A_VALUE = iox::internal::HasGetErrorMethod::value; EXPECT_THAT(DOES_OR_ELSE_HAVE_A_VALUE, Eq(Factory::EXPECT_OR_ELSE_WITH_VALUE)); } @@ -36,7 +36,7 @@ TYPED_TEST(FunctionalInterface_test, OrElseHasCorrectSignature) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define IOX_TEST_FUNCTIONAL_INTERFACE(TestName, variationPoint) \ using SutType = typename TestFixture::TestFactoryType::Type; \ - constexpr bool HAS_GET_ERROR_METHOD = iox::cxx::internal::HasGetErrorMethod::value; \ + constexpr bool HAS_GET_ERROR_METHOD = iox::internal::HasGetErrorMethod::value; \ /* NOLINTNEXTLINE(bugprone-macro-parentheses) prevents clang-tidy parsing failures */ \ TestName::template performTest( \ [](auto& sut, auto callback) { (variationPoint).or_else(callback); }) diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_types.cpp b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_types.cpp similarity index 97% rename from iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_types.cpp rename to iceoryx_hoofs/test/moduletests/test_design_functional_interface_types.cpp index eca7021d71..cff2c60041 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_types.cpp +++ b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_types.cpp @@ -14,9 +14,9 @@ // // SPDX-License-Identifier: Apache-2.0 -#include "test_cxx_functional_interface_types.hpp" +#include "test_design_functional_interface_types.hpp" -namespace test_cxx_functional_interface +namespace test_design_functional_interface { ////////////////////////////////// /// BEGIN GenericValueErrorFactory @@ -165,4 +165,4 @@ ExpectedErrorFactory::Type ExpectedErrorFactory::createInvalidObject() noexcept //////////////////////////// -} // namespace test_cxx_functional_interface +} // namespace test_design_functional_interface diff --git a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_types.hpp b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_types.hpp similarity index 94% rename from iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_types.hpp rename to iceoryx_hoofs/test/moduletests/test_design_functional_interface_types.hpp index 4eec3ef8e9..5d156b52aa 100644 --- a/iceoryx_hoofs/test/moduletests/test_cxx_functional_interface_types.hpp +++ b/iceoryx_hoofs/test/moduletests/test_design_functional_interface_types.hpp @@ -14,14 +14,14 @@ // // SPDX-License-Identifier: Apache-2.0 -#ifndef IOX_HOOFS_MODULETESTS_TEST_CXX_FUNCTIONAL_INTERFACE_TYPES_HPP -#define IOX_HOOFS_MODULETESTS_TEST_CXX_FUNCTIONAL_INTERFACE_TYPES_HPP +#ifndef IOX_HOOFS_MODULETESTS_TEST_DESIGN_FUNCTIONAL_INTERFACE_TYPES_HPP +#define IOX_HOOFS_MODULETESTS_TEST_DESIGN_FUNCTIONAL_INTERFACE_TYPES_HPP #include "iox/expected.hpp" #include "iox/optional.hpp" -#include "test_cxx_functional_interface_common.hpp" +#include "test_design_functional_interface_common.hpp" -namespace test_cxx_functional_interface +namespace test_design_functional_interface { struct GenericValueErrorFactory { @@ -160,6 +160,6 @@ using FunctionalInterfaceImplementations = testing::Types::value; \ + constexpr bool HAS_VALUE_METHOD = iox::internal::HasValueMethod::value; \ ValueOrReturnsValueWhenValid::template performTest( \ [](auto& sut, auto alternativeValue) { return (variationPoint).value_or(alternativeValue); }); diff --git a/iceoryx_hoofs/vocabulary/include/iox/expected.hpp b/iceoryx_hoofs/vocabulary/include/iox/expected.hpp index 775599ce63..839cb7d03e 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/expected.hpp +++ b/iceoryx_hoofs/vocabulary/include/iox/expected.hpp @@ -18,7 +18,7 @@ #define IOX_HOOFS_VOCABULARY_EXPECTED_HPP #include "iceoryx_hoofs/cxx/attributes.hpp" -#include "iceoryx_hoofs/cxx/functional_interface.hpp" +#include "iox/functional_interface.hpp" #include "iox/optional.hpp" #include "iox/variant.hpp" @@ -133,7 +133,7 @@ class IOX_NO_DISCARD expected; /// allHailHypnotoad->push_back(7); /// @endcode template -class IOX_NO_DISCARD expected final : public cxx::FunctionalInterface, void, ErrorType> +class IOX_NO_DISCARD expected final : public FunctionalInterface, void, ErrorType> { public: /// @brief default ctor is deleted since you have to clearly state if the @@ -260,7 +260,7 @@ class IOX_NO_DISCARD expected final : public cxx::FunctionalInterface /// @param ErrorType type of the error which can be stored in the expected template class IOX_NO_DISCARD expected final - : public cxx::FunctionalInterface, ValueType, ErrorType> + : public FunctionalInterface, ValueType, ErrorType> { public: /// @brief default ctor is deleted since you have to clearly state if the diff --git a/iceoryx_hoofs/vocabulary/include/iox/optional.hpp b/iceoryx_hoofs/vocabulary/include/iox/optional.hpp index 7693d7ed90..686459752c 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/optional.hpp +++ b/iceoryx_hoofs/vocabulary/include/iox/optional.hpp @@ -17,9 +17,9 @@ #ifndef IOX_HOOFS_VOCABULARY_OPTIONAL_HPP #define IOX_HOOFS_VOCABULARY_OPTIONAL_HPP -#include "iceoryx_hoofs/cxx/functional_interface.hpp" #include "iceoryx_hoofs/cxx/requires.hpp" #include "iceoryx_hoofs/iceoryx_hoofs_types.hpp" +#include "iox/functional_interface.hpp" #include // needed for placement new in the construct_value member function #include @@ -68,7 +68,7 @@ constexpr in_place_t in_place{}; /// } /// @endcode template -class optional final : public cxx::FunctionalInterface, T, void> +class optional final : public FunctionalInterface, T, void> { public: using type = T; From 55d8a1dc167429debd4ce83cbc63960e4f4ed019 Mon Sep 17 00:00:00 2001 From: Marika Lehmann Date: Wed, 1 Feb 2023 14:29:19 +0100 Subject: [PATCH 5/7] iox-#1391 Fix Bazel build Signed-off-by: Marika Lehmann --- iceoryx_hoofs/BUILD.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iceoryx_hoofs/BUILD.bazel b/iceoryx_hoofs/BUILD.bazel index 6d20ce0562..d43ccc06e7 100644 --- a/iceoryx_hoofs/BUILD.bazel +++ b/iceoryx_hoofs/BUILD.bazel @@ -41,13 +41,13 @@ cc_library( ], includes = [ "container/include/", + "design/include", "include/", "legacy/include/", "memory/include/", "primitives/include/", "utility/include/", "vocabulary/include/", - "design/include", ], linkopts = select({ "//iceoryx_platform:linux-clang": [ From 1b9030f70d08911d4d0b3ea72094bd529a622808 Mon Sep 17 00:00:00 2001 From: Marika Lehmann Date: Wed, 1 Feb 2023 16:55:41 +0100 Subject: [PATCH 6/7] iox-#1391 Use absolute include paths, adapt deprecating Signed-off-by: Marika Lehmann --- .../include/iox/detail/newtype/comparable.hpp | 3 ++- .../design/include/iox/detail/newtype/sortable.hpp | 3 ++- iceoryx_hoofs/design/include/iox/newtype.hpp | 14 +++++++------- .../iceoryx_hoofs/design_pattern/builder.hpp | 3 +-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/iceoryx_hoofs/design/include/iox/detail/newtype/comparable.hpp b/iceoryx_hoofs/design/include/iox/detail/newtype/comparable.hpp index 2817d8910c..f3d4110f69 100644 --- a/iceoryx_hoofs/design/include/iox/detail/newtype/comparable.hpp +++ b/iceoryx_hoofs/design/include/iox/detail/newtype/comparable.hpp @@ -16,7 +16,8 @@ // SPDX-License-Identifier: Apache-2.0 #ifndef IOX_HOOFS_DESIGN_NEWTYPE_COMPARABLE_HPP #define IOX_HOOFS_DESIGN_NEWTYPE_COMPARABLE_HPP -#include "internal.hpp" + +#include "iox/detail/newtype/internal.hpp" namespace iox { diff --git a/iceoryx_hoofs/design/include/iox/detail/newtype/sortable.hpp b/iceoryx_hoofs/design/include/iox/detail/newtype/sortable.hpp index 3eb8667f02..33ee245d07 100644 --- a/iceoryx_hoofs/design/include/iox/detail/newtype/sortable.hpp +++ b/iceoryx_hoofs/design/include/iox/detail/newtype/sortable.hpp @@ -16,7 +16,8 @@ // SPDX-License-Identifier: Apache-2.0 #ifndef IOX_HOOFS_DESIGN_NEWTYPE_SORTABLE_HPP #define IOX_HOOFS_DESIGN_NEWTYPE_SORTABLE_HPP -#include "internal.hpp" + +#include "iox/detail/newtype/internal.hpp" namespace iox { diff --git a/iceoryx_hoofs/design/include/iox/newtype.hpp b/iceoryx_hoofs/design/include/iox/newtype.hpp index 47ca92edd2..0e4ea72893 100644 --- a/iceoryx_hoofs/design/include/iox/newtype.hpp +++ b/iceoryx_hoofs/design/include/iox/newtype.hpp @@ -17,14 +17,14 @@ #ifndef IOX_HOOFS_DESIGN_NEWTYPE_HPP #define IOX_HOOFS_DESIGN_NEWTYPE_HPP -#include "detail/newtype/assignment.hpp" -#include "detail/newtype/comparable.hpp" -#include "detail/newtype/constructor.hpp" -#include "detail/newtype/convertable.hpp" -#include "detail/newtype/internal.hpp" -#include "detail/newtype/protected_constructor.hpp" -#include "detail/newtype/sortable.hpp" #include "iceoryx_hoofs/cxx/algorithm.hpp" +#include "iox/detail/newtype/assignment.hpp" +#include "iox/detail/newtype/comparable.hpp" +#include "iox/detail/newtype/constructor.hpp" +#include "iox/detail/newtype/convertable.hpp" +#include "iox/detail/newtype/internal.hpp" +#include "iox/detail/newtype/protected_constructor.hpp" +#include "iox/detail/newtype/sortable.hpp" namespace iox { diff --git a/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp index 1e38a75b9b..70f665595d 100644 --- a/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp +++ b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp @@ -18,7 +18,6 @@ #define IOX_HOOFS_DESIGN_PATTERN_BUILDER_HPP #include "iox/builder.hpp" -/// @todo iox-#1593 Deprecate include -/// [[deprecated("Deprecated in 3.0, removed in 4.0, please include 'iox/builder.hpp' instead")]] +/// @deprecated please include 'iox/builder.hpp' instead of 'iceoryx_hoofs/design_pattern/builder.hpp' #endif From d880c2d8c16abbc792098ad6e6896331f4055ac7 Mon Sep 17 00:00:00 2001 From: Marika Lehmann Date: Fri, 3 Feb 2023 09:23:40 +0100 Subject: [PATCH 7/7] iox-#1391 Use pragma message, adapt two overlooked include paths Signed-off-by: Marika Lehmann --- .../internal/posix_wrapper/shared_memory_object.hpp | 2 +- .../internal/posix_wrapper/shared_memory_object/memory_map.hpp | 2 +- .../legacy/include/iceoryx_hoofs/design_pattern/builder.hpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object.hpp index af506cc43e..2f72a0ad19 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object.hpp @@ -18,10 +18,10 @@ #define IOX_HOOFS_POSIX_WRAPPER_SHARED_MEMORY_OBJECT_HPP #include "iceoryx_hoofs/cxx/filesystem.hpp" -#include "iceoryx_hoofs/design_pattern/builder.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/memory_map.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/shared_memory.hpp" #include "iceoryx_platform/stat.hpp" +#include "iox/builder.hpp" #include "iox/bump_allocator.hpp" #include "iox/optional.hpp" diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/memory_map.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/memory_map.hpp index 13ac2e45fa..6ed3ecb197 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/memory_map.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/memory_map.hpp @@ -17,9 +17,9 @@ #ifndef IOX_HOOFS_POSIX_WRAPPER_SHARED_MEMORY_OBJECT_MEMORY_MAP_HPP #define IOX_HOOFS_POSIX_WRAPPER_SHARED_MEMORY_OBJECT_MEMORY_MAP_HPP -#include "iceoryx_hoofs/design_pattern/builder.hpp" #include "iceoryx_hoofs/internal/posix_wrapper/shared_memory_object/shared_memory.hpp" #include "iceoryx_platform/mman.hpp" +#include "iox/builder.hpp" #include diff --git a/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp index 70f665595d..a6d32e6753 100644 --- a/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp +++ b/iceoryx_hoofs/legacy/include/iceoryx_hoofs/design_pattern/builder.hpp @@ -18,6 +18,7 @@ #define IOX_HOOFS_DESIGN_PATTERN_BUILDER_HPP #include "iox/builder.hpp" -/// @deprecated please include 'iox/builder.hpp' instead of 'iceoryx_hoofs/design_pattern/builder.hpp' +#pragma message( \ + "Deprecated in 3.0, removed in 4.0, please include 'iox/builder.hpp' instead of 'iceoryx_hoofs/design_pattern/builder.hpp'") #endif