Classes | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
fkie_message_filters::Divider< Inputs > Class Template Reference

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

#include <divider.h>

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

Classes

class  DividerSource
 

Public Types

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

Public Member Functions

Connections connect_to_sinks (Sink< Inputs > &... sinks) noexcept
 Convenience function to connect all sources at once. 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...
 
template<std::size_t N>
Divider< Inputs... >::template SourceType< N > & source () noexcept
 
template<std::size_t N>
const Divider< Inputs... >::template SourceType< N > & source () const noexcept
 
template<std::size_t N>
SourceType< N > & source () noexcept
 Access the source for the Nth data element. More...
 
template<std::size_t N>
const SourceType< N > & source () const noexcept
 Access the source for the Nth data element. More...
 
- Public Member Functions inherited from fkie_message_filters::Sink< Inputs... >
Connection connect_to_source (Source< Inputs... > &src) noexcept
 Connect this sink to a source. More...
 
void disconnect_from_all_sources () noexcept
 Disconnect from all connected sources. More...
 
virtual ~Sink ()
 
- Public Member Functions inherited from fkie_message_filters::FilterBase
virtual void reset () noexcept
 Reset filter state. More...
 
virtual ~FilterBase ()
 

Protected Member Functions

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

Private Member Functions

template<std::size_t N, typename ThisSink , typename... OtherSinks>
void connect_to_sinks_impl (Connections &conn, ThisSink &sink, OtherSinks &... sinks) noexcept
 
template<std::size_t N>
void connect_to_sinks_impl (Connections &conn) noexcept
 
template<std::size_t N, typename ThisInput , typename... OtherInputs>
void forward_to_sources (const ThisInput &in, const OtherInputs &... ins)
 
template<std::size_t N>
void forward_to_sources ()
 

Private Attributes

std::tuple< DividerSource< Inputs >... > sources_
 

Additional Inherited Members

- Static Public Attributes inherited from fkie_message_filters::Sink< Inputs... >
static constexpr std::size_t NUM_INPUTS
 Number of input arguments. 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.

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

Definition at line 59 of file divider.h.

Member Typedef Documentation

◆ Connections

template<class... Inputs>
using fkie_message_filters::Divider< Inputs >::Connections = std::array<Connection, NUM_INPUTS>

Array of connection objects.

Definition at line 64 of file divider.h.

◆ SourceType

template<class... Inputs>
template<std::size_t N>
using fkie_message_filters::Divider< Inputs >::SourceType = helpers::select_nth<N, Source<Inputs>...>

Base class of the Nth source.

Definition at line 66 of file divider.h.

Member Function Documentation

◆ connect_to_sinks()

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

Convenience function to connect all sources at once.

Definition at line 44 of file divider_impl.h.

◆ connect_to_sinks_impl() [1/2]

template<class... Inputs>
template<std::size_t N, typename ThisSink , typename... OtherSinks>
void fkie_message_filters::Divider< Inputs >::connect_to_sinks_impl ( Connections conn,
ThisSink &  sink,
OtherSinks &...  sinks 
)
privatenoexcept

Definition at line 104 of file divider_impl.h.

◆ connect_to_sinks_impl() [2/2]

template<class... Inputs>
template<std::size_t N>
void fkie_message_filters::Divider< Inputs >::connect_to_sinks_impl ( Connections conn)
privatenoexcept

Definition at line 98 of file divider_impl.h.

◆ disconnect()

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

Disconnect from all connected sources and sinks.

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

Definition at line 63 of file divider_impl.h.

◆ disconnect_from_all_sinks()

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

Disconnect all sources from their sinks.

Definition at line 52 of file divider_impl.h.

◆ forward_to_sources() [1/2]

template<class... Inputs>
template<std::size_t N, typename ThisInput , typename... OtherInputs>
void fkie_message_filters::Divider< Inputs >::forward_to_sources ( const ThisInput &  in,
const OtherInputs &...  ins 
)
private

Definition at line 90 of file divider_impl.h.

◆ forward_to_sources() [2/2]

template<class... Inputs>
template<std::size_t N>
void fkie_message_filters::Divider< Inputs >::forward_to_sources ( )
private

Definition at line 84 of file divider_impl.h.

◆ 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.

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

Definition at line 77 of file divider_impl.h.

◆ source() [1/4]

template<class... Inputs>
template<std::size_t N>
Divider<Inputs...>::template SourceType<N>& fkie_message_filters::Divider< Inputs >::source ( )
noexcept

Definition at line 31 of file divider_impl.h.

◆ source() [2/4]

template<class... Inputs>
template<std::size_t N>
const Divider<Inputs...>::template SourceType<N>& fkie_message_filters::Divider< Inputs >::source ( ) const
noexcept

Definition at line 38 of file divider_impl.h.

◆ source() [3/4]

template<class... Inputs>
template<std::size_t N>
SourceType<N>& fkie_message_filters::Divider< Inputs >::source ( )
noexcept

Access the source for the Nth data element.

◆ source() [4/4]

template<class... Inputs>
template<std::size_t N>
const SourceType<N>& fkie_message_filters::Divider< Inputs >::source ( ) const
noexcept

Access the source for the Nth data element.

Member Data Documentation

◆ sources_

template<class... Inputs>
std::tuple<DividerSource<Inputs>...> fkie_message_filters::Divider< Inputs >::sources_
private

Definition at line 97 of file divider.h.


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


fkie_message_filters
Author(s): Timo Röhling
autogenerated on Sun Sep 12 2021 02:52:13