SensESP 3.0.0-beta.6
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 > Class Template Reference

Construct a new transform based on a single function. More...

#include <sensesp/transforms/lambda_transform.h>

Inheritance diagram for sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >:
[legend]

Public Member Functions

 LambdaTransform (std::function< OUT(IN)> function, const String &config_path="")
 
 LambdaTransform (std::function< OUT(IN)> function, const ParamInfo *param_info, const String &config_path="")
 
 LambdaTransform (std::function< OUT(IN, P1)> function, P1 param1, const ParamInfo *param_info, const String &config_path="")
 
 LambdaTransform (std::function< OUT(IN, P1, P2)> function, P1 param1, P2 param2, const ParamInfo *param_info, const String &config_path="")
 LambdaTransform constructor for two-parameter function.
 
 LambdaTransform (std::function< OUT(IN, P1, P2, P3)> function, P1 param1, P2 param2, P3 param3, const ParamInfo *param_info, const String &config_path="")
 
 LambdaTransform (std::function< OUT(IN, P1, P2, P3, P4)> function, P1 param1, P2 param2, P3 param3, P4 param4, const ParamInfo *param_info, const String &config_path="")
 
 LambdaTransform (std::function< OUT(IN, P1, P2, P3, P4, P5)> function, P1 param1, P2 param2, P3 param3, P4 param4, P5 param5, const ParamInfo *param_info, const String &config_path="")
 
 LambdaTransform (std::function< OUT(IN, P1, P2, P3, P4, P5, P6)> function, P1 param1, P2 param2, P3 param3, P4 param4, P5 param5, P6 param6, const ParamInfo *param_info, const String &config_path="")
 
void set (const IN &input) override
 
bool to_json (JsonObject &doc) override
 
bool from_json (const JsonObject &config) override
 
const ParamInfoget_param_info () const
 
- Public Member Functions inherited from sensesp::Transform< IN, OUT >
 Transform (String config_path="")
 
Transform< IN, OUT > * connect_from (ValueProducer< OUT > *producer0, ValueProducer< OUT > *producer1=NULL, ValueProducer< OUT > *producer2=NULL, ValueProducer< OUT > *producer3=NULL, ValueProducer< OUT > *producer4=NULL)
 
- Public Member Functions inherited from sensesp::TransformBase
 TransformBase (const String &config_path)
 
- Public Member Functions inherited from sensesp::FileSystemSaveable
 FileSystemSaveable (const String &config_path)
 
virtual bool load () override
 Load and populate the object from a persistent storage.
 
virtual bool save () override
 Save the object to a persistent storage.
 
virtual bool clear () override
 Delete the data from a persistent storage.
 
bool find_config_file (const String &config_path, String &filename)
 
- Public Member Functions inherited from sensesp::Saveable
 Saveable (const String &config_path)
 
virtual bool refresh ()
 Refresh the object. This may or may not access the persistent storage but is not expected to overwrite the object's state.
 
const String & get_config_path () const
 
- Public Member Functions inherited from sensesp::Serializable
- Public Member Functions inherited from sensesp::ValueConsumer< IN >
virtual void set_input (const IN &new_value)
 
void connect_from (ValueProducer< IN > *producer)
 
- Public Member Functions inherited from sensesp::ValueProducer< OUT >
 ValueProducer ()
 
 ValueProducer (const OUT &initial_value)
 
virtual const OUT & get () const
 
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< OUT, 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.
 
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< OUT, typenameVConsumer::input_type >::value, VConsumer * >::type connect_to (VConsumer *consumer)
 
std::enable_if< std::is_base_of< ValueConsumer< typenameVConsumer::input_type >, VConsumer >::value &&std::is_convertible< OUT, typenameVConsumer::input_type >::value, VConsumer * >::type connect_to (VConsumer &consumer)
 
void emit (const OUT &new_value)
 
- Public Member Functions inherited from sensesp::Observable
 Observable ()
 
 Observable (Observable &&other)
 Move constructor.
 
void notify ()
 
void attach (std::function< void()> observer)
 

Public Attributes

P1 param1_
 
P2 param2_
 
P3 param3_
 
P4 param4_
 
P5 param5_
 
P6 param6_
 

Additional Inherited Members

- Public Types inherited from sensesp::ValueConsumer< IN >
using input_type
 
- Static Public Member Functions inherited from sensesp::TransformBase
static const std::set< TransformBase * > & get_transforms ()
 
- Protected Attributes inherited from sensesp::Saveable
const String config_path_
 
- Protected Attributes inherited from sensesp::ValueProducer< OUT >
OUT output_
 

Detailed Description

template<class IN, class OUT, class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
class sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >

Construct a new transform based on a single function.

LambdaTransform provides an easy way of creating custom transformations without having to create new Transform classes. You just create a transform function and feed that to a LambdaTransform constructor together with possible configuration parameters values and configuration parameter metadata (key names and descriptions).

