-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstatus.hpp
48 lines (37 loc) · 967 Bytes
/
status.hpp
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
#pragma once
#include <cstdint>
#include <functional>
namespace ipmi_flash
{
/** The status of the update mechanism or the verification mechanism */
enum class ActionStatus : std::uint8_t
{
running = 0,
success = 1,
failed = 2,
unknown = 3,
};
class TriggerableActionInterface
{
public:
using Callback = std::move_only_function<void(TriggerableActionInterface&)>;
virtual ~TriggerableActionInterface() = default;
/**
* Trigger action.
*
* @return true if successfully started, false otherwise.
*/
virtual bool trigger() = 0;
/** Abort the action if possible. */
virtual void abort() = 0;
/** Check the current state of the action. */
virtual ActionStatus status() = 0;
/** Sets the callback that is executed on completion of the trigger. */
void setCallback(Callback&& cb)
{
this->cb = std::move(cb);
}
protected:
Callback cb;
};
} // namespace ipmi_flash