BPMN-OS
BPMN for optimization and simulation
Loading...
Searching...
No Matches
Restriction.cpp
Go to the documentation of this file.
1#include "Restriction.h"
2
3using namespace BPMNOS::Model;
4
6 : element(restriction)
7 , id(restriction->id.value.value)
8 , expression(Expression(restriction->expression.value.value,attributeRegistry))
9 , scope(Scope::FULL)
10{
11 if ( restriction->scope.has_value() ) {
12 if ( restriction->scope->get().value.value == "entry" ) {
13 scope = Scope::ENTRY;
14 }
15 else if ( restriction->scope->get().value.value == "exit" ) {
16 scope = Scope::EXIT;
17 }
18 }
19}
20
21template <typename DataType>
22bool Restriction::isSatisfied(const BPMNOS::Values& status, const DataType& data, const BPMNOS::Values& globals) const {
23 auto feasible = expression.execute(status,data,globals);
24 return feasible.has_value() && feasible.value();
25}
26
27template bool Restriction::isSatisfied<BPMNOS::Values>(const BPMNOS::Values& status, const BPMNOS::Values& data, const BPMNOS::Values& globals) const;
28template bool Restriction::isSatisfied<BPMNOS::SharedValues>(const BPMNOS::Values& status, const BPMNOS::SharedValues& data, const BPMNOS::Values& globals) const;
Class representing a mathematical expression.
Definition Expression.h:17
std::optional< BPMNOS::number > execute(const BPMNOS::Values &status, const DataType &data, const BPMNOS::Values &globals) const
const Expression expression
Definition Restriction.h:23
bool isSatisfied(const BPMNOS::Values &status, const DataType &data, const BPMNOS::Values &globals) const
Check if the restriction is satisfied using an expression applied on status and data attribute values...
Restriction(XML::bpmnos::tRestriction *restriction, const AttributeRegistry &attributeRegistry)
std::optional< std::reference_wrapper< Attribute > > scope
Attribute value can be expected to be of type 'std::string'.