src/utilities/filetypes/RunOptions.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "RunOptions.hpp" | ||
| 7 | #include "RunOptions_Impl.hpp" | ||
| 8 | #include "ForwardTranslatorOptions.hpp" | ||
| 9 | |||
| 10 | #include "../core/Assert.hpp" | ||
| 11 | #include "../core/DeprecatedHelpers.hpp" | ||
| 12 | |||
| 13 | #include <json/json.h> | ||
| 14 | |||
| 15 | #include <json/value.h> | ||
| 16 | #include <memory> | ||
| 17 | #include <string> | ||
| 18 | |||
| 19 | namespace openstudio { | ||
| 20 | namespace detail { | ||
| 21 | |||
| 22 | 58 | void RunOptions_Impl::onUpdate() { | |
| 23 | 58 | this->onChange.nano_emit(); | |
| 24 | 58 | } | |
| 25 | |||
| 26 | 108 | Json::Value RunOptions_Impl::toJSON() const { | |
| 27 | 108 | Json::Value root; | |
| 28 | |||
| 29 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 57 times.
|
108 | if (!m_is_debug_defaulted) { |
| 30 |
2/2✓ Branch 1 taken 51 times.
✓ Branch 4 taken 51 times.
|
51 | root["debug"] = m_debug; |
| 31 | } | ||
| 32 | |||
| 33 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 107 times.
|
108 | if (!m_is_epjson_defaulted) { |
| 34 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | root["epjson"] = m_epjson; |
| 35 | } | ||
| 36 | |||
| 37 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
|
108 | if (!m_is_fast_defaulted) { |
| 38 | ✗ | root["fast"] = m_fast; | |
| 39 | } | ||
| 40 | |||
| 41 |
2/2✓ Branch 0 taken 28 times.
✓ Branch 1 taken 80 times.
|
108 | if (!m_is_preserveRunDir_defaulted) { |
| 42 |
2/2✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
|
28 | root["preserve_run_dir"] = m_preserveRunDir; |
| 43 | } | ||
| 44 | |||
| 45 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
|
108 | if (!m_is_skipExpandObjects_defaulted) { |
| 46 | ✗ | root["skip_expand_objects"] = m_skipExpandObjects; | |
| 47 | } | ||
| 48 | |||
| 49 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
|
108 | if (!m_is_skipEnergyPlusPreprocess_defaulted) { |
| 50 | ✗ | root["skip_energyplus_preprocess"] = m_skipEnergyPlusPreprocess; | |
| 51 | } | ||
| 52 | |||
| 53 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
|
108 | if (!m_is_skipZipResults_defaulted) { |
| 54 | ✗ | root["skip_zip_results"] = m_skipZipResults; | |
| 55 | } | ||
| 56 | |||
| 57 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
|
108 | if (!m_is_cleanup_defaulted) { |
| 58 | ✗ | root["cleanup"] = m_cleanup; | |
| 59 | } | ||
| 60 | |||
| 61 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 106 times.
|
216 | if (m_customOutputAdapter) { |
| 62 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | root["output_adapter"] = m_customOutputAdapter->toJSON(); |
| 63 | } | ||
| 64 | |||
| 65 |
4/4✓ Branch 1 taken 108 times.
✓ Branch 4 taken 108 times.
✓ Branch 6 taken 1 time.
✓ Branch 7 taken 107 times.
|
108 | if (auto ft_opt = m_forwardTranslatorOptions.toJSON()) { |
| 66 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | root["ft_options"] = ft_opt; |
| 67 | 108 | } | |
| 68 | 108 | return root; | |
| 69 | ✗ | } | |
| 70 | |||
| 71 | 7 | std::string RunOptions_Impl::string() const { | |
| 72 | // Write to string | ||
| 73 |
1/1✓ Branch 1 taken 7 times.
|
7 | Json::StreamWriterBuilder wbuilder; |
| 74 | // mimic the old StyledWriter behavior: | ||
| 75 |
3/3✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
|
21 | wbuilder["indentation"] = " "; |
| 76 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | std::string result = Json::writeString(wbuilder, toJSON()); |
| 77 | |||
| 78 | 14 | return result; | |
| 79 | 7 | } | |
| 80 | |||
| 81 | 168 | bool RunOptions_Impl::debug() const { | |
| 82 | 168 | return m_debug; | |
| 83 | } | ||
| 84 | |||
| 85 | 7 | bool RunOptions_Impl::isDebugDefaulted() const { | |
| 86 | 7 | return m_is_debug_defaulted; | |
| 87 | } | ||
| 88 | |||
| 89 | 21 | bool RunOptions_Impl::setDebug(bool debug) { | |
| 90 | 21 | m_debug = debug; | |
| 91 | 21 | m_is_debug_defaulted = false; | |
| 92 | 21 | onUpdate(); | |
| 93 | 21 | return true; | |
| 94 | } | ||
| 95 | |||
| 96 | 1 | void RunOptions_Impl::resetDebug() { | |
| 97 | 1 | m_debug = DEFAULT_DEBUG; | |
| 98 | 1 | m_is_debug_defaulted = true; | |
| 99 | 1 | onUpdate(); | |
| 100 | 1 | } | |
| 101 | |||
| 102 | 18 | bool RunOptions_Impl::epjson() const { | |
| 103 | 18 | return m_epjson; | |
| 104 | } | ||
| 105 | |||
| 106 | 7 | bool RunOptions_Impl::isEpjsonDefaulted() const { | |
| 107 | 7 | return m_is_epjson_defaulted; | |
| 108 | } | ||
| 109 | |||
| 110 | 5 | bool RunOptions_Impl::setEpjson(bool epjson) { | |
| 111 | 5 | m_epjson = epjson; | |
| 112 | 5 | m_is_epjson_defaulted = false; | |
| 113 | 5 | onUpdate(); | |
| 114 | 5 | return true; | |
| 115 | } | ||
| 116 | |||
| 117 | 1 | void RunOptions_Impl::resetEpjson() { | |
| 118 | 1 | m_epjson = DEFAULT_EPJSON; | |
| 119 | 1 | m_is_epjson_defaulted = true; | |
| 120 | 1 | onUpdate(); | |
| 121 | 1 | } | |
| 122 | |||
| 123 | 79 | bool RunOptions_Impl::fast() const { | |
| 124 | 79 | return m_fast; | |
| 125 | } | ||
| 126 | |||
| 127 | 7 | bool RunOptions_Impl::isFastDefaulted() const { | |
| 128 | 7 | return m_is_fast_defaulted; | |
| 129 | } | ||
| 130 | |||
| 131 | 1 | bool RunOptions_Impl::setFast(bool fast) { | |
| 132 | 1 | m_fast = fast; | |
| 133 | 1 | m_is_fast_defaulted = false; | |
| 134 | 1 | onUpdate(); | |
| 135 | 1 | return true; | |
| 136 | } | ||
| 137 | |||
| 138 | 1 | void RunOptions_Impl::resetFast() { | |
| 139 | 1 | m_fast = DEFAULT_FAST; | |
| 140 | 1 | m_is_fast_defaulted = true; | |
| 141 | 1 | onUpdate(); | |
| 142 | 1 | } | |
| 143 | |||
| 144 | 27 | bool RunOptions_Impl::preserveRunDir() const { | |
| 145 | 27 | return m_preserveRunDir; | |
| 146 | } | ||
| 147 | |||
| 148 | 7 | bool RunOptions_Impl::isPreserveRunDirDefaulted() const { | |
| 149 | 7 | return m_is_preserveRunDir_defaulted; | |
| 150 | } | ||
| 151 | |||
| 152 | 13 | bool RunOptions_Impl::setPreserveRunDir(bool preserveRunDir) { | |
| 153 | 13 | m_preserveRunDir = preserveRunDir; | |
| 154 | 13 | m_is_preserveRunDir_defaulted = false; | |
| 155 | 13 | onUpdate(); | |
| 156 | 13 | return true; | |
| 157 | } | ||
| 158 | |||
| 159 | 1 | void RunOptions_Impl::resetPreserveRunDir() { | |
| 160 | 1 | m_preserveRunDir = DEFAULT_PRESERVERUNDIR; | |
| 161 | 1 | m_is_preserveRunDir_defaulted = true; | |
| 162 | 1 | onUpdate(); | |
| 163 | 1 | } | |
| 164 | |||
| 165 | 16 | bool RunOptions_Impl::skipExpandObjects() const { | |
| 166 | 16 | return m_skipExpandObjects; | |
| 167 | } | ||
| 168 | |||
| 169 | 7 | bool RunOptions_Impl::isSkipExpandObjectsDefaulted() const { | |
| 170 | 7 | return m_is_skipExpandObjects_defaulted; | |
| 171 | } | ||
| 172 | |||
| 173 | 1 | bool RunOptions_Impl::setSkipExpandObjects(bool skipExpandObjects) { | |
| 174 | 1 | m_skipExpandObjects = skipExpandObjects; | |
| 175 | 1 | m_is_skipExpandObjects_defaulted = false; | |
| 176 | 1 | onUpdate(); | |
| 177 | 1 | return true; | |
| 178 | } | ||
| 179 | |||
| 180 | 1 | void RunOptions_Impl::resetSkipExpandObjects() { | |
| 181 | 1 | m_skipExpandObjects = DEFAULT_SKIPEXPANDOBJECTS; | |
| 182 | 1 | m_is_skipExpandObjects_defaulted = true; | |
| 183 | 1 | onUpdate(); | |
| 184 | 1 | } | |
| 185 | |||
| 186 | 18 | bool RunOptions_Impl::skipEnergyPlusPreprocess() const { | |
| 187 | 18 | return m_skipEnergyPlusPreprocess; | |
| 188 | } | ||
| 189 | |||
| 190 | 8 | bool RunOptions_Impl::isSkipEnergyPlusPreprocessDefaulted() const { | |
| 191 | 8 | return m_is_skipEnergyPlusPreprocess_defaulted; | |
| 192 | } | ||
| 193 | |||
| 194 | 1 | bool RunOptions_Impl::setSkipEnergyPlusPreprocess(bool skipEnergyPlusPreprocess) { | |
| 195 | 1 | m_skipEnergyPlusPreprocess = skipEnergyPlusPreprocess; | |
| 196 | 1 | m_is_skipEnergyPlusPreprocess_defaulted = false; | |
| 197 | 1 | onUpdate(); | |
| 198 | 1 | return true; | |
| 199 | } | ||
| 200 | |||
| 201 | 1 | void RunOptions_Impl::resetSkipEnergyPlusPreprocess() { | |
| 202 | 1 | m_skipEnergyPlusPreprocess = DEFAULT_SKIPENERGYPLUSPREPROCESS; | |
| 203 | 1 | m_is_skipEnergyPlusPreprocess_defaulted = true; | |
| 204 | 1 | onUpdate(); | |
| 205 | 1 | } | |
| 206 | |||
| 207 | 26 | bool RunOptions_Impl::skipZipResults() const { | |
| 208 | 26 | return m_skipZipResults; | |
| 209 | } | ||
| 210 | |||
| 211 | 6 | bool RunOptions_Impl::isSkipZipResultsDefaulted() const { | |
| 212 | 6 | return m_is_skipZipResults_defaulted; | |
| 213 | } | ||
| 214 | |||
| 215 | 1 | bool RunOptions_Impl::setSkipZipResults(bool skipZipResults) { | |
| 216 | 1 | m_skipZipResults = skipZipResults; | |
| 217 | 1 | m_is_skipZipResults_defaulted = false; | |
| 218 | 1 | onUpdate(); | |
| 219 | 1 | return true; | |
| 220 | } | ||
| 221 | |||
| 222 | 1 | void RunOptions_Impl::resetSkipZipResults() { | |
| 223 | 1 | m_skipZipResults = DEFAULT_SKIPZIPRESULTS; | |
| 224 | 1 | m_is_skipZipResults_defaulted = true; | |
| 225 | 1 | onUpdate(); | |
| 226 | 1 | } | |
| 227 | |||
| 228 | 27 | bool RunOptions_Impl::cleanup() const { | |
| 229 | 27 | return m_cleanup; | |
| 230 | } | ||
| 231 | |||
| 232 | 7 | bool RunOptions_Impl::isCleanupDefaulted() const { | |
| 233 | 7 | return m_is_cleanup_defaulted; | |
| 234 | } | ||
| 235 | |||
| 236 | 1 | bool RunOptions_Impl::setCleanup(bool cleanup) { | |
| 237 | 1 | m_cleanup = cleanup; | |
| 238 | 1 | m_is_cleanup_defaulted = false; | |
| 239 | 1 | onUpdate(); | |
| 240 | 1 | return true; | |
| 241 | } | ||
| 242 | |||
| 243 | 1 | void RunOptions_Impl::resetCleanup() { | |
| 244 | 1 | m_cleanup = DEFAULT_CLEANUP; | |
| 245 | 1 | m_is_cleanup_defaulted = true; | |
| 246 | 1 | onUpdate(); | |
| 247 | 1 | } | |
| 248 | |||
| 249 | 14 | boost::optional<CustomOutputAdapter> RunOptions_Impl::customOutputAdapter() const { | |
| 250 | 14 | return m_customOutputAdapter; | |
| 251 | } | ||
| 252 | |||
| 253 | 4 | bool RunOptions_Impl::setCustomOutputAdapter(const CustomOutputAdapter& adapter) { | |
| 254 | 4 | m_customOutputAdapter = adapter; | |
| 255 | 4 | onUpdate(); | |
| 256 | 4 | return true; | |
| 257 | } | ||
| 258 | |||
| 259 | ✗ | void RunOptions_Impl::resetCustomOutputAdapter() { | |
| 260 | ✗ | m_customOutputAdapter.reset(); | |
| 261 | ✗ | onUpdate(); | |
| 262 | ✗ | } | |
| 263 | |||
| 264 | 20 | ForwardTranslatorOptions RunOptions_Impl::forwardTranslatorOptions() const { | |
| 265 | 20 | return m_forwardTranslatorOptions; | |
| 266 | } | ||
| 267 | |||
| 268 | 2 | bool RunOptions_Impl::setForwardTranslatorOptions(const ForwardTranslatorOptions& forwardTranslatorOptions) { | |
| 269 |
1/1✓ Branch 2 taken 2 times.
|
2 | m_forwardTranslatorOptions = ForwardTranslatorOptions(forwardTranslatorOptions.getImpl()); |
| 270 | 2 | onUpdate(); | |
| 271 | 2 | return true; | |
| 272 | } | ||
| 273 | |||
| 274 | ✗ | void RunOptions_Impl::resetForwardTranslatorOptions() { | |
| 275 | ✗ | m_forwardTranslatorOptions.reset(); | |
| 276 | ✗ | onUpdate(); | |
| 277 | ✗ | } | |
| 278 | |||
| 279 | 1 | void RunOptions_Impl::overrideValuesWith(const RunOptions& other) { | |
| 280 | |||
| 281 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (!other.isDebugDefaulted()) { |
| 282 | 1 | setDebug(other.debug()); | |
| 283 | } | ||
| 284 | |||
| 285 |
1/2✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
|
1 | if (!other.isEpjsonDefaulted()) { |
| 286 | 1 | setEpjson(other.epjson()); | |
| 287 | } | ||
| 288 | |||
| 289 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!other.isFastDefaulted()) { |
| 290 | ✗ | setFast(other.fast()); | |
| 291 | } | ||
| 292 | |||
| 293 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!other.isPreserveRunDirDefaulted()) { |
| 294 | ✗ | setPreserveRunDir(other.preserveRunDir()); | |
| 295 | } | ||
| 296 | |||
| 297 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!other.isSkipExpandObjectsDefaulted()) { |
| 298 | ✗ | setSkipExpandObjects(other.skipExpandObjects()); | |
| 299 | } | ||
| 300 | |||
| 301 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!other.isSkipEnergyPlusPreprocessDefaulted()) { |
| 302 | ✗ | setSkipEnergyPlusPreprocess(other.skipEnergyPlusPreprocess()); | |
| 303 | } | ||
| 304 | |||
| 305 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!other.isSkipZipResultsDefaulted()) { |
| 306 | ✗ | setSkipZipResults(other.skipZipResults()); | |
| 307 | } | ||
| 308 | |||
| 309 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
|
1 | if (!other.isCleanupDefaulted()) { |
| 310 | ✗ | setCleanup(other.cleanup()); | |
| 311 | } | ||
| 312 | |||
| 313 |
2/2✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
1 | m_forwardTranslatorOptions.overrideValuesWith(other.forwardTranslatorOptions()); |
| 314 | 1 | } | |
| 315 | |||
| 316 | } // namespace detail | ||
| 317 | |||
| 318 | ✗ | CustomOutputAdapter CustomOutputAdapter::fromString(std::string customFileName, std::string className, const std::string& options) { | |
| 319 | |||
| 320 | ✗ | if (options.empty()) { | |
| 321 | ✗ | return CustomOutputAdapter(std::move(customFileName), std::move(className)); | |
| 322 | } | ||
| 323 | ✗ | const Json::CharReaderBuilder rbuilder; | |
| 324 | ✗ | std::istringstream ss(options); | |
| 325 | ✗ | std::string formattedErrors; | |
| 326 | ✗ | Json::Value parsedOptions; | |
| 327 | ✗ | const bool parsingSuccessful = Json::parseFromStream(rbuilder, ss, &parsedOptions, &formattedErrors); | |
| 328 | ✗ | if (!parsingSuccessful) { | |
| 329 | ✗ | parsedOptions = Json::Value(Json::nullValue); | |
| 330 | } | ||
| 331 | ✗ | return CustomOutputAdapter(std::move(customFileName), std::move(className), std::move(parsedOptions)); | |
| 332 | ✗ | } | |
| 333 | |||
| 334 | 4 | CustomOutputAdapter::CustomOutputAdapter(std::string customFileName, std::string className, Json::Value options) | |
| 335 | 4 | : m_customFileName(std::move(customFileName)), m_className(std::move(className)), m_options(std::move(options)) {} | |
| 336 | |||
| 337 | 4 | std::string CustomOutputAdapter::customFileName() const { | |
| 338 | 4 | return m_customFileName; | |
| 339 | } | ||
| 340 | |||
| 341 | 4 | std::string CustomOutputAdapter::className() const { | |
| 342 | 4 | return m_className; | |
| 343 | } | ||
| 344 | |||
| 345 | 1 | std::string CustomOutputAdapter::options() const { | |
| 346 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
1 | if (m_options.isNull()) { |
| 347 |
1/1✓ Branch 1 taken 1 time.
|
2 | return ""; |
| 348 | } | ||
| 349 | |||
| 350 | // Write to string | ||
| 351 | ✗ | Json::StreamWriterBuilder wbuilder; | |
| 352 | // mimic the old StyledWriter behavior: | ||
| 353 | ✗ | wbuilder["indentation"] = " "; | |
| 354 | ✗ | return Json::writeString(wbuilder, m_options); | |
| 355 | ✗ | } | |
| 356 | |||
| 357 | 1 | Json::Value CustomOutputAdapter::optionsJSON() const { | |
| 358 | 1 | return m_options; | |
| 359 | } | ||
| 360 | |||
| 361 | 2 | Json::Value CustomOutputAdapter::toJSON() const { | |
| 362 | 2 | Json::Value outputAdapter; | |
| 363 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | outputAdapter["custom_file_name"] = m_customFileName; |
| 364 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | outputAdapter["class_name"] = m_className; |
| 365 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | outputAdapter["options"] = m_options; |
| 366 | 2 | return outputAdapter; | |
| 367 | ✗ | } | |
| 368 | |||
| 369 | 289 | RunOptions::RunOptions() : m_impl(std::make_shared<detail::RunOptions_Impl>()) { | |
| 370 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 289 times.
✗ Branch 5 not taken.
|
289 | OS_ASSERT(getImpl<detail::RunOptions_Impl>()); |
| 371 | 289 | } | |
| 372 | |||
| 373 | 736 | RunOptions::~RunOptions() = default; | |
| 374 | |||
| 375 | 21 | boost::optional<RunOptions> RunOptions::fromString(const std::string& s) { | |
| 376 | |||
| 377 | // We let it fail with a warning message | ||
| 378 |
1/1✓ Branch 1 taken 21 times.
|
21 | Json::CharReaderBuilder rbuilder; |
| 379 |
1/1✓ Branch 1 taken 21 times.
|
21 | std::istringstream ss(s); |
| 380 | 21 | std::string formattedErrors; | |
| 381 |
1/1✓ Branch 1 taken 21 times.
|
21 | Json::Value value; |
| 382 |
1/1✓ Branch 1 taken 21 times.
|
21 | bool parsingSuccessful = Json::parseFromStream(rbuilder, ss, &value, &formattedErrors); |
| 383 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
|
21 | if (!parsingSuccessful) { |
| 384 | ✗ | LOG(Warn, "Couldn't parse RunOptions from string s='" << s << "'. Error: '" << formattedErrors << "'."); | |
| 385 | ✗ | return boost::none; | |
| 386 | } | ||
| 387 | |||
| 388 |
1/1✓ Branch 1 taken 21 times.
|
21 | RunOptions result; |
| 389 | |||
| 390 |
8/9✓ Branch 1 taken 21 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 20 times.
✓ Branch 6 taken 1 time.
✓ Branch 9 taken 1 time.
✓ Branch 11 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 time.
✓ Branch 14 taken 20 times.
|
21 | if (value.isMember("epjson") && value["epjson"].isBool()) { |
| 391 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | result.setEpjson(value["epjson"].asBool()); |
| 392 | } | ||
| 393 | |||
| 394 |
8/9✓ Branch 1 taken 21 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 12 times.
✓ Branch 6 taken 9 times.
✓ Branch 9 taken 9 times.
✓ Branch 11 taken 9 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 9 times.
✓ Branch 14 taken 12 times.
|
21 | if (value.isMember("debug") && value["debug"].isBool()) { |
| 395 |
3/3✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
|
9 | result.setDebug(value["debug"].asBool()); |
| 396 | } | ||
| 397 | |||
| 398 |
3/9✓ Branch 1 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 21 times.
|
21 | if (value.isMember("fast") && value["fast"].isBool()) { |
| 399 | ✗ | result.setFast(value["fast"].asBool()); | |
| 400 | } | ||
| 401 | |||
| 402 |
8/9✓ Branch 1 taken 21 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 15 times.
✓ Branch 6 taken 6 times.
✓ Branch 9 taken 6 times.
✓ Branch 11 taken 6 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 6 times.
✓ Branch 14 taken 15 times.
|
21 | if (value.isMember("preserve_run_dir") && value["preserve_run_dir"].isBool()) { |
| 403 |
3/3✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 7 taken 6 times.
|
6 | result.setPreserveRunDir(value["preserve_run_dir"].asBool()); |
| 404 | } | ||
| 405 | |||
| 406 |
3/9✓ Branch 1 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 21 times.
|
21 | if (value.isMember("skip_expand_objects") && value["skip_expand_objects"].isBool()) { |
| 407 | ✗ | result.setSkipExpandObjects(value["skip_expand_objects"].asBool()); | |
| 408 | } | ||
| 409 | |||
| 410 |
3/9✓ Branch 1 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 21 times.
|
21 | if (value.isMember("skip_energyplus_preprocess") && value["skip_energyplus_preprocess"].isBool()) { |
| 411 | ✗ | result.setSkipEnergyPlusPreprocess(value["skip_energyplus_preprocess"].asBool()); | |
| 412 | } | ||
| 413 | |||
| 414 |
3/9✓ Branch 1 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 6 not taken.
✗ Branch 9 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 21 times.
|
21 | if (value.isMember("skip_zip_results") && value["skip_zip_results"].isBool()) { |
| 415 | ✗ | result.setSkipZipResults(value["skip_zip_results"].asBool()); | |
| 416 | } | ||
| 417 | |||
| 418 |
3/3✓ Branch 1 taken 21 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 19 times.
|
21 | if (value.isMember("output_adapter")) { |
| 419 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | Json::Value outputAdapter = value["output_adapter"]; |
| 420 |
5/8✓ Branch 1 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 2 times.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
|
2 | if (outputAdapter.isMember("custom_file_name") && outputAdapter.isMember("class_name")) { |
| 421 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | std::string customFileName = outputAdapter["custom_file_name"].asString(); |
| 422 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | std::string className = outputAdapter["class_name"].asString(); |
| 423 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | Json::Value options = outputAdapter["options"]; |
| 424 |
1/1✓ Branch 7 taken 2 times.
|
2 | const CustomOutputAdapter coa(std::move(customFileName), std::move(className), std::move(options)); |
| 425 |
1/1✓ Branch 1 taken 2 times.
|
2 | result.setCustomOutputAdapter(coa); |
| 426 | 2 | } | |
| 427 | 2 | } | |
| 428 | |||
| 429 |
8/9✓ Branch 1 taken 21 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 20 times.
✓ Branch 6 taken 1 time.
✓ Branch 9 taken 1 time.
✓ Branch 11 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 time.
✓ Branch 14 taken 20 times.
|
21 | if (value.isMember("ft_options") && value["ft_options"].isObject()) { |
| 430 |
3/3✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
1 | result.setForwardTranslatorOptions(ForwardTranslatorOptions::fromJSON(value["ft_options"])); |
| 431 | } | ||
| 432 | |||
| 433 |
1/1✓ Branch 1 taken 21 times.
|
21 | return result; |
| 434 | 21 | } | |
| 435 | |||
| 436 | 101 | Json::Value RunOptions::toJSON() const { | |
| 437 |
1/1✓ Branch 3 taken 101 times.
|
101 | return getImpl<detail::RunOptions_Impl>()->toJSON(); |
| 438 | } | ||
| 439 | |||
| 440 | 7 | std::string RunOptions::string() const { | |
| 441 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::RunOptions_Impl>()->string(); |
| 442 | } | ||
| 443 | |||
| 444 | 168 | bool RunOptions::debug() const { | |
| 445 |
1/1✓ Branch 3 taken 168 times.
|
168 | return getImpl<detail::RunOptions_Impl>()->debug(); |
| 446 | } | ||
| 447 | |||
| 448 | 7 | bool RunOptions::isDebugDefaulted() const { | |
| 449 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::RunOptions_Impl>()->isDebugDefaulted(); |
| 450 | } | ||
| 451 | |||
| 452 | 20 | bool RunOptions::setDebug(bool debug) { | |
| 453 |
1/1✓ Branch 3 taken 20 times.
|
20 | return getImpl<detail::RunOptions_Impl>()->setDebug(debug); |
| 454 | } | ||
| 455 | |||
| 456 | 1 | void RunOptions::resetDebug() { | |
| 457 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::RunOptions_Impl>()->resetDebug(); |
| 458 | 1 | } | |
| 459 | |||
| 460 | 18 | bool RunOptions::epjson() const { | |
| 461 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::RunOptions_Impl>()->epjson(); |
| 462 | } | ||
| 463 | |||
| 464 | 7 | bool RunOptions::isEpjsonDefaulted() const { | |
| 465 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::RunOptions_Impl>()->isEpjsonDefaulted(); |
| 466 | } | ||
| 467 | |||
| 468 | 4 | bool RunOptions::setEpjson(bool epjson) { | |
| 469 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::RunOptions_Impl>()->setEpjson(epjson); |
| 470 | } | ||
| 471 | |||
| 472 | 1 | void RunOptions::resetEpjson() { | |
| 473 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::RunOptions_Impl>()->resetEpjson(); |
| 474 | 1 | } | |
| 475 | |||
| 476 | 79 | bool RunOptions::fast() const { | |
| 477 |
1/1✓ Branch 3 taken 79 times.
|
79 | return getImpl<detail::RunOptions_Impl>()->fast(); |
| 478 | } | ||
| 479 | |||
| 480 | 7 | bool RunOptions::isFastDefaulted() const { | |
| 481 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::RunOptions_Impl>()->isFastDefaulted(); |
| 482 | } | ||
| 483 | |||
| 484 | 1 | bool RunOptions::setFast(bool fast) { | |
| 485 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::RunOptions_Impl>()->setFast(fast); |
| 486 | } | ||
| 487 | |||
| 488 | 1 | void RunOptions::resetFast() { | |
| 489 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::RunOptions_Impl>()->resetFast(); |
| 490 | 1 | } | |
| 491 | |||
| 492 | 27 | bool RunOptions::preserveRunDir() const { | |
| 493 |
1/1✓ Branch 3 taken 27 times.
|
27 | return getImpl<detail::RunOptions_Impl>()->preserveRunDir(); |
| 494 | } | ||
| 495 | |||
| 496 | 7 | bool RunOptions::isPreserveRunDirDefaulted() const { | |
| 497 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::RunOptions_Impl>()->isPreserveRunDirDefaulted(); |
| 498 | } | ||
| 499 | |||
| 500 | 13 | bool RunOptions::setPreserveRunDir(bool preserveRunDir) { | |
| 501 |
1/1✓ Branch 3 taken 13 times.
|
13 | return getImpl<detail::RunOptions_Impl>()->setPreserveRunDir(preserveRunDir); |
| 502 | } | ||
| 503 | |||
| 504 | 1 | void RunOptions::resetPreserveRunDir() { | |
| 505 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::RunOptions_Impl>()->resetPreserveRunDir(); |
| 506 | 1 | } | |
| 507 | |||
| 508 | 16 | bool RunOptions::skipExpandObjects() const { | |
| 509 |
1/1✓ Branch 3 taken 16 times.
|
16 | return getImpl<detail::RunOptions_Impl>()->skipExpandObjects(); |
| 510 | } | ||
| 511 | |||
| 512 | 7 | bool RunOptions::isSkipExpandObjectsDefaulted() const { | |
| 513 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::RunOptions_Impl>()->isSkipExpandObjectsDefaulted(); |
| 514 | } | ||
| 515 | |||
| 516 | 1 | bool RunOptions::setSkipExpandObjects(bool skipExpandObjects) { | |
| 517 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::RunOptions_Impl>()->setSkipExpandObjects(skipExpandObjects); |
| 518 | } | ||
| 519 | |||
| 520 | 1 | void RunOptions::resetSkipExpandObjects() { | |
| 521 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::RunOptions_Impl>()->resetSkipExpandObjects(); |
| 522 | 1 | } | |
| 523 | |||
| 524 | 18 | bool RunOptions::skipEnergyPlusPreprocess() const { | |
| 525 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::RunOptions_Impl>()->skipEnergyPlusPreprocess(); |
| 526 | } | ||
| 527 | |||
| 528 | 8 | bool RunOptions::isSkipEnergyPlusPreprocessDefaulted() const { | |
| 529 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::RunOptions_Impl>()->isSkipEnergyPlusPreprocessDefaulted(); |
| 530 | } | ||
| 531 | |||
| 532 | 1 | bool RunOptions::setSkipEnergyPlusPreprocess(bool skipEnergyPlusPreprocess) { | |
| 533 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::RunOptions_Impl>()->setSkipEnergyPlusPreprocess(skipEnergyPlusPreprocess); |
| 534 | } | ||
| 535 | |||
| 536 | 1 | void RunOptions::resetSkipEnergyPlusPreprocess() { | |
| 537 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::RunOptions_Impl>()->resetSkipEnergyPlusPreprocess(); |
| 538 | 1 | } | |
| 539 | |||
| 540 | 26 | bool RunOptions::skipZipResults() const { | |
| 541 |
1/1✓ Branch 3 taken 26 times.
|
26 | return getImpl<detail::RunOptions_Impl>()->skipZipResults(); |
| 542 | } | ||
| 543 | |||
| 544 | 6 | bool RunOptions::isSkipZipResultsDefaulted() const { | |
| 545 |
1/1✓ Branch 3 taken 6 times.
|
6 | return getImpl<detail::RunOptions_Impl>()->isSkipZipResultsDefaulted(); |
| 546 | } | ||
| 547 | |||
| 548 | 1 | bool RunOptions::setSkipZipResults(bool skipZipResults) { | |
| 549 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::RunOptions_Impl>()->setSkipZipResults(skipZipResults); |
| 550 | } | ||
| 551 | |||
| 552 | 1 | void RunOptions::resetSkipZipResults() { | |
| 553 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::RunOptions_Impl>()->resetSkipZipResults(); |
| 554 | 1 | } | |
| 555 | |||
| 556 | 27 | bool RunOptions::cleanup() const { | |
| 557 |
1/1✓ Branch 3 taken 27 times.
|
27 | return getImpl<detail::RunOptions_Impl>()->cleanup(); |
| 558 | } | ||
| 559 | |||
| 560 | 7 | bool RunOptions::isCleanupDefaulted() const { | |
| 561 |
1/1✓ Branch 3 taken 7 times.
|
7 | return getImpl<detail::RunOptions_Impl>()->isCleanupDefaulted(); |
| 562 | } | ||
| 563 | |||
| 564 | 1 | bool RunOptions::setCleanup(bool cleanup) { | |
| 565 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::RunOptions_Impl>()->setCleanup(cleanup); |
| 566 | } | ||
| 567 | |||
| 568 | 1 | void RunOptions::resetCleanup() { | |
| 569 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::RunOptions_Impl>()->resetCleanup(); |
| 570 | 1 | } | |
| 571 | 14 | boost::optional<CustomOutputAdapter> RunOptions::customOutputAdapter() const { | |
| 572 |
1/1✓ Branch 3 taken 14 times.
|
14 | return getImpl<detail::RunOptions_Impl>()->customOutputAdapter(); |
| 573 | } | ||
| 574 | |||
| 575 | 4 | bool RunOptions::setCustomOutputAdapter(const CustomOutputAdapter& adapter) { | |
| 576 |
1/1✓ Branch 3 taken 4 times.
|
4 | return getImpl<detail::RunOptions_Impl>()->setCustomOutputAdapter(adapter); |
| 577 | } | ||
| 578 | |||
| 579 | ✗ | void RunOptions::resetCustomOutputAdapter() { | |
| 580 | ✗ | getImpl<detail::RunOptions_Impl>()->resetCustomOutputAdapter(); | |
| 581 | ✗ | } | |
| 582 | |||
| 583 | 17 | ForwardTranslatorOptions RunOptions::forwardTranslatorOptions() const { | |
| 584 |
1/1✓ Branch 3 taken 17 times.
|
17 | return getImpl<detail::RunOptions_Impl>()->forwardTranslatorOptions(); |
| 585 | } | ||
| 586 | |||
| 587 | 1 | bool RunOptions::setForwardTranslatorOptions(const ForwardTranslatorOptions& forwardTranslatorOptions) { | |
| 588 |
1/1✓ Branch 3 taken 1 time.
|
1 | return getImpl<detail::RunOptions_Impl>()->setForwardTranslatorOptions(forwardTranslatorOptions); |
| 589 | } | ||
| 590 | |||
| 591 | ✗ | void RunOptions::resetForwardTranslatorOptions() { | |
| 592 | ✗ | getImpl<detail::RunOptions_Impl>()->resetForwardTranslatorOptions(); | |
| 593 | ✗ | } | |
| 594 | |||
| 595 | 1 | void RunOptions::overrideValuesWith(const RunOptions& other) { | |
| 596 |
1/1✓ Branch 3 taken 1 time.
|
1 | getImpl<detail::RunOptions_Impl>()->overrideValuesWith(other); |
| 597 | 1 | } | |
| 598 | |||
| 599 | /// @cond | ||
| 600 | |||
| 601 | // DEPRECATED | ||
| 602 | 3 | std::string RunOptions::forwardTranslateOptions() const { | |
| 603 |
5/5✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
|
12 | DEPRECATED_AT_MSG(3, 6, 0, "Use `ForwardTranslatorOptions RunOptions::forwardTranslatorOptions` instead."); |
| 604 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
|
3 | return getImpl<detail::RunOptions_Impl>()->forwardTranslatorOptions().string(); |
| 605 | } | ||
| 606 | |||
| 607 | 1 | bool RunOptions::setForwardTranslateOptions(const std::string& options) { | |
| 608 |
5/5✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
|
4 | DEPRECATED_AT_MSG( |
| 609 | 3, 6, 0, | ||
| 610 | "Use `ForwardTranslatorOptions RunOptions::setForwardTranslatorOptions(const ForwardTranslatorOptions& forwardTranslatorOptions)` instead."); | ||
| 611 | |||
| 612 |
2/3✓ Branch 1 taken 1 time.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
|
2 | if (auto ftOptions_ = ForwardTranslatorOptions::fromString(options)) { |
| 613 |
2/2✓ Branch 3 taken 1 time.
✓ Branch 6 taken 1 time.
|
1 | return getImpl<detail::RunOptions_Impl>()->setForwardTranslatorOptions(ftOptions_.get()); |
| 614 | 1 | } | |
| 615 | ✗ | return false; | |
| 616 | } | ||
| 617 | |||
| 618 | ✗ | void RunOptions::resetForwardTranslateOptions() { | |
| 619 | ✗ | DEPRECATED_AT_MSG(3, 6, 0, "Use resetForwardTranslateOptions instead."); | |
| 620 | ✗ | getImpl<detail::RunOptions_Impl>()->resetForwardTranslatorOptions(); | |
| 621 | ✗ | } | |
| 622 | |||
| 623 | /// @endcond | ||
| 624 | |||
| 625 | ✗ | std::ostream& operator<<(std::ostream& os, const RunOptions& runOptions) { | |
| 626 | ✗ | os << runOptions.string(); | |
| 627 | ✗ | return os; | |
| 628 | } | ||
| 629 | |||
| 630 | } // namespace openstudio | ||
| 631 |