Skip to content

Commit

Permalink
iox-eclipse-iceoryx#408 review findings and clang-format
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Poehnl <michael.poehnl@apex.ai>
  • Loading branch information
budrus authored and marthtz committed May 12, 2021
1 parent 53914c0 commit cd055f5
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 34 deletions.
2 changes: 1 addition & 1 deletion iceoryx_binding_c/test/moduletests/test_publisher.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 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 Expand Up @@ -234,4 +235,3 @@ TEST_F(iox_pub_test, sendDeliversChunk)
EXPECT_TRUE(*maybeSharedChunk == chunk);
EXPECT_TRUE(static_cast<DummySample*>(maybeSharedChunk->getPayload())->dummy == 4711);
}

6 changes: 3 additions & 3 deletions iceoryx_examples/icedelivery/iox_publisher_with_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ int main()
iox::popo::PublisherOptions publisherOptions;

// the publishers stores the last 10 samples for possible late joiners
publisherOptions.historyCapacity = 10U;
publisherOptions.historyCapacity = 10U;

// when the publisher is created, it is not yet visible
// when the publisher is created, it is not yet visible
publisherOptions.offerOnCreate = false;

// grouping of publishers and subscribers within a process
publisherOptions.nodeName = "Pub_Node_With_Options";
publisherOptions.nodeName = "Pub_Node_With_Options";

iox::popo::Publisher<RadarObject> publisher({"Radar", "FrontLeft", "Object"}, publisherOptions);

Expand Down
18 changes: 9 additions & 9 deletions iceoryx_examples/icedelivery/iox_subscriber_with_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@ int main()

// create subscriber with some options set
iox::popo::SubscriberOptions subscriberOptions;
// the queue can hold 10 samples, on overflow the oldest sample will be replaced with the new arriving one

// the queue can hold 10 samples, on overflow the oldest sample will be replaced with the new arriving one
subscriberOptions.queueCapacity = 10U;

// When starting the subscriber late it will miss the first samples which the
// publisher has send. The history request ensures that we at least get the last 5
// samples sent by the publisher when we subscribe (if at least 5 were already sent
// and the publisher has history enabled).
subscriberOptions.historyRequest = 5U;
// when the subscriber is created, no attempts are made to connect to any publishers that may exist

// when the subscriber is created, no attempts are made to connect to any publishers that may exist
subscriberOptions.subscribeOnCreate = false;
// grouping of publishers and subscribers within a process
subscriberOptions.nodeName = "Sub_Node_With_Options";

// grouping of publishers and subscribers within a process
subscriberOptions.nodeName = "Sub_Node_With_Options";

iox::popo::Subscriber<RadarObject> subscriber({"Radar", "FrontLeft", "Object"}, subscriberOptions);

// We have to explicitly call subscribe() otherwise the subscriber will not try to connect to publishers
subscriber.subscribe();

Expand Down
1 change: 1 addition & 0 deletions iceoryx_examples/iceperf/iceoryx.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 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
1 change: 0 additions & 1 deletion iceoryx_examples/waitset/ice_waitset_grouping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ int main()
{
subscriberVector.emplace_back(iox::capro::ServiceDescription{"Radar", "FrontLeft", "Counter"});
auto& subscriber = subscriberVector.back();

}

constexpr uint64_t FIRST_GROUP_ID = 123U;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ class PortManager
void removeEntryFromServiceRegistry(const capro::IdString_t& service, const capro::IdString_t& instance) noexcept;

template <typename T, std::enable_if_t<std::is_same<T, iox::build::OneToManyPolicy>::value>* = nullptr>
cxx::optional<ProcessName_t> doesViolateCommunicationPolicy(const capro::ServiceDescription& service) const
noexcept;
cxx::optional<ProcessName_t>
doesViolateCommunicationPolicy(const capro::ServiceDescription& service) const noexcept;

template <typename T, std::enable_if_t<std::is_same<T, iox::build::ManyToManyPolicy>::value>* = nullptr>
cxx::optional<ProcessName_t> doesViolateCommunicationPolicy(const capro::ServiceDescription& service
Expand Down
3 changes: 1 addition & 2 deletions iceoryx_posh/include/iceoryx_posh/popo/publisher_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ struct PublisherOptions
iox::NodeName_t nodeName{""};

/// @brief The option whether the publisher should already be offered when creating it
bool offerOnCreate = {true};

bool offerOnCreate{true};
};

} // namespace popo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ struct SubscriberOptions
iox::NodeName_t nodeName{""};

/// @brief The option whether the subscriber shall try to subscribe when creating it
bool subscribeOnCreate = {true};

bool subscribeOnCreate{true};
};

} // namespace popo
Expand Down
1 change: 1 addition & 0 deletions iceoryx_posh/source/popo/ports/publisher_port_data.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2020, 2021 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 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
1 change: 1 addition & 0 deletions iceoryx_posh/source/popo/ports/publisher_port_roudi.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 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
1 change: 1 addition & 0 deletions iceoryx_posh/source/popo/ports/subscriber_port_data.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2020, 2021 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 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
13 changes: 6 additions & 7 deletions iceoryx_posh/source/roudi/port_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,13 @@ void PortManager::doDiscoveryForPublisherPort(PublisherPortRouDiType& publisherP
else if (capro::CaproMessageType::STOP_OFFER == caproMessage.m_type)
{
this->removeEntryFromServiceRegistry(caproMessage.m_serviceDescription.getServiceIDString(),
caproMessage.m_serviceDescription.getInstanceIDString());
caproMessage.m_serviceDescription.getInstanceIDString());
}
else
{
// protocol error
errorHandler(Error::kPORT_MANAGER__HANDLE_PUBLISHER_PORTS_INVALID_CAPRO_MESSAGE,
nullptr,
iox::ErrorLevel::MODERATE);
errorHandler(
Error::kPORT_MANAGER__HANDLE_PUBLISHER_PORTS_INVALID_CAPRO_MESSAGE, nullptr, iox::ErrorLevel::MODERATE);
}

