#pragma once #include #include #include #include #include #include #include "sensors/sensor.hpp" /* * The SensorManager holds all sensors across all zones. */ class SensorManager { public: SensorManager() : _passiveListeningBus(std::move(sdbusplus::bus::new_default())), _hostSensorBus(std::move(sdbusplus::bus::new_default())) { // Create a manger for the sensor root because we own it. static constexpr auto SensorRoot = "/xyz/openbmc_project/extsensors"; sdbusplus::server::manager::manager(_hostSensorBus, SensorRoot); } /* * Add a Sensor to the Manager. */ void addSensor( std::string type, std::string name, std::unique_ptr sensor) { _sensorMap[name] = std::move(sensor); auto entry = _sensorTypeList.find(type); if (entry == _sensorTypeList.end()) { _sensorTypeList[type] = {}; } _sensorTypeList[type].push_back(name); } // TODO(venture): Should implement read/write by name. std::unique_ptr& getSensor(std::string name) { return _sensorMap.at(name); } sdbusplus::bus::bus& getPassiveBus(void) { return _passiveListeningBus; } sdbusplus::bus::bus& getHostBus(void) { return _hostSensorBus; } private: std::map> _sensorMap; std::map> _sensorTypeList; sdbusplus::bus::bus _passiveListeningBus; sdbusplus::bus::bus _hostSensorBus; }; std::shared_ptr BuildSensors( std::map& Config); std::shared_ptr BuildSensorsFromConfig(std::string& path);