Skip to content

Commit 5c55953

Browse files
Merge pull request #1865 from ApexAI/iox-1391-move-design-types-to-separate-module
iox-1391 move design types to separate module
2 parents 2dd519c + d880c2d commit 5c55953

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+319
-225
lines changed

.clang-tidy-diff-scans.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
./iceoryx_hoofs/vocabulary/**/*
5252
./iceoryx_hoofs/test/moduletests/test_vocabulary_*
5353

54+
./iceoryx_hoofs/design/**/*
55+
./iceoryx_hoofs/test/moduletests/test_design_*
56+
5457
# IMPORTANT:
5558
# after the first # everything is considered a comment, add new files and
5659
# directories only at the top of this file

doc/website/release-notes/iceoryx-unreleased.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
- posix wrapper `SharedMemoryObject` is silent on success [\#971](https://github.com/eclipse-iceoryx/iceoryx/issues/971)
7878
- Remove creation design pattern class with in place implementation [\#1036](https://github.com/eclipse-iceoryx/iceoryx/issues/1036)
7979
- posix wrapper `SharedMemoryObject` uses builder pattern instead of creation
80-
- Builder pattern extracted from `helplets.hpp` into `design_pattern/builder.hpp`
80+
- Builder pattern extracted from `helplets.hpp` into `iox/builder.hpp`
8181
- Uninteresting mock function calls in tests [\#1341](https://github.com/eclipse-iceoryx/iceoryx/issues/1341)
8282
- `cxx::unique_ptr` owns deleter, remove all deleter classes [\#1143](https://github.com/eclipse-iceoryx/iceoryx/issues/1143)
8383
- Remove `iox::posix::Timer` [\#337](https://github.com/eclipse-iceoryx/iceoryx/issues/337)
@@ -146,14 +146,14 @@
146146
.create();
147147
```
148148

149-
2. Builder pattern extracted from `helplets.hpp` into `design_pattern/builder.hpp`
149+
2. Builder pattern extracted from `helplets.hpp` into `iox/builder.hpp`
150150

151151
```cpp
152152
// before
153153
#include "iceoryx_hoofs/cxx/helplets.hpp"
154154

155155
// after
156-
#include "iceoryx_hoofs/design_pattern/builder.hpp"
156+
#include "iox/builder.hpp"
157157
```
158158

159159
3. `UnnamedSemaphore` replaces `Semaphore` with `CreateUnnamed*` option
@@ -220,7 +220,7 @@
220220
via a pointer to `FunctionalInterface`
221221

222222
```cpp
223-
iox::cxx::FunctionalInterface<iox::optional<MyClass>, MyClass, void>* soSmart =
223+
iox::FunctionalInterface<iox::optional<MyClass>, MyClass, void>* soSmart =
224224
new iox::optional<MyClass>{};
225225

226226
delete soSmart; // <- not possible anymore
@@ -229,12 +229,12 @@
229229
7. It is not possible to delete a class which is derived from `NewType` via a pointer to `NewType`
230230

231231
```cpp
232-
struct Foo : public iox::cxx::NewType<uint64_t, iox::cxx::newtype::ConstructByValueCopy>
232+
struct Foo : public iox::NewType<uint64_t, iox::newtype::ConstructByValueCopy>
233233
{
234234
using ThisType::ThisType;
235235
};
236236

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

239239
delete soSmart; // <- not possible anymore
240240
```
@@ -244,17 +244,17 @@
244244
```cpp
245245
// before
246246
// for the compiler Foo and Bar are the same type
247-
using Foo = iox::cxx::NewType<uint64_t, iox::cxx::newtype::ConstructByValueCopy>;
248-
using Bar = iox::cxx::NewType<uint64_t, iox::cxx::newtype::ConstructByValueCopy>;
247+
using Foo = iox::NewType<uint64_t, iox::newtype::ConstructByValueCopy>;
248+
using Bar = iox::NewType<uint64_t, iox::newtype::ConstructByValueCopy>;
249249
250250
// after
251251
// compile time error when Foo and Bar are mixed up
252-
struct Foo : public iox::cxx::NewType<uint64_t, iox::cxx::newtype::ConstructByValueCopy>
252+
struct Foo : public iox::NewType<uint64_t, iox::newtype::ConstructByValueCopy>
253253
{
254254
using ThisType::ThisType;
255255
};
256256
// or with the IOX_NEW_TYPE macro
257-
IOX_NEW_TYPE(Bar, uint64_t, iox::cxx::newtype::ConstructByValueCopy);
257+
IOX_NEW_TYPE(Bar, uint64_t, iox::newtype::ConstructByValueCopy);
258258
```
259259

260260
9. `FileLock` uses the builder pattern. Path and permissions can now be set.

iceoryx_hoofs/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,14 @@ cc_library(
3434
"vocabulary/source/**/*.cpp",
3535
"source/**/*.hpp",
3636
"memory/source/*.cpp",
37+
"design/source/*.cpp",
3738
]),
38-
hdrs = glob(["include/**"]) + glob(["legacy/**"]) + glob(["memory/**"]) + glob(["container/**"]) + glob(["vocabulary/**"]) + glob(["utility/**"]) + glob(["primitives/**"]) + [
39+
hdrs = glob(["include/**"]) + glob(["legacy/**"]) + glob(["memory/**"]) + glob(["container/**"]) + glob(["vocabulary/**"]) + glob(["utility/**"]) + glob(["primitives/**"]) + glob(["design/**"]) + [
3940
":iceoryx_hoofs_deployment_hpp",
4041
],
4142
includes = [
4243
"container/include/",
44+
"design/include",
4345
"include/",
4446
"legacy/include/",
4547
"memory/include/",

iceoryx_hoofs/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ iox_add_library(
5353
${PROJECT_SOURCE_DIR}/vocabulary/include
5454
${PROJECT_SOURCE_DIR}/utility/include
5555
${PROJECT_SOURCE_DIR}/primitives/include
56+
${PROJECT_SOURCE_DIR}/design/include
5657
${CMAKE_BINARY_DIR}/generated/iceoryx_hoofs/include
5758
INSTALL_INTERFACE include/${PREFIX}
5859
EXPORT_INCLUDE_DIRS include/
@@ -62,12 +63,12 @@ iox_add_library(
6263
vocabulary/include/
6364
utility/include/
6465
primitives/include/
66+
design/include/
6567
FILES
6668
source/concurrent/loffli.cpp
6769
source/cxx/adaptive_wait.cpp
6870
source/cxx/deadline_timer.cpp
6971
source/cxx/filesystem.cpp
70-
source/cxx/functional_interface.cpp
7172
source/cxx/requires.cpp
7273
source/cxx/type_traits.cpp
7374
source/cxx/unique_id.cpp
@@ -95,6 +96,7 @@ iox_add_library(
9596
source/units/duration.cpp
9697
memory/source/bump_allocator.cpp
9798
memory/source/memory.cpp
99+
design/source/functional_interface.cpp
98100
)
99101

100102
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/iceoryx_hoofs_deployment.hpp.in"

iceoryx_hoofs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ The module structure is a logical grouping. It is replicated for `concurrent` an
127127
|`PeriodicTask` | i | Periodically executes a callable specified by the template parameter in a configurable time interval. |
128128
|`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) |
129129
|`mutex` | i | Mutex interface, see [ManPage pthread_mutex_lock](https://man7.org/linux/man-pages/man3/pthread_mutex_lock.3p.html). |
130+
|`Scheduler` | | Supported schedulers and functions to get their priority range are contained here. |
130131
|`UnnamedSemaphore` | | Unamed semaphore interface, see [ManPage sem_overview](https://man7.org/linux/man-pages/man7/sem_overview.7.html) |
131132
|`NamedSemaphore` | | Named semaphore interface, see [ManPage sem_overview](https://man7.org/linux/man-pages/man7/sem_overview.7.html) |
132133
|`thread` | | Heap-less replacement for `std::thread`. |

iceoryx_hoofs/include/iceoryx_hoofs/design_pattern/builder.hpp renamed to iceoryx_hoofs/design/include/iox/builder.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
//
1515
// SPDX-License-Identifier: Apache-2.0
1616

17-
#ifndef IOX_HOOFS_DESIGN_PATTERN_BUILDER_HPP
18-
#define IOX_HOOFS_DESIGN_PATTERN_BUILDER_HPP
17+
#ifndef IOX_HOOFS_DESIGN_BUILDER_HPP
18+
#define IOX_HOOFS_DESIGN_BUILDER_HPP
1919

2020
/// @brief Macro which generates a setter method useful for a builder pattern.
2121
/// @param[in] type the data type of the parameter

iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/functional_interface.inl renamed to iceoryx_hoofs/design/include/iox/detail/functional_interface.inl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@
1414
//
1515
// SPDX-License-Identifier: Apache-2.0
1616

17-
#ifndef IOX_HOOFS_CXX_FUNCTIONAL_INTERFACE_INL
18-
#define IOX_HOOFS_CXX_FUNCTIONAL_INTERFACE_INL
17+
#ifndef IOX_HOOFS_DESIGN_FUNCTIONAL_INTERFACE_INL
18+
#define IOX_HOOFS_DESIGN_FUNCTIONAL_INTERFACE_INL
1919

20-
#include "iceoryx_hoofs/cxx/functional_interface.hpp"
2120
#include "iox/detail/string_type_traits.hpp"
21+
#include "iox/functional_interface.hpp"
2222

2323
namespace iox
2424
{
25-
namespace cxx
26-
{
2725
namespace internal
2826
{
2927
///////////////
@@ -33,31 +31,31 @@ template <typename Derived>
3331
template <typename StringType>
3432
inline void Expect<Derived>::expect(const StringType& msg) const noexcept
3533
{
36-
static_assert(is_char_array<StringType>::value || is_cxx_string<StringType>::value,
34+
static_assert(cxx::is_char_array<StringType>::value || is_cxx_string<StringType>::value,
3735
"Only char arrays and iox::strings are allowed as message type.");
3836

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

4139
if (!derivedThis)
4240
{
4341
print_expect_message(&msg[0]);
44-
Ensures(false);
42+
cxx::Ensures(false);
4543
}
4644
}
4745

4846
template <typename Derived, typename ValueType>
4947
template <typename StringType>
5048
inline ValueType& ExpectWithValue<Derived, ValueType>::expect(const StringType& msg) & noexcept
5149
{
52-
static_assert(is_char_array<StringType>::value || is_cxx_string<StringType>::value,
50+
static_assert(cxx::is_char_array<StringType>::value || is_cxx_string<StringType>::value,
5351
"Only char arrays and iox::strings are allowed as message type.");
5452

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

5755
if (!derivedThis)
5856
{
5957
print_expect_message(&msg[0]);
60-
Ensures(false);
58+
cxx::Ensures(false);
6159
}
6260

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

313311

314312
} // namespace internal
315-
} // namespace cxx
316313
} // namespace iox
317314
#endif

iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype.inl renamed to iceoryx_hoofs/design/include/iox/detail/newtype.inl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414
// limitations under the License.
1515
//
1616
// SPDX-License-Identifier: Apache-2.0
17-
#ifndef IOX_HOOFS_CXX_NEWTYPE_INL
18-
#define IOX_HOOFS_CXX_NEWTYPE_INL
17+
#ifndef IOX_HOOFS_DESIGN_NEWTYPE_INL
18+
#define IOX_HOOFS_DESIGN_NEWTYPE_INL
1919

20-
#include "iceoryx_hoofs/cxx/newtype.hpp"
20+
#include "iox/newtype.hpp"
2121

2222
namespace iox
2323
{
24-
namespace cxx
25-
{
2624
template <typename T, template <typename> class... Policies>
2725
// AXIVION Next Construct AutosarC++19_03-A12.6.1 : m_value is initialized by the default constructor of T; the code
2826
// 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<T, Policies...>::operator T() const noexcept
118116
return m_value;
119117
}
120118

121-
} // namespace cxx
122119
} // namespace iox
123120

124121
#endif

iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/assignment.hpp renamed to iceoryx_hoofs/design/include/iox/detail/newtype/assignment.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414
// limitations under the License.
1515
//
1616
// SPDX-License-Identifier: Apache-2.0
17-
#ifndef IOX_HOOFS_CXX_NEWTYPE_ASSIGNMENT_HPP
18-
#define IOX_HOOFS_CXX_NEWTYPE_ASSIGNMENT_HPP
17+
#ifndef IOX_HOOFS_DESIGN_NEWTYPE_ASSIGNMENT_HPP
18+
#define IOX_HOOFS_DESIGN_NEWTYPE_ASSIGNMENT_HPP
1919

2020
namespace iox
2121
{
22-
namespace cxx
23-
{
2422
namespace newtype
2523
{
2624
template <typename>
@@ -76,7 +74,6 @@ struct AssignByValueMove
7674
};
7775

7876
} // namespace newtype
79-
} // namespace cxx
8077
} // namespace iox
8178

8279
#endif

iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/newtype/comparable.hpp renamed to iceoryx_hoofs/design/include/iox/detail/newtype/comparable.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
// limitations under the License.
1515
//
1616
// SPDX-License-Identifier: Apache-2.0
17-
#ifndef IOX_HOOFS_CXX_NEWTYPE_COMPARABLE_HPP
18-
#define IOX_HOOFS_CXX_NEWTYPE_COMPARABLE_HPP
19-
#include "iceoryx_hoofs/internal/cxx/newtype/internal.hpp"
17+
#ifndef IOX_HOOFS_DESIGN_NEWTYPE_COMPARABLE_HPP
18+
#define IOX_HOOFS_DESIGN_NEWTYPE_COMPARABLE_HPP
19+
20+
#include "iox/detail/newtype/internal.hpp"
2021

2122
namespace iox
2223
{
23-
namespace cxx
24-
{
2524
namespace newtype
2625
{
2726
template <typename T>
@@ -48,7 +47,6 @@ struct Comparable
4847
};
4948

5049
} // namespace newtype
51-
} // namespace cxx
5250
} // namespace iox
5351

5452
#endif

0 commit comments

Comments
 (0)