13ecb3503SPatrick Venture #pragma once 23ecb3503SPatrick Venture 33ecb3503SPatrick Venture #include <cstdint> 4*41dedad6SPatrick Williams #include <functional> 53ecb3503SPatrick Venture 61d5a31c9SPatrick Venture namespace ipmi_flash 73ecb3503SPatrick Venture { 83ecb3503SPatrick Venture 9da66fd84SPatrick Venture /** The status of the update mechanism or the verification mechanism */ 10da66fd84SPatrick Venture enum class ActionStatus : std::uint8_t 118e801e18SPatrick Venture { 128e801e18SPatrick Venture running = 0, 138e801e18SPatrick Venture success = 1, 148e801e18SPatrick Venture failed = 2, 158e801e18SPatrick Venture unknown = 3, 168e801e18SPatrick Venture }; 178e801e18SPatrick Venture 181d66fe6eSPatrick Venture class TriggerableActionInterface 191d66fe6eSPatrick Venture { 201d66fe6eSPatrick Venture public: 21*41dedad6SPatrick Williams using Callback = std::move_only_function<void(TriggerableActionInterface&)>; 224175b4caSWilliam A. Kennington III 231d66fe6eSPatrick Venture virtual ~TriggerableActionInterface() = default; 241d66fe6eSPatrick Venture 251d66fe6eSPatrick Venture /** 261d66fe6eSPatrick Venture * Trigger action. 271d66fe6eSPatrick Venture * 281d66fe6eSPatrick Venture * @return true if successfully started, false otherwise. 291d66fe6eSPatrick Venture */ 301d66fe6eSPatrick Venture virtual bool trigger() = 0; 311d66fe6eSPatrick Venture 321d66fe6eSPatrick Venture /** Abort the action if possible. */ 331d66fe6eSPatrick Venture virtual void abort() = 0; 341d66fe6eSPatrick Venture 351d66fe6eSPatrick Venture /** Check the current state of the action. */ 361d66fe6eSPatrick Venture virtual ActionStatus status() = 0; 374175b4caSWilliam A. Kennington III 384175b4caSWilliam A. Kennington III /** Sets the callback that is executed on completion of the trigger. */ setCallback(Callback && cb)394175b4caSWilliam A. Kennington III void setCallback(Callback&& cb) 404175b4caSWilliam A. Kennington III { 414175b4caSWilliam A. Kennington III this->cb = std::move(cb); 424175b4caSWilliam A. Kennington III } 434175b4caSWilliam A. Kennington III 444175b4caSWilliam A. Kennington III protected: 454175b4caSWilliam A. Kennington III Callback cb; 461d66fe6eSPatrick Venture }; 471d66fe6eSPatrick Venture 488e801e18SPatrick Venture } // namespace ipmi_flash 49