GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 2 / 1 / 3
Functions: 100.0% 1 / 1 / 2
Branches: -% 0 / 1 / 1

src/utilities/filetypes/RunOptions.hpp
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 #ifndef UTILITIES_FILETYPES_RUNOPTIONS_HPP
7 #define UTILITIES_FILETYPES_RUNOPTIONS_HPP
8
9 #include "../UtilitiesAPI.hpp"
10
11 #include "../core/Logger.hpp"
12 #include "../core/Deprecated.hpp"
13
14 #include <json/json.h>
15
16 namespace openstudio {
17
18 class ForwardTranslatorOptions;
19
20 namespace detail {
21 class WorkflowJSON_Impl;
22 class RunOptions_Impl;
23 class ForwardTranslatorOptions_Impl;
24 } // namespace detail
25
26 class UTILITIES_API CustomOutputAdapter
27 {
28 public:
29 // Couldn't add both ctors, it's ambiguous... so retaining existing as a static factory fromString
30 static CustomOutputAdapter fromString(std::string customFileName, std::string className, const std::string& options);
31 explicit CustomOutputAdapter(std::string customFileName, std::string className, Json::Value options = Json::nullValue);
32
33 std::string customFileName() const;
34 std::string className() const;
35 std::string options() const;
36 Json::Value optionsJSON() const;
37
38 Json::Value toJSON() const;
39
40 private:
41 REGISTER_LOGGER("openstudio.CustomOutputAdapter");
42
43 std::string m_customFileName;
44 std::string m_className;
45 Json::Value m_options;
46 };
47
48 /** Base class for defining a run options for a OpenStudio Workflow. */
49 class UTILITIES_API RunOptions
50 {
51 public:
52 RunOptions();
53
54 // TODO: uneeded
55 virtual ~RunOptions();
56
57 /// Construct from JSON formatted string
58 static boost::optional<RunOptions> fromString(const std::string& s);
59
60 Json::Value toJSON() const;
61
62 /// Serialize to JSON formatted string
63 std::string string() const;
64
65 /** Print debugging messages, defaults to false */
66 bool debug() const;
67 bool isDebugDefaulted() const;
68 bool setDebug(bool debug);
69 void resetDebug();
70
71 /** Create, export and run using epjson format. Default is false */
72 bool epjson() const;
73 bool isEpjsonDefaulted() const;
74 bool setEpjson(bool epjson);
75 void resetEpjson();
76
77 /** Speeds up workflow by skipping steps not needed for running simulations, defaults to false */
78 bool fast() const;
79 bool isFastDefaulted() const;
80 bool setFast(bool fast);
81 void resetFast();
82
83 bool preserveRunDir() const;
84 bool isPreserveRunDirDefaulted() const;
85 bool setPreserveRunDir(bool preserveRunDir);
86 void resetPreserveRunDir();
87
88 /** Skips the call to the EnergyPlus ExpandObjects program, defaults to false */
89 bool skipExpandObjects() const;
90 bool isSkipExpandObjectsDefaulted() const;
91 bool setSkipExpandObjects(bool skipExpandObjects);
92 void resetSkipExpandObjects();
93
94 /** Does not add add default output requests to EnergyPlus input if true.
95 * Requests from reporting measures are added in either case, defaults to false */
96 bool skipEnergyPlusPreprocess() const;
97 bool isSkipEnergyPlusPreprocessDefaulted() const;
98 bool setSkipEnergyPlusPreprocess(bool skipEnergyPlusPreprocess);
99 void resetSkipEnergyPlusPreprocess();
100
101 /** Skips creating the data_point.zip file. Setting to `true` can cause issues with workflows expecting .zip files to signal completion
102 * (e.g., OpenStudio Analysis Framework), defaults to false */
103 bool skipZipResults() const;
104 bool isSkipZipResultsDefaulted() const;
105 bool setSkipZipResults(bool skipZipResults);
106 void resetSkipZipResults();
107
108 /** Remove unnecessary files during post processing, defaults to true */
109 bool cleanup() const;
110 bool isCleanupDefaulted() const;
111 bool setCleanup(bool cleanup);
112 void resetCleanup();
113
114 boost::optional<CustomOutputAdapter> customOutputAdapter() const;
115 bool setCustomOutputAdapter(const CustomOutputAdapter& adapter);
116 void resetCustomOutputAdapter();
117
118 OS_DEPRECATED(3, 6, 0) std::string forwardTranslateOptions() const;
119 OS_DEPRECATED(3, 6, 0) bool setForwardTranslateOptions(const std::string& options);
120 OS_DEPRECATED(3, 6, 0) void resetForwardTranslateOptions();
121
122 ForwardTranslatorOptions forwardTranslatorOptions() const;
123 bool setForwardTranslatorOptions(const ForwardTranslatorOptions& forwardTranslatorOptions);
124 void resetForwardTranslatorOptions();
125
126 /* Any non-defaulted value from other is brought over */
127 void overrideValuesWith(const RunOptions& other);
128
129 protected:
130 // get the impl
131 template <typename T>
132 968 std::shared_ptr<T> getImpl() const {
133 968 return std::dynamic_pointer_cast<T>(m_impl);
134 }
135
136 friend class detail::WorkflowJSON_Impl;
137
138 private:
139 // configure logging
140 − REGISTER_LOGGER("openstudio.RunOptions");
141
142 // pointer to implementation
143 std::shared_ptr<detail::RunOptions_Impl> m_impl;
144 };
145
146 UTILITIES_API std::ostream& operator<<(std::ostream& os, const RunOptions& runOptions);
147
148 } // namespace openstudio
149
150 #endif //UTILITIES_FILETYPES_RUNOPTIONS_HPP
151