#include <RecoveryAction.h>
Inheritance diagram for RecoveryAction:
A recovery action is an action that is executed in response to the detection of a failure. Recovery actions are implemented as a form of punctual action. They add to their base class the next recovery action attribute and the execution check.
Recovery actions can be linked in sequential chains. The client only sees one single recovery action (the one at the head of the chain) but its execution can lead to all actions in the chain being executed in sequence. The next recovery action attribute holds the pointer to the next recovery action in the chain.
The execution check is performed before executing the recovery action. Its implementation is left open and concrete subclasses can use it to define the conditions under which the execution of the recovery action is allowed.
This is an abstract class because it leaves open the definition of actual actions to be performed by the recovery action component and the definition of the execution check open. This class only implements the management of the next recovery action.
Punctual actions return an outcome. The outcome of a recovery action R is the outcome of the last recovery action in the chain of recovery actions that has R as its first item.
Implementation Note: This could in principle be implemented as a subclass of ConditionalPunctualAction
. This is not done because class a failure of the execution check in class ConditionalPunctualAction
simply leads to an immediate termination of the punctual action. In the case of the RecoveryAction
class, instead, a failure of the execution check leads to an attempt to execute the next recovery action.
Definition at line 58 of file RecoveryAction.h.
Public Member Functions | |
RecoveryAction (void) | |
Instantiate a recovery action. | |
void | setNextRecoveryAction (RecoveryAction *pNextRecoveryAction) |
Set the next recovery action. | |
RecoveryAction * | getNextRecoveryAction (void) |
Get the next recovery action. | |
Protected Member Functions | |
virtual TD_ActionOutcome | doAction (void) |
Execute the recovery action if the execution check is satisfied and pass on the execute request to the next recovery action (if one is defined). | |
virtual bool | canExecute (void) |
Encapsulate implementation of the execution check. | |
virtual TD_ActionOutcome | doRecoveryAction (void)=0 |
Encapsulate implementation of the concrete recovery actions associated to this component. |
|
Instantiate a recovery action. The next recovery action is set to null. Definition at line 16 of file RecoveryAction.cpp. |
|
Encapsulate implementation of the execution check.
This method is called by method
Reimplemented in DC_DummyRecoveryAction. Definition at line 32 of file RecoveryAction.cpp. |
|
Execute the recovery action if the execution check is satisfied and pass on the execute request to the next recovery action (if one is defined). A pseudo-code implementation for this method is as follows: outcome = ACTION_CANNOT_EXECUTE; if ( canExecute() ) outcome = doRecoveryAction() if ( nextRecoveryAction != pNULL) outcome = nextRecoveryAction->execute(); return outcome;The doRecoveryAction() method is abstract and encapsulates the implementation of the actions associated to this recovery action. Thus, this class enforces the handing over of execution requests from one recovery action to the next but it leaves the definition of the specific recovery actions to concrete subclasses.
Implements PunctualAction. Definition at line 20 of file RecoveryAction.cpp. |
|
Encapsulate implementation of the concrete recovery actions associated to this component.
This method is called by method
Implemented in DC_DummyRecoveryAction, DC_NullRecoveryAction, and DC_SampleRecoveryAction. |
|
Get the next recovery action. If no recovery action has been chained to this one, then a value of pNULL is returned.
Definition at line 41 of file RecoveryAction.cpp. |
|
Set the next recovery action.
Definition at line 36 of file RecoveryAction.cpp. |