MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / applyArguments

Method applyArguments

src/workflow/OSWorkflow.cpp:194–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194void OSWorkflow::applyArguments(measure::OSArgumentMap& argumentMap, const std::string& argumentName, const openstudio::Variant& argumentValue) {
195 LOG(Info, "Setting argument value '" << argumentName << "' to '" << argumentValue << "'");
196
197 // if (!argumentValue.hasValue()) {
198 // fmt::print("Warn: Value for argument '{}' not set in argument list therefore will use default\n", argumentName);
199 // return;
200 // }
201 if (!argumentMap.contains(argumentName)) {
202 throw std::runtime_error(fmt::format("Could not find argument '{}' in argument_map\n", argumentName));
203 }
204
205 auto& v = argumentMap.at(argumentName);
206
207 bool value_set = false;
208 VariantType variantType = argumentValue.variantType();
209
210 if (variantType == VariantType::String) {
211 value_set = v.setValue(argumentValue.valueAsString());
212 } else if (variantType == VariantType::Double) {
213 value_set = v.setValue(argumentValue.valueAsDouble());
214 } else if (variantType == VariantType::Integer) {
215 value_set = v.setValue(argumentValue.valueAsInteger());
216 } else if (variantType == VariantType::Boolean) {
217 value_set = v.setValue(argumentValue.valueAsBoolean());
218 }
219
220 if (!value_set) {
221 throw std::runtime_error(fmt::format("Could not set argument '{}' to value '{}': passed argument has type '{}' while '{}' was expected",
222 argumentName, argumentValue, argumentValue.variantType().valueName(), v.type().valueName()));
223 }
224}
225
226void OSWorkflow::saveOSMToRootDirIfDebug() {
227 if (!workflowJSON.runOptions() || !workflowJSON.runOptions()->debug()) {

Callers

nothing calls this directly

Calls 8

valueNameMethod · 0.80
variantTypeMethod · 0.45
setValueMethod · 0.45
valueAsStringMethod · 0.45
valueAsDoubleMethod · 0.45
valueAsIntegerMethod · 0.45
valueAsBooleanMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected