blob: 0539fb6154d5a3615ed5e54de0c22bdd04c90670 [file] [log] [blame]
#ifndef STATEMACHINE_HPP
#define STATEMACHINE_HPP
#include "libpldm/base.h"
#include <string>
#include <vector>
/**
* @brief Represents the status for all the state machine at any give instance
*/
enum class StateMachineStatus
{
ReadyToPickNextRequest,
WaitingForResponse,
NoPendingAction,
RequestFailed,
NoNextCommandFound,
};
/**
* @brief Represents the status of an operation
*/
enum class OperationStatus
{
Success,
IncorrectPldmMsg,
IncorrectResponseMsg,
PldmSendFailure,
PldmRecvFailure,
NoNextCommandFound,
EncodingRequestFailure,
OperationFailure,
StateMachineInitializationError,
PartialFailure,
};
/**
* @brief A factory for any state machine with respect to RDE. The State
* machines can be for discovery or operation and derive this class
*/
class StateMachineFactory
{
public:
StateMachineFactory()
{}
/**
* @brief Triggers the state machine from its initial state
*/
virtual OperationStatus run() = 0;
/**
* Triggers the next command in the state machine until no more next
* commands
*/
virtual OperationStatus triggerNextCommand() = 0;
/**
* @brief Updates the state machine after receiving a response
*/
virtual OperationStatus pushCommandResponse(struct pldm_msg* respMsg,
size_t respSize) = 0;
/**
* @brief Prints the state of the machine for debug purposes
*/
virtual void printState() = 0;
virtual ~StateMachineFactory()
{}
};
#endif