// SysfsRead.hpp // // SPDX-License-Identifier GPL-3.0-or-later // Author: Unai Blazquez Gomez #pragma once #include enum class SysfsStatus { /// @brief File cannot be opened or does not exist. Unreachable, /// @brief File exists but is just empty. Empty, /// @brief File content indicates taht production is enabled (e.g. "1") Enabled, /// @brief File requests a cooldown ("error: temp too high") ErrorTempTooHigh, /// @brief File contains an UnexpectedValue; producer must not send. UnexpectedValue }; class SysfsReader { public: /// @brief Construct a SysfsReader bound to a specific input file path. /// @param input_path Path to the sysfs-like input file. explicit SysfsReader(const std::filesystem::path& input_path); /// @brief Read and interpret the current status of the input file. /// /// This function never throws on common I/O errors; instead it reports them /// via the SysfsStatus enum. /// @return Interpreted status of the input file SysfsStatus read_status() const; private: std::filesystem::path m_path; // Path to the input file. };