SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::ValueProducer< T > Class Template Reference

A base class for any sensor or piece of code that outputs a value for consumption elsewhere. More...

#include <sensesp/system/valueproducer.h>

Inheritance diagram for sensesp::ValueProducer< T >:
[legend]

Public Member Functions

 ValueProducer ()
 
virtual const T & get () const
 
void connect_to (ValueConsumer< T > *consumer, uint8_t input_channel=0)
 
template<typename CT >
void connect_to (ValueConsumer< CT > *consumer, uint8_t input_channel=0)
 Connect a producer to a consumer of a different type.
 
template<typename T2 >
Transform< T, T2 > * connect_to (Transform< T, T2 > *consumer_producer, uint8_t input_channel=0)
 
template<typename TT , typename T2 >
Transform< TT, T2 > * connect_to (Transform< TT, T2 > *consumer_producer, uint8_t input_channel=0)
 Connect a producer to a transform with a different input type.
 
void emit (T new_value)
 
- Public Member Functions inherited from sensesp::Observable
 Observable ()
 
 Observable (Observable &&other)
 Move constructor.
 
void notify ()
 
void attach (std::function< void()> observer)
 

Protected Attributes

output
 

Detailed Description

template<typename T>
class sensesp::ValueProducer< T >

A base class for any sensor or piece of code that outputs a value for consumption elsewhere.

They are Observable, allowing code to be notified whenever a new value is available. They can be connected directly to ValueConsumers of the same type using the connect_to() method.

See also
ValueConsumer

Definition at line 24 of file valueproducer.h.

Constructor & Destructor Documentation

◆ ValueProducer()

template<typename T >
sensesp::ValueProducer< T >::ValueProducer ( )
inline

Definition at line 26 of file valueproducer.h.

Member Function Documentation

◆ connect_to() [1/4]

template<typename T >
template<typename T2 >
Transform< T, T2 > * sensesp::ValueProducer< T >::connect_to ( Transform< T, T2 > *  consumer_producer,
uint8_t  input_channel = 0 
)
inline

If the consumer this producer is connecting to is ALSO a producer of values of the same type, connect_to() calls can be chained together, as this specialized version returns the producer/consumer being conencted to so connect_to() can be called on THAT object.

Parameters
input_channelConsumers can have one or more inputs feeding them This parameter allows you to specify which input number this producer is connecting to. For single input consumers, leave the index at zero.
See also
ValueConsumer::set_input()

Definition at line 77 of file valueproducer.h.

Here is the call graph for this function:

◆ connect_to() [2/4]

template<typename T >
template<typename TT , typename T2 >
Transform< TT, T2 > * sensesp::ValueProducer< T >::connect_to ( Transform< TT, T2 > *  consumer_producer,
uint8_t  input_channel = 0 
)
inline

Connect a producer to a transform with a different input type.

This allows you to connect a producer to a transform with a different input type. Automatic type conversion is performed.

Template Parameters
TTTransform input type
T2Transform output type
Parameters
consumer_producerTransform object to connect to
input_channel
Returns
Transform<TT, T2>*

Definition at line 98 of file valueproducer.h.

Here is the call graph for this function:

◆ connect_to() [3/4]

template<typename T >
template<typename CT >
void sensesp::ValueProducer< T >::connect_to ( ValueConsumer< CT > *  consumer,
uint8_t  input_channel = 0 
)
inline

Connect a producer to a consumer of a different type.

This allows you to connect a producer to a consumer of a different type. Automatic type conversion is performed.

Template Parameters
CTConsumer type
Parameters
consumerConsumer object to connect to
input_channel

Definition at line 59 of file valueproducer.h.

Here is the call graph for this function:

◆ connect_to() [4/4]

template<typename T >
void sensesp::ValueProducer< T >::connect_to ( ValueConsumer< T > *  consumer,
uint8_t  input_channel = 0 
)
inline

Connects this producer to the specified consumer, registering that consumer for notifications to when this producer's value changes

Parameters
input_channelConsumers can have one or more inputs feeding them This parameter allows you to specify which input number this producer is connecting to. For single input consumers, leave the index at zero.
See also
ValueConsumer::set_input()

Definition at line 42 of file valueproducer.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emit()

template<typename T >
void sensesp::ValueProducer< T >::emit ( new_value)
inline

Definition at line 109 of file valueproducer.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

template<typename T >
virtual const T & sensesp::ValueProducer< T >::get ( ) const
inlinevirtual

Returns the current value of this producer

Definition at line 31 of file valueproducer.h.

Here is the caller graph for this function:

Member Data Documentation

◆ output

template<typename T >
T sensesp::ValueProducer< T >::output
protected

The current value of this producer is stored here in this output member (unless descendant classes override ValueProducer::get())

Definition at line 119 of file valueproducer.h.


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