Classes | Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
fkie_message_filters::Combiner< PolicyTmpl, IOs > Class Template Reference

Combine multiple sources into a single one. More...

#include <combiner.h>

Inheritance diagram for fkie_message_filters::Combiner< PolicyTmpl, IOs >:
Inheritance graph
[legend]

Classes

class  CombinerSink
 

Public Types

using Connections = std::array< Connection, NUM_SINKS >
 Array of connection objects. More...
 
using Policy = PolicyTmpl< IOs... >
 Class type of the policy that applies to the combiner. More...
 
template<std::size_t N>
using SinkType = helpers::io_rewrap_t< helpers::select_nth< N, IOs... >, Sink >
 Base class for the Nth sink. More...
 

Public Member Functions

 Combiner (const Policy &policy=Policy()) noexcept
 Constructor. More...
 
Connections connect_to_sources (helpers::io_rewrap_t< IOs, Source > &... sources) noexcept
 Convenience function to connect all sinks at once. More...
 
void disconnect () noexcept override
 Disconnect from all connected sources and sinks. More...
 
void disconnect_from_all_sources () noexcept
 Disconnect the sinks from their sources. More...
 
const Policypolicy () const noexcept
 Access combiner policy. More...
 
void reset () noexcept override
 Reset filter. More...
 
void set_policy (const Policy &policy) noexcept
 Set combiner policy. More...
 
template<std::size_t N>
Combiner< PolicyTmpl, IOs... >::template SinkType< N > & sink () noexcept
 
template<std::size_t N>
const Combiner< PolicyTmpl, IOs... >::template SinkType< N > & sink () const noexcept
 
template<std::size_t N>
SinkType< N > & sink () noexcept
 Access the sink for the Nth input. More...
 
template<std::size_t N>
const SinkType< N > & sink () const noexcept
 Access the sink for the Nth input. More...
 

Static Public Attributes

static constexpr std::size_t NUM_SINKS = sizeof...(IOs)
 Number of sinks. More...
 

Private Types

using IncomingTuples = std::tuple< typename helpers::io_tuple_t< IOs >... >
 
using OutgoingTuple = helpers::io_tuple_t< helpers::io_concat_t< IOs... > >
 

Private Member Functions

void connect_policy () noexcept
 
template<std::size_t N, typename ThisSource , typename... OtherSources>
void connect_to_sources_impl (Connections &conn, ThisSource &src, OtherSources &... sources) noexcept
 
template<std::size_t N>
void connect_to_sources_impl (Connections &conn) noexcept
 

Private Attributes

std::mutex combiner_mutex_
 
Policy policy_
 
std::tuple< typename IOs::template Rewrap< CombinerSink >... > sinks_
 

Detailed Description

template<template< typename... > class PolicyTmpl, class... IOs>
class fkie_message_filters::Combiner< PolicyTmpl, IOs >

Combine multiple sources into a single one.

Sometimes, a filter pipeline will receive corresponding inputs from different sources, which must be processed together. The combiner provides a policy-driven way to aggregate data from multiple sources into a single sink. Policies can be anything from a simple FIFO to an elaborate approximate time stamp synchronization.

The output arity of the filter is the sum of all input arities. For example, given two binary input filters (M1,M2) and (M3,M4), the combiner will create a quaternary output (M1,M2,M3,M4). Furthermore, policies which examine data generally look at the first argument of each input. In this example, the timing policies would match the inputs based on M1 and M3. You can prepend a Selector filter to swap the argument order if you need a different element examined, or the Divider filter to match all arguments independently.

using InBuffer1 = mf::Buffer<M1, M2>;
using InBuffer2 = mf::Buffer<M3, M4>;
using OutBuffer = mf::Buffer<M1, M2, M3, M4>;
InBuffer1 buf1;
InBuffer2 buf2;
OutBuffer out;
Combiner combiner;
combiner.connect_to_sources(buf1, buf2);
combiner.connect_to_sink(out);
See also
combiner_policies, Divider, Selector

Definition at line 72 of file combiner.h.

Member Typedef Documentation

◆ Connections

template<template< typename... > class PolicyTmpl, class... IOs>
using fkie_message_filters::Combiner< PolicyTmpl, IOs >::Connections = std::array<Connection, NUM_SINKS>

Array of connection objects.

Definition at line 82 of file combiner.h.

◆ IncomingTuples

template<template< typename... > class PolicyTmpl, class... IOs>
using fkie_message_filters::Combiner< PolicyTmpl, IOs >::IncomingTuples = std::tuple<typename helpers::io_tuple_t<IOs>...>
private

Definition at line 132 of file combiner.h.

◆ OutgoingTuple

template<template< typename... > class PolicyTmpl, class... IOs>
using fkie_message_filters::Combiner< PolicyTmpl, IOs >::OutgoingTuple = helpers::io_tuple_t<helpers::io_concat_t<IOs...> >
private

Definition at line 133 of file combiner.h.

◆ Policy

template<template< typename... > class PolicyTmpl, class... IOs>
using fkie_message_filters::Combiner< PolicyTmpl, IOs >::Policy = PolicyTmpl<IOs...>

Class type of the policy that applies to the combiner.

Definition at line 87 of file combiner.h.

◆ SinkType

template<template< typename... > class PolicyTmpl, class... IOs>
template<std::size_t N>
using fkie_message_filters::Combiner< PolicyTmpl, IOs >::SinkType = helpers::io_rewrap_t<helpers::select_nth<N, IOs...>, Sink>

Base class for the Nth sink.

Definition at line 85 of file combiner.h.

Constructor & Destructor Documentation

◆ Combiner()

