85 lines
1.4 KiB
C++
85 lines
1.4 KiB
C++
|
|
/*
|
|||
|
|
* SettableValue.hh
|
|||
|
|
*
|
|||
|
|
* Created on: 10 <EFBFBD><EFBFBD><EFBFBD>. 2020 <EFBFBD>.
|
|||
|
|
* Author: LeonidTitov
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#ifndef UMLIBRARY_SCHEMATIC_SETTABLEVALUE_HH_
|
|||
|
|
#define UMLIBRARY_SCHEMATIC_SETTABLEVALUE_HH_
|
|||
|
|
|
|||
|
|
#include "../systemic/IValueAsync.hpp"
|
|||
|
|
|
|||
|
|
#include <cstdint>
|
|||
|
|
|
|||
|
|
namespace schematic {
|
|||
|
|
|
|||
|
|
template<typename T>
|
|||
|
|
class SettableBase : public systemic::IValueType<T> {
|
|||
|
|
public:
|
|||
|
|
SettableBase();
|
|||
|
|
|
|||
|
|
void set( T value );
|
|||
|
|
T get() const;
|
|||
|
|
|
|||
|
|
const volatile T & value() const;
|
|||
|
|
|
|||
|
|
protected:
|
|||
|
|
T stored_value;
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
class SettableValue : public SettableBase<float> {
|
|||
|
|
public:
|
|||
|
|
|
|||
|
|
struct Setting {
|
|||
|
|
float preset_value; //!<<3C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
|
|
|||
|
|
bool isValid();
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
void configure( Setting & config );
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
class SettableFlag : public SettableBase<bool> {
|
|||
|
|
public:
|
|||
|
|
|
|||
|
|
struct Setting {
|
|||
|
|
uint16_t preset_value; //!<<3C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
|
|
|||
|
|
bool isValid();
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
void configure( Setting & config );
|
|||
|
|
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
template<typename T>
|
|||
|
|
inline schematic::SettableBase<T>::SettableBase() : stored_value(T(0)) {}
|
|||
|
|
|
|||
|
|
template<typename T>
|
|||
|
|
inline void schematic::SettableBase<T>::set( T value ) {
|
|||
|
|
|
|||
|
|
stored_value = value;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
template<typename T>
|
|||
|
|
inline T schematic::SettableBase<T>::get() const {
|
|||
|
|
|
|||
|
|
return stored_value;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
template<typename T>
|
|||
|
|
inline const volatile T & schematic::SettableBase<T>::value() const {
|
|||
|
|
|
|||
|
|
return stored_value;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endif /* UMLIBRARY_SCHEMATIC_SETTABLEVALUE_HH_ */
|