Skip to content

Commit

Permalink
iox-eclipse-iceoryx#2130 Move 'container' types from 'iceoryx_dust' t…
Browse files Browse the repository at this point in the history
…o 'iceoryx_hoofs'
  • Loading branch information
elBoberido committed Dec 12, 2023
1 parent d5eaa65 commit ba3942b
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 34 deletions.
3 changes: 1 addition & 2 deletions iceoryx_dust/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ cc_library(
"posix/ipc/source/**/*.cpp",
"posix/sync/source/**/*.cpp",
]),
hdrs = glob(["cli/**"]) + glob(["container/**"]) + glob(["filesystem/**"]) + glob(["memory/**"]) + glob(["utility/**"]) + glob(["posix/ipc/**"]) + glob(["posix/sync/**"]) + [
hdrs = glob(["cli/**"]) + glob(["filesystem/**"]) + glob(["memory/**"]) + glob(["utility/**"]) + glob(["posix/ipc/**"]) + glob(["posix/sync/**"]) + [
":iceoryx_dust_deployment_hpp",
],
includes = [
"cli/include/",
"container/include/",
"filesystem/include/",
"generated/include/",
"memory/include/",
Expand Down
2 changes: 0 additions & 2 deletions iceoryx_dust/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ iox_add_library(
PRIVATE_LIBS_LINUX ${CODE_COVERAGE_LIBS}
PUBLIC_LIBS iceoryx_hoofs::iceoryx_hoofs
BUILD_INTERFACE ${PROJECT_SOURCE_DIR}/cli/include
${PROJECT_SOURCE_DIR}/container/include
${PROJECT_SOURCE_DIR}/filesystem/include
${PROJECT_SOURCE_DIR}/memory/include
${PROJECT_SOURCE_DIR}/posix/ipc/include
Expand All @@ -56,7 +55,6 @@ iox_add_library(
${CMAKE_BINARY_DIR}/generated/iceoryx_dust/include
INSTALL_INTERFACE include/${PREFIX}
EXPORT_INCLUDE_DIRS cli/include/
container/include/
filesystem/include/
memory/include/
posix/ipc/include/
Expand Down
2 changes: 0 additions & 2 deletions iceoryx_dust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ grouped together in categories or namespace, depending on where or how they are

| class/file | description |
|:---------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`forward_list` | Heap and exception free, relocatable implementation of `std::forward_list` |
|`FileReader` | Wrapper for opening files and reading them. |
|`FixedPositionContainer` | A fixed-position container is similar to a list but is optimized for iterating over its elements without the back-and-forth jumping that can occur during iteration in a list. |
|`MessageQueue` | Interface for Message Queues, see [ManPage mq_overview](https://www.man7.org/linux/man-pages/man7/mq_overview.7.html). |
|`SignalWatcher` | Batteries included signal handling with polling and optional blocking wait for `SIGINT` and `SIGTERM`. |
|`NamedPipe` | Shared memory based IPC channel. Mainly a `UnixDomainSocket` replacement on Windows. |
Expand Down
2 changes: 2 additions & 0 deletions iceoryx_hoofs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ The module structure is a logical grouping. It is replicated for `concurrent` an
| class | internal | description |
|:---------------------:|:--------:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`vector` | | Heap and exception free implementation of `std::vector` |
|`forward_list` | | Heap and exception free, relocatable implementation of `std::forward_list` |
|`list` | | Heap and exception free, relocatable implementation of `std::list` |
|`FixedPositionContainer` | | A fixed-position container is similar to a list but is optimized for iterating over its elements without the back-and-forth jumping that can occur during iteration in a list. |
|`UninitializedArray` | | Wrapper class for an uninitialized C-style array which can be zeroed via a template parameter |

### Vocabulary types (vocabulary)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//
// SPDX-License-Identifier: Apache-2.0

#ifndef IOX_DUST_CONTAINER_DETAIL_FIXED_POSITION_CONTAINER_INL
#define IOX_DUST_CONTAINER_DETAIL_FIXED_POSITION_CONTAINER_INL
#ifndef IOX_HOOFS_CONTAINER_DETAIL_FIXED_POSITION_CONTAINER_INL
#define IOX_HOOFS_CONTAINER_DETAIL_FIXED_POSITION_CONTAINER_INL

#include "iox/fixed_position_container.hpp"

Expand All @@ -30,7 +30,7 @@ inline FixedPositionContainer<T, CAPACITY>::FixedPositionContainer() noexcept
{
m_status[i] = SlotStatus::FREE;

IndexType next = static_cast<IndexType>(i + 1U);
auto next = static_cast<IndexType>(i + 1U);
m_next[i] = next;
i = next;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ inline void FixedPositionContainer<T, CAPACITY>::copy_and_move_impl(RhsType&& rh

m_status[i] = SlotStatus::FREE;

IndexType next = static_cast<IndexType>(i + 1U);
auto next = static_cast<IndexType>(i + 1U);
m_next[i] = next;
}

Expand Down Expand Up @@ -171,7 +171,7 @@ inline void FixedPositionContainer<T, CAPACITY>::clear() noexcept

m_status[i] = SlotStatus::FREE;

IndexType next = static_cast<IndexType>(i + 1U);
auto next = static_cast<IndexType>(i + 1U);
m_next[i] = next;
i = next;
}
Expand Down Expand Up @@ -287,7 +287,7 @@ FixedPositionContainer<T, CAPACITY>::emplace(Targs&&... args) noexcept
else
{
IOX_ENSURES_WITH_MSG(index != 0, "Corruption detected!");
for (IndexType i = static_cast<IndexType>(index - 1U);; --i)
for (auto i = static_cast<IndexType>(index - 1U);; --i)
{
if (m_status[i] == SlotStatus::USED)
{
Expand Down Expand Up @@ -442,7 +442,7 @@ FixedPositionContainer<T, CAPACITY>::erase(const IndexType index) noexcept
}

IOX_ENSURES_WITH_MSG(index != 0, "Corruption detected! Index cannot be 0 at this location!");
for (IndexType i = static_cast<IndexType>(index - 1U); !is_removed_from_used_list || !is_added_to_free_list; --i)
for (auto i = static_cast<IndexType>(index - 1U); !is_removed_from_used_list || !is_added_to_free_list; --i)
{
if (!is_removed_from_used_list && m_status[i] == SlotStatus::USED)
{
Expand Down Expand Up @@ -590,4 +590,4 @@ FixedPositionContainer<T, CAPACITY>::cend() const noexcept
}
} // namespace iox

#endif // IOX_DUST_CONTAINER_DETAIL_FIXED_POSITION_CONTAINER_INL
#endif // IOX_HOOFS_CONTAINER_DETAIL_FIXED_POSITION_CONTAINER_INL
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//
// SPDX-License-Identifier: Apache-2.0

#ifndef IOX_DUST_CONTAINER_FORWARD_LIST_INL
#define IOX_DUST_CONTAINER_FORWARD_LIST_INL
#ifndef IOX_HOOFS_CONTAINER_FORWARD_LIST_INL
#define IOX_HOOFS_CONTAINER_FORWARD_LIST_INL


#include "iox/forward_list.hpp"
Expand Down Expand Up @@ -610,4 +610,4 @@ inline bool forward_list<T, Capacity>::isInvalidIterOrDifferentLists(const const

} // namespace iox

#endif // IOX_DUST_CONTAINER_FORWARD_LIST_INL
#endif // IOX_HOOFS_CONTAINER_FORWARD_LIST_INL
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
//
// SPDX-License-Identifier: Apache-2.0

#ifndef IOX_DUST_CONTAINER_FIXED_POSITION_CONTAINER_HPP
#define IOX_DUST_CONTAINER_FIXED_POSITION_CONTAINER_HPP
#ifndef IOX_HOOFS_CONTAINER_FIXED_POSITION_CONTAINER_HPP
#define IOX_HOOFS_CONTAINER_FIXED_POSITION_CONTAINER_HPP

#include "iceoryx_hoofs/cxx/requires.hpp"
#include "iox/algorithm.hpp"
Expand Down Expand Up @@ -332,4 +332,4 @@ class FixedPositionContainer final

#include "iox/detail/fixed_position_container.inl"

#endif // IOX_DUST_CONTAINER_FIXED_POSITION_CONTAINER_HPP
#endif // IOX_HOOFS_CONTAINER_FIXED_POSITION_CONTAINER_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//
// SPDX-License-Identifier: Apache-2.0

#ifndef IOX_DUST_CONTAINER_FORWARD_LIST_HPP
#define IOX_DUST_CONTAINER_FORWARD_LIST_HPP
#ifndef IOX_HOOFS_CONTAINER_FORWARD_LIST_HPP
#define IOX_HOOFS_CONTAINER_FORWARD_LIST_HPP

#include "iceoryx_hoofs/cxx/requires.hpp"
#include "iox/uninitialized_array.hpp"
Expand Down Expand Up @@ -363,4 +363,4 @@ class forward_list

#include "iox/detail/forward_list.inl"

#endif // IOX_DUST_CONTAINER_FORWARD_LIST_HPP
#endif // IOX_HOOFS_CONTAINER_FORWARD_LIST_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ class MovableButNonCopyableTestClass
{
public:
// moveable only class requires this
MovableButNonCopyableTestClass(const T value)
explicit MovableButNonCopyableTestClass(const T value)
: value(value)
{
}

MovableButNonCopyableTestClass(const MovableButNonCopyableTestClass& rhs) = delete;
MovableButNonCopyableTestClass& operator=(const MovableButNonCopyableTestClass& rhs) = delete;

MovableButNonCopyableTestClass(MovableButNonCopyableTestClass&& rhs)
MovableButNonCopyableTestClass(MovableButNonCopyableTestClass&& rhs) noexcept
: value(rhs.value)
{
value = rhs.value;
}

MovableButNonCopyableTestClass& operator=(MovableButNonCopyableTestClass&& rhs)
MovableButNonCopyableTestClass& operator=(MovableButNonCopyableTestClass&& rhs) noexcept
{
if (this != &rhs)
{
Expand Down Expand Up @@ -93,7 +93,7 @@ struct FixedPositionContainer_test : public Test
fillComplex(sut_complex);
}

void fillComplex(SutComplex& s)
static void fillComplex(SutComplex& s)
{
for (DataType i = 0; i < CAPACITY; ++i)
{
Expand Down Expand Up @@ -487,7 +487,7 @@ TEST_F(FixedPositionContainer_test, UsingCopyAssignmentFromMultipleElementsConta

std::vector<DataType> EXPECTED_VALUE{56U, 57U, 58U, 59U};
constexpr uint64_t EXPECTED_SIZE{4U};
for (SutComplex::IndexType i = 0; i < EXPECTED_VALUE.size(); ++i)
for (SutComplex::IndexType i = 0; i < EXPECTED_SIZE; ++i)
{
sut_complex.emplace(EXPECTED_VALUE[i]);
}
Expand All @@ -498,7 +498,7 @@ TEST_F(FixedPositionContainer_test, UsingCopyAssignmentFromMultipleElementsConta
EXPECT_THAT(copy_sut_complex.full(), Eq(false));
EXPECT_THAT(copy_sut_complex.empty(), Eq(false));
EXPECT_THAT(copy_sut_complex.size(), Eq(sut_complex.size()));
for (SutComplex::IndexType i = 0; i < sut_complex.size(); ++i)
for (SutComplex::IndexType i = 0; i < EXPECTED_SIZE; ++i)
{
EXPECT_THAT(copy_sut_complex.iter_from_index(i)->value, Eq(EXPECTED_VALUE[i]));
EXPECT_THAT(copy_sut_complex.iter_from_index(i), Ne(sut_complex.iter_from_index(i)));
Expand Down Expand Up @@ -2310,11 +2310,14 @@ TEST_F(FixedPositionContainer_test, EraseWithPointerPointingOutOfContainerCallsE

auto* ptr_first = sut.begin().to_ptr();

// NOLINTJUSTIFICATION required for test
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic)
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { sut.erase(ptr_first - 1U); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { sut.erase(ptr_first + CAPACITY); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
}

TEST_F(FixedPositionContainer_test, EraseWithUnalignedPointerCallsErrorHandler)
Expand All @@ -2324,6 +2327,8 @@ TEST_F(FixedPositionContainer_test, EraseWithUnalignedPointerCallsErrorHandler)
fillSut();

auto* ptr_first = sut.begin().to_ptr();
// NOLINTJUSTIFICATION required for test
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast, performance-no-int-to-ptr)
auto* ptr_unaligned = reinterpret_cast<DataType*>(reinterpret_cast<uintptr_t>(ptr_first) + 1U);

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { sut.erase(ptr_unaligned); },
Expand Down Expand Up @@ -3122,10 +3127,10 @@ TEST_F(FixedPositionContainer_test, ToPtrOnEndIteratorCallsErrorHandler)
{
::testing::Test::RecordProperty("TEST_ID", "51b76d04-6c8c-486e-88c9-8b6b760c41d4");

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { auto _ [[maybe_unused]] = sut.end().to_ptr(); },
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { auto* _ [[maybe_unused]] = sut.end().to_ptr(); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { auto _ [[maybe_unused]] = sut.cend().to_ptr(); },
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { const auto* _ [[maybe_unused]] = sut.cend().to_ptr(); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
}

Expand All @@ -3136,7 +3141,7 @@ TEST_F(FixedPositionContainer_test, ToPtrOnInvalidIteratorCallsErrorHandler)
auto it = sut.emplace(135U);
sut.erase(it);

IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { auto _ [[maybe_unused]] = it.to_ptr(); },
IOX_EXPECT_FATAL_FAILURE<iox::HoofsError>([&] { auto* _ [[maybe_unused]] = it.to_ptr(); },
iox::HoofsError::EXPECTS_ENSURES_FAILED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ TEST_F(forward_list_test, IteratorTraitsGetValueType)
TEST_F(forward_list_test, IteratorTraitsCheckIteratorCategoryOnConstIterator)
{
::testing::Test::RecordProperty("TEST_ID", "ffbb06eb-5267-45e0-91e4-6172a27a3489");
auto iter = sut.cbefore_begin();
auto iter [[maybe_unused]] = sut.cbefore_begin();
ASSERT_NE(typeid(std::iterator_traits<decltype(iter)>::iterator_category), typeid(std::random_access_iterator_tag));
EXPECT_EQ(typeid(std::iterator_traits<decltype(iter)>::iterator_category), typeid(std::forward_iterator_tag));
}
Expand Down

0 comments on commit ba3942b

Please sign in to comment.