add .clang-format
Change-Id: I94ce26d595367e08d6fb3734535bcd855f1b1473
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/hwmonio.hpp b/hwmonio.hpp
index d49f4db..902888f 100644
--- a/hwmonio.hpp
+++ b/hwmonio.hpp
@@ -3,7 +3,8 @@
#include <chrono>
#include <string>
-namespace hwmonio {
+namespace hwmonio
+{
static constexpr auto retries = 10;
static constexpr auto delay = std::chrono::milliseconds{100};
@@ -16,25 +17,19 @@
*/
class HwmonIOInterface
{
- public:
- virtual ~HwmonIOInterface() = default;
+ public:
+ virtual ~HwmonIOInterface() = default;
- virtual int64_t read(
- const std::string& type,
- const std::string& id,
- const std::string& sensor,
- size_t retries,
- std::chrono::milliseconds delay) const = 0;
+ virtual int64_t read(const std::string& type, const std::string& id,
+ const std::string& sensor, size_t retries,
+ std::chrono::milliseconds delay) const = 0;
- virtual void write(
- uint32_t val,
- const std::string& type,
- const std::string& id,
- const std::string& sensor,
- size_t retries,
- std::chrono::milliseconds delay) const = 0;
+ virtual void write(uint32_t val, const std::string& type,
+ const std::string& id, const std::string& sensor,
+ size_t retries,
+ std::chrono::milliseconds delay) const = 0;
- virtual std::string path() const = 0;
+ virtual std::string path() const = 0;
};
/** @class HwmonIO
@@ -48,79 +43,71 @@
*/
class HwmonIO : public HwmonIOInterface
{
- public:
- HwmonIO() = delete;
- HwmonIO(const HwmonIO&) = default;
- HwmonIO(HwmonIO&&) = default;
- HwmonIO& operator=(const HwmonIO&) = default;
- HwmonIO& operator=(HwmonIO&&) = default;
- ~HwmonIO() = default;
+ public:
+ HwmonIO() = delete;
+ HwmonIO(const HwmonIO&) = default;
+ HwmonIO(HwmonIO&&) = default;
+ HwmonIO& operator=(const HwmonIO&) = default;
+ HwmonIO& operator=(HwmonIO&&) = default;
+ ~HwmonIO() = default;
- /** @brief Constructor
- *
- * @param[in] path - hwmon instance root - eg:
- * /sys/class/hwmon/hwmon<N>
- */
- explicit HwmonIO(const std::string& path);
+ /** @brief Constructor
+ *
+ * @param[in] path - hwmon instance root - eg:
+ * /sys/class/hwmon/hwmon<N>
+ */
+ explicit HwmonIO(const std::string& path);
- /** @brief Perform formatted hwmon sysfs read.
- *
- * Propagates any exceptions other than ENOENT.
- * ENOENT will result in a call to exit(0) in case
- * the underlying hwmon driver is unbound and
- * the program is inadvertently left running.
- *
- * For possibly transient errors will retry up to
- * the specified number of times.
- *
- * @param[in] type - The hwmon type (ex. temp).
- * @param[in] id - The hwmon id (ex. 1).
- * @param[in] sensor - The hwmon sensor (ex. input).
- * @param[in] retries - The number of times to retry.
- * @param[in] delay - The time to sleep between retry attempts.
- *
- * @return val - The read value.
- */
- int64_t read(
- const std::string& type,
- const std::string& id,
- const std::string& sensor,
- size_t retries,
- std::chrono::milliseconds delay) const override;
+ /** @brief Perform formatted hwmon sysfs read.
+ *
+ * Propagates any exceptions other than ENOENT.
+ * ENOENT will result in a call to exit(0) in case
+ * the underlying hwmon driver is unbound and
+ * the program is inadvertently left running.
+ *
+ * For possibly transient errors will retry up to
+ * the specified number of times.
+ *
+ * @param[in] type - The hwmon type (ex. temp).
+ * @param[in] id - The hwmon id (ex. 1).
+ * @param[in] sensor - The hwmon sensor (ex. input).
+ * @param[in] retries - The number of times to retry.
+ * @param[in] delay - The time to sleep between retry attempts.
+ *
+ * @return val - The read value.
+ */
+ int64_t read(const std::string& type, const std::string& id,
+ const std::string& sensor, size_t retries,
+ std::chrono::milliseconds delay) const override;
- /** @brief Perform formatted hwmon sysfs write.
- *
- * Propagates any exceptions other than ENOENT.
- * ENOENT will result in a call to exit(0) in case
- * the underlying hwmon driver is unbound and
- * the program is inadvertently left running.
- *
- * For possibly transient errors will retry up to
- * the specified number of times.
- *
- * @param[in] val - The value to be written.
- * @param[in] type - The hwmon type (ex. fan).
- * @param[in] id - The hwmon id (ex. 1).
- * @param[in] retries - The number of times to retry.
- * @param[in] delay - The time to sleep between retry attempts.
- */
- void write(
- uint32_t val,
- const std::string& type,
- const std::string& id,
- const std::string& sensor,
- size_t retries,
- std::chrono::milliseconds delay) const override;
+ /** @brief Perform formatted hwmon sysfs write.
+ *
+ * Propagates any exceptions other than ENOENT.
+ * ENOENT will result in a call to exit(0) in case
+ * the underlying hwmon driver is unbound and
+ * the program is inadvertently left running.
+ *
+ * For possibly transient errors will retry up to
+ * the specified number of times.
+ *
+ * @param[in] val - The value to be written.
+ * @param[in] type - The hwmon type (ex. fan).
+ * @param[in] id - The hwmon id (ex. 1).
+ * @param[in] retries - The number of times to retry.
+ * @param[in] delay - The time to sleep between retry attempts.
+ */
+ void write(uint32_t val, const std::string& type, const std::string& id,
+ const std::string& sensor, size_t retries,
+ std::chrono::milliseconds delay) const override;
+ /** @brief Hwmon instance path access.
+ *
+ * @return path - The hwmon instance path.
+ */
+ std::string path() const override;
- /** @brief Hwmon instance path access.
- *
- * @return path - The hwmon instance path.
- */
- std::string path() const override;
-
- private:
- std::string p;
+ private:
+ std::string p;
};
} // namespace hwmonio