SensESP 2.7.2
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_input (IN input, uint8_t input_channel=0) override
 
- Public Member Functions inherited from sensesp::ValueConsumer< IN >
void connect_from (ValueProducer< IN > *producer, uint8_t input_channel=0)
 

Protected Attributes

std::function< void(IN)> function
 

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_input()

template<class IN >
void sensesp::LambdaConsumer< IN >::set_input ( IN  new_value,
uint8_t  input_channel = 0 
)
inlineoverridevirtual

Used to set an input of this consumer. It is usually called automatically by a ValueProducer.

Parameters
new_valuethe value of the input
input_channelConsumers can have one or more inputs feeding them. This parameter allows you to specify which input number the producer is connecting to. For single input consumers, leave the index at zero.

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 35 of file lambda_consumer.h.


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