Skip to content

Commit

Permalink
Merge pull request #511 from elfenpiff/iox2-496-disable-slice-specifi…
Browse files Browse the repository at this point in the history
…c-builder-methods

[#496] disable slice specific builder methods
  • Loading branch information
elfenpiff authored Nov 12, 2024
2 parents 5b8e6ee + 2a91131 commit 9463c6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/release-notes/iceoryx2-unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* Rename `NodeEvent` into `WaitEvent` [#390](https://github.com/eclipse-iceoryx/iceoryx2/issues/390)
* Bazel support for the Rust crates [#349](https://github.com/eclipse-iceoryx/iceoryx2/issues/349)
* Remove ACL dependency [#457](https://github.com/eclipse-iceoryx/iceoryx2/issues/457)
* Remove `max_slice_len` publisher builder option for non-slice types [#496](https://github.com/eclipse-iceoryx/iceoryx2/issues/496)
* Publish Subscribe Header contains number of elements contained in a `Sample` [#498](https://github.com/eclipse-iceoryx/iceoryx2/issues/498)

### Workflow
Expand Down
17 changes: 13 additions & 4 deletions iceoryx2-ffi/cxx/include/iox2/port_factory_publisher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ class PortFactoryPublisher {
/// [`Publisher::loan()`] or [`Publisher::loan_uninit()`] in parallel.
IOX_BUILDER_OPTIONAL(uint64_t, max_loaned_samples);

/// Sets the maximum slice length that a user can allocate with
/// [`Publisher::loan_slice()`] or [`Publisher::loan_slice_uninit()`].
IOX_BUILDER_OPTIONAL(uint64_t, max_slice_len);

public:
PortFactoryPublisher(const PortFactoryPublisher&) = delete;
PortFactoryPublisher(PortFactoryPublisher&&) = default;
auto operator=(const PortFactoryPublisher&) -> PortFactoryPublisher& = delete;
auto operator=(PortFactoryPublisher&&) -> PortFactoryPublisher& = default;
~PortFactoryPublisher() = default;

/// Sets the maximum slice length that a user can allocate with
/// [`Publisher::loan_slice()`] or [`Publisher::loan_slice_uninit()`].
template <typename T = Payload, typename = std::enable_if_t<iox::IsSlice<T>::VALUE, void>>
auto max_slice_len(uint64_t value) && -> PortFactoryPublisher&&;

/// Creates a new [`Publisher`] or returns a [`PublisherCreateError`] on failure.
auto create() && -> iox::expected<Publisher<S, Payload, UserHeader>, PublisherCreateError>;

Expand All @@ -57,13 +58,21 @@ class PortFactoryPublisher {
explicit PortFactoryPublisher(iox2_port_factory_publisher_builder_h handle);

iox2_port_factory_publisher_builder_h m_handle;
iox::optional<uint64_t> m_max_slice_len;
};

template <ServiceType S, typename Payload, typename UserHeader>
inline PortFactoryPublisher<S, Payload, UserHeader>::PortFactoryPublisher(iox2_port_factory_publisher_builder_h handle)
: m_handle { handle } {
}

template <ServiceType S, typename Payload, typename UserHeader>
template <typename T, typename>
inline auto PortFactoryPublisher<S, Payload, UserHeader>::max_slice_len(uint64_t value) && -> PortFactoryPublisher&& {
m_max_slice_len.emplace(value);
return std::move(*this);
}

template <ServiceType S, typename Payload, typename UserHeader>
inline auto
PortFactoryPublisher<S, Payload, UserHeader>::create() && -> iox::expected<Publisher<S, Payload, UserHeader>,
Expand Down

0 comments on commit 9463c6d

Please sign in to comment.