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

A value container that notifies its observers if it gets changed. More...

#include <sensesp/system/observablevalue.h>

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

Public Member Functions

 ObservableValue ()=default
 
 ObservableValue (const T &value)
 
 ObservableValue (const ObservableValue &)=delete
 
ObservableValueoperator= (const ObservableValue &)=delete
 
void set (const T &value) override
 
const T & operator= (const T &value)
 
T & operator++ ()
 
T & operator-- ()
 
operator++ (int)
 
operator-- (int)
 
const T & operator+= (const T &value)
 
const T & operator-= (const T &value)
 
- Public Member Functions inherited from sensesp::ValueConsumer< T >
virtual void set_input (const T &new_value)
 
void connect_from (ValueProducer< T > *producer)
 
- Public Member Functions inherited from sensesp::ValueProducer< T >
 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)
 

Friends

template<class U >
bool operator== (ObservableValue< U > const &lhs, U const &rhs)
 
template<class U >
bool operator!= (ObservableValue< U > const &lhs, U const &rhs)
 

Additional Inherited Members

- Public Types inherited from sensesp::ValueConsumer< T >
using input_type = T
 
- Protected Attributes inherited from sensesp::ValueProducer< T >
output_
 

Detailed Description

template<class T>
class sensesp::ObservableValue< T >

A value container that notifies its observers if it gets changed.

Definition at line 29 of file observablevalue.h.

Constructor & Destructor Documentation

◆ ObservableValue() [1/3]

template<class T >
sensesp::ObservableValue< T >::ObservableValue ( )
default

◆ ObservableValue() [2/3]

template<class T >
sensesp::ObservableValue< T >::ObservableValue ( const T & value)
inline

Definition at line 33 of file observablevalue.h.

◆ ObservableValue() [3/3]

template<class T >
sensesp::ObservableValue< T >::ObservableValue ( const ObservableValue< T > & )
delete

Member Function Documentation

◆ operator++() [1/2]

template<class T >
T & sensesp::ObservableValue< T >::operator++ ( )
inline

Definition at line 47 of file observablevalue.h.

Here is the call graph for this function:

◆ operator++() [2/2]

template<class T >
T sensesp::ObservableValue< T >::operator++ ( int )
inline

Definition at line 57 of file observablevalue.h.

Here is the call graph for this function:

◆ operator+=()

template<class T >
const T & sensesp::ObservableValue< T >::operator+= ( const T & value)
inline

Definition at line 69 of file observablevalue.h.

Here is the call graph for this function:

◆ operator--() [1/2]

template<class T >
T & sensesp::ObservableValue< T >::operator-- ( )
inline

Definition at line 52 of file observablevalue.h.

Here is the call graph for this function:

◆ operator--() [2/2]

template<class T >
T sensesp::ObservableValue< T >::operator-- ( int )
inline

Definition at line 63 of file observablevalue.h.

Here is the call graph for this function:

◆ operator-=()

template<class T >
const T & sensesp::ObservableValue< T >::operator-= ( const T & value)
inline

Definition at line 74 of file observablevalue.h.

Here is the call graph for this function:

◆ operator=() [1/2]

template<class T >
ObservableValue & sensesp::ObservableValue< T >::operator= ( const ObservableValue< T > & )
delete

◆ operator=() [2/2]

template<class T >
const T & sensesp::ObservableValue< T >::operator= ( const T & value)
inline

Definition at line 42 of file observablevalue.h.

Here is the call graph for this function:

◆ set()

template<class T >
void sensesp::ObservableValue< T >::set ( const T & 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< T >.

Reimplemented in sensesp::PersistingObservableValue< T >, sensesp::PersistingObservableValue< String >, sensesp::TaskQueueProducer< T >, sensesp::TaskQueueProducer< int >, and sensesp::TaskQueueProducer< SKWSConnectionState >.

Definition at line 40 of file observablevalue.h.

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

Friends And Related Symbol Documentation

◆ operator!=

template<class T >
template<class U >
bool operator!= ( ObservableValue< U > const & lhs,
U const & rhs )
friend

◆ operator==

template<class T >
template<class U >
bool operator== ( ObservableValue< U > const & lhs,
U const & rhs )
friend

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