summaryrefslogtreecommitdiffstats
path: root/occ_presence.hpp
blob: 9e66acce6b41d48d36c910fa17e44e5a041c4c10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once

#include "occ_errors.hpp"
namespace open_power
{
namespace occ
{

class Manager;

/** @class Presence
 *  @brief Monitors the number of OCCs present
 */
class Presence : public Error
{
  public:
    Presence() = delete;
    Presence(const Presence&) = delete;
    Presence& operator=(const Presence&) = delete;
    Presence(Presence&&) = default;
    Presence& operator=(Presence&&) = default;

    /** @brief Constructs the Presence object
     *
     *  @param[in] event    - Reference to sd_event unique_ptr
     *  @param[in] file     - File used by driver to communicate errors
     *  @param[in] mgr      - OCC manager instance
     *  @param[in] callBack - Optional function callback on error condition
     */
    Presence(EventPtr& event, const fs::path& file, const Manager& mgr,
             std::function<void(bool)> callBack = nullptr) :
        Error(event, file, callBack),
        manager(mgr)
    {
        // Nothing to do here.
    }

  private:
    /** Store the manager instance to enable getting number of OCCs */
    const Manager& manager;

    /** @brief When the error event is received, analyzes it
     *         and makes a callback to error handler if the
     *         content denotes an error condition
     */
    void analyzeEvent() override;
};

} // namespace occ
} // namespace open_power
OpenPOWER on IntegriCloud