1#ifndef SENSESP_SYSTEM_OBSERVABLEVALUE_H
2#define SENSESP_SYSTEM_OBSERVABLEVALUE_H
106 virtual void set(
const T& value)
override {
111 virtual bool to_json(JsonObject& doc)
override {
116 virtual bool from_json(
const JsonObject& config)
override {
117 if (!config[
"value"].is<T>()) {
120 this->
output_ = config[
"value"].as<T>();
129 String schema = R
"({"type":"object","properties":{"value":{"title":"Value","type":"{{type_string}}"}}})";
130 const T value = obj.
get();
virtual bool load() override
Load and populate the object from a persistent storage.
virtual bool save() override
Save the object to a persistent storage.
A value container that notifies its observers if it gets changed.
ObservableValue()=default
friend bool operator==(ObservableValue< U > const &lhs, U const &rhs)
ObservableValue(const ObservableValue &)=delete
const T & operator+=(const T &value)
void set(const T &value) override
friend bool operator!=(ObservableValue< U > const &lhs, U const &rhs)
ObservableValue(const T &value)
const T & operator=(const T &value)
const T & operator-=(const T &value)
ObservableValue & operator=(const ObservableValue &)=delete
An ObservableValue that saves its value to the configuration.
virtual bool from_json(const JsonObject &config) override
virtual void set(const T &value) override
PersistingObservableValue(const T &value, String config_path="")
virtual bool to_json(JsonObject &doc) override
A base class for piece of code (like a transform) that accepts data for input. ValueConsumers can acc...
A base class for any sensor or piece of code that outputs a value for consumption elsewhere.
virtual const T & get() const
void emit(const T &new_value)
const String ConfigSchema(const SmartSwitchController &obj)
std::shared_ptr< reactesp::EventLoop > event_loop()
bool operator!=(ObservableValue< T > const &lhs, T const &rhs)
bool operator==(ObservableValue< T > const &lhs, T const &rhs)
const char * get_schema_type_string(const int)