template<template< typename... > class PolicyTmpl, class... IOs>
fkie_message_filters::Combiner< PolicyTmpl, IOs >::Combiner ( const Policy policy = Policy())
explicitnoexcept

Constructor.

  • policy Instance of the policy class that applies to the combiner.

Definition at line 30 of file combiner_impl.h.

Member Function Documentation

◆ connect_policy()

template<template< typename... > class PolicyTmpl, class... IOs>
void fkie_message_filters::Combiner< PolicyTmpl, IOs >::connect_policy ( )
privatenoexcept

Definition at line 43 of file combiner_impl.h.

◆ connect_to_sources()

template<template< typename... > class PolicyTmpl, class... IOs>
Combiner< PolicyTmpl, IOs... >::Connections fkie_message_filters::Combiner< PolicyTmpl, IOs >::connect_to_sources ( helpers::io_rewrap_t< IOs, Source > &...  sources)
noexcept

Convenience function to connect all sinks at once.

Definition at line 137 of file combiner_impl.h.

◆ connect_to_sources_impl() [1/2]

template<template< typename... > class PolicyTmpl, class... IOs>
template<std::size_t N, typename ThisSource , typename... OtherSources>
void fkie_message_filters::Combiner< PolicyTmpl, IOs >::connect_to_sources_impl ( Connections conn,
ThisSource &  src,
OtherSources &...  sources 
)
privatenoexcept

Definition at line 130 of file combiner_impl.h.

◆ connect_to_sources_impl() [2/2]

template<template< typename... > class PolicyTmpl, class... IOs>
template<std::size_t N>
void fkie_message_filters::Combiner< PolicyTmpl, IOs >::connect_to_sources_impl ( Connections conn)
privatenoexcept

Definition at line 124 of file combiner_impl.h.

◆ disconnect()

template<template< typename... > class PolicyTmpl, class... IOs>
void fkie_message_filters::Combiner< PolicyTmpl, IOs >::disconnect ( )
overridenoexcept

Disconnect from all connected sources and sinks.

Definition at line 116 of file combiner_impl.h.

◆ disconnect_from_all_sources()

template<template< typename... > class PolicyTmpl, class... IOs>
void fkie_message_filters::Combiner< PolicyTmpl, IOs >::disconnect_from_all_sources ( )
noexcept

Disconnect the sinks from their sources.

Definition at line 105 of file combiner_impl.h.

◆ policy()

template<template< typename... > class PolicyTmpl, class... IOs>
const Combiner< PolicyTmpl, IOs... >::Policy & fkie_message_filters::Combiner< PolicyTmpl, IOs >::policy ( ) const
noexcept

Access combiner policy.

Definition at line 99 of file combiner_impl.h.

◆ reset()

template<template< typename... > class PolicyTmpl, class... IOs>
void fkie_message_filters::Combiner< PolicyTmpl, IOs >::reset ( )
overridenoexcept

Reset filter.

This will reset the internal state by calling the PolicyTmpl::reset() method

Definition at line 78 of file combiner_impl.h.

◆ set_policy()

template<template< typename... > class PolicyTmpl, class... IOs>
void fkie_message_filters::Combiner< PolicyTmpl, IOs >::set_policy ( const Policy policy)
noexcept

Set combiner policy.

Any previous policy is superseded. Implies a call to reset().

Definition at line 70 of file combiner_impl.h.

◆ sink() [1/4]

template<template< typename... > class PolicyTmpl, class... IOs>
template<std::size_t N>
Combiner<PolicyTmpl, IOs...>::template SinkType<N>& fkie_message_filters::Combiner< PolicyTmpl, IOs >::sink ( )
noexcept

Definition at line 86 of file combiner_impl.h.

◆ sink() [2/4]

template<template< typename... > class PolicyTmpl, class... IOs>
template<std::size_t N>
const Combiner<PolicyTmpl, IOs...>::template SinkType<N>& fkie_message_filters::Combiner< PolicyTmpl, IOs >::sink ( ) const
noexcept

Definition at line 93 of file combiner_impl.h.

◆ sink() [3/4]

template<template< typename... > class PolicyTmpl, class... IOs>
template<std::size_t N>
SinkType<N>& fkie_message_filters::Combiner< PolicyTmpl, IOs >::sink ( )
noexcept

Access the sink for the Nth input.

◆ sink() [4/4]

template<template< typename... > class PolicyTmpl, class... IOs>
template<std::size_t N>
const SinkType<N>& fkie_message_filters::Combiner< PolicyTmpl, IOs >::sink ( ) const
noexcept

Access the sink for the Nth input.

Member Data Documentation

◆ combiner_mutex_

template<template< typename... > class PolicyTmpl, class... IOs>
std::mutex fkie_message_filters::Combiner< PolicyTmpl, IOs >::combiner_mutex_
private

Definition at line 148 of file combiner.h.

◆ NUM_SINKS

template<template< typename... > class PolicyTmpl, class... IOs>
constexpr std::size_t fkie_message_filters::Combiner< PolicyTmpl, IOs >::NUM_SINKS = sizeof...(IOs)
static

Number of sinks.

Definition at line 80 of file combiner.h.

◆ policy_

template<template< typename... > class PolicyTmpl, class... IOs>
Policy fkie_message_filters::Combiner< PolicyTmpl, IOs >::policy_
private

Definition at line 149 of file combiner.h.

◆ sinks_

template<template< typename... > class PolicyTmpl, class... IOs>
std::tuple<typename IOs::template Rewrap<CombinerSink>...> fkie_message_filters::Combiner< PolicyTmpl, IOs >::sinks_
private

Definition at line 150 of file combiner.h.


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


fkie_message_filters
Author(s): Timo Röhling
autogenerated on Mon Feb 28 2022 22:21:44