12 , attributeRegistry(attributeRegistry)
15 std::string attributeName;
17 strutil::replace_all( input,
"∈",
" in ");
20 auto conditions = strutil::split(input,
'<');
21 if ( conditions.size() == 3 ) {
23 if ( conditions[1][0] ==
'=' ) {
25 conditions[1].erase(0, 1);
33 for (
auto dependency :
lowerBound.value().inputs ) {
38 attributeName = strutil::trim_copy(conditions[1]);
40 if ( conditions[2][0] ==
'=' ) {
42 conditions[2].erase(0, 1);
51 for (
auto dependency :
upperBound.value().inputs ) {
56 else if (
auto parts = strutil::split(input,
" in "); parts.size() == 2 ) {
58 attributeName = strutil::trim_copy(parts.front());
59 auto rhs = strutil::trim_copy(parts.back());
61 if ( (rhs.front() ==
'[' && rhs.back() ==
']') || (rhs.front() ==
'{' && rhs.back() ==
'}') ) {
62 auto alternatives = strutil::split(
encodeCollection( rhs.substr(1, rhs.size()-2) ),
',' );
63 for (
auto& alternative : alternatives ) {
65 for (
auto dependency :
enumeration.back().inputs ) {
70 throw std::runtime_error(
"Choice: empty enumeration");
74 throw std::runtime_error(
"Choice: invalid enumeration '" + rhs +
"'");
78 attributeName = strutil::trim_copy(input);
83 if ( attributeName ==
"" ) {
84 throw std::runtime_error(
"Choice: unable to determine attribute name");
90 throw std::runtime_error(
"Choice: no enumeration provided for string");
93 throw std::runtime_error(
"Choice: attribute is a collection");
99template <
typename DataType>
104 BPMNOS::number min =
lowerBound.value().execute(status,data,globals).value_or(std::numeric_limits<BPMNOS::number>::min());
108 BPMNOS::number max =
upperBound.value().execute(status,data,globals).value_or(std::numeric_limits<BPMNOS::number>::max());
113 min = std::ceil((
double)min);
114 max = std::floor((
double)max);
124template <
typename DataType>
127 std::vector<BPMNOS::number> allowedValues;
129 auto allowedValue = alternative.execute(status,data,globals);
130 if ( allowedValue.has_value() ) {
131 allowedValues.push_back( allowedValue.value() );
135 return allowedValues;
#define BPMNOS_NUMBER_PRECISION
bool isImmutable
Flag indicating whether attribute value may be changed by operator, choice, or intermediate catch eve...
std::optional< Expression > upperBound
std::set< const Attribute * > dependencies
Choice(XML::bpmnos::tDecision *decision, const AttributeRegistry &attributeRegistry)
std::pair< BPMNOS::number, BPMNOS::number > getBounds(const BPMNOS::Values &status, const DataType &data, const BPMNOS::Values &globals) const
Returns the minimal and maximal value the attribute may take.
std::vector< BPMNOS::number > getEnumeration(const BPMNOS::Values &status, const DataType &data, const BPMNOS::Values &globals) const
Returns the allowed values the attribute may take.
const AttributeRegistry & attributeRegistry
std::optional< Expression > lowerBound
std::vector< Expression > enumeration
std::pair< bool, bool > strictness
Attribute & condition
Attribute value can be expected to be of type 'std::string'.
std::string encodeQuotedStrings(std::string text)
std::string encodeCollection(std::string text)
Function to replace a collection that is not preceded by an alphanumeric or underscore.
BPMNOS_NUMBER_TYPE number