SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
|
Converts input from one data type to another, then outputs the new type. More...
#include <sensesp/transforms/typecast.h>
Public Member Functions | |
Typecast (std::function< OUT(IN)> cast=[](IN input) -> OUT { return static_cast< OUT >(input);}) | |
Public Member Functions inherited from sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 > | |
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 ParamInfo * | get_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) |
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 () |
Public Attributes inherited from sensesp::LambdaTransform< IN, OUT, P1, P2, P3, P4, P5, P6 > | |
P1 | param1_ |
P2 | param2_ |
P3 | param3_ |
P4 | param4_ |
P5 | param5_ |
P6 | param6_ |
Protected Attributes inherited from sensesp::Saveable | |
const String | config_path_ |
Protected Attributes inherited from sensesp::ValueProducer< OUT > | |
OUT | output_ |
Converts input from one data type to another, then outputs the new type.
To use Typecast, simply construct a new instance of Typecast.
If the data type of IN is capable of doing a typecast to OUT on its own (i.e. C++ has an implicit conversion available, or IN defines a overloaded typecast operator for OUT), then no additional work is needed.
If a compiler-derived typecast from IN to OUT does not exist (or is not the functionality you are looking for), then you must pass in a lambda expression that is capable of doing the conversion explicitly.
The | data type of input. |
The | data type of output. |
Definition at line 34 of file typecast.h.
|
inline |
Definition at line 36 of file typecast.h.