src/model/OutputJSON.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 "OutputJSON.hpp" | ||
| 7 | #include "OutputJSON_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Model.hpp" | ||
| 10 | #include "Model_Impl.hpp" | ||
| 11 | |||
| 12 | #include <utilities/idd/IddFactory.hxx> | ||
| 13 | #include <utilities/idd/IddEnums.hxx> | ||
| 14 | #include <utilities/idd/OS_Output_JSON_FieldEnums.hxx> | ||
| 15 | |||
| 16 | #include "../utilities/core/Assert.hpp" | ||
| 17 | |||
| 18 | namespace openstudio { | ||
| 19 | namespace model { | ||
| 20 | |||
| 21 | namespace detail { | ||
| 22 | |||
| 23 | 10 | OutputJSON_Impl::OutputJSON_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 24 | 10 | : ModelObject_Impl(idfObject, model, keepHandle) { | |
| 25 |
4/6✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
✓ Branch 7 taken 10 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 10 times.
✗ Branch 13 not taken.
|
10 | OS_ASSERT(idfObject.iddObject().type() == OutputJSON::iddObjectType()); |
| 26 | 10 | } | |
| 27 | |||
| 28 | ✗ | OutputJSON_Impl::OutputJSON_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 29 | ✗ | : ModelObject_Impl(other, model, keepHandle) { | |
| 30 | ✗ | OS_ASSERT(other.iddObject().type() == OutputJSON::iddObjectType()); | |
| 31 | ✗ | } | |
| 32 | |||
| 33 | 17 | OutputJSON_Impl::OutputJSON_Impl(const OutputJSON_Impl& other, Model_Impl* model, bool keepHandle) : ModelObject_Impl(other, model, keepHandle) {} | |
| 34 | |||
| 35 | ✗ | const std::vector<std::string>& OutputJSON_Impl::outputVariableNames() const { | |
| 36 | ✗ | static const std::vector<std::string> result; | |
| 37 | ✗ | if (result.empty()) { | |
| 38 | } | ||
| 39 | ✗ | return result; | |
| 40 | } | ||
| 41 | |||
| 42 | ✗ | IddObjectType OutputJSON_Impl::iddObjectType() const { | |
| 43 | ✗ | return OutputJSON::iddObjectType(); | |
| 44 | } | ||
| 45 | |||
| 46 | 8 | std::string OutputJSON_Impl::optionType() const { | |
| 47 |
1/1✓ Branch 1 taken 8 times.
|
8 | boost::optional<std::string> value = getString(OS_Output_JSONFields::OptionType, true); |
| 48 |
1/3✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
|
8 | OS_ASSERT(value); |
| 49 |
2/2✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
|
16 | return value.get(); |
| 50 | 8 | } | |
| 51 | |||
| 52 | 11 | bool OutputJSON_Impl::outputJSON() const { | |
| 53 | 11 | return getBooleanFieldValue(OS_Output_JSONFields::OutputJSON); | |
| 54 | } | ||
| 55 | |||
| 56 | 11 | bool OutputJSON_Impl::outputCBOR() const { | |
| 57 | 11 | return getBooleanFieldValue(OS_Output_JSONFields::OutputCBOR); | |
| 58 | } | ||
| 59 | |||
| 60 | 11 | bool OutputJSON_Impl::outputMessagePack() const { | |
| 61 | 11 | return getBooleanFieldValue(OS_Output_JSONFields::OutputMessagePack); | |
| 62 | } | ||
| 63 | |||
| 64 | 18 | bool OutputJSON_Impl::setOptionType(const std::string& optionType) { | |
| 65 | 18 | bool result = setString(OS_Output_JSONFields::OptionType, optionType); | |
| 66 | 18 | return result; | |
| 67 | } | ||
| 68 | |||
| 69 | 21 | bool OutputJSON_Impl::setOutputJSON(bool outputJSON) { | |
| 70 | 21 | return setBooleanFieldValue(OS_Output_JSONFields::OutputJSON, outputJSON); | |
| 71 | } | ||
| 72 | |||
| 73 | 21 | bool OutputJSON_Impl::setOutputCBOR(bool outputCBOR) { | |
| 74 | 21 | return setBooleanFieldValue(OS_Output_JSONFields::OutputCBOR, outputCBOR); | |
| 75 | } | ||
| 76 | |||
| 77 | 21 | bool OutputJSON_Impl::setOutputMessagePack(bool outputMessagePack) { | |
| 78 | 21 | return setBooleanFieldValue(OS_Output_JSONFields::OutputMessagePack, outputMessagePack); | |
| 79 | } | ||
| 80 | |||
| 81 | } // namespace detail | ||
| 82 | |||
| 83 | 7772 | IddObjectType OutputJSON::iddObjectType() { | |
| 84 |
1/1✓ Branch 1 taken 7772 times.
|
7772 | return {IddObjectType::OS_Output_JSON}; |
| 85 | } | ||
| 86 | |||
| 87 | ✗ | std::vector<std::string> OutputJSON::optionTypeValues() { | |
| 88 | ✗ | return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_Output_JSONFields::OptionType); | |
| 89 | } | ||
| 90 | |||
| 91 | 8 | std::string OutputJSON::optionType() const { | |
| 92 |
1/1✓ Branch 3 taken 8 times.
|
8 | return getImpl<detail::OutputJSON_Impl>()->optionType(); |
| 93 | } | ||
| 94 | |||
| 95 | 11 | bool OutputJSON::outputJSON() const { | |
| 96 |
1/1✓ Branch 3 taken 11 times.
|
11 | return getImpl<detail::OutputJSON_Impl>()->outputJSON(); |
| 97 | } | ||
| 98 | |||
| 99 | 11 | bool OutputJSON::outputCBOR() const { | |
| 100 |
1/1✓ Branch 3 taken 11 times.
|
11 | return getImpl<detail::OutputJSON_Impl>()->outputCBOR(); |
| 101 | } | ||
| 102 | |||
| 103 | 11 | bool OutputJSON::outputMessagePack() const { | |
| 104 |
1/1✓ Branch 3 taken 11 times.
|
11 | return getImpl<detail::OutputJSON_Impl>()->outputMessagePack(); |
| 105 | } | ||
| 106 | |||
| 107 | 18 | bool OutputJSON::setOptionType(const std::string& optionType) { | |
| 108 |
1/1✓ Branch 3 taken 18 times.
|
18 | return getImpl<detail::OutputJSON_Impl>()->setOptionType(optionType); |
| 109 | } | ||
| 110 | |||
| 111 | 21 | bool OutputJSON::setOutputJSON(bool outputJSON) { | |
| 112 |
1/1✓ Branch 3 taken 21 times.
|
21 | return getImpl<detail::OutputJSON_Impl>()->setOutputJSON(outputJSON); |
| 113 | } | ||
| 114 | |||
| 115 | 21 | bool OutputJSON::setOutputCBOR(bool outputCBOR) { | |
| 116 |
1/1✓ Branch 3 taken 21 times.
|
21 | return getImpl<detail::OutputJSON_Impl>()->setOutputCBOR(outputCBOR); |
| 117 | } | ||
| 118 | |||
| 119 | 21 | bool OutputJSON::setOutputMessagePack(bool outputMessagePack) { | |
| 120 |
1/1✓ Branch 3 taken 21 times.
|
21 | return getImpl<detail::OutputJSON_Impl>()->setOutputMessagePack(outputMessagePack); |
| 121 | } | ||
| 122 | |||
| 123 | /// @cond | ||
| 124 |
1/1✓ Branch 2 taken 14 times.
|
14 | OutputJSON::OutputJSON(std::shared_ptr<detail::OutputJSON_Impl> impl) : ModelObject(impl) {} |
| 125 | 10 | OutputJSON::OutputJSON(Model& model) : ModelObject(OutputJSON::iddObjectType(), model) { | |
| 126 | // This is a required-field, so pick one... | ||
| 127 | // might as well default to more (TimeSeriesAndTabular) than less (TimeSeries) | ||
| 128 |
2/2✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
|
10 | setOptionType("TimeSeriesAndTabular"); |
| 129 | // Same defaults as EnergyPlus IDD | ||
| 130 |
1/1✓ Branch 1 taken 10 times.
|
10 | setOutputJSON(true); |
| 131 |
1/1✓ Branch 1 taken 10 times.
|
10 | setOutputCBOR(false); |
| 132 |
1/1✓ Branch 1 taken 10 times.
|
10 | setOutputMessagePack(false); |
| 133 | 10 | } | |
| 134 | |||
| 135 | /// @endcond | ||
| 136 | |||
| 137 | } // namespace model | ||
| 138 | } // namespace openstudio | ||
| 139 |