Skip to content

Commit 9950a3c

Browse files
committed
iox-#2408 clang format node experimental client, server
1 parent 325bf46 commit 9950a3c

File tree

7 files changed

+86
-64
lines changed

7 files changed

+86
-64
lines changed

iceoryx_posh/experimental/include/iox/posh/experimental/client.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919

2020
#include "iceoryx_posh/iceoryx_posh_types.hpp"
2121
#include "iceoryx_posh/internal/runtime/posh_runtime_impl.hpp"
22-
#include <iceoryx_posh/popo/client.hpp>
23-
#include <iceoryx_posh/popo/untyped_client.hpp>
22+
#include "iceoryx_posh/popo/client.hpp"
23+
#include "iceoryx_posh/popo/untyped_client.hpp"
2424
#include "iox/builder.hpp"
2525
#include "iox/expected.hpp"
2626
#include "iox/unique_ptr.hpp"
2727

2828
namespace iox::posh::experimental
2929
{
3030

31+
using iox::popo::Client;
3132
using iox::popo::ClientChunkQueueData_t;
3233
using iox::popo::ConsumerTooSlowPolicy;
3334
using iox::popo::QueueFullPolicy;
3435
using iox::popo::UntypedClient;
35-
using iox::popo::Client;
3636

3737
enum class ClientBuilderError : uint8_t
3838
{
@@ -78,7 +78,7 @@ class ClientBuilder
7878
private:
7979
friend class Node;
8080
explicit ClientBuilder(runtime::PoshRuntime& runtime,
81-
const capro::ServiceDescription& service_description) noexcept;
81+
const capro::ServiceDescription& service_description) noexcept;
8282

8383
private:
8484
// NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) Intentionally used since the ClientBuilder is not intended to be moved

iceoryx_posh/experimental/include/iox/posh/experimental/detail/client.inl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace iox::posh::experimental
2323
{
2424
inline ClientBuilder::ClientBuilder(runtime::PoshRuntime& runtime,
25-
const capro::ServiceDescription& service_description) noexcept
25+
const capro::ServiceDescription& service_description) noexcept
2626
: m_runtime(runtime)
2727
, m_service_description(service_description)
2828
{
@@ -32,7 +32,8 @@ template <typename Req, typename Res>
3232
inline expected<unique_ptr<Client<Req, Res>>, ClientBuilderError> ClientBuilder::create() noexcept
3333
{
3434
auto* client_port_data = m_runtime.getMiddlewareClient(
35-
m_service_description, {m_response_queue_capacity, "", m_connect_on_create, m_response_queue_full_policy, m_server_too_slow_policy});
35+
m_service_description,
36+
{m_response_queue_capacity, "", m_connect_on_create, m_response_queue_full_policy, m_server_too_slow_policy});
3637
if (client_port_data == nullptr)
3738
{
3839
return err(ClientBuilderError::OUT_OF_RESOURCES);
@@ -47,13 +48,15 @@ inline expected<unique_ptr<Client<Req, Res>>, ClientBuilderError> ClientBuilder:
4748
inline expected<unique_ptr<iox::popo::UntypedClient>, ClientBuilderError> ClientBuilder::create() noexcept
4849
{
4950
auto* client_port_data = m_runtime.getMiddlewareClient(
50-
m_service_description, {m_response_queue_capacity, "", m_connect_on_create, m_response_queue_full_policy, m_server_too_slow_policy});
51+
m_service_description,
52+
{m_response_queue_capacity, "", m_connect_on_create, m_response_queue_full_policy, m_server_too_slow_policy});
5153
if (client_port_data == nullptr)
5254
{
5355
return err(ClientBuilderError::OUT_OF_RESOURCES);
5456
}
5557
return ok(unique_ptr<iox::popo::UntypedClient>{
56-
new (std::nothrow) iox::popo::UntypedClient{iox::popo::ClientPortUser{*client_port_data}}, [&](auto* const client) {
58+
new (std::nothrow) iox::popo::UntypedClient{iox::popo::ClientPortUser{*client_port_data}},
59+
[&](auto* const client) {
5760
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory) raw pointer is required by the unique_ptr API
5861
delete client;
5962
}});

iceoryx_posh/experimental/include/iox/posh/experimental/detail/server.inl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace iox::posh::experimental
2323
{
2424
inline ServerBuilder::ServerBuilder(runtime::PoshRuntime& runtime,
25-
const capro::ServiceDescription& service_description) noexcept
25+
const capro::ServiceDescription& service_description) noexcept
2626
: m_runtime(runtime)
2727
, m_service_description(service_description)
2828
{
@@ -33,7 +33,8 @@ template <typename Req, typename Res>
3333
inline expected<unique_ptr<Server<Req, Res>>, ServerBuilderError> ServerBuilder::create() noexcept
3434
{
3535
auto* server_port_data = m_runtime.getMiddlewareServer(
36-
m_service_description, {m_request_queue_capacity, "", m_offer_on_create, m_request_queue_full_policy, m_client_too_slow_policy});
36+
m_service_description,
37+
{m_request_queue_capacity, "", m_offer_on_create, m_request_queue_full_policy, m_client_too_slow_policy});
3738
if (server_port_data == nullptr)
3839
{
3940
return err(ServerBuilderError::OUT_OF_RESOURCES);
@@ -48,16 +49,17 @@ inline expected<unique_ptr<Server<Req, Res>>, ServerBuilderError> ServerBuilder:
4849
inline expected<unique_ptr<UntypedServer>, ServerBuilderError> ServerBuilder::create() noexcept
4950
{
5051
auto* server_port_data = m_runtime.getMiddlewareServer(
51-
m_service_description, {m_request_queue_capacity, "", m_offer_on_create, m_request_queue_full_policy, m_client_too_slow_policy});
52+
m_service_description,
53+
{m_request_queue_capacity, "", m_offer_on_create, m_request_queue_full_policy, m_client_too_slow_policy});
5254
if (server_port_data == nullptr)
5355
{
5456
return err(ServerBuilderError::OUT_OF_RESOURCES);
5557
}
56-
return ok(unique_ptr<UntypedServer>{
57-
new (std::nothrow) UntypedServer{iox::popo::ServerPortUser{*server_port_data}}, [&](auto* const server) {
58-
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory) raw pointer is required by the unique_ptr API
59-
delete server;
60-
}});
58+
return ok(unique_ptr<UntypedServer>{new (std::nothrow) UntypedServer{iox::popo::ServerPortUser{*server_port_data}},
59+
[&](auto* const server) {
60+
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory) raw pointer is required by the unique_ptr API
61+
delete server;
62+
}});
6163
}
6264

6365
} // namespace iox::posh::experimental

iceoryx_posh/experimental/include/iox/posh/experimental/node.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
#include "iox/builder.hpp"
2727
#include "iox/expected.hpp"
2828
#include "iox/optional.hpp"
29+
#include "iox/posh/experimental/client.hpp"
2930
#include "iox/posh/experimental/publisher.hpp"
30-
#include "iox/posh/experimental/subscriber.hpp"
3131
#include "iox/posh/experimental/server.hpp"
32-
#include "iox/posh/experimental/client.hpp"
32+
#include "iox/posh/experimental/subscriber.hpp"
3333
#include "iox/posh/experimental/wait_set.hpp"
3434
#include "iox/unique_ptr.hpp"
3535

@@ -141,11 +141,7 @@ class Node
141141
runtime::IpcRuntimeInterface&& runtime_interface,
142142
optional<runtime::SharedMemoryUser>&&) noexcept;
143143

