blob: a3e7420827583646818db3340dafe3030a9c3821 [file] [log] [blame]
Patrick Venture863b9242018-03-08 08:29:23 -08001#pragma once
2
3#include <map>
4#include <memory>
5#include <string>
6#include <vector>
7
8#include <sdbusplus/bus.hpp>
9#include <sdbusplus/server.hpp>
10
11#include "sensors/sensor.hpp"
12
13
14/*
15 * The SensorManager holds all sensors across all zones.
16 */
17class SensorManager
18{
19 public:
20 SensorManager()
21 : _passiveListeningBus(std::move(sdbusplus::bus::new_default())),
22 _hostSensorBus(std::move(sdbusplus::bus::new_default()))
23 {
Gunnar Mills08afbb22018-06-14 08:50:53 -050024 // Create a manager for the sensor root because we own it.
Patrick Venture863b9242018-03-08 08:29:23 -080025 static constexpr auto SensorRoot = "/xyz/openbmc_project/extsensors";
26 sdbusplus::server::manager::manager(_hostSensorBus, SensorRoot);
27 }
28
29 /*
30 * Add a Sensor to the Manager.
31 */
32 void addSensor(
33 std::string type,
34 std::string name,
Patrick Venture5e929092018-06-08 10:55:23 -070035 std::unique_ptr<Sensor> sensor);
Patrick Venture863b9242018-03-08 08:29:23 -080036
37 // TODO(venture): Should implement read/write by name.
38 std::unique_ptr<Sensor>& getSensor(std::string name)
39 {
40 return _sensorMap.at(name);
41 }
42
43 sdbusplus::bus::bus& getPassiveBus(void)
44 {
45 return _passiveListeningBus;
46 }
47
48 sdbusplus::bus::bus& getHostBus(void)
49 {
50 return _hostSensorBus;
51 }
52
53 private:
54 std::map<std::string, std::unique_ptr<Sensor>> _sensorMap;
55 std::map<std::string, std::vector<std::string>> _sensorTypeList;
56
57 sdbusplus::bus::bus _passiveListeningBus;
58 sdbusplus::bus::bus _hostSensorBus;
59};
60