1#ifndef BPMNOS_Execution_StateMachine_H
2#define BPMNOS_Execution_StateMachine_H
29class StateMachine :
public std::enable_shared_from_this<StateMachine> {
65 std::map< const BPMN::FlowNode*, unsigned int > instantiations;
67 void registerRecipient();
68 void unregisterRecipient();
81 void initiateBoundaryEvents(
Token* token);
83 void initiateEventSubprocesses(
Token* token);
84 void createMultiInstanceActivityTokens(
Token* token);
85 void deleteMultiInstanceActivityToken(
Token* token);
86 void deleteAdHocSubProcessToken(
Token* token);
87 void compensateActivity(
Token* token);
89 std::vector<Token*> createTokenCopies(
Token* token,
const std::vector<BPMN::SequenceFlow*>& sequenceFlows);
93 void interruptActivity(
Token* token);
94 void clearObsoleteTokens();
96 void handleDivergingGateway(
Token* token);
97 void handleEventBasedGatewayActivation(
Token* token);
98 void handleEscalation(
Token* token);
99 void handleFailure(
Token* token);
101 void attemptShutdown();
103 void deleteNonInterruptingEventSubProcess(
StateMachine* eventSubProcess);
104 void deleteCompensationEventSubProcess(
StateMachine* eventSubProcess);
105 void deleteTokensAwaitingBoundaryEvent(
Token* token);
106 void completeCompensationActivity(
Token* token);
107 void completeCompensationEventSubProcess();
108 void advanceTokenWaitingForCompensation(
Token* waitingToken);
109 void compensate(
Tokens compensations,
Token* waitingToken);
111 Token* findTokenAwaitingErrorBoundaryEvent(
Token* activityToken);
Represents a state machine for BPMN execution of a scope in the model.
const BPMN::Scope * scope
Pointer to the current scope.
StateMachine(const SystemState *systemState, const BPMN::Process *process, Values dataAttributes)
StateMachines pendingEventSubProcesses
Container with state machines of all inactive event subprocesses that may be triggered.
const SystemState * systemState
const BPMN::Process * process
Pointer to the top-level process.
StateMachines compensationEventSubProcesses
Container with state machines created for a compensation event subprocesses of a child subprocess.
StateMachines nonInterruptingEventSubProcesses
Container with state machines of all active event subprocesses that are not interrupting.
const StateMachine * root
Pointer to the root state machine.
Values getData(const BPMN::Scope *scope)
std::shared_ptr< StateMachine > interruptingEventSubProcess
State machines representing an active event subprocess that is interrupting.
void run(Values status)
Create initial token and advance it.
std::optional< BPMNOS::number > instance
Numeric representation of instance id (TODO: can we const this?)
StateMachines compensableSubProcesses
Container holding state machines for completed subprocesses with a compensation event subprocess and ...
Tokens tokens
Container with all tokens within the scope of the state machine.
Values ownedData
Container holding data attributes owned by the state machine.
Tokens compensationTokens
Container with all tokens created for a compensation activity.
SharedValues data
Container holding references to all data attributes.
Tokens getCompensationTokens(const BPMN::Activity *activity=nullptr) const
Returns the compensation tokens for a given activity or for all activities.
A class representing the state that the execution or simulation of a given scenario is in.
Represents a token running through a (sub)process.
Base class for all boundary events attached to an Activity.
Base class for BPMN elements that may contain incoming and outgoing sequence flows.
Base class for BPMN elements that may contain a ChildNode elements.
std::vector< std::shared_ptr< StateMachine > > StateMachines
std::vector< std::shared_ptr< Token > > Tokens