Skip to content

Commit

Permalink
iox-#218 Clang format.
Browse files Browse the repository at this point in the history
Signed-off-by: Ithier Jeff (CC-AD/EYF1) <[email protected]>
  • Loading branch information
orecham committed Sep 29, 2020
1 parent 80b471e commit d7df2b2
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace iox
{
namespace popo
{

// ============================== BasePublisher ============================== //

template <typename T, typename port_t>
Expand Down Expand Up @@ -93,23 +92,21 @@ inline bool BasePublisher<T, port_t>::hasSubscribers() const noexcept
template <typename T, typename port_t>
inline Sample<T> BasePublisher<T, port_t>::convertChunkHeaderToSample(const mepoo::ChunkHeader* const header) noexcept
{
return Sample<T>(
cxx::unique_ptr<T>(reinterpret_cast<T*>(header->payload()), m_sampleDeleter),
*this);
return Sample<T>(cxx::unique_ptr<T>(reinterpret_cast<T*>(header->payload()), m_sampleDeleter), *this);
}

// ============================== Sample Deleter ============================== //

template <typename T, typename port_t>
inline BasePublisher<T, port_t>::PublisherSampleDeleter::PublisherSampleDeleter(port_t& port)
: m_port(std::ref(port))
{}
{
}

template <typename T, typename port_t>
inline void BasePublisher<T, port_t>::PublisherSampleDeleter::operator()(T* const ptr) const
{
auto header =
mepoo::convertPayloadPointerToChunkHeader(reinterpret_cast<void*>(ptr));
auto header = mepoo::convertPayloadPointerToChunkHeader(reinterpret_cast<void*>(ptr));
m_port.get().freeChunk(header);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace iox
{
namespace popo
{

// ============================== BaseSubscriber ============================== //

template <typename T, typename port_t>
Expand Down Expand Up @@ -121,13 +120,13 @@ inline bool BaseSubscriber<T, port_t>::hasTriggered() const noexcept
template <typename T, typename port_t>
inline BaseSubscriber<T, port_t>::SubscriberSampleDeleter::SubscriberSampleDeleter(port_t& port)
: m_port(std::ref(port))
{}
{
}

template <typename T, typename port_t>
inline void BaseSubscriber<T, port_t>::SubscriberSampleDeleter::operator()(T* const ptr) const
{
auto header =
mepoo::convertPayloadPointerToChunkHeader(reinterpret_cast<void*>(ptr));
auto header = mepoo::convertPayloadPointerToChunkHeader(reinterpret_cast<void*>(ptr));
m_port.get().releaseChunk(header);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace iox
{
namespace popo
{

template <typename base_subscriber_t>
UntypedSubscriberImpl<base_subscriber_t>::UntypedSubscriberImpl(const capro::ServiceDescription& service)
: base_subscriber_t(service)
Expand Down Expand Up @@ -63,7 +62,8 @@ inline bool UntypedSubscriberImpl<base_subscriber_t>::hasNewSamples() const noex
}

template <typename base_subscriber_t>
inline cxx::expected<cxx::optional<Sample<const void>>, ChunkReceiveError> UntypedSubscriberImpl<base_subscriber_t>::receive() noexcept
inline cxx::expected<cxx::optional<Sample<const void>>, ChunkReceiveError>
UntypedSubscriberImpl<base_subscriber_t>::receive() noexcept
{
return base_subscriber_t::receive();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#ifndef IOX_EXPERIMENTAL_POSH_POPO_BASE_PUBLISHER_HPP
#define IOX_EXPERIMENTAL_POSH_POPO_BASE_PUBLISHER_HPP

#include "iceoryx_posh/popo/modern_api/sample.hpp"
#include "iceoryx_posh/internal/popo/ports/publisher_port_user.hpp"
#include "iceoryx_posh/popo/modern_api/sample.hpp"
#include "iceoryx_utils/cxx/expected.hpp"
#include "iceoryx_utils/cxx/optional.hpp"

Expand Down Expand Up @@ -106,9 +106,8 @@ class BasePublisher : public PublisherInterface<T>
BasePublisher(const capro::ServiceDescription& service);

private:

///
/// @brief The PublisherSampleDeleter struct is a custom deleter in functor form which releases laons to a sample's
/// @brief The PublisherSampleDeleter struct is a custom deleter in functor form which releases loans to a sample's
/// underlying memory chunk via a publishers publisher port.
/// Each publisher should create its own instance of this deleter struct to work with its specific port.
///
Expand All @@ -117,10 +116,11 @@ class BasePublisher : public PublisherInterface<T>
///
struct PublisherSampleDeleter
{
public:
public:
PublisherSampleDeleter(port_t& port);
void operator()(T* const ptr) const;
private:

private:
std::reference_wrapper<port_t> m_port;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#ifndef IOX_EXPERIMENTAL_POSH_POPO_BASE_SUBSCRIBER_HPP
#define IOX_EXPERIMENTAL_POSH_POPO_BASE_SUBSCRIBER_HPP

#include "iceoryx_posh/popo/modern_api/sample.hpp"
#include "iceoryx_posh/internal/popo/ports/subscriber_port_user.hpp"
#include "iceoryx_posh/popo/condition.hpp"
#include "iceoryx_posh/popo/modern_api/sample.hpp"
#include "iceoryx_utils/cxx/expected.hpp"
#include "iceoryx_utils/cxx/optional.hpp"
#include "iceoryx_utils/cxx/unique_ptr.hpp"
Expand Down Expand Up @@ -96,9 +96,8 @@ class BaseSubscriber : public Condition
BaseSubscriber(const capro::ServiceDescription& service);

private:

///
/// @brief The SubscriberSampleDeleter struct is a custom deleter in functor form which releases laons to a sample's
/// @brief The SubscriberSampleDeleter struct is a custom deleter in functor form which releases loans to a sample's
/// underlying memory chunk via a subscriber's subscriber port.
/// Each subscriber should create its own instance of this deleter struct to work with its specific port.
///
Expand All @@ -107,10 +106,11 @@ class BaseSubscriber : public Condition
///
struct SubscriberSampleDeleter
{
public:
public:
SubscriberSampleDeleter(port_t& port);
void operator()(T* const ptr) const;
private:

private:
std::reference_wrapper<port_t> m_port;
};

Expand Down
4 changes: 2 additions & 2 deletions iceoryx_posh/include/iceoryx_posh/popo/modern_api/sample.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Sample
void publish() noexcept;

protected:
cxx::unique_ptr<T> m_samplePtr{[](T* const){}}; // Placeholder. This is overwritten on sample construction.
cxx::unique_ptr<T> m_samplePtr{[](T* const) {}}; // Placeholder. This is overwritten on sample construction.
std::reference_wrapper<PublisherInterface<T>> m_publisherRef;
};

Expand All @@ -93,7 +93,7 @@ class Sample<const T>
const mepoo::ChunkHeader* getHeader() noexcept;

private:
cxx::unique_ptr<T> m_samplePtr{[](T* const){}}; // Placeholder. This is overwritten on sample construction.
cxx::unique_ptr<T> m_samplePtr{[](T* const) {}}; // Placeholder. This is overwritten on sample construction.
};

} // namespace popo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace iox
{
namespace popo
{

template <typename base_subscriber_t = BaseSubscriber<void>>
class UntypedSubscriberImpl : public base_subscriber_t
{
Expand Down
10 changes: 5 additions & 5 deletions iceoryx_posh/test/mocks/subscriber_mock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "iceoryx_posh/mepoo/chunk_header.hpp"
#include "iceoryx_posh/popo/modern_api/base_subscriber.hpp"
#include "iceoryx_posh/popo/modern_api/sample.hpp"
#include "iceoryx_posh/mepoo/chunk_header.hpp"
#include "iceoryx_utils/cxx/expected.hpp"
#include "iceoryx_utils/cxx/optional.hpp"

Expand Down Expand Up @@ -45,21 +45,21 @@ class MockSubscriberPortUser
MOCK_METHOD0(isConditionVariableSet, bool());
};

template<typename T>
template <typename T>
class MockBaseSubscriber
{
public:
public:
MockBaseSubscriber(const iox::capro::ServiceDescription&){};
MOCK_CONST_METHOD0(getUid, iox::popo::uid_t());
MOCK_CONST_METHOD0(getServiceDescription, iox::capro::ServiceDescription());
MOCK_METHOD1(subscribe, void(uint64_t));
MOCK_CONST_METHOD0(getSubscriptionState, iox::SubscribeState());
MOCK_METHOD0(unsubscribe, void());
MOCK_CONST_METHOD0(hasNewSamples, bool());
MOCK_METHOD0_T(receive, iox::cxx::expected<iox::cxx::optional<iox::popo::Sample<const T>>, iox::popo::ChunkReceiveError>());
MOCK_METHOD0_T(receive,
iox::cxx::expected<iox::cxx::optional<iox::popo::Sample<const T>>, iox::popo::ChunkReceiveError>());
MOCK_METHOD0(releaseQueuedSamples, void());
MOCK_METHOD1(setConditionVariable, bool(iox::popo::ConditionVariableData*));
MOCK_METHOD0(unsetConditionVariable, bool(void));
MOCK_METHOD0(hasTriggered, bool(void));
};

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "iceoryx_posh/popo/modern_api/base_subscriber.hpp"
#include "iceoryx_posh/iceoryx_posh_types.hpp"
#include "iceoryx_posh/popo/modern_api/base_subscriber.hpp"
#include "iceoryx_utils/cxx/expected.hpp"
#include "iceoryx_utils/cxx/optional.hpp"
#include "iceoryx_utils/cxx/unique_ptr.hpp"
Expand Down
9 changes: 4 additions & 5 deletions iceoryx_posh/test/moduletests/test_popo_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "iceoryx_posh/popo/modern_api/sample.hpp"
#include "iceoryx_posh/popo/modern_api/base_publisher.hpp"
#include "iceoryx_posh/popo/modern_api/sample.hpp"
#include "iceoryx_utils/cxx/unique_ptr.hpp"
#include "test.hpp"

Expand All @@ -26,10 +26,10 @@ struct DummyData
int val = 42;
};

template<typename T>
template <typename T>
class MockPublisherInterface : public iox::popo::PublisherInterface<T>
{
public:
public:
void publish(iox::popo::Sample<T>&& sample) noexcept
{
return publishMock(std::move(sample));
Expand Down Expand Up @@ -58,7 +58,7 @@ class SampleTest : public Test
TEST_F(SampleTest, PublishesSampleViaPublisherInterface)
{
// ===== Setup ===== //
iox::cxx::unique_ptr<DummyData> testSamplePtr{new DummyData(), [](DummyData* ptr){delete ptr;}};
iox::cxx::unique_ptr<DummyData> testSamplePtr{new DummyData(), [](DummyData* ptr) { delete ptr; }};
MockPublisherInterface<DummyData> mockPublisherInterface{};

auto sut = iox::popo::Sample<DummyData>(std::move(testSamplePtr), mockPublisherInterface);
Expand All @@ -79,4 +79,3 @@ TEST_F(SampleTest, Template)
// ===== Verify ===== //
// ===== Cleanup ===== //
}

14 changes: 7 additions & 7 deletions iceoryx_posh/test/moduletests/test_popo_typed_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ TEST_F(TypedPublisherTest, PublishesSampleViaBasePublisher)
TEST_F(TypedPublisherTest, CanLoanSamplesAndPublishTheResultOfALambdaWithAdditionalArguments)
{
// ===== Setup ===== //
auto chunk =
reinterpret_cast<iox::mepoo::ChunkHeader*>(iox::cxx::alignedAlloc(32, sizeof(iox::mepoo::ChunkHeader) + sizeof(DummyData)));
auto sample = new iox::popo::Sample<DummyData>(
iox::cxx::unique_ptr<DummyData>(reinterpret_cast<DummyData*>(chunk->payload()),
[](DummyData* const) {} // Placeholder deleter.
),
sut);
auto chunk = reinterpret_cast<iox::mepoo::ChunkHeader*>(
iox::cxx::alignedAlloc(32, sizeof(iox::mepoo::ChunkHeader) + sizeof(DummyData)));
auto sample =
new iox::popo::Sample<DummyData>(iox::cxx::unique_ptr<DummyData>(reinterpret_cast<DummyData*>(chunk->payload()),
[](DummyData* const) {} // Placeholder deleter.
),
sut);
EXPECT_CALL(sut, loan).WillOnce(
Return(ByMove(iox::cxx::success<iox::popo::Sample<DummyData>>(std::move(*sample)))));
EXPECT_CALL(sut, publishMocked).Times(1);
Expand Down
4 changes: 3 additions & 1 deletion iceoryx_posh/test/moduletests/test_popo_typed_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ TEST_F(TypedSubscriberTest, ChecksForNewSamplesViaBaseSubscriber)
TEST_F(TypedSubscriberTest, ReceivesSamplesViaBaseSubscriber)
{
// ===== Setup ===== //
EXPECT_CALL(sut, receive).Times(1).WillOnce(Return(ByMove(iox::cxx::success<iox::cxx::optional<iox::popo::Sample<const DummyData>>>())));
EXPECT_CALL(sut, receive)
.Times(1)
.WillOnce(Return(ByMove(iox::cxx::success<iox::cxx::optional<iox::popo::Sample<const DummyData>>>())));
// ===== Test ===== //
sut.receive();
// ===== Verify ===== //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ TEST_F(UntypedSubscriberTest, ChecksForNewSamplesViaBaseSubscriber)
TEST_F(UntypedSubscriberTest, ReceivesSamplesViaBaseSubscriber)
{
// ===== Setup ===== //
EXPECT_CALL(sut, receive).Times(1).WillOnce(Return(ByMove(iox::cxx::success<iox::cxx::optional<iox::popo::Sample<const void>>>())));
EXPECT_CALL(sut, receive)
.Times(1)
.WillOnce(Return(ByMove(iox::cxx::success<iox::cxx::optional<iox::popo::Sample<const void>>>())));
// ===== Test ===== //
sut.receive();
// ===== Verify ===== //
Expand Down

0 comments on commit d7df2b2

Please sign in to comment.