GCC Code Coverage Report


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

src/utilities/units/GPDUnit.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_UNITS_GPDUNIT_HPP
7 #define UTILITIES_UNITS_GPDUNIT_HPP
8
9 #include "../UtilitiesAPI.hpp"
10 #include "Unit.hpp"
11
12 namespace openstudio {
13 namespace detail {
14
15 class GPDUnit_Impl;
16
17 } // namespace detail
18
19 /** Structure to hold GPDUnit exponents needed for GPDUnit construction. For purposes of
20 * conversion we need a length base unit. Therefore, gal cannot be a base unit. For convenience
21 * of construction, GPDExpnt takes a gal argument, but subsequently this is stored as a power of
22 * cube root of gallons (crgal). \relates GPDUnit */
23 struct UTILITIES_API GPDExpnt
24 {
25 public:
26 1538 GPDExpnt(int inH2O = 0, int gal = 0, int day = 0, int R = 0, int A = 0, int cd = 0, int lbmol = 0, int deg = 0, int sr = 0, int people = 0,
27 int cycle = 0, int dollar = 0)
28 1538 : m_inH2O(inH2O),
29 1538 m_crgal(3 * gal),
30 1538 m_day(day),
31 1538 m_R(R),
32 1538 m_A(A),
33 1538 m_cd(cd),
34 1538 m_lbmol(lbmol),
35 1538 m_deg(deg),
36 1538 m_sr(sr),
37 1538 m_people(people),
38 1538 m_cycle(cycle),
39 1538 m_dollar(dollar) {}
40
41 private:
42 int m_inH2O;
43 int m_crgal;
44 int m_day;
45 int m_R;
46 int m_A;
47 int m_cd;
48 int m_lbmol;
49 int m_deg;
50 int m_sr;
51 int m_people;
52 int m_cycle;
53 int m_dollar;
54
55 friend class detail::GPDUnit_Impl;
56 };
57
58 /** GPDUnit is a Unit with baseUnits fixed by its constructors, see GPDExpnt. setBaseUnitExponent
59 * throws an exception if any other string is passed in as a baseUnit. GPDUnit.hpp declares
60 * related operators and UnitFactory callback functions. */
61 class UTILITIES_API GPDUnit : public Unit
62 {
63 public:
64 /** @name Constructors and Destructors */
65 //@{
66
67 /** Default constructor.
68 *
69 * \param[in] exponents holds the exponents for each base unit.
70 * \param[in] scaleExponent exponent for scale. For instance 3 for kilo.
71 * \param[in] prettyString optional string to use in place of standardString. */
72 GPDUnit(const GPDExpnt& exponents = GPDExpnt(), int scaleExponent = 0, const std::string& prettyString = "");
73
74 /** Alternate constructor. Specify the abbreviation of the scale, rather than its
75 * exponent.
76 *
77 * \param[in] scaleAbbreviation is string equal to a scale abbreviation. For instance
78 * "k" for kilo.
79 * \param[in] exponents holds the exponents for each base unit.
80 * \param[in] prettyString optional string to use in place of standardString. */
81 GPDUnit(const std::string& scaleAbbreviation, const GPDExpnt& exponents = GPDExpnt(), const std::string& prettyString = "");
82
83 1931 virtual ~GPDUnit() override = default;
84
85 //@}
86 protected:
87 /// @cond
88 using ImplType = detail::GPDUnit_Impl;
89
90 explicit GPDUnit(std::shared_ptr<detail::GPDUnit_Impl> impl);
91
92 friend class detail::GPDUnit_Impl;
93 friend class Unit;
94 /// @endcond
95 private:
96 REGISTER_LOGGER("openstudio.units.GPDUnit");
97 };
98
99 /** \relates GPDUnit*/
100 using OptionalGPDUnit = boost::optional<GPDUnit>;
101
102 /** \relates GPDUnit*/
103 using GPDUnitVector = std::vector<GPDUnit>;
104
105 /** @name Create Functions Used by UnitFactory */
106 //@{
107
108 // base units
109
110 /** \relates GPDUnit */
111 UTILITIES_API GPDUnit createGPDPressure();
112 /** \relates GPDUnit */
113 UTILITIES_API GPDUnit createGPDLength();
114 /** \relates GPDUnit */
115 UTILITIES_API GPDUnit createGPDTime();
116 /** \relates GPDUnit */
117 UTILITIES_API GPDUnit createGPDTemperature();
118 /** \relates GPDUnit */
119 UTILITIES_API GPDUnit createGPDElectricCurrent();
120 /** \relates GPDUnit */
121 UTILITIES_API GPDUnit createGPDLuminousIntensity();
122 /** \relates GPDUnit */
123 UTILITIES_API GPDUnit createGPDAmountOfSubstance();
124 /** \relates GPDUnit */
125 UTILITIES_API GPDUnit createGPDAngle();
126 /** \relates GPDUnit */
127 UTILITIES_API GPDUnit createGPDSolidAngle();
128 /** \relates GPDUnit */
129 UTILITIES_API GPDUnit createGPDPeople();
130 /** relates GPDUnit */
131 UTILITIES_API GPDUnit createGPDCycle();
132 /** relates GPDUnit */
133 UTILITIES_API GPDUnit createGPDCurrency();
134
135 // first order derived units
136
137 /** Gallons (gal). \relates GPDUnit */
138 UTILITIES_API GPDUnit createGPDVolume();
139 /** Gallons per day (gpd) = gal/day. \relates GPDUnit */
140 UTILITIES_API GPDUnit createGPDVolumetricFlowrate();
141 /** Lumen (lm) = cd*sr. \relates GPDUnit */
142 UTILITIES_API GPDUnit createGPDLuminousFlux();
143
144 //@}
145
146 } // namespace openstudio
147
148 #endif // UTILITIES_UNITS_GPDUNIT_HPP
149