blob: cd9f68992c5f48068825ce2c56b7891198e5dda8 [file] [log] [blame]
Matthew Barth293477d2017-02-17 15:39:36 -06001#pragma once
2
Matthew Barthb8034452017-02-17 16:39:46 -06003#include <sdbusplus/bus.hpp>
4#include "fan_properties.hpp"
Matthew Barthd6403822017-02-17 17:10:19 -06005#include "sensor_base.hpp"
Matthew Barthb8034452017-02-17 16:39:46 -06006
Matthew Barth293477d2017-02-17 15:39:36 -06007
8namespace phosphor
9{
10namespace fan
11{
12namespace presence
13{
14
15class FanEnclosure
16{
Matthew Barth1562ac72017-02-20 16:01:21 -060017 using Property = std::string;
18 using Value = sdbusplus::message::variant<bool, int64_t, std::string>;
19 // Association between property and its value
20 using PropertyMap = std::map<Property, Value>;
21 using Interface = std::string;
22 // Association between interface and the dbus property
23 using InterfaceMap = std::map<Interface, PropertyMap>;
24 using Object = sdbusplus::message::object_path;
25 // Association between object and the interface
26 using ObjectMap = std::map<Object, InterfaceMap>;
27
Matthew Barth293477d2017-02-17 15:39:36 -060028 public:
29 FanEnclosure() = delete;
30 FanEnclosure(const FanEnclosure&) = delete;
31 FanEnclosure(FanEnclosure&&) = default;
32 FanEnclosure& operator=(const FanEnclosure&) = delete;
Matthew Barthb8034452017-02-17 16:39:46 -060033 FanEnclosure& operator=(FanEnclosure&&) = delete;
Matthew Barth293477d2017-02-17 15:39:36 -060034 ~FanEnclosure() = default;
35
Matthew Barthb8034452017-02-17 16:39:46 -060036 FanEnclosure(sdbusplus::bus::bus& bus,
37 const phosphor::fan::Properties& fanProp) :
38 bus(bus),
39 invPath(std::get<0>(fanProp)),
40 fanDesc(std::get<1>(fanProp))
41 {
42 //Add this fan to inventory
Matthew Barth736d1432017-02-20 16:09:21 -060043 updInventory();
Matthew Barthb8034452017-02-17 16:39:46 -060044 }
45
Matthew Barthcd4f4d12017-02-17 17:48:56 -060046 void updInventory();
Matthew Barthd6403822017-02-17 17:10:19 -060047 void addSensor(
48 std::unique_ptr<Sensor>&& sensor);
49
Matthew Barth293477d2017-02-17 15:39:36 -060050 private:
Matthew Barthb8034452017-02-17 16:39:46 -060051 sdbusplus::bus::bus& bus;
52 const std::string invPath;
53 const std::string fanDesc;
Matthew Barthd6403822017-02-17 17:10:19 -060054 std::vector<std::unique_ptr<Sensor>> sensors;
Matthew Barthb8034452017-02-17 16:39:46 -060055
Matthew Barth736d1432017-02-20 16:09:21 -060056 //TODO openbmc/openbmc#1299 - Move getInvService() to a utility file
57 std::string getInvService();
Matthew Barth1562ac72017-02-20 16:01:21 -060058 ObjectMap getObjectMap();
Matthew Barth293477d2017-02-17 15:39:36 -060059
60};
61
62} // namespace presence
63} // namespace fan
64} // namespace phosphor