1#ifndef BPMNOS_Execution_Token_H
2#define BPMNOS_Execution_Token_H
10#include <nlohmann/json.hpp>
19typedef std::vector< std::shared_ptr<Token> >
Tokens;
45 std::shared_ptr<StateMachine>
owned;
48 enum class State {
CREATED,
READY,
ENTERED,
BUSY,
COMPLETED,
EXITING,
DEPARTED,
ARRIVED,
WAITING,
DONE,
FAILED,
FAILING,
WITHDRAWN };
50 static inline std::string
stateName[] = {
"CREATED",
"READY",
"ENTERED",
"BUSY",
"COMPLETED",
"EXITING",
"DEPARTED",
"ARRIVED",
"WAITING",
"DONE",
"FAILED",
"FAILING",
"WITHDRAWN" };
53 Token(
const std::vector<Token*>& others);
75 nlohmann::ordered_json
jsonify()
const;
77 void occupySequentialPerformer();
78 void releaseSequentialPerformer();
80 bool entryIsFeasible()
const;
81 bool completionIsFeasible()
const;
82 bool exitIsFeasible()
const;
87 void advanceFromCreated();
88 void advanceToReady();
89 void advanceToEntered();
93 void advanceToCompleted();
95 void advanceToExiting();
97 void advanceToDeparting();
99 void advanceToArrived();
101 void advanceToFailed();
105 void awaitCompensation();
107 void awaitReadyEvent();
109 void awaitEntryEvent();
111 void awaitChoiceEvent();
112 void awaitTaskCompletionEvent();
113 void awaitExitEvent();
118 void awaitMessageDelivery();
120 void awaitEventBasedGateway();
122 void awaitGatewayActivation();
124 template<
typename DecisionType,
typename... Args>
125 std::shared_ptr<DecisionType> createDecisionRequest(Args&&... args);
134 void sendMessage(
size_t index = 0 );
138 void update(
State newState);
145 template <
typename TokenPtr>
146 static BPMNOS::Values mergeStatus(
const std::vector<TokenPtr>& tokens) {
147 assert( !tokens.empty() );
148 size_t n = tokens.front()->status.size();
153 for (
size_t i = 0; i < n; i++ ) {
154 for (
auto& token : tokens ) {
156 if ( result[i].value() < token->status[i].value() ) {
157 result[i] = token->status[i];
160 else if ( !result[i].has_value() ) {
161 result[i] = token->status[i];
163 else if ( token->status[i].has_value() && token->status[i].value() != result[i].value() ) {
164 result[i] = std::nullopt;
Represents a state machine for BPMN execution of a scope in the model.
A class representing the state that the execution or simulation of a given scenario is in.
Represents a token running through a (sub)process.
constexpr Type getObservableType() const override
BPMNOS::number getInstanceId() const
const BPMN::FlowNode * node
Token * performing
Pointer to the activity token currently performed (only applies if node is a performer referenced by ...
const BPMNOS::Model::AttributeRegistry & getAttributeRegistry() const
const StateMachine * owner
State machine owning the token.
std::shared_ptr< StateMachine > owned
State machine owned by the token.
SharedValues * data
Pointer to the data of the owner or owned state machine subprocesses)
std::shared_ptr< DecisionRequest > decisionRequest
const BPMN::SequenceFlow * sequenceFlow
static std::string stateName[]
Token * getSequentialPerformerToken() const
Returns token at sequential performer for tokens at activities within sequential adhoc subprocesses.
auto_list< std::weak_ptr< Token > > pendingSequentialEntries
List of tokens awaiting an activity entry (only applies if node is a performer referenced by sequenti...
nlohmann::ordered_json jsonify() const
List of tuples with automatic removal of tuples containing an expired weak_ptr.
Class holding extension elements representing execution data for nodes.
Base class for BPMN elements that may contain incoming and outgoing sequence flows.
The SequenceFlow class encapsulates the information and relationships associated with a sequence flow...
std::vector< std::shared_ptr< Token > > Tokens
std::unordered_map< std::string, std::unique_ptr< Content > > ContentMap
std::unordered_map< std::string, std::variant< std::optional< number >, std::string > > VariedValueMap
BPMNOS_NUMBER_TYPE number
Represents a pending decision.
static constexpr size_t Timestamp