126b815faSBrad Bishop #pragma once 26292aeedSMatthew Barth 36292aeedSMatthew Barth #include <map> 46292aeedSMatthew Barth #include <set> 56292aeedSMatthew Barth #include <string> 66292aeedSMatthew Barth 7a4353bcfSMatt Spinler /** 8a4353bcfSMatt Spinler * @class SensorSet 9a4353bcfSMatt Spinler * @brief Finds and holds the available hwmon sensors for a device 10a4353bcfSMatt Spinler * @details When passed a hwmon device directory on construction, 11a4353bcfSMatt Spinler * this class will find all hwmon sysfs files in that directory 12a4353bcfSMatt Spinler * and store them in a map. The public begin() and end() methods 13a4353bcfSMatt Spinler * on this class allow traversal of this map. 14a4353bcfSMatt Spinler * 15a4353bcfSMatt Spinler * For example, a file named temp5_input will have a map entry of: 16a4353bcfSMatt Spinler * 17a4353bcfSMatt Spinler * key: pair<string, string> = {"temp", "5"} 18a4353bcfSMatt Spinler * value: std::string = "input" 19a4353bcfSMatt Spinler */ 206292aeedSMatthew Barth class SensorSet 216292aeedSMatthew Barth { 226292aeedSMatthew Barth public: 23043d3230SPatrick Venture typedef std::map<std::pair<std::string, std::string>, std::set<std::string>> 24043d3230SPatrick Venture container_t; 2575017aefSBrad Bishop using mapped_type = container_t::mapped_type; 2675017aefSBrad Bishop using key_type = container_t::key_type; 276292aeedSMatthew Barth 28a4353bcfSMatt Spinler /** 29a4353bcfSMatt Spinler * @brief Constructor 30a4353bcfSMatt Spinler * @details Builds a map of the hwmon sysfs files in the passed 31a4353bcfSMatt Spinler * in directory. 32a4353bcfSMatt Spinler * 33a4353bcfSMatt Spinler * @param[in] path - path to the hwmon device directory 34a4353bcfSMatt Spinler * 35a4353bcfSMatt Spinler */ 3692bbd05bSBrad Bishop explicit SensorSet(const std::string& path); 3792bbd05bSBrad Bishop ~SensorSet() = default; 3892bbd05bSBrad Bishop SensorSet() = delete; 3992bbd05bSBrad Bishop SensorSet(const SensorSet&) = delete; 4092bbd05bSBrad Bishop SensorSet& operator=(const SensorSet&) = delete; 4192bbd05bSBrad Bishop SensorSet(SensorSet&&) = default; 4292bbd05bSBrad Bishop SensorSet& operator=(SensorSet&&) = default; 436292aeedSMatthew Barth 44a4353bcfSMatt Spinler /** 45a4353bcfSMatt Spinler * @brief Returns an iterator to the beginning of the map 46a4353bcfSMatt Spinler * 47a4353bcfSMatt Spinler * @return const_iterator 48a4353bcfSMatt Spinler */ begin()496292aeedSMatthew Barth container_t::const_iterator begin() 506292aeedSMatthew Barth { 51*d0f5097cSPatrick Venture return const_cast<const container_t&>(_container).begin(); 526292aeedSMatthew Barth } 536292aeedSMatthew Barth 54a4353bcfSMatt Spinler /** 55a4353bcfSMatt Spinler * @brief Returns an iterator to the end of the map 56a4353bcfSMatt Spinler * 57a4353bcfSMatt Spinler * @return const_iterator 58a4353bcfSMatt Spinler */ end()596292aeedSMatthew Barth container_t::const_iterator end() 606292aeedSMatthew Barth { 61*d0f5097cSPatrick Venture return const_cast<const container_t&>(_container).end(); 626292aeedSMatthew Barth } 636292aeedSMatthew Barth 646292aeedSMatthew Barth private: 65a4353bcfSMatt Spinler /** 66a4353bcfSMatt Spinler * @brief The map of hwmon files in the directory 67a4353bcfSMatt Spinler * @details For example: 68a4353bcfSMatt Spinler * key = pair("temp", "1") 69a4353bcfSMatt Spinler * value = "input" 70a4353bcfSMatt Spinler */ 71*d0f5097cSPatrick Venture container_t _container; 726292aeedSMatthew Barth }; 73