mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2025-02-25 18:55:24 -06:00
lib: add unit to DynamicReadable constructor
This commit is contained in:
parent
4962729983
commit
1d937341c2
@ -35,7 +35,7 @@ struct Enumeration {
|
||||
};
|
||||
|
||||
using AssignmentArgument = std::variant<int, double, uint>;
|
||||
using ReadableValue = std::variant<int, uint, double>;
|
||||
using ReadableValue = std::variant<int, uint, double, std::string>;
|
||||
using ReadResult = std::variant<ReadError, ReadableValue>;
|
||||
using RangeInfo = std::variant<Range<int>, Range<double>>;
|
||||
using EnumerationVec = std::vector<Enumeration>;
|
||||
@ -60,17 +60,26 @@ private:
|
||||
class DynamicReadable {
|
||||
public:
|
||||
DynamicReadable() {}
|
||||
DynamicReadable(const std::function<std::variant<ReadError, ReadableValue>()> readFunc) {
|
||||
DynamicReadable(const std::function<std::variant<ReadError,
|
||||
ReadableValue>()> readFunc,
|
||||
std::optional<std::string> unit = std::nullopt) {
|
||||
m_readFunc = readFunc;
|
||||
m_unit = unit;
|
||||
}
|
||||
/*std::variant<ReadError, ReadableValue>*/ ReadResult read() {
|
||||
return m_readFunc();
|
||||
}
|
||||
auto unit() {return m_unit;}
|
||||
private:
|
||||
std::function<std::variant<ReadError, ReadableValue>()> m_readFunc;
|
||||
std::optional<std::string> m_unit;
|
||||
};
|
||||
|
||||
struct StaticReadable {
|
||||
ReadableValue value;
|
||||
std::optional<std::string> unit;
|
||||
};
|
||||
|
||||
// DeviceNode has a name, and optionally implements one of [Assignable, DynamicReadable]
|
||||
using DeviceInterface = std::variant<Assignable, DynamicReadable>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user