144-
static iox::runtime::PoshRuntime& getNodeRuntime([[maybe_unused]] optional<const RuntimeName_t*> name)
145-
{
146-
IOX_ASSERT(s_defaultRuntime, "Node Default Runtime has not been created");
147-
return *Node::s_defaultRuntime;
148-
}
144+
static iox::runtime::PoshRuntime& getNodeRuntime([[maybe_unused]] optional<const RuntimeName_t*> name);
149145

150146
private:
151147
unique_ptr<runtime::PoshRuntime> m_runtime;

iceoryx_posh/experimental/include/iox/posh/experimental/server.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
#include "iceoryx_posh/iceoryx_posh_types.hpp"
2121
#include "iceoryx_posh/internal/runtime/posh_runtime_impl.hpp"
2222
#include "iceoryx_posh/popo/server.hpp"
23-
#include <iceoryx_posh/popo/untyped_server.hpp>
2423
#include "iox/builder.hpp"
2524
#include "iox/expected.hpp"
2625
#include "iox/unique_ptr.hpp"
26+
#include <iceoryx_posh/popo/untyped_server.hpp>
2727

2828
namespace iox::posh::experimental
2929
{
3030

31-
using iox::popo::ServerChunkQueueData_t;
3231
using iox::popo::ConsumerTooSlowPolicy;
3332
using iox::popo::QueueFullPolicy;
3433
using iox::popo::Server;
34+
using iox::popo::ServerChunkQueueData_t;
3535
using iox::popo::UntypedServer;
3636

3737
enum class ServerBuilderError : uint8_t
@@ -77,7 +77,7 @@ class ServerBuilder
7777
private:
7878
friend class Node;
7979
explicit ServerBuilder(runtime::PoshRuntime& runtime,
80-
const capro::ServiceDescription& service_description) noexcept;
80+
const capro::ServiceDescription& service_description) noexcept;
8181

