BPMN-OS
BPMN for optimization and simulation
Loading...
Searching...
No Matches
ReadyHandler.cpp
Go to the documentation of this file.
1#include "ReadyHandler.h"
3#include <cassert>
4
5using namespace BPMNOS::Execution;
6
10
11std::shared_ptr<Event> ReadyHandler::dispatchEvent( const SystemState* systemState ) {
12 for ( auto& [token_ptr] : systemState->tokensAwaitingReadyEvent ) {
13 if ( auto token = token_ptr.lock() ) {
14 assert( token );
15 std::optional<BPMNOS::Values> statusAttributes = systemState->getStatusAttributes( token->owner->root, token->node );
16 std::optional<BPMNOS::Values> dataAttributes = systemState->getDataAttributes( token->owner->root, token->node );
17 if ( statusAttributes.has_value() && dataAttributes.has_value() ) {
18 return std::make_shared<ReadyEvent>( token.get(), std::move(statusAttributes.value()), std::move(dataAttributes.value()) );
19 }
20 }
21 }
22 return nullptr;
23}
std::shared_ptr< Event > dispatchEvent(const SystemState *systemState) override
A class representing the state that the execution or simulation of a given scenario is in.
Definition SystemState.h:21
std::optional< BPMNOS::Values > getStatusAttributes(const StateMachine *root, const BPMN::Node *node) const
std::optional< BPMNOS::Values > getDataAttributes(const StateMachine *root, const BPMN::Node *node) const
auto_list< std::weak_ptr< Token > > tokensAwaitingReadyEvent
Container holding all tokens awaiting a ready event.
Definition SystemState.h:76