Template Parameters
INTransform function input value type
OUTTransform function output value type
P1Transform function parameter 1 type
P2Transform function parameter 2 type
P3Transform function parameter 3 type
P4Transform function parameter 4 type
P5Transform function parameter 5 type
P6Transform function parameter 6 type

Definition at line 42 of file lambda_transform.h.

Constructor & Destructor Documentation

◆ LambdaTransform() [1/8]

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::LambdaTransform ( std::function< OUT(IN)> function,
const String & config_path = "" )
inline

Definition at line 44 of file lambda_transform.h.

Here is the call graph for this function:

◆ LambdaTransform() [2/8]

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::LambdaTransform ( std::function< OUT(IN)> function,
const ParamInfo * param_info,
const String & config_path = "" )
inline

Definition at line 50 of file lambda_transform.h.

Here is the call graph for this function:

◆ LambdaTransform() [3/8]

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::LambdaTransform ( std::function< OUT(IN, P1)> function,
P1 param1,
const ParamInfo * param_info,
const String & config_path = "" )
inline

Definition at line 59 of file lambda_transform.h.

Here is the call graph for this function:

◆ LambdaTransform() [4/8]

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::LambdaTransform ( std::function< OUT(IN, P1, P2)> function,
P1 param1,
P2 param2,
const ParamInfo * param_info,
const String & config_path = "" )
inline

LambdaTransform constructor for two-parameter function.

Construct a new LambdaTransform object which takes an input and two configuration parameters. Multiple overloaded constructors exist; their arguments can be extrapolated from this one.

Parameters
functionFunction to be executed for every new input value
param1Configuration parameter 1
param2Configuration parameter 2
param_infoKeys and Descriptions of each configuration parameter
config_pathConfiguration path for the transform

Definition at line 82 of file lambda_transform.h.

Here is the call graph for this function:

◆ LambdaTransform() [5/8]

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::LambdaTransform ( std::function< OUT(IN, P1, P2, P3)> function,
P1 param1,
P2 param2,
P3 param3,
const ParamInfo * param_info,
const String & config_path = "" )
inline

Definition at line 93 of file lambda_transform.h.

Here is the call graph for this function:

◆ LambdaTransform() [6/8]

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::LambdaTransform ( std::function< OUT(IN, P1, P2, P3, P4)> function,
P1 param1,
P2 param2,
P3 param3,
P4 param4,
const ParamInfo * param_info,
const String & config_path = "" )
inline

Definition at line 106 of file lambda_transform.h.

Here is the call graph for this function:

◆ LambdaTransform() [7/8]

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::LambdaTransform ( std::function< OUT(IN, P1, P2, P3, P4, P5)> function,
P1 param1,
P2 param2,
P3 param3,
P4 param4,
P5 param5,
const ParamInfo * param_info,
const String & config_path = "" )
inline

Definition at line 120 of file lambda_transform.h.

Here is the call graph for this function:

◆ LambdaTransform() [8/8]

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::LambdaTransform ( std::function< OUT(IN, P1, P2, P3, P4, P5, P6)> function,
P1 param1,
P2 param2,
P3 param3,
P4 param4,
P5 param5,
P6 param6,
const ParamInfo * param_info,
const String & config_path = "" )
inline

Definition at line 135 of file lambda_transform.h.

Here is the call graph for this function:

Member Function Documentation

◆ from_json()

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
bool sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::from_json ( const JsonObject & root)
inlineoverridevirtual

Deserializes the current object data from a JsonObject.

Reimplemented from sensesp::Serializable.

Definition at line 203 of file lambda_transform.h.

◆ get_param_info()

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
const ParamInfo * sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::get_param_info ( ) const
inline

Definition at line 234 of file lambda_transform.h.

Here is the caller graph for this function:

◆ set()

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
void sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::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 152 of file lambda_transform.h.

Here is the call graph for this function:

◆ to_json()

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
bool sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::to_json ( JsonObject & root)
inlineoverridevirtual

Serializes the current object data into a JsonObject.

Reimplemented from sensesp::Serializable.

Definition at line 183 of file lambda_transform.h.

Member Data Documentation

◆ param1_

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
P1 sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::param1_

Definition at line 236 of file lambda_transform.h.

◆ param2_

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
P2 sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::param2_

Definition at line 237 of file lambda_transform.h.

◆ param3_

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
P3 sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::param3_

Definition at line 238 of file lambda_transform.h.

◆ param4_

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
P4 sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::param4_

Definition at line 239 of file lambda_transform.h.

◆ param5_

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
P5 sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::param5_

Definition at line 240 of file lambda_transform.h.

◆ param6_

template<class IN , class OUT , class P1 = bool, class P2 = bool, class P3 = bool, class P4 = bool, class P5 = bool, class P6 = bool>
P6 sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 >::param6_

Definition at line 241 of file lambda_transform.h.


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