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{
12 throw std::runtime_error("Restriction: illegal restriction '" + expression.expression + "'");
13 }
14 if ( restriction->scope.has_value() ) {
15 if ( restriction->scope->get().value.value == "entry" ) {
16 scope = Scope::ENTRY;
17 }
18 else if ( restriction->scope->get().value.value == "completion" ) {
19 scope = Scope::COMPLETION;
20 }
21 else if ( restriction->scope->get().value.value == "exit" ) {
22 scope = Scope::EXIT;
23 }
24 }
25}
26
27template <typename DataType>
28bool Restriction::isSatisfied(const BPMNOS::Values& status, const DataType& data, const BPMNOS::Values& globals) const {
29 auto feasible = expression.execute(status,data,globals);
30 return feasible.has_value() && feasible.value();
31}
32
33template bool Restriction::isSatisfied<BPMNOS::Values>(const BPMNOS::Values& status, const BPMNOS::Values& data, const BPMNOS::Values& globals) const;
34template 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'.