Edward A. James | 636577f | 2017-10-06 10:53:55 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "occ_errors.hpp" |
| 4 | namespace open_power |
| 5 | { |
| 6 | namespace occ |
| 7 | { |
| 8 | |
| 9 | class Manager; |
| 10 | |
| 11 | /** @class Presence |
| 12 | * @brief Monitors the number of OCCs present |
| 13 | */ |
| 14 | class Presence : public Error |
| 15 | { |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 16 | public: |
| 17 | Presence() = delete; |
| 18 | Presence(const Presence&) = delete; |
| 19 | Presence& operator=(const Presence&) = delete; |
| 20 | Presence(Presence&&) = default; |
| 21 | Presence& operator=(Presence&&) = default; |
Edward A. James | 636577f | 2017-10-06 10:53:55 -0500 | [diff] [blame] | 22 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 23 | /** @brief Constructs the Presence object |
| 24 | * |
| 25 | * @param[in] event - Reference to sd_event unique_ptr |
| 26 | * @param[in] file - File used by driver to communicate errors |
| 27 | * @param[in] mgr - OCC manager instance |
| 28 | * @param[in] callBack - Optional function callback on error condition |
| 29 | */ |
| 30 | Presence(EventPtr& event, const fs::path& file, const Manager& mgr, |
| 31 | std::function<void(bool)> callBack = nullptr) : |
| 32 | Error(event, file, callBack), |
| 33 | manager(mgr) |
| 34 | { |
| 35 | // Nothing to do here. |
| 36 | } |
Edward A. James | 636577f | 2017-10-06 10:53:55 -0500 | [diff] [blame] | 37 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 38 | private: |
| 39 | /** Store the manager instance to enable getting number of OCCs */ |
| 40 | const Manager& manager; |
Edward A. James | 636577f | 2017-10-06 10:53:55 -0500 | [diff] [blame] | 41 | |
Gunnar Mills | 94df8c9 | 2018-09-14 14:50:03 -0500 | [diff] [blame] | 42 | /** @brief When the error event is received, analyzes it |
| 43 | * and makes a callback to error handler if the |
| 44 | * content denotes an error condition |
| 45 | */ |
| 46 | void analyzeEvent() override; |
Edward A. James | 636577f | 2017-10-06 10:53:55 -0500 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | } // namespace occ |
| 50 | } // namespace open_power |