blob: c9ab3fc96d8f0650f36dc3bfec5f2cd035da474a [file] [log] [blame]
Edward A. James636577f2017-10-06 10:53:55 -05001#pragma once
2
3#include "occ_errors.hpp"
4namespace open_power
5{
6namespace occ
7{
8
9class Manager;
10
11/** @class Presence
12 * @brief Monitors the number of OCCs present
13 */
14class Presence : public Error
15{
Gunnar Mills94df8c92018-09-14 14:50:03 -050016 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. James636577f2017-10-06 10:53:55 -050022
Gunnar Mills94df8c92018-09-14 14:50:03 -050023 /** @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,
Eddie James9789e712022-05-25 15:43:40 -050031 std::function<void(int)> callBack = nullptr) :
Patrick Williamsd7542c82024-08-16 15:20:28 -040032 Error(event, file, callBack), manager(mgr)
Gunnar Mills94df8c92018-09-14 14:50:03 -050033 {
34 // Nothing to do here.
35 }
Edward A. James636577f2017-10-06 10:53:55 -050036
Gunnar Mills94df8c92018-09-14 14:50:03 -050037 private:
38 /** Store the manager instance to enable getting number of OCCs */
39 const Manager& manager;
Edward A. James636577f2017-10-06 10:53:55 -050040
Gunnar Mills94df8c92018-09-14 14:50:03 -050041 /** @brief When the error event is received, analyzes it
42 * and makes a callback to error handler if the
43 * content denotes an error condition
44 */
45 void analyzeEvent() override;
Edward A. James636577f2017-10-06 10:53:55 -050046};
47
48} // namespace occ
49} // namespace open_power