SensESP 3.0.0
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 ()
 
 ValueProducer (const T &initial_value)
 
virtual const T & get () const
 
template<typename VConsumer >
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< T, typenameVConsumer::input_type >::value, std::shared_ptr< VConsumer > >::type connect_to (std::shared_ptr< VConsumer > consumer)
 Connect a producer to a transform with a different input type.
 
template<typename VConsumer >
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< T, typenameVConsumer::input_type >::value, VConsumer * >::type connect_to (VConsumer *consumer)
 
template<typename VConsumer >
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< T, typenameVConsumer::input_type >::value, VConsumer * >::type connect_to (VConsumer &consumer)
 
void emit (const 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 25 of file valueproducer.h.

Constructor & Destructor Documentation

◆ ValueProducer() [1/2]

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

Definition at line 27 of file valueproducer.h.

◆ ValueProducer() [2/2]

template<typename T >
sensesp::ValueProducer< T >::ValueProducer ( const T & initial_value)
inline

Definition at line 28 of file valueproducer.h.

Member Function Documentation

◆ connect_to() [1/3]

template<typename T >
template<typename VConsumer >
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< T, typenameVConsumer::input_type >::value, std::shared_ptr< VConsumer > >::type sensesp::ValueProducer< T >::connect_to ( std::shared_ptr< VConsumer > consumer)
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
VConsumerValueConsumer type
CInputConsumer input type
Parameters
consumer_producerTransform object to connect to
Returns
std::shared_ptr<VConsumer> The connected consumer

Definition at line 52 of file valueproducer.h.

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

◆ connect_to() [2/3]

template<typename T >
template<typename VConsumer >
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< T, typenameVConsumer::input_type >::value, VConsumer * >::type sensesp::ValueProducer< T >::connect_to ( VConsumer & consumer)
inline

Definition at line 84 of file valueproducer.h.

Here is the call graph for this function:

◆ connect_to() [3/3]

template<typename T >
template<typename VConsumer >
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< T, typenameVConsumer::input_type >::value, VConsumer * >::type sensesp::ValueProducer< T >::connect_to ( VConsumer * consumer)
inline

Definition at line 70 of file valueproducer.h.

Here is the call graph for this function:

◆ emit()

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

Definition at line 91 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 33 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 101 of file valueproducer.h.


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