8 : state(
State::CREATED)
10 , waitingToken(nullptr)
24 for (
auto& [key,contentDefinition] : messageDefinition->contentMap) {
25 if ( token->status[contentDefinition->attribute->index].has_value() ) {
26 contentValueMap.emplace( key, attributeRegistry.getValue(contentDefinition->attribute,token->status,*token->data,token->globals) );
29 contentValueMap.emplace( key, std::nullopt );
35 if (
header.size() != otherHeader.size() ) {
39 for (
size_t i = 0; i <
header.size(); i++ ) {
40 if (
header[i].has_value() && otherHeader[i].has_value() &&
header[i].value() != otherHeader[i].value() ) {
49 nlohmann::ordered_json jsonObject;
52 jsonObject[
"state"] = stateName[(int)
state];
56 for (
auto headerName : messageDefinition->header ) {
57 if ( !
header[i].has_value() ) {
58 jsonObject[
"header"][headerName] = nullptr ;
68 if ( std::holds_alternative< std::optional<number> >(contentValue) && std::get< std::optional<number> >(contentValue).has_value() ) {
71 if (
auto it = messageDefinition->contentMap.find(key); it != messageDefinition->contentMap.end() ) {
72 type = it->second->attribute->type;
74 number value = std::get< std::optional<number> >(contentValue).value();
77 else if (std::holds_alternative<std::string>(contentValue)) {
79 jsonObject[
"content"][key] = std::get< std::string >(contentValue);
83 jsonObject[
"content"][key] =
nullptr;
91template <
typename DataType>
97 if (
auto it = targetContentDefinition.find(key); it != targetContentDefinition.end() ) {
98 auto& [_,definition] = *it;
99 auto attribute = definition->attribute;
101 if ( std::holds_alternative< std::optional<number> >(contentValue) && std::get< std::optional<number> >(contentValue).has_value() ) {
103 attributeRegistry.
setValue(attribute, status, data, globals, std::get< std::optional<number> >(contentValue).value() );
105 else if (std::holds_alternative<std::string>(contentValue)) {
107 Value value = std::get< std::string >(contentValue);
111 attributeRegistry.
setValue(attribute, status, data, globals, std::nullopt );
120 if ( targetContentDefinition.size() >
contentValueMap.size() - counter ) {
122 for (
auto& [key,definition] : targetContentDefinition) {
125 attributeRegistry.
setValue(definition->attribute, status, data, globals, std::nullopt );
bool matches(const BPMNOS::Values &otherHeader) const
Returns true if headers have the same size and all values that are defined are the same.
nlohmann::ordered_json jsonify() const
void apply(const BPMN::FlowNode *node, const BPMNOS::Model::AttributeRegistry &attributeRegistry, BPMNOS::Values &status, DataType &data, BPMNOS::Values &globals) const
Updates the status at a node based on the message content.
VariedValueMap contentValueMap
Message(Token *token, size_t index)
std::optional< BPMNOS::number > recipient
const BPMN::FlowNode * origin
Represents a token running through a (sub)process.
const BPMN::FlowNode * node
const BPMNOS::Model::AttributeRegistry & getAttributeRegistry() const
SharedValues * data
Pointer to the data of the owner or owned state machine subprocesses)
void setValue(const Attribute *attribute, Values &status, Values &data, Values &globals, std::optional< BPMNOS::number > value) const
Class holding extension elements representing execution data for nodes.
const MessageDefinition * getMessageDefinition(size_t index) const
std::unique_ptr< ExtensionElements > extensionElements
std::string id
Id of element.
T * represents()
Attempts to cast the element to the specified type T.
Base class for BPMN elements that may contain incoming and outgoing sequence flows.
std::string to_string(number numericValue, const ValueType &type)
Converts a number to a string.
number to_number(const std::string &valueString, const ValueType &type)
Converts a string to a number.
BPMNOS_NUMBER_TYPE number
std::variant< bool, int, double, std::string > Value