src/utilities/units/BTUUnit.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_BTUUNIT_HPP | ||
| 7 | #define UTILITIES_UNITS_BTUUNIT_HPP | ||
| 8 | |||
| 9 | #include "../UtilitiesAPI.hpp" | ||
| 10 | #include "Unit.hpp" | ||
| 11 | |||
| 12 | namespace openstudio { | ||
| 13 | namespace detail { | ||
| 14 | |||
| 15 | class BTUUnit_Impl; | ||
| 16 | |||
| 17 | } // namespace detail | ||
| 18 | |||
| 19 | /** Structure to hold BTUUnit exponents needed for BTUUnit construction. \relates BTUUnit */ | ||
| 20 | struct UTILITIES_API BTUExpnt | ||
| 21 | { | ||
| 22 | public: | ||
| 23 | 1765 | BTUExpnt(int btu = 0, int ft = 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 | 1765 | : m_btu(btu), | |
| 26 | 1765 | m_ft(ft), | |
| 27 | 1765 | m_h(h), | |
| 28 | 1765 | m_R(R), | |
| 29 | 1765 | m_A(A), | |
| 30 | 1765 | m_cd(cd), | |
| 31 | 1765 | m_lbmol(lbmol), | |
| 32 | 1765 | m_deg(deg), | |
| 33 | 1765 | m_sr(sr), | |
| 34 | 1765 | m_people(people), | |
| 35 | 1765 | m_cycle(cycle), | |
| 36 | 1765 | m_dollar(dollar) {} | |
| 37 | |||
| 38 | private: | ||
| 39 | int m_btu; | ||
| 40 | int m_ft; | ||
| 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::BTUUnit_Impl; | ||
| 53 | }; | ||
| 54 | |||
| 55 | /** BTUUnit is a Unit with baseUnits fixed by its constructors, see BTUExpnt. | ||
| 56 | * setBaseUnitExponent throws an exception if any other string is passed in as a baseUnit. | ||
| 57 | * BTUUnit.hpp declares related operators and UnitFactory callback functions. */ | ||
| 58 | class UTILITIES_API BTUUnit : public Unit | ||
| 59 | { | ||
| 60 | public: | ||
| 61 | /** @name Constructors and Destructors */ | ||
| 62 | //@{ | ||
| 63 | |||
| 64 | /** Default constructor. Example: \verbatim | ||
| 65 | BTUUnit myEnergy(BtuExpnt(1),3); | ||
| 66 | std::cout << myEnergy; // produces "kBtu" \endverbatim | ||
| 67 | * | ||
| 68 | * \param[in] exponents holds the exponents for each base unit. | ||
| 69 | * \param[in] scaleExponent exponent for scale. For instance 3 for kilo. | ||
| 70 | * \param[in] prettyString optional string to use in place of standardString. */ | ||
| 71 | BTUUnit(const BTUExpnt& exponents = BTUExpnt(), int scaleExponent = 0, const std::string& prettyString = ""); | ||
| 72 | |||
| 73 | /** Alternate constructor. Specify the abbreviation of the scale, rather than its | ||
| 74 | * exponent. | ||
| 75 | * | ||
| 76 | * \param[in] scaleAbbreviation is string equal to a scale abbreviation. For instance | ||
| 77 | * "k" for kilo. | ||
| 78 | * \param[in] exponents holds the exponents for each base unit. | ||
| 79 | * \param[in] prettyString optional string to use in place of standardString. */ | ||
| 80 | BTUUnit(const std::string& scaleAbbreviation, const BTUExpnt& exponents = BTUExpnt(), const std::string& prettyString = ""); | ||
| 81 | |||
| 82 | 2684 | virtual ~BTUUnit() override = default; | |
| 83 | |||
| 84 | //@} | ||
| 85 | protected: | ||
| 86 | /// @cond | ||
| 87 | using ImplType = detail::BTUUnit_Impl; | ||
| 88 | |||
| 89 | explicit BTUUnit(std::shared_ptr<detail::BTUUnit_Impl> impl); | ||
| 90 | |||
| 91 | friend class Unit; | ||
| 92 | friend class detail::BTUUnit_Impl; | ||
| 93 | |||
| 94 | /// @endcond | ||
| 95 | private: | ||
| 96 | REGISTER_LOGGER("openstudio.units.BTUUnit"); | ||
| 97 | }; | ||
| 98 | |||
| 99 | /** \relates BTUUnit*/ | ||
| 100 | using OptionalBTUUnit = boost::optional<BTUUnit>; | ||
| 101 | |||
| 102 | /** \relates BTUUnit*/ | ||
| 103 | using BTUUnitVector = std::vector<BTUUnit>; | ||
| 104 | |||
| 105 | /** @name Create Functions Used by UnitFactory */ | ||
| 106 | //@{ | ||
| 107 | |||
| 108 | // base units | ||
| 109 | |||
| 110 | /** \relates BTUUnit */ | ||
| 111 | UTILITIES_API BTUUnit createBTUEnergy(); | ||
| 112 | /** \relates BTUUnit */ | ||
| 113 | UTILITIES_API BTUUnit createBTULength(); | ||
| 114 | /** \relates BTUUnit */ | ||
| 115 | UTILITIES_API BTUUnit createBTUTime(); | ||
| 116 | /** \relates BTUUnit */ | ||
| 117 | UTILITIES_API BTUUnit createBTUTemperature(); | ||
| 118 | /** \relates BTUUnit */ | ||
| 119 | UTILITIES_API BTUUnit createBTUElectricCurrent(); | ||
| 120 | /** \relates BTUUnit */ | ||
| 121 | UTILITIES_API BTUUnit createBTULuminousIntensity(); | ||
| 122 | /** \relates BTUUnit */ | ||
| 123 | UTILITIES_API BTUUnit createBTUAmountOfSubstance(); | ||
| 124 | /** \relates BTUUnit */ | ||
| 125 | UTILITIES_API BTUUnit createBTUAngle(); | ||
| 126 | /** \relates BTUUnit */ | ||
| 127 | UTILITIES_API BTUUnit createBTUSolidAngle(); | ||
| 128 | /** \relates BTUUnit */ | ||
| 129 | UTILITIES_API BTUUnit createBTUPeople(); | ||
| 130 | /** \relates BTUUnit */ | ||
| 131 | UTILITIES_API BTUUnit createBTUCycle(); | ||
| 132 | /** \relates BTUUnit */ | ||
| 133 | UTILITIES_API BTUUnit createBTUCurrency(); | ||
| 134 | |||
| 135 | // first order derived units | ||
| 136 | |||
| 137 | /** Btu/h. \relates BTUUnit */ | ||
| 138 | UTILITIES_API BTUUnit createBTUPower(); | ||
| 139 | /** Lumen (lm) = cd*sr. \relates BTUUnit */ | ||
| 140 | UTILITIES_API BTUUnit createBTULuminousFlux(); | ||
| 141 | /** Foot-candles (fc) = lm/ft^2 = cd*sr/ft^2. \relates BTUUnit */ | ||
| 142 | UTILITIES_API BTUUnit createBTUIlluminance(); | ||
| 143 | |||
| 144 | //@} | ||
| 145 | |||
| 146 | } // namespace openstudio | ||
| 147 | |||
| 148 | #endif // UTILITIES_UNITS_BTUUNIT_HPP | ||
| 149 |