GCC Code Coverage Report


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

src/measure/OSMeasureInfoGetter.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 MEASURE_OSMEASUREINFOGETTER_HPP
7 #define MEASURE_OSMEASUREINFOGETTER_HPP
8
9 #include "MeasureAPI.hpp"
10
11 #include "OSArgument.hpp"
12 #include "OSOutput.hpp"
13
14 #include "../utilities/core/Optional.hpp"
15 #include "../utilities/bcl/BCLMeasure.hpp"
16
17 #include <vector>
18 #include <string>
19
20 namespace openstudio {
21
22 class Workspace;
23
24 namespace model {
25 class Model;
26 }
27
28 namespace measure {
29
30 /** OSMeasureInfo contains information that can be extracted from an OSMeasure by a parser.
31 */
32 class MEASURE_API OSMeasureInfo
33 {
34 public:
35 /// Constructor used when Ruby interpreter fails to get information about the script
36 OSMeasureInfo(const std::string& error);
37
38 /// Constructor used when Ruby interpreter succeeds to get information about the script
39 OSMeasureInfo(const MeasureType& measureType, const std::string& className, const std::string& name, const std::string& description,
40 const std::string& taxonomy, const std::string& modelerDescription, const std::vector<OSArgument>& arguments,
41 const std::vector<OSOutput>& outputs);
42
43 /// will be empty if information was successfully extracted from the script, otherwise includes error information
44 boost::optional<std::string> error() const;
45
46 /// type of measure if information was successfully extracted from the script, otherwise undefined
47 MeasureType measureType() const;
48
49 /// name of measure class if information was successfully extracted from the script, otherwise empty
50 std::string className() const;
51
52 /// result of measure's name method if information was successfully extracted from the script, otherwise empty
53 std::string name() const;
54
55 /// result of measure's description method if information was successfully extracted from the script, otherwise empty
56 std::string description() const;
57
58 /// result of measure's taxonomy method if information was successfully extracted from the script, otherwise empty
59 std::string taxonomy() const;
60
61 /// result of measure's modeler_description method if information was successfully extracted from the script, otherwise empty
62 std::string modelerDescription() const;
63
64 /// result of measure's arguments method called with empty model if information was successfully extracted from the script, otherwise empty
65 std::vector<OSArgument> arguments() const;
66
67 std::vector<BCLMeasureArgument> bclMeasureArguments() const;
68
69 /// result of measure's outputs method called with empty model if information was successfully extracted from the script, otherwise empty
70 std::vector<OSOutput> outputs() const;
71
72 /// Compares the measure's information from the xml with information extracted from the ruby measure
73 /// Updates the measure if needed, returns true if an update was performed
74 bool update(BCLMeasure& measure) const;
75
76 private:
77 − REGISTER_LOGGER("openstudio.measure.OSMeasureInfo");
78
79 boost::optional<std::string> m_error;
80 MeasureType m_measureType;
81 std::string m_className;
82 std::string m_name;
83 std::string m_description;
84 std::string m_taxonomy;
85 std::string m_modelerDescription;
86 std::vector<OSArgument> m_arguments;
87 std::vector<OSOutput> m_outputs;
88 };
89
90 /** Interface class for using embedded Ruby to extract arguments from an OSMeasure.
91 * See src/measure/test/EmbeddedRuby_GTest.cpp for this use case. If your application is written in
92 * Ruby, this functionality is available through non-member helper function
93 * Opudio::Measure::infoExtractorRubyFunction(BCLMeasure), see
94 * ruby/openstudio/measure/test/OSMeasureInfoGetter_Test.rb for an example. */
95 class MEASURE_API OSMeasureInfoGetter
96 {
97 public:
98 virtual ~OSMeasureInfoGetter() = default;
99
100 virtual OSMeasureInfo getInfo(const BCLMeasure& measure) = 0;
101
102 /** Use this method to pass in a (EnergyPlus) Workspace or a (OpenStudio) Model. */
103 virtual OSMeasureInfo getInfo(const BCLMeasure& measure, const Workspace& workspace) = 0;
104
105 virtual OSMeasureInfo getInfo(const BCLMeasure& measure, const model::Model& model, const Workspace& workspace) = 0;
106
107 OSMeasureInfo getInfo(const BCLMeasure& measure, const boost::optional<model::Model>& model, const boost::optional<Workspace>& workspace);
108 };
109
110 /** Non-member function that returns Ruby code text for retrieving info from a BCLMeasure. This
111 * function is used by both the embedded Ruby OSMeasureInfoGetter and native Ruby
112 * (OpenStudio::Measure::getInfo) implementations of the functionality, such that either usage
113 * pathway should produce identical results. \relates OSMeasureInfoGetter */
114 MEASURE_API std::string infoExtractorRubyFunction();
115
116 /** Interface class for rendering the ruby readme via ERB, parent class for the RubyMeasureInfoBinding
117 * declared in ruby/bindings/InitRubyBindings.cpp so we can use it from C++ */
118 class MEASURE_API MeasureInfoBinding
119 {
120 public:
121 ✗ virtual ~MeasureInfoBinding() = default;
122 virtual void setMeasureInfo(OSMeasureInfo& info);
123 virtual bool renderFile(const std::string& readmeInPath);
124 };
125
126 } // namespace measure
127 } // namespace openstudio
128
129 #endif // MEASURE_OSMEASUREINFOGETTER_HPP
130