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 | { |
| 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; |
| 22 | |
| 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, |
| 31 | const fs::path& file, |
| 32 | const Manager& mgr, |
Eddie James | 482e31f | 2017-09-14 13:17:17 -0500 | [diff] [blame^] | 33 | std::function<void(bool)> callBack = nullptr) : |
Edward A. James | 636577f | 2017-10-06 10:53:55 -0500 | [diff] [blame] | 34 | Error(event, file, callBack), |
| 35 | manager(mgr) |
| 36 | { |
| 37 | // Nothing to do here. |
| 38 | } |
| 39 | |
| 40 | private: |
| 41 | /** Store the manager instance to enable getting number of OCCs */ |
| 42 | const Manager& manager; |
| 43 | |
| 44 | /** @brief When the error event is received, analyzes it |
| 45 | * and makes a callback to error handler if the |
| 46 | * content denotes an error condition |
| 47 | */ |
| 48 | void analyzeEvent() override; |
| 49 | }; |
| 50 | |
| 51 | } // namespace occ |
| 52 | } // namespace open_power |