this->sendToAllMatchingSubscriberPorts(caproMessage, publisherPort);
Expand Down Expand Up @@ -214,8 +213,8 @@ void PortManager::doDiscoveryForSubscriberPort(SubscriberPortType& subscriberPor
{
// protocol error
errorHandler(Error::kPORT_MANAGER__HANDLE_SUBSCRIBER_PORTS_INVALID_CAPRO_MESSAGE,
nullptr,
iox::ErrorLevel::MODERATE);
nullptr,
iox::ErrorLevel::MODERATE);
}
});
}
Expand Down Expand Up @@ -635,7 +634,7 @@ PortManager::acquireSubscriberPortData(const capro::ServiceDescription& service,
if (subscriberPortData)
{
m_portIntrospection.addSubscriber(*subscriberPortData);

// we do discovery here for trying to connect with publishers if subscribe on create is desired
SubscriberPortType subscriberPort(subscriberPortData);
doDiscoveryForSubscriberPort(subscriberPort);
Expand Down
1 change: 1 addition & 0 deletions iceoryx_posh/source/runtime/posh_runtime.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2019, 2021 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 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
8 changes: 5 additions & 3 deletions iceoryx_posh/test/moduletests/test_popo_publisher_port.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH, Apex.AI Inc. All rights reserved.
// Copyright (c) 2021 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 Expand Up @@ -72,22 +73,23 @@ class PublisherPort_test : public Test
iox::posix::Allocator m_memoryAllocator{m_memory, MEMORY_SIZE};
iox::mepoo::MePooConfig m_mempoolconf;
iox::mepoo::MemoryManager m_memoryManager;
iox::popo::PublisherOptions m_noOfferOnCreatePublisherOptions{0U, "", false};;
iox::popo::PublisherOptions m_noOfferOnCreatePublisherOptions{0U, "", false};
;

// publisher port w/o offer on create
iox::popo::PublisherPortData m_publisherPortData{
iox::capro::ServiceDescription("a", "b", "c"), "myApp", &m_memoryManager, m_noOfferOnCreatePublisherOptions};
iox::popo::PublisherPortRouDi m_sutNoOfferOnCreateRouDiSide{&m_publisherPortData};
iox::popo::PublisherPortUser m_sutNoOfferOnCreateUserSide{&m_publisherPortData};

// publisher port w/ history
// publisher port w/ history
iox::popo::PublisherOptions m_withHistoryPublisherOptions{iox::MAX_PUBLISHER_HISTORY, "", true};
iox::popo::PublisherPortData m_publisherPortDataHistory{
iox::capro::ServiceDescription("x", "y", "z"), "myApp", &m_memoryManager, m_withHistoryPublisherOptions};
iox::popo::PublisherPortUser m_sutWithHistoryUserSide{&m_publisherPortDataHistory};
iox::popo::PublisherPortRouDi m_sutWithHistoryRouDiSide{&m_publisherPortDataHistory};

// publisher port w/ default options
// publisher port w/ default options
iox::popo::PublisherOptions m_withDefaultPublisherOptions{};
iox::popo::PublisherPortData m_publisherPortDataDefault{
iox::capro::ServiceDescription("x", "y", "z"), "myApp", &m_memoryManager, m_withDefaultPublisherOptions};
Expand Down
6 changes: 4 additions & 2 deletions iceoryx_posh/test/moduletests/test_popo_subscriber_port.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 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 Expand Up @@ -57,8 +58,9 @@ class SubscriberPortSingleProducer_test : public Test

iox::cxx::GenericRAII m_uniqueRouDiId{[] { iox::popo::internal::setUniqueRouDiId(0); },
[] { iox::popo::internal::unsetUniqueRouDiId(); }};

iox::popo::SubscriberOptions m_noSubscribeOnCreateOptions {iox::popo::SubscriberPortData::ChunkQueueData_t::MAX_CAPACITY, 0U, "", false};

iox::popo::SubscriberOptions m_noSubscribeOnCreateOptions{
iox::popo::SubscriberPortData::ChunkQueueData_t::MAX_CAPACITY, 0U, "", false};
iox::popo::SubscriberPortData m_subscriberPortDataSingleProducer{
TEST_SERVICE_DESCRIPTION,
"myApp",
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 @@ -378,10 +378,10 @@ TEST_F(PortManager_test, offerOnCreateAndSubscribeOnCreate_needsNoMoreDiscoveryL
->acquirePublisherPortData(
{1, 1, 1}, publisherOptions, "guiseppe", m_payloadMemoryManager, PortConfigInfo())
.value());

SubscriberPortUser subscriber(
m_portManager->acquireSubscriberPortData({1, 1, 1}, subscriberOptions, "schlomo", PortConfigInfo()).value());


ASSERT_TRUE(publisher.hasSubscribers());
EXPECT_THAT(subscriber.getSubscriptionState(), Eq(iox::SubscribeState::SUBSCRIBED));
Expand Down

0 comments on commit cd055f5

Please sign in to comment.