FKIE Message Filters
Improved filters for processing ROS messages
|
Simplified filter with user-defined callback function. More...
#include <fkie_message_filters/simple_user_filter.h>
Public Types | |
using | Input = IO< Inputs... > |
Grouped input types. More... | |
using | Output = IO< Outputs... > |
Grouped output types. More... | |
using | ProcessingFunction = std::function< bool(const Inputs &...)> |
Processing function type. More... | |
Public Member Functions | |
Connection | connect_to_sink (Sink< Outputs... > &dst) noexcept |
Connect this source to a sink. More... | |
Connection | connect_to_source (Source< Inputs... > &src) noexcept |
Connect this sink to a source. More... | |
void | disconnect_from_all_sinks () noexcept |
Disconnect from all connected sinks. More... | |
void | disconnect_from_all_sources () noexcept |
Disconnect from all connected sources. More... | |
virtual void | reset () noexcept |
Reset filter state. More... | |
void | set_processing_function (const ProcessingFunction &f) noexcept |
Set the user-defined processing function. More... | |
Static Public Attributes | |
static constexpr std::size_t | NUM_INPUTS = sizeof...(Inputs) |
Number of input arguments. | |
static constexpr std::size_t | NUM_OUTPUTS |
Number of output arguments. | |
Protected Member Functions | |
void | receive (const Inputs &... in) override |
Process incoming data. More... | |
void | send (const Outputs &... out) |
Pass data to all connected sinks. More... | |
Simplified filter with user-defined callback function.
This is a simplified version of the UserFilter where inputs and outputs are identical. A user-defined processing function is called for all incoming data. If the function returns true
, the data is passed on, otherwise the data is discarded.
The filter will throw a std::bad_function_call
exception if it is invoked without a user-defined processing function.
|
inherited |
Grouped input types.
This type can be used to define sources with matching types.
|
inherited |
Grouped output types.
This type can be used to define sinks with matching types.
using fkie_message_filters::SimpleUserFilter< Inputs >::ProcessingFunction = std::function<bool(const Inputs&...)> |
Processing function type.
This can be any user-defined function and will be called to process incoming data.
true | if the data shall be passed to the connected sinks |
false | if the data shall be discarded |
|
noexceptinherited |
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.
dst
the sink that is to be connected
|
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
|
noexceptinherited |
Disconnect from all connected sinks.
Severs the connection to all sinks, turning the send() method into a no-op.
|
noexceptinherited |
Disconnect from all connected sources.
Severs the connection to all sources. The receive() method will not be called any more.
|
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 >.
|
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.
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... >.
|
protectedinherited |
Pass data to all connected sinks.
out
data
|
noexcept |
Set the user-defined processing function.
You must call this method before the filter gets invoked with incoming data.