MotorControlModuleSDFM_TMS3.../Projects/EFC_Communication/UMLibrary/schematic/SettableValue.hh
2024-06-07 11:12:56 +03:00

85 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* SettableValue.hh
*
* Created on: 10 авг. 2020 г.
* 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; //!<Предустановленное значение.
bool isValid();
};
void configure( Setting & config );
};
class SettableFlag : public SettableBase<bool> {
public:
struct Setting {
uint16_t preset_value; //!<Предустановленное значение.
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_ */