8282
private:
8383
// NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members) Intentionally used since the ServerBuilder is not intended to be moved

iceoryx_posh/experimental/source/node.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,10 @@ WaitSetBuilder Node::wait_set() noexcept
172172
return WaitSetBuilder{*m_runtime.get()};
173173
}
174174

175+
iox::runtime::PoshRuntime& Node::getNodeRuntime([[maybe_unused]] optional<const RuntimeName_t*> name)
176+
{
177+
IOX_ASSERT(s_defaultRuntime, "Node Default Runtime has not been created");
178+
return *Node::s_defaultRuntime;
179+
}
180+
175181
} // namespace iox::posh::experimental

iceoryx_posh/test/integrationtests/test_posh_experimental_node.cpp

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,8 @@ TEST(Node_test, CreatingUntypedServer)
627627
auto domainId = iox::DomainId(1);
628628
RouDiEnv roudi(domainId);
629629

630-
auto node = RouDiEnvNodeBuilder("hypnotoad").domain_id(domainId).create().expect("Creating a node should not fail!");
630+
auto node =
631+
RouDiEnvNodeBuilder("hypnotoad").domain_id(domainId).create().expect("Creating a node should not fail!");
631632

632633
auto server = node.server({"all", "glory", "hypnotoad"}).offer_on_create(true).create();
633634
ASSERT_FALSE(server.has_error());
@@ -637,19 +638,22 @@ TEST(Node_test, CreatingServer)
637638
{
638639
::testing::Test::RecordProperty("TEST_ID", "e422d450-7e1b-4435-b9ff-d0b0530f8f45");
639640

640-
struct Request {
641+
struct Request
642+
{
641643
uint32_t valueA;
642644
uint32_t valueB;
643645
};
644646

645-
struct Response {
647+
struct Response
648+
{
646649
uint32_t sum;
647650
};
648651

649652
auto domainId = iox::DomainId(1);
650653
RouDiEnv roudi(domainId);
651654

652-
auto node = RouDiEnvNodeBuilder("hypnotoad").domain_id(domainId).create().expect("Creating a node should not fail!");
655+
auto node =
656+
RouDiEnvNodeBuilder("hypnotoad").domain_id(domainId).create().expect("Creating a node should not fail!");
653657
auto server = node.server({"all", "glory", "hypnotoad"}).offer_on_create(true).create<Request, Response>();
654658
ASSERT_FALSE(server.has_error());
655659
}
@@ -661,7 +665,8 @@ TEST(Node_test, CreatingUntypedClient)
661665
auto domainId = iox::DomainId(1);
662666
RouDiEnv roudi(domainId);
663667

664-
auto node = RouDiEnvNodeBuilder("hypnotoad").domain_id(domainId).create().expect("Creating a node should not fail!");
668+
auto node =
669+
RouDiEnvNodeBuilder("hypnotoad").domain_id(domainId).create().expect("Creating a node should not fail!");
665670

666671
auto client = node.client({"all", "glory", "hypnotoad"}).connect_on_create(false).create();
667672
ASSERT_FALSE(client.has_error());
@@ -671,19 +676,22 @@ TEST(Node_test, CreatingClient)
671676
{
672677
::testing::Test::RecordProperty("TEST_ID", "290badda-a938-46b8-87ff-b4998ce43d95");
673678

674-
struct Request {
679+
struct Request
680+
{
675681
uint32_t valueA;
676682
uint32_t valueB;
677683
};
678684

679-
struct Response {
685+
struct Response
686+
{
680687
uint32_t sum;
681688
};
682689

683690
auto domainId = iox::DomainId(1);
684691
RouDiEnv roudi(domainId);
685692

686-
auto node = RouDiEnvNodeBuilder("hypnotoad").domain_id(domainId).create().expect("Creating a node should not fail!");
693+
auto node =
694+
RouDiEnvNodeBuilder("hypnotoad").domain_id(domainId).create().expect("Creating a node should not fail!");
687695

688696
auto client = node.client({"all", "glory", "hypnotoad"}).connect_on_create(false).create<Request, Response>();
689697
ASSERT_FALSE(client.has_error());
@@ -693,12 +701,14 @@ TEST(Node_test, UntypedServerClientRequestResponse)
693701
{
694702
::testing::Test::RecordProperty("TEST_ID", "38c02027-f2e5-47cf-9771-65868525647a");
695703

696-
struct Request {
704+
struct Request
705+
{
697706
uint32_t valueA;
698707
uint32_t valueB;
699708
};
700709

701-
struct Response {
710+
struct Response
711+
{
702712
uint32_t sum;
703713
};
704714

@@ -720,41 +730,46 @@ TEST(Node_test, UntypedServerClientRequestResponse)
720730
auto request = static_cast<Request*>(requestPayload);
721731
request->valueA = 4;
722732
request->valueB = 10;
723-
client->send(request)
724-
.or_else([&](auto& error) { GTEST_FAIL() << "Client: Could not send request: " << error; });
733+
client->send(request).or_else(
734+
[&](auto& error) { GTEST_FAIL() << "Client: Could not send request: " << error; });
725735
})
726-
.or_else([&](auto& error) {GTEST_FAIL() << "Client: Could not allocate data request: " << error; });
736+
.or_else([&](auto& error) { GTEST_FAIL() << "Client: Could not allocate data request: " << error; });
727737

728738
GTEST_ASSERT_EQ(client->getConnectionState(), iox::ConnectionState::CONNECTED);
729739

730-
server->take().and_then([&](const auto& requestPayload) {
731-
auto request = static_cast<const Request*>(requestPayload);
732-
const iox::popo::RequestHeader* requestHeader = iox::popo::RequestHeader::fromPayload(requestPayload);
733-
734-
GTEST_ASSERT_EQ(requestHeader->getSequenceId(), 1);
735-
server->loan(requestHeader, sizeof(Response), alignof(Response))
736-
.and_then([&](auto& responsePayload) {
737-
auto response = static_cast<Response*>(responsePayload);
738-
response->sum = request->valueA + request->valueB;
739-
server->send(response).or_else(
740-
[&](auto& error) { GTEST_FAIL() << "Server: Could not send Response: " << error << std::endl; });
741-
})
742-
.or_else([](auto& error) { GTEST_FAIL() << "Server: Could not allocate response: " << error; });
743-
}).or_else([](iox::popo::ServerRequestResult result) {
744-
GTEST_FAIL() << "Server: Could not get request: " << iox::popo::asStringLiteral(result);
745-
});
740+
server->take()
741+
.and_then([&](const auto& requestPayload) {
742+
auto request = static_cast<const Request*>(requestPayload);
743+
const iox::popo::RequestHeader* requestHeader = iox::popo::RequestHeader::fromPayload(requestPayload);
744+
745+
GTEST_ASSERT_EQ(requestHeader->getSequenceId(), 1);
746+
server->loan(requestHeader, sizeof(Response), alignof(Response))
747+
.and_then([&](auto& responsePayload) {
748+
auto response = static_cast<Response*>(responsePayload);
749+
response->sum = request->valueA + request->valueB;
750+
server->send(response).or_else([&](auto& error) {
751+
GTEST_FAIL() << "Server: Could not send Response: " << error << std::endl;
752+
});
753+
})
754+
.or_else([](auto& error) { GTEST_FAIL() << "Server: Could not allocate response: " << error; });
755+
})
756+
.or_else([](iox::popo::ServerRequestResult result) {
757+
GTEST_FAIL() << "Server: Could not get request: " << iox::popo::asStringLiteral(result);
758+
});
746759

747760
GTEST_ASSERT_EQ(client->hasResponses(), true);
748761

749-
client->take().and_then([&](const auto& responsePayload) {
750-
auto responseHeader = iox::popo::ResponseHeader::fromPayload(responsePayload);
751-
GTEST_ASSERT_EQ(responseHeader->getSequenceId(), 1);
752-
auto response = static_cast<const Response*>(responsePayload);
753-
GTEST_ASSERT_EQ(response->sum, 14);
754-
client->releaseResponse(responsePayload);
755-
}).or_else([](iox::popo::ChunkReceiveResult result) {
756-
GTEST_FAIL() << "Client: Could not get response: " << iox::popo::asStringLiteral(result);
757-
});
762+
client->take()
763+
.and_then([&](const auto& responsePayload) {
764+
auto responseHeader = iox::popo::ResponseHeader::fromPayload(responsePayload);
765+
GTEST_ASSERT_EQ(responseHeader->getSequenceId(), 1);
766+
auto response = static_cast<const Response*>(responsePayload);
767+
GTEST_ASSERT_EQ(response->sum, 14);
768+
client->releaseResponse(responsePayload);
769+
})
770+
.or_else([](iox::popo::ChunkReceiveResult result) {
771+
GTEST_FAIL() << "Client: Could not get response: " << iox::popo::asStringLiteral(result);
772+
});
758773
}
759774

760775
} // namespace

0 commit comments

Comments
 (0)