1 #pragma once 2 3 #include "sensors/sensor.hpp" 4 5 #include <map> 6 #include <memory> 7 #include <sdbusplus/bus.hpp> 8 #include <sdbusplus/server.hpp> 9 #include <string> 10 #include <vector> 11 12 /* 13 * The SensorManager holds all sensors across all zones. 14 */ 15 class SensorManager 16 { 17 public: 18 SensorManager(sdbusplus::bus::bus& pass, sdbusplus::bus::bus& host) : 19 _passiveListeningBus(&pass), _hostSensorBus(&host) 20 { 21 // manager gets its interface from the bus. :D 22 sdbusplus::server::manager::manager(*_hostSensorBus, SensorRoot); 23 } 24 25 SensorManager() = default; 26 ~SensorManager() = default; 27 SensorManager(const SensorManager&) = delete; 28 SensorManager& operator=(const SensorManager&) = delete; 29 SensorManager(SensorManager&&) = default; 30 SensorManager& operator=(SensorManager&&) = default; 31 32 /* 33 * Add a Sensor to the Manager. 34 */ 35 void addSensor(const std::string& type, const std::string& name, 36 std::unique_ptr<Sensor> sensor); 37 38 // TODO(venture): Should implement read/write by name. 39 Sensor* getSensor(const std::string& name) const 40 { 41 return _sensorMap.at(name).get(); 42 } 43 44 sdbusplus::bus::bus& getPassiveBus(void) 45 { 46 return *_passiveListeningBus; 47 } 48 49 sdbusplus::bus::bus& getHostBus(void) 50 { 51 return *_hostSensorBus; 52 } 53 54 private: 55 std::map<std::string, std::unique_ptr<Sensor>> _sensorMap; 56 std::map<std::string, std::vector<std::string>> _sensorTypeList; 57 58 sdbusplus::bus::bus* _passiveListeningBus; 59 sdbusplus::bus::bus* _hostSensorBus; 60 61 static constexpr auto SensorRoot = "/xyz/openbmc_project/extsensors"; 62 }; 63