SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::LambdaConsumer< IN > Class Template Reference

Provides an easy way of calling a function based on the output of any ValueProducer. More...

#include <sensesp/system/lambda_consumer.h>

Inheritance diagram for sensesp::LambdaConsumer< IN >:
[legend]

Public Member Functions

 LambdaConsumer (std::function< void(IN)> function)
 
void set (const IN &input) override
 
- Public Member Functions inherited from sensesp::ValueConsumer< IN >
virtual void set_input (const IN &new_value)
 
void connect_from (ValueProducer< IN > *producer)
 

Protected Attributes

std::function< void(IN)> function
 

Additional Inherited Members

- Public Types inherited from sensesp::ValueConsumer< IN >
using input_type
 

Detailed Description

template<class IN>
class sensesp::LambdaConsumer< IN >

Provides an easy way of calling a function based on the output of any ValueProducer.

To use LambdaConsumer, you create the function in main.cpp as a lambda expression, and then pass it as the "function" parameter to the LambaConsumer constructor. See https://github.com/SignalK/SensESP/blob/master/examples/lambda_consumer.cpp for a detailed example.

Template Parameters
INConsumer function input value type
Parameters
functionA pointer to the function that's being called.

Definition at line 25 of file lambda_consumer.h.

Constructor & Destructor Documentation

◆ LambdaConsumer()

template<class IN >
sensesp::LambdaConsumer< IN >::LambdaConsumer ( std::function< void(IN)> function)
inline

Definition at line 27 of file lambda_consumer.h.

Member Function Documentation

◆ set()

template<class IN >
void sensesp::LambdaConsumer< IN >::set ( const IN & new_value)
inlineoverridevirtual

Used to set an input of this consumer. It is called automatically by a ValueProducer but can also be called manually.

Parameters
new_valuethe value of the input

Reimplemented from sensesp::ValueConsumer< IN >.

Definition at line 30 of file lambda_consumer.h.

Member Data Documentation

◆ function

template<class IN >
std::function<void(IN)> sensesp::LambdaConsumer< IN >::function
protected

Definition at line 33 of file lambda_consumer.h.


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