BPMN-OS
BPMN for optimization and simulation
Loading...
Searching...
No Matches
MessageDeliveryDecision.cpp
Go to the documentation of this file.
4
5using namespace BPMNOS::Execution;
6
8 : Event(token)
9 , MessageDeliveryEvent(token,message)
10 , Decision(evaluator)
11{
13}
14
15std::optional<double> MessageDeliveryDecision::evaluate() {
17 return evaluation;
18}
19
20nlohmann::ordered_json MessageDeliveryDecision::jsonify() const {
21 nlohmann::ordered_json jsonObject;
22
23 jsonObject["decision"] = "messagedelivery";
24 jsonObject["processId"] = token->owner->process->id;
25 jsonObject["instanceId"] = BPMNOS::to_string((*token->data)[BPMNOS::Model::ExtensionElements::Index::Instance].get().value(),STRING);
26 jsonObject["nodeId"] = token->node->id;
27
28 if ( auto object = message.lock() ) {
29 jsonObject["message"] = object->jsonify();
30 }
31
32 if ( evaluation.has_value() ) {
33 jsonObject["evaluation"] = (double)evaluation.value();
34 }
35
36 return jsonObject;
37}
Represents an abstract base class for a pending decision.
Definition Decision.h:15
std::optional< double > evaluation
Latest evaluation or null if decision has not been evaluated or evaluation is no longer valid.
Definition Decision.h:20
void determineDependencies(const std::set< const BPMNOS::Model::Attribute * > &dependencies)
Definition Decision.cpp:12
Represents an abstract base class for a pending Evaluator.
Definition Evaluator.h:15
virtual std::optional< double > evaluate(EntryDecision *decision)=0
virtual std::set< const BPMNOS::Model::Attribute * > getDependencies(EntryDecision *decision)=0
const BPMN::Process * process
Pointer to the top-level process.
Represents a token running through a (sub)process.
Definition Token.h:35
const BPMN::FlowNode * node
Definition Token.h:46
const StateMachine * owner
State machine owning the token.
Definition Token.h:44
SharedValues * data
Pointer to the data of the owner or owned state machine subprocesses)
Definition Token.h:58
std::string id
Id of element.
Definition bpmn++.h:16298
std::string to_string(number numericValue, const ValueType &type)
Converts a number to a string.
Definition Number.cpp:150
@ STRING
Definition Value.h:9
const Token * token
Definition Event.h:18
std::optional< double > evaluate() override
Evaluates the reward for the decision. Returns null if decision is infeasible.
nlohmann::ordered_json jsonify() const override
MessageDeliveryDecision(const Token *token, const Message *message, Evaluator *evaluator)
Represents the event of a message from the message pool being delivered.
std::weak_ptr< const Message > message