Add callback support to triggerable actions
Change-Id: Icc27fbe9403eda418f41e12c76af7f3216f4b72a
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/status.hpp b/status.hpp
index 869fe89..e3342d2 100644
--- a/status.hpp
+++ b/status.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <function2/function2.hpp>
+
#include <cstdint>
namespace ipmi_flash
@@ -17,6 +19,8 @@
class TriggerableActionInterface
{
public:
+ using Callback = fu2::unique_function<void(TriggerableActionInterface&)>;
+
virtual ~TriggerableActionInterface() = default;
/**
@@ -31,6 +35,15 @@
/** 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