src/utilities/units/WhUnit.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_WHUNIT_HPP | ||
| 7 | #define UTILITIES_UNITS_WHUNIT_HPP | ||
| 8 | |||
| 9 | #include "../UtilitiesAPI.hpp" | ||
| 10 | #include "Unit.hpp" | ||
| 11 | |||
| 12 | namespace openstudio { | ||
| 13 | namespace detail { | ||
| 14 | |||
| 15 | class WhUnit_Impl; | ||
| 16 | |||
| 17 | } // namespace detail | ||
| 18 | |||
| 19 | /** Structure to hold WhUnit exponents needed for WhUnit construction. \relates WhUnit */ | ||
| 20 | struct UTILITIES_API WhExpnt | ||
| 21 | { | ||
| 22 | public: | ||
| 23 | 10584 | WhExpnt(int W = 0, int h = 0, int m = 0, int K = 0, int A = 0, int cd = 0, int mol = 0, int rad = 0, int sr = 0, int people = 0, int cycle = 0, | |
| 24 | int dollar = 0) | ||
| 25 | 10584 | : m_W(W), m_h(h), m_m(m), m_K(K), m_A(A), m_cd(cd), m_mol(mol), m_rad(rad), m_sr(sr), m_people(people), m_cycle(cycle), m_dollar(dollar) {} | |
| 26 | |||
| 27 | private: | ||
| 28 | int m_W; | ||
| 29 | int m_h; | ||
| 30 | int m_m; | ||
| 31 | int m_K; | ||
| 32 | int m_A; | ||
| 33 | int m_cd; | ||
| 34 | int m_mol; | ||
| 35 | int m_rad; | ||
| 36 | int m_sr; | ||
| 37 | int m_people; | ||
| 38 | int m_cycle; | ||
| 39 | int m_dollar; | ||
| 40 | |||
| 41 | friend class detail::WhUnit_Impl; | ||
| 42 | }; | ||
| 43 | |||
| 44 | /** WhUnit is a Unit with baseUnits W, h, m, K, and people. | ||
| 45 | * setBaseUnitExponent throws and exception if any other string is passed in as a | ||
| 46 | * baseUnit. WhUnit.hpp declares related operators and UnitFactory callback functions. */ | ||
| 47 | class UTILITIES_API WhUnit : public Unit | ||
| 48 | { | ||
| 49 | public: | ||
| 50 | /** @name Constructors and Destructors */ | ||
| 51 | //@{ | ||
| 52 | |||
| 53 | /** Default constructor. Example: \verbatim | ||
| 54 | WhUnit myEnergy(WhExpnt(1,1),3,"Wh"); | ||
| 55 | std::cout << myEnergy; // produces "kWh" \endverbatim | ||
| 56 | * | ||
| 57 | * \param[in] exponents holds the exponents for each base unit. | ||
| 58 | * \param[in] scaleExponent exponent for scale. For instance 3 for kilo. | ||
| 59 | * \param[in] prettyString optional string to use in place of standardString. */ | ||
| 60 | WhUnit(const WhExpnt& exponents = WhExpnt(), int scaleExponent = 0, const std::string& prettyString = ""); | ||
| 61 | |||
| 62 | /** Alternate constructor. Specify the abbreviation of the scale, rather than its | ||
| 63 | * exponent. Example: \verbatim | ||
| 64 | WhUnit myEnergy("k",WhExpnt(1,1),"Wh"); | ||
| 65 | std::cout << myEnergy; // produces "kWh" \endverbatim | ||
| 66 | * | ||
| 67 | * \param[in] scaleAbbreviation is string equal to a scale abbreviation. For instance | ||
| 68 | * "k" for kilo. | ||
| 69 | * \param[in] exponents holds the exponents for each base unit. | ||
| 70 | * \param[in] prettyString optional string to use in place of standardString. */ | ||
| 71 | WhUnit(const std::string& scaleAbbreviation, const WhExpnt& exponents = WhExpnt(), const std::string& prettyString = ""); | ||
| 72 | |||
| 73 | 37764 | virtual ~WhUnit() override = default; | |
| 74 | |||
| 75 | //@} | ||
| 76 | protected: | ||
| 77 | /// @cond | ||
| 78 | using ImplType = detail::WhUnit_Impl; | ||
| 79 | |||
| 80 | explicit WhUnit(std::shared_ptr<detail::WhUnit_Impl> impl); | ||
| 81 | |||
| 82 | friend class Unit; | ||
| 83 | friend class detail::WhUnit_Impl; | ||
| 84 | |||
| 85 | /// @endcond | ||
| 86 | private: | ||
| 87 | REGISTER_LOGGER("openstudio.units.WhUnit"); | ||
| 88 | }; | ||
| 89 | |||
| 90 | /** \relates WhUnit*/ | ||
| 91 | using OptionalWhUnit = boost::optional<WhUnit>; | ||
| 92 | |||
| 93 | /** \relates WhUnit*/ | ||
| 94 | using WhUnitVector = std::vector<WhUnit>; | ||
| 95 | |||
| 96 | /** @name Create Functions Used by UnitFactory */ | ||
| 97 | //@{ | ||
| 98 | |||
| 99 | /** \relates WhUnit */ | ||
| 100 | UTILITIES_API WhUnit createWhPower(); | ||
| 101 | /** \relates WhUnit */ | ||
| 102 | UTILITIES_API WhUnit createWhTime(); | ||
| 103 | /** \relates WhUnit */ | ||
| 104 | UTILITIES_API WhUnit createWhLength(); | ||
| 105 | /** \relates WhUnit */ | ||
| 106 | UTILITIES_API WhUnit createWhTemperature(); | ||
| 107 | /** \relates WhUnit */ | ||
| 108 | UTILITIES_API WhUnit createWhElectricCurrent(); | ||
| 109 | /** \relates WhUnit */ | ||
| 110 | UTILITIES_API WhUnit createWhLuminousIntensity(); | ||
| 111 | /** \relates WhUnit */ | ||
| 112 | UTILITIES_API WhUnit createWhAmountOfSubstance(); | ||
| 113 | /** \relates WhUnit */ | ||
| 114 | UTILITIES_API WhUnit createWhAngle(); | ||
| 115 | /** \relates WhUnit */ | ||
| 116 | UTILITIES_API WhUnit createWhSolidAngle(); | ||
| 117 | /** \relates WhUnit */ | ||
| 118 | UTILITIES_API WhUnit createWhPeople(); | ||
| 119 | /** \relates WhUnit */ | ||
| 120 | UTILITIES_API WhUnit createWhCycle(); | ||
| 121 | /** \relates WhUnit */ | ||
| 122 | UTILITIES_API WhUnit createWhCurrency(); | ||
| 123 | |||
| 124 | /** \relates WhUnit */ | ||
| 125 | UTILITIES_API WhUnit createWhEnergy(); | ||
| 126 | /** Volt (V) = W/A. \relates WhUnit */ | ||
| 127 | UTILITIES_API WhUnit createWhElectricalPotential(); | ||
| 128 | /** Ohm (ohm) = V/A = W/A^2. \relates WhUnit */ | ||
| 129 | UTILITIES_API WhUnit createWhElectricResistance(); | ||
| 130 | /** Lumen (lm) = cd*sr. \relates WhUnit */ | ||
| 131 | UTILITIES_API WhUnit createWhLuminousFlux(); | ||
| 132 | /** Lux (lux or lx) = lm/m^2 = cd*sr/m^2. \relates WhUnit */ | ||
| 133 | UTILITIES_API WhUnit createWhIlluminance(); | ||
| 134 | |||
| 135 | //@} | ||
| 136 | |||
| 137 | } // namespace openstudio | ||
| 138 | |||
| 139 | #endif // UTILITIES_UNITS_WHUNIT_HPP | ||
| 140 |