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 exitIsFeasible()
const;
86 void advanceFromCreated();
87 void advanceToReady();
88 void advanceToEntered();
92 void advanceToCompleted();
94 void advanceToExiting();
96 void advanceToDeparting();
98 void advanceToArrived();
100 void advanceToFailed();
104 void awaitCompensation();
106 void awaitReadyEvent();
108 void awaitEntryEvent();
110 void awaitChoiceEvent();
111 void awaitTaskCompletionEvent();
112 void awaitExitEvent();
117 void awaitMessageDelivery();
119 void awaitEventBasedGateway();
121 void awaitGatewayActivation();
123 template<
typename DecisionType,
typename... Args>
124 std::shared_ptr<DecisionType> createDecisionRequest(Args&&... args);
133 void sendMessage(
size_t index = 0 );
135 Token* getSequentialPerfomerToken()
const;
137 void update(
State newState);
144 template <
typename TokenPtr>
145 static BPMNOS::Values mergeStatus(
const std::vector<TokenPtr>& tokens) {
146 assert( !tokens.empty() );
147 size_t n = tokens.front()->status.size();
152 for (
size_t i = 0; i < n; i++ ) {
153 for (
auto& token : tokens ) {
155 if ( result[i].value() < token->status[i].value() ) {
156 result[i] = token->status[i];
159 else if ( !result[i].has_value() ) {
160 result[i] = token->status[i];
162 else if ( token->status[i].has_value() && token->status[i].value() != result[i].value() ) {
163 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
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.
void setStatus(const BPMNOS::Values &other)
Copies all elements except the instance id from other to status
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[]
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