FKIE Message Filters
Improved filters for processing ROS messages
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
fkie_message_filters::Divider< Inputs > Class Template Reference

Split an N-ary source into N unary ones. More...

#include <fkie_message_filters/divider.h>

Inheritance diagram for fkie_message_filters::Divider< Inputs >:
Inheritance graph
[legend]
Collaboration diagram for fkie_message_filters::Divider< Inputs >:
Collaboration graph
[legend]

Public Types

using Connections = std::array< Connection, NUM_INPUTS >
 Array of connection objects.
 
using Input = IO< Inputs... >
 Grouped input types. More...
 
template<std::size_t N>
using SourceType = helpers::select_nth< N, Source< Inputs >... >
 Base class of the Nth source.
 

Public Member Functions

Connections connect_to_sinks (Sink< Inputs > &... sinks) noexcept
 Convenience function to connect all sources at once. More...
 
Connection connect_to_source (Source< Inputs... > &src) noexcept
 Connect this sink to a source. More...
 
void disconnect () noexcept override
 Disconnect from all connected sources and sinks. More...
 
void disconnect_from_all_sinks () noexcept
 Disconnect all sources from their sinks. More...
 
void disconnect_from_all_sources () noexcept
 Disconnect from all connected sources. More...
 
virtual void reset () noexcept
 Reset filter state. More...
 
template<std::size_t N>
SourceType< N > & source () noexcept
 Access the source for the Nth data element.
 
template<std::size_t N>
const SourceType< N > & source () const noexcept
 Access the source for the Nth data element.
 

Static Public Attributes

static constexpr std::size_t NUM_INPUTS
 Number of input arguments.
 

Protected Member Functions

void receive (const Inputs &... in) override
 Process incoming data. More...
 

Detailed Description

template<class... Inputs>
class fkie_message_filters::Divider< Inputs >

Split an N-ary source into N unary ones.

The divider splits an N-ary source into its constituent elements, so they can be processed independently. It is mostly used as the penultimate pipeline filter to forward message tuples to independent Publisher instances.

Technically, the divider acts as one sink and N sources, one for each data type that is passed in. You can connect the sources independently using the source() function.

The divider will always completely separate the input arguments. If you want a partial split only, you should use one or more Selector filters instead.

namespace mf = fkie_message_filters;
using BufferIn = mf::Buffer<M1, M2>;
using MyDivider = mf::Divider<BufferIn::Output>;
BufferIn buf_in;
MyDivider div;
mf::Publisher<M1, mf::RosMessage> pub1;
mf::Publisher<M2, mf::RosMessage> pub2;
mf::chain(buf_in, div);
div.connect_to_sinks(pub1, pub2);
See also
Combiner

Member Typedef Documentation

◆ Input

using fkie_message_filters::Sink< Inputs >::Input = IO<Inputs...>
inherited

Grouped input types.

This type can be used to define sources with matching types.

Member Function Documentation

◆ connect_to_sinks()

template<class... Inputs>
Connections fkie_message_filters::Divider< Inputs >::connect_to_sinks ( Sink< Inputs > &...  sinks)
noexcept

Convenience function to connect all sources at once.

Exceptions
Does not throw any exceptions.

◆ connect_to_source()

Connection fkie_message_filters::Sink< Inputs >::connect_to_source ( Source< Inputs... > &  src)
noexceptinherited

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.

  • src the source that is to be connected
Returns
a connection object that can be used to monitor or sever the created connection
Exceptions
Does not throw any exceptions.

◆ disconnect()

template<class... Inputs>
void fkie_message_filters::Divider< Inputs >::disconnect ( )
overridevirtualnoexcept

Disconnect from all connected sources and sinks.

Exceptions
Does not throw any exceptions.

Reimplemented from fkie_message_filters::Sink< Inputs... >.

◆ disconnect_from_all_sinks()

template<class... Inputs>
void fkie_message_filters::Divider< Inputs >::disconnect_from_all_sinks ( )
noexcept

Disconnect all sources from their sinks.

Exceptions
Does not throw any exceptions.

◆ disconnect_from_all_sources()

void fkie_message_filters::Sink< Inputs >::disconnect_from_all_sources ( )
noexceptinherited

Disconnect from all connected sources.

Severs the connection to all sources. The receive() method will not be called any more.

Exceptions
Does not throw any exceptions.

◆ receive()

template<class... Inputs>
void fkie_message_filters::Divider< Inputs >::receive ( const Inputs &...  in)
overrideprotectedvirtual

Process incoming data.

Derived classes need to override this method to handle all data that is to be consumed by the sink.

Exceptions
Depends on the implementation.

Implements fkie_message_filters::Sink< Inputs... >.

◆ reset()

virtual void fkie_message_filters::FilterBase::reset ( )
inlinevirtualnoexceptinherited

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.

Exceptions
Does not throw any exceptions.

Reimplemented in fkie_message_filters::Buffer< Inputs >, fkie_message_filters::Buffer< Inputs... >, fkie_message_filters::TfFilter< Inputs >, fkie_message_filters::TfFilter< Inputs... >, fkie_message_filters::Combiner< PolicyTmpl, IOs >, fkie_message_filters::Sequencer< Inputs >, and fkie_message_filters::Sequencer< Inputs... >.


The documentation for this class was generated from the following file: