Template Class Latch

Inheritance Relationships

Base Type

Class Documentation

template<typename ...IOs>
class Latch : public fkie_message_filters::combiner_policies::PolicyBase<IOs...>

Latch policy.

This is a policy for the Combiner class. It works similar to the Fifo policy, but it retains the latest data from each connected source and will reuse data if some inputs arrive at a slower rate than others. The policy can be configured to generate output if a particular source is updated or any source receives new data.

As the policy must be able to create copies of incoming data, it is not suitable for move-only input types.

Public Types

using EmitterCB = std::function<void(OutgoingTuple&)>

Callback for assembled outputs.

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

Tuple type of incoming data tuples.

using OutgoingTuple = helpers::io_tuple_t<helpers::io_concat_t<IOs...>>

Combined tuple type for data output.

Public Functions

Latch() noexcept

Constructor.

By default, the policy will generate output whenever the first connected source receives data.

Latch &trigger_on(std::size_t source) noexcept

Generate output on any update.

Instruct the policy to generate output whenever new data arrives from a particular source.

Latch &trigger_on_any() noexcept

Generate output on any update.

Instruct the policy to generate output whenever any new data arrives.

Protected Types

using MaybeOutgoingTuples = std::tuple<std::optional<helpers::io_tuple_t<IOs>>...>

Tuple of outgoing tuple candidates.

This is basically a tuple of optionals, so elements can remain empty until a suitable data element has been found by the policy.

Protected Functions

template<std::size_t N>
void add(std::unique_lock<std::mutex>&, std::tuple_element_t<N, IncomingTuples>&&)

Input function.

This function will be called by the Combiner class for incoming data.

void emit(OutgoingTuple &out)

Emit data.

This returns combined data back to the Combiner class.

virtual void reset() noexcept override

Reset internal state.

This function is called by the Combiner if the filter is reset.

void set_emitter_callback(const EmitterCB&) noexcept

Set output function.

This function is called by the policy whenever it has output ready to be passed on.

Friends

friend class fkie_message_filters::Combiner