src/utilities/units/MPHUnit.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_MPHUNIT_HPP | ||
| 7 | #define UTILITIES_UNITS_MPHUNIT_HPP | ||
| 8 | |||
| 9 | #include "../UtilitiesAPI.hpp" | ||
| 10 | #include "Unit.hpp" | ||
| 11 | |||
| 12 | namespace openstudio { | ||
| 13 | namespace detail { | ||
| 14 | |||
| 15 | class MPHUnit_Impl; | ||
| 16 | |||
| 17 | } // namespace detail | ||
| 18 | |||
| 19 | /** Structure to hold MPHUnit exponents needed for MPHUnit construction. \relates MPHUnit */ | ||
| 20 | struct UTILITIES_API MPHExpnt | ||
| 21 | { | ||
| 22 | public: | ||
| 23 | 1368 | MPHExpnt(int inHg = 0, int mi = 0, int h = 0, int R = 0, int A = 0, int cd = 0, int lbmol = 0, int deg = 0, int sr = 0, int people = 0, | |
| 24 | int cycle = 0, int dollar = 0) | ||
| 25 | 1368 | : m_inHg(inHg), | |
| 26 | 1368 | m_mi(mi), | |
| 27 | 1368 | m_h(h), | |
| 28 | 1368 | m_R(R), | |
| 29 | 1368 | m_A(A), | |
| 30 | 1368 | m_cd(cd), | |
| 31 | 1368 | m_lbmol(lbmol), | |
| 32 | 1368 | m_deg(deg), | |
| 33 | 1368 | m_sr(sr), | |
| 34 | 1368 | m_people(people), | |
| 35 | 1368 | m_cycle(cycle), | |
| 36 | 1368 | m_dollar(dollar) {} | |
| 37 | |||
| 38 | private: | ||
| 39 | int m_inHg; | ||
| 40 | int m_mi; | ||
| 41 | int m_h; | ||
| 42 | int m_R; | ||
| 43 | int m_A; | ||
| 44 | int m_cd; | ||
| 45 | int m_lbmol; | ||
| 46 | int m_deg; | ||
| 47 | int m_sr; | ||
| 48 | int m_people; | ||
| 49 | int m_cycle; | ||
| 50 | int m_dollar; | ||
| 51 | |||
| 52 | friend class detail::MPHUnit_Impl; | ||
| 53 | }; | ||
| 54 | |||
| 55 | /** MPHUnit is a Unit with baseUnits fixed by its constructors, see MPHExpnt. setBaseUnitExponent | ||
| 56 | * throws an exception if any other string is passed in as a baseUnit. MPHUnit.hpp declares | ||
| 57 | * related operators and UnitFactory callback functions. */ | ||
| 58 | class UTILITIES_API MPHUnit : public Unit | ||
| 59 | { | ||
| 60 | public: | ||
| 61 | /** @name Constructors and Destructors */ | ||
| 62 | //@{ | ||
| 63 | |||
| 64 | /** Default constructor. | ||
| 65 | * | ||
| 66 | * \param[in] exponents holds the exponents for each base unit. | ||
| 67 | * \param[in] scaleExponent exponent for scale. For instance 3 for kilo. | ||
| 68 | * \param[in] prettyString optional string to use in place of standardString. */ | ||
| 69 | MPHUnit(const MPHExpnt& exponents = MPHExpnt(), int scaleExponent = 0, const std::string& prettyString = ""); | ||
| 70 | |||
| 71 | /** Alternate constructor. Specify the abbreviation of the scale, rather than its | ||
| 72 | * exponent. | ||
| 73 | * | ||
| 74 | * \param[in] scaleAbbreviation is string equal to a scale abbreviation. For instance | ||
| 75 | * "k" for kilo. | ||
| 76 | * \param[in] exponents holds the exponents for each base unit. | ||
| 77 | * \param[in] prettyString optional string to use in place of standardString. */ | ||
| 78 | MPHUnit(const std::string& scaleAbbreviation, const MPHExpnt& exponents = MPHExpnt(), const std::string& prettyString = ""); | ||
| 79 | |||
| 80 | 1681 | virtual ~MPHUnit() override = default; | |
| 81 | |||
| 82 | //@} | ||
| 83 | protected: | ||
| 84 | /// @cond | ||
| 85 | using ImplType = detail::MPHUnit_Impl; | ||
| 86 | |||
| 87 | explicit MPHUnit(std::shared_ptr<detail::MPHUnit_Impl> impl); | ||
| 88 | |||
| 89 | friend class Unit; | ||
| 90 | friend class detail::MPHUnit_Impl; | ||
| 91 | /// @endcond | ||
| 92 | private: | ||
| 93 | REGISTER_LOGGER("openstudio.units.MPHUnit"); | ||
| 94 | }; | ||
| 95 | |||
| 96 | /** \relates MPHUnit*/ | ||
| 97 | using OptionalMPHUnit = boost::optional<MPHUnit>; | ||
| 98 | |||
| 99 | /** \relates MPHUnit*/ | ||
| 100 | using MPHUnitVector = std::vector<MPHUnit>; | ||
| 101 | |||
| 102 | /** @name Create Functions Used by UnitFactory */ | ||
| 103 | //@{ | ||
| 104 | |||
| 105 | // base units | ||
| 106 | |||
| 107 | /** \relates MPHUnit */ | ||
| 108 | UTILITIES_API MPHUnit createMPHPressure(); | ||
| 109 | /** \relates MPHUnit */ | ||
| 110 | UTILITIES_API MPHUnit createMPHLength(); | ||
| 111 | /** \relates MPHUnit */ | ||
| 112 | UTILITIES_API MPHUnit createMPHTime(); | ||
| 113 | /** \relates MPHUnit */ | ||
| 114 | UTILITIES_API MPHUnit createMPHTemperature(); | ||
| 115 | /** \relates MPHUnit */ | ||
| 116 | UTILITIES_API MPHUnit createMPHElectricCurrent(); | ||
| 117 | /** \relates MPHUnit */ | ||
| 118 | UTILITIES_API MPHUnit createMPHLuminousIntensity(); | ||
| 119 | /** \relates MPHUnit */ | ||
| 120 | UTILITIES_API MPHUnit createMPHAmountOfSubstance(); | ||
| 121 | /** \relates MPHUnit */ | ||
| 122 | UTILITIES_API MPHUnit createMPHAngle(); | ||
| 123 | /** \relates MPHUnit */ | ||
| 124 | UTILITIES_API MPHUnit createMPHSolidAngle(); | ||
| 125 | /** \relates MPHUnit */ | ||
| 126 | UTILITIES_API MPHUnit createMPHPeople(); | ||
| 127 | /** \relates MPHUnit */ | ||
| 128 | UTILITIES_API MPHUnit createMPHCycle(); | ||
| 129 | /** \relates MPHUnit */ | ||
| 130 | UTILITIES_API MPHUnit createMPHCurrency(); | ||
| 131 | |||
| 132 | // first order derived units | ||
| 133 | |||
| 134 | /** Miles per hour (mph) = mi/h. \relates MPHUnit */ | ||
| 135 | UTILITIES_API MPHUnit createMPHVelocity(); | ||
| 136 | /** Lumen (lm) = cd*sr. \relates MPHUnit */ | ||
| 137 | UTILITIES_API MPHUnit createMPHLuminousFlux(); | ||
| 138 | |||
| 139 | //@} | ||
| 140 | |||
| 141 | } // namespace openstudio | ||
| 142 | |||
| 143 | #endif // UTILITIES_UNITS_MPHUNIT_HPP | ||
| 144 |