From d644b19236bdac1442315d185704563982845b41 Mon Sep 17 00:00:00 2001 From: ljamt Date: Mon, 30 Mar 2020 18:43:54 +0200 Subject: [PATCH] Fix: Support multiple nested variable groups (#549) * Triggering the bug #548 * Allow returning empty if no variables are found in the variable group #548 * simplifying get_variable_group_variables #548 --- src/cpp/cse_config_parser.cpp | 15 +++++++++------ .../msmi/CraneController_OspModelDescription.xml | 5 +++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/cpp/cse_config_parser.cpp b/src/cpp/cse_config_parser.cpp index e171aa09f..f426ef0a1 100644 --- a/src/cpp/cse_config_parser.cpp +++ b/src/cpp/cse_config_parser.cpp @@ -728,8 +728,9 @@ extended_model_description get_emd( std::vector get_variable_group_variables( const std::unordered_map& descriptions, - const cse_config_parser::VariableEndpoint endpoint) + const cse_config_parser::VariableEndpoint& endpoint) { + std::vector groupVariables; auto groupIt = descriptions.find(endpoint.name); if (groupIt == descriptions.end()) { for (const auto& description : descriptions) { @@ -738,14 +739,16 @@ std::vector get_variable_group_variables( for (const auto& variableGroupDescr : description.second.variable_group_descriptions) { nestedDescriptions.insert({variableGroupDescr.name, variableGroupDescr}); } - return get_variable_group_variables(nestedDescriptions, endpoint); + groupVariables = get_variable_group_variables(nestedDescriptions, endpoint); + if (groupVariables.size() > 0) { + break; + } } } - std::ostringstream oss; - oss << "Cannot find variable group description: " << endpoint.simulator << ":" << endpoint.name; - throw std::out_of_range(oss.str()); + } else { + groupVariables = groupIt->second.variables; } - return groupIt->second.variables; + return groupVariables; } std::vector get_variable_groups( diff --git a/test/data/msmi/CraneController_OspModelDescription.xml b/test/data/msmi/CraneController_OspModelDescription.xml index e0d48880f..4a7a00b32 100644 --- a/test/data/msmi/CraneController_OspModelDescription.xml +++ b/test/data/msmi/CraneController_OspModelDescription.xml @@ -15,6 +15,11 @@ + + + + +