| #pragma once |
| |
| #include <map> |
| #include <set> |
| #include <string> |
| |
| /** |
| * @class SensorSet |
| * @brief Finds and holds the available hwmon sensors for a device |
| * @details When passed a hwmon device directory on construction, |
| * this class will find all hwmon sysfs files in that directory |
| * and store them in a map. The public begin() and end() methods |
| * on this class allow traversal of this map. |
| * |
| * For example, a file named temp5_input will have a map entry of: |
| * |
| * key: pair<string, string> = {"temp", "5"} |
| * value: std::string = "input" |
| */ |
| class SensorSet |
| { |
| public: |
| typedef std::map<std::pair<std::string, std::string>, std::set<std::string>> |
| container_t; |
| using mapped_type = container_t::mapped_type; |
| using key_type = container_t::key_type; |
| |
| /** |
| * @brief Constructor |
| * @details Builds a map of the hwmon sysfs files in the passed |
| * in directory. |
| * |
| * @param[in] path - path to the hwmon device directory |
| * |
| */ |
| explicit SensorSet(const std::string& path); |
| ~SensorSet() = default; |
| SensorSet() = delete; |
| SensorSet(const SensorSet&) = delete; |
| SensorSet& operator=(const SensorSet&) = delete; |
| SensorSet(SensorSet&&) = default; |
| SensorSet& operator=(SensorSet&&) = default; |
| |
| /** |
| * @brief Returns an iterator to the beginning of the map |
| * |
| * @return const_iterator |
| */ |
| container_t::const_iterator begin() |
| { |
| return const_cast<const container_t&>(_container).begin(); |
| } |
| |
| /** |
| * @brief Returns an iterator to the end of the map |
| * |
| * @return const_iterator |
| */ |
| container_t::const_iterator end() |
| { |
| return const_cast<const container_t&>(_container).end(); |
| } |
| |
| private: |
| /** |
| * @brief The map of hwmon files in the directory |
| * @details For example: |
| * key = pair("temp", "1") |
| * value = "input" |
| */ |
| container_t _container; |
| }; |