Template Class Selector
Defined in File selector.hpp
Inheritance Relationships
Base Type
public fkie_message_filters::Filter< IO< Inputs... >, IO< Inputs... >::template Select< Is... > >(Template Class Filter)
Class Documentation
-
template<class ...Inputs, std::size_t... Is>
class Selector : public fkie_message_filters::Filter<IO<Inputs...>, IO<Inputs...>::template Select<Is...>> Reorder or reduce an N-ary filter.
This filter reorders the arguments of an N-ary filter and/or chooses an arbitrary subset of the input arguments. The output arguments are selected from the input by index. The following example reduces a ternary filter to a binary filter of the first two arguments, in swapped order:
namespace mf = fkie_message_filters; using BufferIn = mf::Buffer<T0, T1, T2>; using Select = mf::Selector<BufferIn::Output, 1, 0>; using BufferOut = mf::Buffer<T1, T0>; BufferIn buf_in; Select select; BufferOut buf_out; mf::chain(buf_in, select, buf_out);
Public Types
Public Functions
-
Connection connect_to_sink(Sink<Outputs...> &dst) noexcept
Connect this source to a sink.
Can be called multiple times to connect multiple sinks; in that case, the sinks receive data in the same order as they have been connected. This function does basically the same thing as Sink::connect_to_source(), only from the opposite point of view.
dstthe sink that is to be connected
Does not throw any exceptions.
- Returns:
a connection object that can be used to monitor or sever the created connection
-
Connection connect_to_source(Source<Inputs...> &src) noexcept
Connect this sink to a source.
Can be called multiple times to connect multiple sources; in that case, the sink receives data from all connected sources. This function does basically the same thing as Source::connect_to_sink(), only from the opposite point of view.
srcthe source that is to be connected
Does not throw any exceptions.
- Returns:
a connection object that can be used to monitor or sever the created connection
-
virtual void disconnect() noexcept override
Disconnect from all connected sources and sinks.
Convenience function that calls disconnect_from_all_sources() and disonnect_from_all_sinks().
Does not throw any exceptions.
-
void disconnect_from_all_sinks() noexcept
Disconnect from all connected sinks.
Severs the connection to all sinks, turning the send() method into a no-op.
Does not throw any exceptions.
-
void disconnect_from_all_sources() noexcept
Disconnect from all connected sources.
Severs the connection to all sources. The receive() method will not be called any more.
Does not throw any exceptions.
-
inline virtual void reset() noexcept
Reset filter state.
For stateful filters, this method resets the internal state as if the filter had just been created. Existing connections to sources and sinks are unaffected.
The default implementation does nothing.
Does not throw any exceptions.
Public Static Attributes
-
static std::size_t NUM_INPUTS
Number of input arguments.
-
static std::size_t NUM_OUTPUTS
Number of output arguments.
Protected Functions
-
virtual void receive(helpers::argument_t<Inputs>... in) override
Process incoming data.
Derived classes need to override this method to handle all data that is to be consumed by the sink.
Depends on the implementation.
-
void send(helpers::argument_t<Outputs>... out)
Pass data to all connected sinks.
outdata
Does not throw any exceptions, but will propagate uncaught exceptions from filter callbacks.
-
Connection connect_to_sink(Sink<Outputs...> &dst) noexcept