Skip to content

Commit 890a642

Browse files
committed
iox-#2499 Add 'IOX_HOOFS_SUBSET as define in iceoryx_hoofs_deployment.hpp'
1 parent 58b3dfb commit 890a642

File tree

13 files changed

+100
-379
lines changed

13 files changed

+100
-379
lines changed

iceoryx_hoofs/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ configure_file(
2222
src = "cmake/iceoryx_hoofs_deployment.hpp.in",
2323
out = "generated/include/iox/iceoryx_hoofs_deployment.hpp",
2424
config_constants = {
25+
"IOX_HOOFS_SUBSET": "0",
2526
"IOX_MAX_NAMED_PIPE_MESSAGE_SIZE": "4096",
2627
"IOX_MAX_NAMED_PIPE_NUMBER_OF_MESSAGES": "10",
2728
# FIXME: for values see "iceoryx_hoofs/cmake/IceoryxHoofsDeployment.cmake" ... for now some nice defaults

iceoryx_hoofs/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ iox_add_library(
104104
)
105105

106106
if(IOX_USE_HOOFS_SUBSET_ONLY)
107-
target_compile_definitions(iceoryx_hoofs PUBLIC IOX_HOOFS_SUBSET)
108-
endif(IOX_USE_HOOFS_SUBSET_ONLY)
107+
set(IOX_HOOFS_SUBSET 1)
108+
else()
109+
set(IOX_HOOFS_SUBSET 0)
110+
endif()
109111

110112
if(NOT IOX_USE_HOOFS_SUBSET_ONLY)
111113
target_sources(

iceoryx_hoofs/cmake/iceoryx_hoofs_deployment.hpp.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "iox/iceoryx_hoofs_types.hpp"
2121

22+
#define IOX_HOOFS_SUBSET @IOX_HOOFS_SUBSET@
23+
2224
namespace iox
2325
{
2426
namespace build

iceoryx_hoofs/container/include/iox/detail/fixed_position_container.inl

Lines changed: 9 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define IOX_HOOFS_CONTAINER_DETAIL_FIXED_POSITION_CONTAINER_INL
2020

2121
#include "iox/fixed_position_container.hpp"
22+
#include "iox/iceoryx_hoofs_deployment.hpp"
2223

2324
namespace iox
2425
{
@@ -86,80 +87,6 @@ FixedPositionContainer<T, CAPACITY>::operator=(FixedPositionContainer&& rhs) noe
8687
return *this;
8788
}
8889

89-
#ifndef IOX_HOOFS_SUBSET
90-
template <typename T, uint64_t CAPACITY>
91-
template <MoveAndCopyOperations Opt, typename RhsType>
92-
inline void FixedPositionContainer<T, CAPACITY>::copy_and_move_impl(RhsType&& rhs) noexcept
93-
{
94-
// alias helper struct
95-
using Helper = MoveAndCopyHelper<Opt>;
96-
97-
constexpr bool is_ctor = Helper::is_ctor;
98-
constexpr bool is_move = Helper::is_move;
99-
100-
// status array is not yet initialized for constructor creation
101-
if constexpr (is_ctor)
102-
{
103-
for (IndexType i = 0; i < CAPACITY; ++i)
104-
{
105-
m_status[i] = SlotStatus::FREE;
106-
}
107-
}
108-
109-
IndexType i{Index::FIRST};
110-
auto rhs_it = (std::forward<RhsType>(rhs)).begin();
111-
112-
for (; rhs_it.to_index() != Index::INVALID; ++i, ++rhs_it)
113-
{
114-
if (m_status[i] == SlotStatus::USED)
115-
{
116-
// When the slot is in the 'USED' state, it is safe to proceed with either construction (ctor) or assignment
117-
// operation. Therefore, creation can be carried out according to the option specified by Opt.
118-
Helper::transfer(m_data[i], Helper::move_or_copy_it(rhs_it));
119-
}
120-
else
121-
{
122-
// When the slot is in the 'FREE' state, it is unsafe to proceed with assignment operation.
123-
// Therefore, we need to force helper to use ctor create to make sure that the 'FREE' slots get initialized.
124-
Helper::create_new(m_data[i], Helper::move_or_copy_it(rhs_it));
125-
}
126-
127-
m_status[i] = SlotStatus::USED;
128-
m_next[i] = static_cast<IndexType>(i + 1U);
129-
}
130-
131-
// reset rest
132-
for (; i < CAPACITY; ++i)
133-
{
134-
if (m_status[i] == SlotStatus::USED)
135-
{
136-
m_data[i].~T();
137-
}
138-
139-
m_status[i] = SlotStatus::FREE;
140-
141-
auto next = static_cast<IndexType>(i + 1U);
142-
m_next[i] = next;
143-
}
144-
145-
// correct m_next
146-
m_next[Index::LAST] = Index::INVALID;
147-
if (!rhs.empty())
148-
{
149-
m_next[rhs.m_size - 1] = Index::INVALID;
150-
}
151-
152-
m_begin_free = static_cast<IndexType>(rhs.m_size);
153-
m_begin_used = rhs.empty() ? Index::INVALID : Index::FIRST;
154-
m_size = rhs.m_size;
155-
156-
// reset rhs if is_move is true
157-
if constexpr (is_move)
158-
{
159-
rhs.clear();
160-
}
161-
}
162-
#else
16390
template <typename T, uint64_t CAPACITY>
16491
template <MoveAndCopyOperations Opt, typename RhsType>
16592
inline void FixedPositionContainer<T, CAPACITY>::copy_and_move_impl(RhsType&& rhs) noexcept
@@ -171,7 +98,11 @@ inline void FixedPositionContainer<T, CAPACITY>::copy_and_move_impl(RhsType&& rh
17198
constexpr bool is_move = Helper::is_move;
17299

173100
// status array is not yet initialized for constructor creation
101+
#if IOX_HOOFS_SUBSET
174102
if (is_ctor)
103+
#else
104+
if constexpr (is_ctor)
105+
#endif
175106
{
176107
for (IndexType i = 0; i < CAPACITY; ++i)
177108
{
@@ -227,12 +158,15 @@ inline void FixedPositionContainer<T, CAPACITY>::copy_and_move_impl(RhsType&& rh
227158
m_size = rhs.m_size;
228159

229160
// reset rhs if is_move is true
161+
#if IOX_HOOFS_SUBSET
230162
if (is_move)
163+
#else
164+
if constexpr (is_move)
165+
#endif
231166
{
232167
rhs.clear();
233168
}
234169
}
235-
#endif
236170

237171
template <typename T, uint64_t CAPACITY>
238172
inline void FixedPositionContainer<T, CAPACITY>::clear() noexcept

0 commit comments

Comments
 (0)