13 , index(
std::numeric_limits<size_t>::max())
14 , id(attribute->id.value.value)
15 , expression(getExpression(attribute->name.value.value,attributeRegistry))
16 , name(getName(attribute->name.value.value))
19 attributeRegistry.add(
this);
26 type = ValueType::BOOLEAN;
29 type = ValueType::INTEGER;
32 type = ValueType::DECIMAL;
35 type = ValueType::STRING;
38 type = ValueType::COLLECTION;
41 if ( attribute->
weight.has_value() ) {
42 if ( attribute->objective.has_value() && attribute->objective->get().value.value ==
"maximize" ) {
43 weight = (double)attribute->weight->get().value;
45 else if ( attribute->
objective.has_value() && attribute->
objective->get().value.value ==
"minimize" ) {
46 weight = -(double)attribute->weight->get().value;
49 throw std::runtime_error(
"Attribute: illegal objective of attribute '" + id +
"'");
53 if ( attribute->objective.has_value() && attribute->objective->get().value.value !=
"none" ) {
54 throw std::runtime_error(
"Attribute: required objective weight missing for attribute '" +
id +
"'");
62std::unique_ptr<const Expression> Attribute::getExpression(std::string& input,
AttributeRegistry& attributeRegistry) {
63 if ( !input.contains(
":=") ) {
69 assert( root.operands.size() == 1 );
70 assert( root.type == LIMEX::Type::group );
71 auto& node = std::get< LIMEX::Node<double> >(root.operands[0]);
72 if ( node.type != LIMEX::Type::assign ) {
73 throw std::runtime_error(
"Attribute: illegal initialization '" + input +
"' for attribute '" +
id +
"'");
78std::string Attribute::getName(std::string& input) {
80 assert(
expression->compiled.getTarget().has_value() );
81 return expression->compiled.getTarget().value();
std::unique_ptr< const Expression > expression
Attribute(XML::bpmnos::tAttribute *attribute, Attribute::Category category, AttributeRegistry &attributeRegistry)
Class representing a mathematical expression.
std::optional< const Attribute * > target
Attribute & type
Attribute value can be expected to be of type 'std::string'.
std::optional< std::reference_wrapper< Attribute > > weight
Attribute value can be expected to be of type 'double'.
std::optional< std::reference_wrapper< Attribute > > objective
Attribute value can be expected to be of type 'std::string'.
const std::string Timestamp
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.