Go to the documentation of this file.
20 #ifndef INCLUDE_FKIE_MESSAGE_FILTERS_COMBINER_H_
21 #define INCLUDE_FKIE_MESSAGE_FILTERS_COMBINER_H_
33 namespace combiner_policies
71 template<
template<
typename...>
class PolicyTmpl,
class... IOs>
74 template<template<typename...> class PolicyTmpl, class... IOs>
75 class Combiner :
public Source<IOs...>
80 static constexpr std::size_t
NUM_SINKS =
sizeof...(IOs);
82 using Connections = std::array<Connection, NUM_SINKS>;
84 template<std::
size_t N>
87 using Policy = PolicyTmpl<IOs...>;
95 template<
std::
size_t N>
98 template<
std::
size_t N>
125 void reset() noexcept override;
134 template<typename... Inputs>
138 using Tuple = std::tuple<Inputs...>;
139 using PolicyInFunc = std::function<void(std::unique_lock<std::mutex>&,
const Tuple&)>;
140 void set_parent(
Combiner* parent) noexcept;
141 void set_policy_input(
const PolicyInFunc&
f) noexcept;
143 void receive(
const Inputs&... in)
override;
145 PolicyInFunc forward_;
150 std::tuple<typename IOs::template Rewrap<CombinerSink>...>
sinks_;
152 template<
std::
size_t N, typename ThisSource, typename... OtherSources>
154 template<
std::
size_t N>
160 #include "combiner_impl.h"
void disconnect() noexcept override
Disconnect from all connected sources and sinks.
void disconnect_from_all_sources() noexcept
Disconnect the sinks from their sources.
std::tuple_element_t< N, std::tuple< Ts... > > select_nth
const Policy & policy() const noexcept
Access combiner policy.
static constexpr std::size_t NUM_SINKS
Number of sinks.
PolicyTmpl< IOs... > Policy
Class type of the policy that applies to the combiner.
void set_policy(const Policy &policy) noexcept
Set combiner policy.
void reset() noexcept override
Reset filter.
std::array< Connection, NUM_SINKS > Connections
Array of connection objects.
std::tuple< typename IOs::template Rewrap< CombinerSink >... > sinks_
SinkType< N > & sink() noexcept
Access the sink for the Nth input.
void connect_policy() noexcept
Connections connect_to_sources(helpers::io_rewrap_t< IOs, Source > &... sources) noexcept
Convenience function to connect all sinks at once.
Combine multiple sources into a single one.
typename io_rewrap< IO, Wrap >::type io_rewrap_t
std::tuple< typename helpers::io_tuple_t< IOs >... > IncomingTuples
void connect_to_sources_impl(Connections &conn, ThisSource &src, OtherSources &... sources) noexcept
Combiner(const Policy &policy=Policy()) noexcept
Constructor.
Base class for data consumers.
std::mutex combiner_mutex_
Base class for data providers.
helpers::io_rewrap_t< helpers::select_nth< N, IOs... >, Sink > SinkType
Base class for the Nth sink.
helpers::io_tuple_t< helpers::io_concat_t< IOs... > > OutgoingTuple
typename io_tuple< IO >::type io_tuple_t
typename io_concat< Ts... >::type io_concat_t