diff --git a/src/include/Crypto.hpp b/src/include/Crypto.hpp index a13b886..2de78e9 100644 --- a/src/include/Crypto.hpp +++ b/src/include/Crypto.hpp @@ -5,6 +5,6 @@ namespace TuxClocker::Crypto { std::string sha256(std::string s); -std::string md5(std::string s); +std::string md5(std::string s); -}; +}; // namespace TuxClocker::Crypto diff --git a/src/include/DBusTypes.hpp b/src/include/DBusTypes.hpp index c996757..20b4eab 100644 --- a/src/include/DBusTypes.hpp +++ b/src/include/DBusTypes.hpp @@ -11,18 +11,17 @@ namespace TC = TuxClocker; namespace TuxClocker::DBus { -template -struct Result { +template struct Result { bool error; T value; - + friend QDBusArgument &operator<<(QDBusArgument &arg, const Result r) { arg.beginStructure(); arg << r.error << r.value; arg.endStructure(); return arg; } - + friend const QDBusArgument &operator>>(const QDBusArgument &arg, Result &r) { arg.beginStructure(); arg >> r.error >> r.value; @@ -39,7 +38,7 @@ struct Range { QDBusVariant min, max; friend QDBusArgument &operator<<(QDBusArgument &arg, const Range r) { arg.beginStructure(); - arg << r.min<< r.max; + arg << r.min << r.max; arg.endStructure(); return arg; } @@ -52,13 +51,14 @@ struct Range { TC::Device::AssignableInfo toAssignableInfo() { auto min_v = min.variant(); auto max_v = max.variant(); - + auto im = static_cast(QMetaType::Int); auto dm = static_cast(QMetaType::Double); if (min_v.type() == im && max_v.type() == im) return TC::Device::Range(min_v.value(), max_v.value()); if (min_v.type() == dm && max_v.type() == dm) - return TC::Device::Range(min_v.value(), max_v.value()); + return TC::Device::Range( + min_v.value(), max_v.value()); // Should never reach here return TC::Device::Range(0, 0); } @@ -107,8 +107,7 @@ struct DeviceNode { } }; -template -struct FlatTreeNode { +template struct FlatTreeNode { T value; QVector childIndices; friend QDBusArgument &operator<<(QDBusArgument &arg, const FlatTreeNode f) { @@ -125,4 +124,4 @@ struct FlatTreeNode { } }; -}; +}; // namespace TuxClocker::DBus diff --git a/src/include/Device.hpp b/src/include/Device.hpp index 4b78c4e..6b40ef0 100644 --- a/src/include/Device.hpp +++ b/src/include/Device.hpp @@ -8,7 +8,7 @@ namespace TuxClocker { namespace Device { - + enum class AssignmentError { InvalidArgument, InvalidType, @@ -21,15 +21,17 @@ enum class ReadError { UnknownError }; -template -struct Range { - Range() {}; - Range(const T &min_, const T &max_) {min = min_, max = max_;} +template struct Range { + Range(){}; + Range(const T &min_, const T &max_) { min = min_, max = max_; } T min, max; }; - + struct Enumeration { - Enumeration(const std::string &name_, const uint &key_) {name = name_; key = key_;} + Enumeration(const std::string &name_, const uint &key_) { + name = name_; + key = key_; + } std::string name; uint key; }; @@ -43,10 +45,11 @@ using AssignableInfo = std::variant>; class Assignable { public: - Assignable(const std::function(AssignmentArgument)> assignmentFunc, - AssignableInfo info, - const std::function()> currentValueFunc, - std::optional unit = std::nullopt) { + Assignable( + const std::function(AssignmentArgument)> assignmentFunc, + AssignableInfo info, + const std::function()> currentValueFunc, + std::optional unit = std::nullopt) { m_assignmentFunc = assignmentFunc; m_assignableInfo = info; m_currentValueFunc = currentValueFunc; @@ -56,9 +59,9 @@ public: return m_assignmentFunc(arg); } // What the Assignable is currently set to - std::optional currentValue() {return m_currentValueFunc();} - AssignableInfo assignableInfo() {return m_assignableInfo;} - std::optional unit() {return m_unit;} + std::optional currentValue() { return m_currentValueFunc(); } + AssignableInfo assignableInfo() { return m_assignableInfo; } + std::optional unit() { return m_unit; } private: AssignableInfo m_assignableInfo; std::function(AssignmentArgument)> m_assignmentFunc; @@ -69,16 +72,13 @@ private: class DynamicReadable { public: DynamicReadable() {} - DynamicReadable(const std::function()> readFunc, - std::optional unit = std::nullopt) { + DynamicReadable(const std::function()> readFunc, + std::optional unit = std::nullopt) { m_readFunc = readFunc; m_unit = unit; } - /*std::variant*/ ReadResult read() { - return m_readFunc(); - } - auto unit() {return m_unit;} + /*std::variant*/ ReadResult read() { return m_readFunc(); } + auto unit() { return m_unit; } private: std::function()> m_readFunc; std::optional m_unit; @@ -90,8 +90,8 @@ public: m_value = value; m_unit = unit; } - ReadableValue value() {return m_value;} - std::optional unit() {return m_unit;} + ReadableValue value() { return m_value; } + std::optional unit() { return m_unit; } private: ReadableValue m_value; std::optional m_unit; @@ -102,7 +102,6 @@ using ResetInfo = std::variant, AssignmentArgument>; class Resettable { private: - }; /* DeviceNode has a name, and optionally implements one of @@ -115,5 +114,5 @@ struct DeviceNode { std::string hash; }; -}; -}; +}; // namespace Device +}; // namespace TuxClocker diff --git a/src/include/Functional.hpp b/src/include/Functional.hpp index ad9eadf..11a9bf3 100644 --- a/src/include/Functional.hpp +++ b/src/include/Functional.hpp @@ -5,28 +5,26 @@ namespace TuxClocker { -// Creates a function with no arguments from a function that takes some from inputs to the function and the function -template +// Creates a function with no arguments from a function that takes some from inputs to the function +// and the function +template auto specializeFunction(Args... args, std::function func) { - return [args = std::make_tuple(std::move(args)...), &func]() { - return std::apply([&func](auto ...args) { - func(args...); - }, std::move(args)); - }; + return [args = std::make_tuple(std::move(args)...), &func]() { + return std::apply([&func](auto... args) { func(args...); }, std::move(args)); + }; } -template typename List, typename In, typename Out> +template