Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include "fan_properties.hpp" |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 5 | #include "sensor_base.hpp" |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 6 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace fan |
| 11 | { |
| 12 | namespace presence |
| 13 | { |
| 14 | |
| 15 | class FanEnclosure |
| 16 | { |
Matthew Barth | 1562ac7 | 2017-02-20 16:01:21 -0600 | [diff] [blame] | 17 | 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 Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 28 | public: |
| 29 | FanEnclosure() = delete; |
| 30 | FanEnclosure(const FanEnclosure&) = delete; |
| 31 | FanEnclosure(FanEnclosure&&) = default; |
| 32 | FanEnclosure& operator=(const FanEnclosure&) = delete; |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 33 | FanEnclosure& operator=(FanEnclosure&&) = delete; |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 34 | ~FanEnclosure() = default; |
| 35 | |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 36 | 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 Barth | 736d143 | 2017-02-20 16:09:21 -0600 | [diff] [blame^] | 43 | updInventory(); |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 44 | } |
| 45 | |
Matthew Barth | cd4f4d1 | 2017-02-17 17:48:56 -0600 | [diff] [blame] | 46 | void updInventory(); |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 47 | void addSensor( |
| 48 | std::unique_ptr<Sensor>&& sensor); |
| 49 | |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 50 | private: |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 51 | sdbusplus::bus::bus& bus; |
| 52 | const std::string invPath; |
| 53 | const std::string fanDesc; |
Matthew Barth | d640382 | 2017-02-17 17:10:19 -0600 | [diff] [blame] | 54 | std::vector<std::unique_ptr<Sensor>> sensors; |
Matthew Barth | b803445 | 2017-02-17 16:39:46 -0600 | [diff] [blame] | 55 | |
Matthew Barth | 736d143 | 2017-02-20 16:09:21 -0600 | [diff] [blame^] | 56 | //TODO openbmc/openbmc#1299 - Move getInvService() to a utility file |
| 57 | std::string getInvService(); |
Matthew Barth | 1562ac7 | 2017-02-20 16:01:21 -0600 | [diff] [blame] | 58 | ObjectMap getObjectMap(); |
Matthew Barth | 293477d | 2017-02-17 15:39:36 -0600 | [diff] [blame] | 59 | |
| 60 | }; |
| 61 | |
| 62 | } // namespace presence |
| 63 | } // namespace fan |
| 64 | } // namespace phosphor |