Matthew Barth | c95c527 | 2020-06-15 19:51:13 -0500 | [diff] [blame^] | 1 | /** |
| 2 | * Copyright © 2020 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
| 17 | |
| 18 | #include "fan.hpp" |
| 19 | #include "tach_sensor.hpp" |
| 20 | #include "trust_manager.hpp" |
| 21 | #include "types.hpp" |
| 22 | |
| 23 | #include <nlohmann/json.hpp> |
| 24 | #include <sdbusplus/bus.hpp> |
| 25 | #include <sdeventplus/event.hpp> |
| 26 | |
| 27 | #include <memory> |
| 28 | #include <optional> |
| 29 | #include <vector> |
| 30 | |
| 31 | namespace phosphor::fan::monitor |
| 32 | { |
| 33 | |
| 34 | using json = nlohmann::json; |
| 35 | |
| 36 | class System |
| 37 | { |
| 38 | public: |
| 39 | System() = delete; |
| 40 | System(const System&) = delete; |
| 41 | System(System&&) = delete; |
| 42 | System& operator=(const System&) = delete; |
| 43 | System& operator=(System&&) = delete; |
| 44 | ~System() = default; |
| 45 | |
| 46 | /** |
| 47 | * Constructor |
| 48 | * Parses and populates the fan monitor trust groups and list of fans |
| 49 | * |
| 50 | * @param[in] mode - mode of fan monitor |
| 51 | * @param[in] bus - sdbusplus bus object |
| 52 | * @param[in] event - event loop reference |
| 53 | */ |
| 54 | System(Mode mode, sdbusplus::bus::bus& bus, |
| 55 | const sdeventplus::Event& event); |
| 56 | |
| 57 | private: |
| 58 | /* The mode of fan monitor */ |
| 59 | Mode _mode; |
| 60 | |
| 61 | /* The sdbusplus bus object */ |
| 62 | sdbusplus::bus::bus& _bus; |
| 63 | |
| 64 | /* The event loop reference */ |
| 65 | const sdeventplus::Event& _event; |
| 66 | |
| 67 | /* Trust manager of trust groups */ |
| 68 | std::unique_ptr<phosphor::fan::trust::Manager> _trust; |
| 69 | |
| 70 | /* List of fan objects to monitor */ |
| 71 | std::vector<std::unique_ptr<Fan>> _fans; |
| 72 | |
| 73 | /** |
| 74 | * @brief Retrieve the configured trust groups |
| 75 | * |
| 76 | * @param[in] jsonObj - JSON object to parse from |
| 77 | * |
| 78 | * @return List of functions applied on trust groups |
| 79 | */ |
| 80 | const std::vector<CreateGroupFunction> getTrustGroups(const json& jsonObj); |
| 81 | |
| 82 | /** |
| 83 | * @brief Retrieve the configured fan definitions |
| 84 | * |
| 85 | * @param[in] jsonObj - JSON object to parse from |
| 86 | * |
| 87 | * @return List of fan definition data on the fans configured |
| 88 | */ |
| 89 | const std::vector<FanDefinition> getFanDefinitions(const json& jsonObj); |
| 90 | }; |
| 91 | |
| 92 | } // namespace phosphor::fan::monitor |