Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1560 Remove unnecessary includes and use stringst…
Browse files Browse the repository at this point in the history
…ream for 'float' and 'double' in 'LogStream' tests

Signed-off-by: Simon Hoinkis <simon.hoinkis@apex.ai>
  • Loading branch information
mossmaurice committed Feb 1, 2023
1 parent aa292b2 commit db36e1a
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 75 deletions.
2 changes: 2 additions & 0 deletions iceoryx_dust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ grouped together in categories or namespace, depending on where or how they are
|`NamedPipe` | Shared memory based ipc channel. Mainly a `UnixDomainSocket` replacement on Windows. |
|`relocatable_ptr` | |
|`static_storage` | Untyped aligned static storage. |
|`convert` | | Converting a number into a string is easy, converting it back can be hard. You can use functions like `strtoll` but you still have to handle errors like under- and overflow, or converting invalid strings into number. Here we abstract all the error handling so that you can convert strings into numbers safely. |
|`serialization` | | Implements a simple serialization concept for classes based on the idea presented here [ISOCPP serialization](https://isocpp.org/wiki/faq/serialization#serialize-text-format). |
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#define IOX_DUST_CLI_ARGUMENTS_HPP

#include "iceoryx_dust/cli/types.hpp"
#include "iceoryx_dust/internal/cli/option.hpp"
#include "iceoryx_dust/cxx/convert.hpp"
#include "iceoryx_dust/internal/cli/option.hpp"
#include "iceoryx_hoofs/cxx/vector.hpp"
#include "iox/expected.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,7 @@ Arguments SuccessTest(const std::vector<std::string>& options,
OptionDefinition optionSet("");
for (const auto& o : optionsToRegister)
{
optionSet.addOptional(
o[0], iox::into<OptionName_t>(o), "", "int", CommandLineParser_test::defaultValue);
optionSet.addOptional(o[0], iox::into<OptionName_t>(o), "", "int", CommandLineParser_test::defaultValue);
}
for (const auto& s : switchesToRegister)
{
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_examples/singleprocess/single_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp"
#include "iceoryx_dust/cxx/convert.hpp"
#include "iceoryx_dust/posix_wrapper/signal_watcher.hpp"
#include "iceoryx_hoofs/log/logging.hpp"
#include "iceoryx_posh/iceoryx_posh_config.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
Expand Down
6 changes: 2 additions & 4 deletions iceoryx_hoofs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@ The module structure is a logical grouping. It is replicated for `concurrent` an
|`function` | | A stack-based `std::function` replacement based on `storable_function` |
|`function_ref` | | C++11 implementation of the next-gen C++ feature `std::function_ref` see [function_ref proposal](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0792r2.html). It behaves like `std::function` but does not own the callable. |

### Utility (utility?)
### Utility (utility)

| class | internal | description |
|:---------------------:|:--------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|`helplets` | | Implementations of [C++ Core Guideline](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) concepts like `not_null` are contained here. Additionally, we are providing some types to verify preconditions at compile time. Think of an int which has to be always greater 5, here we provide types like `greater_or_equal<int, 6>`.|
|`convert` | | Converting a number into a string is easy, converting it back can be hard. You can use functions like `strtoll` but you still have to handle errors like under- and overflow, or converting invalid strings into number. Here we abstract all the error handling so that you can convert strings into numbers safely. |
|`serialization` | | Implements a simple serialization concept for classes based on the idea presented here [ISOCPP serialization](https://isocpp.org/wiki/faq/serialization#serialize-text-format). |
|`helplets` | | Implementations of [C++ Core Guideline](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) concepts like `not_null` are contained here. Additionally, we are providing some types to verify preconditions at compile time. | |
|`system_configuration` | i | Collection of free functions which acquire system information like the page-size. |
|`UniqueId` | i | Monotonic increasing IDs within a process. |

Expand Down
6 changes: 0 additions & 6 deletions iceoryx_hoofs/include/iceoryx_hoofs/cxx/helplets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,11 @@
#include "iceoryx_hoofs/cxx/type_traits.hpp"
#include "iox/string.hpp"

#include <cstring>
#include <iostream>

#include "iceoryx_platform/platform_correction.hpp"
#include "iceoryx_platform/platform_settings.hpp"

namespace iox
{
template <uint64_t Capacity>
class string;
struct TruncateToCapacity_t;
namespace cxx
{
template <typename T, typename = typename std::enable_if<std::is_pointer<T>::value, void>::type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef IOX_HOOFS_CONCURRENT_LOFFLI_HPP
#define IOX_HOOFS_CONCURRENT_LOFFLI_HPP

#include "iceoryx_hoofs/cxx/helplets.hpp" // not_null
#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_hoofs/memory/relative_pointer.hpp"

#include <atomic>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "iox/expected.hpp"
#include "iox/optional.hpp"
#include "iox/string.hpp"
#include "iceoryx_hoofs/cxx/helplets.hpp" // isValidFileName

#include <cstdint>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include "iox/expected.hpp"
#include "iox/optional.hpp"
#include "iox/string.hpp"
#include "iceoryx_hoofs/cxx/helplets.hpp" // isValidFileName

namespace iox
{
Expand Down
1 change: 0 additions & 1 deletion iceoryx_hoofs/source/posix_wrapper/file_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "iceoryx_platform/fcntl.hpp"
#include "iceoryx_platform/stat.hpp"
#include "iceoryx_platform/unistd.hpp"
#include "iceoryx_hoofs/cxx/helplets.hpp" // isValidFileName

#include "iceoryx_platform/platform_correction.hpp"

Expand Down
3 changes: 2 additions & 1 deletion iceoryx_hoofs/test/moduletests/test_cxx_filesystem.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2022 by Apex.AI Inc. All rights reserved.
// Copyright (c) 2019 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 - 2022 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.
Expand Down
16 changes: 16 additions & 0 deletions iceoryx_hoofs/test/moduletests/test_logstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,22 @@ std::string convertToString(const T val)
return std::to_string(val);
}

template <>
std::string convertToString<float>(const float val)
{
std::stringstream ss;
ss << val;
return ss.str();
}

template <>
std::string convertToString<double>(const double val)
{
std::stringstream ss;
ss << val;
return ss.str();
}

template <>
std::string convertToString<bool>(const bool val)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#ifndef IOX_POSH_CAPRO_SERVICE_DESCRIPTION_HPP
#define IOX_POSH_CAPRO_SERVICE_DESCRIPTION_HPP

#include "iceoryx_hoofs/cxx/algorithm.hpp"
#include "iceoryx_dust/cxx/serialization.hpp"
#include "iceoryx_hoofs/cxx/algorithm.hpp"
#include "iceoryx_hoofs/cxx/vector.hpp"
#include "iceoryx_hoofs/log/logstream.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_posh/include/iceoryx_posh/version/version_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#ifndef IOX_POSH_VERSION_VERSION_INFO_HPP
#define IOX_POSH_VERSION_VERSION_INFO_HPP

#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_dust/cxx/serialization.hpp"
#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
#include "iceoryx_posh/version/compatibility_check_level.hpp"
#include "iceoryx_versions.hpp"
Expand Down
11 changes: 5 additions & 6 deletions iceoryx_posh/source/mepoo/memory_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ uint64_t MemoryManager::requiredChunkMemorySize(const MePooConfig& mePooConfig)
// the user has the option to further partition the chunk-payload with
// a user-header and therefore reduce the user-payload size
memorySize += align(static_cast<uint64_t>(mempoolConfig.m_chunkCount)
* MemoryManager::sizeWithChunkHeaderStruct(mempoolConfig.m_size),
MemPool::CHUNK_MEMORY_ALIGNMENT);
* MemoryManager::sizeWithChunkHeaderStruct(mempoolConfig.m_size),
MemPool::CHUNK_MEMORY_ALIGNMENT);
}
return memorySize;
}
Expand All @@ -116,13 +116,12 @@ uint64_t MemoryManager::requiredManagementMemorySize(const MePooConfig& mePooCon
for (const auto& mempool : mePooConfig.m_mempoolConfig)
{
sumOfAllChunks += mempool.m_chunkCount;
memorySize += align(MemPool::freeList_t::requiredIndexMemorySize(mempool.m_chunkCount),
MemPool::CHUNK_MEMORY_ALIGNMENT);
memorySize +=
align(MemPool::freeList_t::requiredIndexMemorySize(mempool.m_chunkCount), MemPool::CHUNK_MEMORY_ALIGNMENT);
}

memorySize += align(sumOfAllChunks * sizeof(ChunkManagement), MemPool::CHUNK_MEMORY_ALIGNMENT);
memorySize +=
align(MemPool::freeList_t::requiredIndexMemorySize(sumOfAllChunks), MemPool::CHUNK_MEMORY_ALIGNMENT);
memorySize += align(MemPool::freeList_t::requiredIndexMemorySize(sumOfAllChunks), MemPool::CHUNK_MEMORY_ALIGNMENT);

return memorySize;
}
Expand Down
3 changes: 1 addition & 2 deletions iceoryx_posh/source/roudi/memory/default_roudi_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ mepoo::MePooConfig DefaultRouDiMemory::introspectionMemPoolConfig() const noexce
mempoolConfig.m_mempoolConfig.push_back(
{align(static_cast<uint32_t>(sizeof(roudi::PortIntrospectionFieldTopic)), ALIGNMENT), CHUNK_COUNT});
mempoolConfig.m_mempoolConfig.push_back(
{align(static_cast<uint32_t>(sizeof(roudi::PortThroughputIntrospectionFieldTopic)), ALIGNMENT),
CHUNK_COUNT});
{align(static_cast<uint32_t>(sizeof(roudi::PortThroughputIntrospectionFieldTopic)), ALIGNMENT), CHUNK_COUNT});
mempoolConfig.m_mempoolConfig.push_back(
{align(static_cast<uint32_t>(sizeof(roudi::SubscriberPortChangingIntrospectionFieldTopic)), ALIGNMENT),
CHUNK_COUNT});
Expand Down
8 changes: 3 additions & 5 deletions iceoryx_posh/source/roudi/roudi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_posh/internal/roudi/roudi.hpp"
#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_dust/cxx/convert.hpp"
#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_hoofs/cxx/helplets.hpp"
#include "iceoryx_hoofs/posix_wrapper/posix_access_rights.hpp"
#include "iceoryx_hoofs/posix_wrapper/thread.hpp"
Expand Down Expand Up @@ -388,11 +388,9 @@ void RouDi::processMessage(const runtime::IpcMessage& message,
}
else
{
capro::Interfaces interface =
StringToCaProInterface(into<capro::IdString_t>(message.getElementAtIndex(2)));
capro::Interfaces interface = StringToCaProInterface(into<capro::IdString_t>(message.getElementAtIndex(2)));

m_prcMgr->addInterfaceForProcess(
runtimeName, interface, into<NodeName_t>(message.getElementAtIndex(3)));
m_prcMgr->addInterfaceForProcess(runtimeName, interface, into<NodeName_t>(message.getElementAtIndex(3)));
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_posh/source/runtime/ipc_runtime_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_posh/internal/runtime/ipc_runtime_interface.hpp"
#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_dust/cxx/convert.hpp"
#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_hoofs/posix_wrapper/posix_access_rights.hpp"
#include "iceoryx_posh/error_handling/error_handling.hpp"
#include "iceoryx_posh/version/version_info.hpp"
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_posh/test/moduletests/test_gw_gateway_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_dust/cxx/convert.hpp"
#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_hoofs/internal/units/duration.hpp"
#include "iceoryx_posh/gateway/channel.hpp"
#include "iceoryx_posh/gateway/gateway_config.hpp"
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_posh/test/moduletests/test_posh_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_dust/cxx/convert.hpp"
#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_hoofs/testing/barrier.hpp"
#include "iceoryx_hoofs/testing/timing_test.hpp"
#include "iceoryx_hoofs/testing/watch_dog.hpp"
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_posh/test/moduletests/test_roudi_portmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ TEST_F(PortManager_test, DeleteInterfacePortfromMaximumNumberAndAddOneIsSuccessf
// this is done because there is no removeInterfaceData method in the PortManager class
m_portManager->deletePortsOfProcess(iox::into<iox::RuntimeName_t>(newProcessName));

auto interfacePort = m_portManager->acquireInterfacePortData(
iox::capro::Interfaces::INTERNAL, iox::into<iox::RuntimeName_t>(newProcessName));
auto interfacePort = m_portManager->acquireInterfacePortData(iox::capro::Interfaces::INTERNAL,
iox::into<iox::RuntimeName_t>(newProcessName));
EXPECT_NE(interfacePort, nullptr);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_dust/cxx/convert.hpp"
#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_hoofs/posix_wrapper/posix_access_rights.hpp"
#include "iceoryx_hoofs/testing/watch_dog.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
Expand Down Expand Up @@ -145,8 +145,8 @@ class PortManager_test : public Test
for (unsigned int i = 0; i < iox::MAX_INTERFACE_NUMBER; i++)
{
auto newProcessName = runtimeName + iox::cxx::convert::toString(i);
auto interfacePort = m_portManager->acquireInterfacePortData(
iox::capro::Interfaces::INTERNAL, iox::into<iox::RuntimeName_t>(newProcessName));
auto interfacePort = m_portManager->acquireInterfacePortData(iox::capro::Interfaces::INTERNAL,
iox::into<iox::RuntimeName_t>(newProcessName));
ASSERT_NE(interfacePort, nullptr);
if (f)
{
Expand All @@ -162,8 +162,7 @@ class PortManager_test : public Test
for (unsigned int i = 0; i < iox::MAX_NUMBER_OF_CONDITION_VARIABLES; i++)
{
auto newProcessName = runtimeName + iox::cxx::convert::toString(i);
auto condVar =
m_portManager->acquireConditionVariableData(iox::into<iox::RuntimeName_t>(newProcessName));
auto condVar = m_portManager->acquireConditionVariableData(iox::into<iox::RuntimeName_t>(newProcessName));
ASSERT_FALSE(condVar.has_error());
if (f)
{
Expand Down
13 changes: 6 additions & 7 deletions iceoryx_posh/test/moduletests/test_roudi_portpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
//
// SPDX-License-Identifier: Apache-2.0

#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_dust/cxx/convert.hpp"
#include "iceoryx_dust/cxx/std_string_support.hpp"
#include "iceoryx_posh/internal/roudi/port_pool_data.hpp"
#include "iceoryx_posh/internal/runtime/node_data.hpp"
#include "iceoryx_posh/popo/client_options.hpp"
Expand Down Expand Up @@ -302,12 +302,11 @@ TEST_F(PortPool_test, GetPublisherPortDataListCompletelyFilledSuccessfully)
std::string instance = "instance" + cxx::convert::toString(i);
RuntimeName_t applicationName = iox::into<RuntimeName_t>("AppName" + cxx::convert::toString(i));

ASSERT_FALSE(
sut.addPublisherPort({iox::into<IdString_t>(service), iox::into<IdString_t>(instance), "foo"},
&m_memoryManager,
applicationName,
m_publisherOptions)
.has_error());
ASSERT_FALSE(sut.addPublisherPort({iox::into<IdString_t>(service), iox::into<IdString_t>(instance), "foo"},
&m_memoryManager,
applicationName,
m_publisherOptions)
.has_error());
}

auto publisherPortDataList = sut.getPublisherPortDataList();
Expand Down
43 changes: 19 additions & 24 deletions tools/introspection/source/introspection_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,15 @@ void IntrospectionApp::printPortIntrospectionData(const std::vector<ComposedPubl
needsLineBreak = false;
wprintw(pad,
" %s |",
printEntry(serviceWidth, iox::into<std::string>(publisherPort.portData->m_caproServiceID))
.c_str());
wprintw(pad,
" %s |",
printEntry(instanceWidth, iox::into<std::string>(publisherPort.portData->m_caproInstanceID))
.c_str());
wprintw(pad,
" %s |",
printEntry(eventWidth, iox::into<std::string>(publisherPort.portData->m_caproEventMethodID))
.c_str());
printEntry(serviceWidth, iox::into<std::string>(publisherPort.portData->m_caproServiceID)).c_str());
wprintw(
pad,
" %s |",
printEntry(instanceWidth, iox::into<std::string>(publisherPort.portData->m_caproInstanceID)).c_str());
wprintw(
pad,
" %s |",
printEntry(eventWidth, iox::into<std::string>(publisherPort.portData->m_caproEventMethodID)).c_str());
wprintw(pad,
" %s |",
printEntry(runtimeNameWidth, iox::into<std::string>(publisherPort.portData->m_name)).c_str());
Expand Down Expand Up @@ -476,24 +475,20 @@ void IntrospectionApp::printPortIntrospectionData(const std::vector<ComposedPubl
do
{
needsLineBreak = false;
wprintw(
pad,
" %s |",
printEntry(serviceWidth, iox::into<std::string>(subscriber.portData->m_caproServiceID)).c_str());
wprintw(
pad,
" %s |",
printEntry(instanceWidth, iox::into<std::string>(subscriber.portData->m_caproInstanceID)).c_str());
wprintw(
pad,
" %s |",
printEntry(eventWidth, iox::into<std::string>(subscriber.portData->m_caproEventMethodID)).c_str());
wprintw(pad,
" %s |",
printEntry(runtimeNameWidth, iox::into<std::string>(subscriber.portData->m_name)).c_str());
printEntry(serviceWidth, iox::into<std::string>(subscriber.portData->m_caproServiceID)).c_str());
wprintw(pad,
" %s |",
printEntry(instanceWidth, iox::into<std::string>(subscriber.portData->m_caproInstanceID)).c_str());
wprintw(pad,
" %s |",
printEntry(nodeNameWidth, iox::into<std::string>(subscriber.portData->m_node)).c_str());
printEntry(eventWidth, iox::into<std::string>(subscriber.portData->m_caproEventMethodID)).c_str());
wprintw(pad,
" %s |",
printEntry(runtimeNameWidth, iox::into<std::string>(subscriber.portData->m_name)).c_str());
wprintw(
pad, " %s |", printEntry(nodeNameWidth, iox::into<std::string>(subscriber.portData->m_node)).c_str());
wprintw(pad,
" %s |",
printEntry(subscriptionStateWidth,
Expand Down

0 comments on commit db36e1a

Please sign in to comment.