Skip to content

Commit

Permalink
Merge pull request eclipse-iceoryx#1865 from ApexAI/iox-1391-move-des…
Browse files Browse the repository at this point in the history
…ign-types-to-separate-module

iox-1391 move design types to separate module
  • Loading branch information
FerdinandSpitzschnueffler authored Feb 3, 2023
2 parents 2dd519c + d880c2d commit 5c55953
Show file tree
Hide file tree
Showing 46 changed files with 319 additions and 225 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy-diff-scans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions doc/website/release-notes/iceoryx-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -220,7 +220,7 @@
via a pointer to `FunctionalInterface`

```cpp
iox::cxx::FunctionalInterface<iox::optional<MyClass>, MyClass, void>* soSmart =
iox::FunctionalInterface<iox::optional<MyClass>, MyClass, void>* soSmart =
new iox::optional<MyClass>{};

delete soSmart; // <- not possible anymore
Expand All @@ -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<uint64_t, iox::cxx::newtype::ConstructByValueCopy>
struct Foo : public iox::NewType<uint64_t, iox::newtype::ConstructByValueCopy>
{
using ThisType::ThisType;
};

iox::cxx::NewType<uint64_t, iox::cxx::newtype::ConstructByValueCopy>* soSmart = new Foo{42};
iox::NewType<uint64_t, iox::newtype::ConstructByValueCopy>* soSmart = new Foo{42};

delete soSmart; // <- not possible anymore
```
Expand All @@ -244,17 +244,17 @@
```cpp
// before
// for the compiler Foo and Bar are the same type
using Foo = iox::cxx::NewType<uint64_t, iox::cxx::newtype::ConstructByValueCopy>;
using Bar = iox::cxx::NewType<uint64_t, iox::cxx::newtype::ConstructByValueCopy>;
using Foo = iox::NewType<uint64_t, iox::newtype::ConstructByValueCopy>;
using Bar = iox::NewType<uint64_t, iox::newtype::ConstructByValueCopy>;
// after
// compile time error when Foo and Bar are mixed up
struct Foo : public iox::cxx::NewType<uint64_t, iox::cxx::newtype::ConstructByValueCopy>
struct Foo : public iox::NewType<uint64_t, iox::newtype::ConstructByValueCopy>
{
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.
Expand Down
4 changes: 3 additions & 1 deletion iceoryx_hoofs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ 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/**"]) + [
hdrs = glob(["include/**"]) + glob(["legacy/**"]) + glob(["memory/**"]) + glob(["container/**"]) + glob(["vocabulary/**"]) + glob(["utility/**"]) + glob(["primitives/**"]) + glob(["design/**"]) + [
":iceoryx_hoofs_deployment_hpp",
],
includes = [
"container/include/",
"design/include",
"include/",
"legacy/include/",
"memory/include/",
Expand Down
4 changes: 3 additions & 1 deletion iceoryx_hoofs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -62,12 +63,12 @@ iox_add_library(
vocabulary/include/
utility/include/
primitives/include/
design/include/
FILES
source/concurrent/loffli.cpp
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
Expand Down Expand Up @@ -95,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"
Expand Down
1 change: 1 addition & 0 deletions iceoryx_hoofs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
///////////////
Expand All @@ -33,31 +31,31 @@ template <typename Derived>
template <typename StringType>
inline void Expect<Derived>::expect(const StringType& msg) const noexcept
{
static_assert(is_char_array<StringType>::value || is_cxx_string<StringType>::value,
static_assert(cxx::is_char_array<StringType>::value || is_cxx_string<StringType>::value,
"Only char arrays and iox::strings are allowed as message type.");

const auto& derivedThis = *static_cast<const Derived*>(this);

if (!derivedThis)
{
print_expect_message(&msg[0]);
Ensures(false);
cxx::Ensures(false);
}
}

template <typename Derived, typename ValueType>
template <typename StringType>
inline ValueType& ExpectWithValue<Derived, ValueType>::expect(const StringType& msg) & noexcept
{
static_assert(is_char_array<StringType>::value || is_cxx_string<StringType>::value,
static_assert(cxx::is_char_array<StringType>::value || is_cxx_string<StringType>::value,
"Only char arrays and iox::strings are allowed as message type.");

auto& derivedThis = *static_cast<Derived*>(this);

if (!derivedThis)
{
print_expect_message(&msg[0]);
Ensures(false);
cxx::Ensures(false);
}

return derivedThis.value();
Expand Down Expand Up @@ -312,6 +310,5 @@ inline const Derived&& OrElse<Derived>::or_else(const or_else_callback_t& callab


} // namespace internal
} // namespace cxx
} // namespace iox
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename T, template <typename> 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
Expand Down Expand Up @@ -118,7 +116,6 @@ inline NewType<T, Policies...>::operator T() const noexcept
return m_value;
}

} // namespace cxx
} // namespace iox

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename>
Expand Down Expand Up @@ -76,7 +74,6 @@ struct AssignByValueMove
};

} // namespace newtype
} // namespace cxx
} // namespace iox

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
// 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 "iox/detail/newtype/internal.hpp"

namespace iox
{
namespace cxx
{
namespace newtype
{
template <typename T>
Expand All @@ -48,7 +47,6 @@ struct Comparable
};

} // namespace newtype
} // namespace cxx
} // namespace iox

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename>
Expand Down Expand Up @@ -75,7 +73,6 @@ struct DefaultConstructable
~DefaultConstructable() = default;
};
} // namespace newtype
} // namespace cxx
} // namespace iox

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename>
Expand All @@ -37,7 +35,6 @@ struct Convertable
};

} // namespace newtype
} // namespace cxx
} // namespace iox

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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 <utility>

namespace iox
{
namespace cxx
{
template <typename, template <typename> class...>
class NewType;
namespace newtype
Expand All @@ -42,7 +40,6 @@ inline typename T::value_type newTypeAccessor(const T& b) noexcept
}
} // namespace internal
} // namespace newtype
} // namespace cxx
} // namespace iox

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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 <typename>
Expand All @@ -36,7 +34,6 @@ struct ProtectedConstructByValueCopy
~ProtectedConstructByValueCopy() = default;
};
} // namespace newtype
} // namespace cxx
} // namespace iox

#endif
Loading

0 comments on commit 5c55953

Please sign in to comment.