src/utilities/units/Misc1Unit.cpp
| 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 | #include "Misc1Unit.hpp" | ||
| 7 | #include "Misc1Unit_Impl.hpp" | ||
| 8 | |||
| 9 | #include "../core/Assert.hpp" | ||
| 10 | |||
| 11 | namespace openstudio { | ||
| 12 | namespace detail { | ||
| 13 | |||
| 14 | 1351 | Misc1Unit_Impl::Misc1Unit_Impl(const Misc1Expnt& exponents, int scaleExponent, const std::string& prettyString) | |
| 15 |
2/2✓ Branch 1 taken 1351 times.
✓ Branch 4 taken 1351 times.
|
1351 | : Unit_Impl(scaleExponent, prettyString, 12, UnitSystem::Misc1) { |
| 16 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[0].first = "ftH_{2}O"; |
| 17 | 1351 | m_units[0].second = exponents.m_ftH2O; | |
| 18 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[1].first = "crL"; |
| 19 | 1351 | m_units[1].second = exponents.m_crL; | |
| 20 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[2].first = "day"; |
| 21 | 1351 | m_units[2].second = exponents.m_day; | |
| 22 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[3].first = "K"; |
| 23 | 1351 | m_units[3].second = exponents.m_K; | |
| 24 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[4].first = "A"; |
| 25 | 1351 | m_units[4].second = exponents.m_A; | |
| 26 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[5].first = "cd"; |
| 27 | 1351 | m_units[5].second = exponents.m_cd; | |
| 28 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[6].first = "mol"; |
| 29 | 1351 | m_units[6].second = exponents.m_mol; | |
| 30 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[7].first = "rad"; |
| 31 | 1351 | m_units[7].second = exponents.m_rad; | |
| 32 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[8].first = "sr"; |
| 33 | 1351 | m_units[8].second = exponents.m_sr; | |
| 34 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[9].first = "people"; |
| 35 | 1351 | m_units[9].second = exponents.m_people; | |
| 36 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[10].first = "cycle"; |
| 37 | 1351 | m_units[10].second = exponents.m_cycle; | |
| 38 |
1/1✓ Branch 2 taken 1351 times.
|
1351 | m_units[11].first = "$"; |
| 39 | 1351 | m_units[11].second = exponents.m_dollar; | |
| 40 | 1351 | } | |
| 41 | |||
| 42 | ✗ | Misc1Unit_Impl::Misc1Unit_Impl(const std::string& scaleAbbreviation, const Misc1Expnt& exponents, const std::string& prettyString) | |
| 43 | ✗ | : Unit_Impl(scaleAbbreviation, prettyString, 12, UnitSystem::Misc1) { | |
| 44 | ✗ | m_units[0].first = "ftH_{2}O"; | |
| 45 | ✗ | m_units[0].second = exponents.m_ftH2O; | |
| 46 | ✗ | m_units[1].first = "crL"; | |
| 47 | ✗ | m_units[1].second = exponents.m_crL; | |
| 48 | ✗ | m_units[2].first = "day"; | |
| 49 | ✗ | m_units[2].second = exponents.m_day; | |
| 50 | ✗ | m_units[3].first = "K"; | |
| 51 | ✗ | m_units[3].second = exponents.m_K; | |
| 52 | ✗ | m_units[4].first = "A"; | |
| 53 | ✗ | m_units[4].second = exponents.m_A; | |
| 54 | ✗ | m_units[5].first = "cd"; | |
| 55 | ✗ | m_units[5].second = exponents.m_cd; | |
| 56 | ✗ | m_units[6].first = "mol"; | |
| 57 | ✗ | m_units[6].second = exponents.m_mol; | |
| 58 | ✗ | m_units[7].first = "rad"; | |
| 59 | ✗ | m_units[7].second = exponents.m_rad; | |
| 60 | ✗ | m_units[8].first = "sr"; | |
| 61 | ✗ | m_units[8].second = exponents.m_sr; | |
| 62 | ✗ | m_units[9].first = "people"; | |
| 63 | ✗ | m_units[9].second = exponents.m_people; | |
| 64 | ✗ | m_units[10].first = "cycle"; | |
| 65 | ✗ | m_units[10].second = exponents.m_cycle; | |
| 66 | ✗ | m_units[11].first = "$"; | |
| 67 | ✗ | m_units[11].second = exponents.m_dollar; | |
| 68 | ✗ | } | |
| 69 | |||
| 70 | 243 | Unit Misc1Unit_Impl::clone() const { | |
| 71 |
3/5✓ Branch 1 taken 243 times.
✓ Branch 4 taken 243 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 243 times.
✗ Branch 10 not taken.
|
243 | OS_ASSERT(system() == UnitSystem::Misc1); |
| 72 |
3/5✓ Branch 1 taken 243 times.
✓ Branch 4 taken 243 times.
✓ Branch 7 taken 243 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
243 | std::shared_ptr<Misc1Unit_Impl> impl(new Misc1Unit_Impl(*this)); |
| 73 |
2/2✓ Branch 2 taken 243 times.
✓ Branch 5 taken 243 times.
|
486 | return Misc1Unit(impl).cast<Unit>(); |
| 74 | 243 | } | |
| 75 | |||
| 76 | 100 | void Misc1Unit_Impl::setBaseUnitExponent(const std::string& baseUnit, int exponent) { | |
| 77 |
1/1✓ Branch 1 taken 100 times.
|
100 | auto loc = findBaseUnit(baseUnit); |
| 78 |
1/2✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
|
100 | if (loc != m_units.end()) { |
| 79 | 100 | loc->second = exponent; | |
| 80 | } else { | ||
| 81 | ✗ | LOG_AND_THROW("Cannot add base units to an instance of Misc1Unit."); | |
| 82 | } | ||
| 83 | 100 | } | |
| 84 | |||
| 85 | } // namespace detail | ||
| 86 | |||
| 87 | 1351 | Misc1Unit::Misc1Unit(const Misc1Expnt& exponents, int scaleExponent, const std::string& prettyString) | |
| 88 |
4/6✓ Branch 1 taken 1351 times.
✓ Branch 4 taken 1351 times.
✓ Branch 7 taken 1351 times.
✓ Branch 10 taken 1351 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
1351 | : Unit(std::shared_ptr<detail::Unit_Impl>(new detail::Misc1Unit_Impl(exponents, scaleExponent, prettyString))) {} |
| 89 | |||
| 90 | ✗ | Misc1Unit::Misc1Unit(const std::string& scaleAbbreviation, const Misc1Expnt& exponents, const std::string& prettyString) | |
| 91 | ✗ | : Unit(std::shared_ptr<detail::Unit_Impl>(new detail::Misc1Unit_Impl(scaleAbbreviation, exponents, prettyString))) {} | |
| 92 | |||
| 93 | /// @cond | ||
| 94 |
1/1✓ Branch 2 taken 243 times.
|
243 | Misc1Unit::Misc1Unit(std::shared_ptr<detail::Misc1Unit_Impl> impl) : Unit(std::dynamic_pointer_cast<detail::Unit_Impl>(impl)) {} |
| 95 | /// @endcond | ||
| 96 | |||
| 97 | 113 | Misc1Unit createMisc1Pressure() { | |
| 98 |
2/2✓ Branch 1 taken 113 times.
✓ Branch 5 taken 113 times.
|
226 | return Misc1Unit(Misc1Expnt(1)); |
| 99 | } | ||
| 100 | |||
| 101 | 100 | Misc1Unit createMisc1Length() { | |
| 102 |
2/2✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
|
100 | Misc1Unit result; |
| 103 |
2/2✓ Branch 1 taken 100 times.
✓ Branch 4 taken 100 times.
|
200 | result.setBaseUnitExponent("crL", 1); |
| 104 | 100 | return result; | |
| 105 | ✗ | } | |
| 106 | |||
| 107 | 101 | Misc1Unit createMisc1Time() { | |
| 108 |
2/2✓ Branch 1 taken 101 times.
✓ Branch 5 taken 101 times.
|
202 | return Misc1Unit(Misc1Expnt(0, 0, 1)); |
| 109 | } | ||
| 110 | |||
| 111 | 100 | Misc1Unit createMisc1Temperature() { | |
| 112 |
2/2✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
|
200 | return Misc1Unit(Misc1Expnt(0, 0, 0, 1)); |
| 113 | } | ||
| 114 | |||
| 115 | 100 | Misc1Unit createMisc1ElectricCurrent() { | |
| 116 |
2/2✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
|
200 | return Misc1Unit(Misc1Expnt(0, 0, 0, 0, 1)); |
| 117 | } | ||
| 118 | |||
| 119 | 100 | Misc1Unit createMisc1LuminousIntensity() { | |
| 120 |
2/2✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
|
200 | return Misc1Unit(Misc1Expnt(0, 0, 0, 0, 0, 1)); |
| 121 | } | ||
| 122 | |||
| 123 | 102 | Misc1Unit createMisc1AmountOfSubstance() { | |
| 124 |
2/2✓ Branch 1 taken 102 times.
✓ Branch 5 taken 102 times.
|
204 | return Misc1Unit(Misc1Expnt(0, 0, 0, 0, 0, 0, 1)); |
| 125 | } | ||
| 126 | |||
| 127 | 100 | Misc1Unit createMisc1Angle() { | |
| 128 |
2/2✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
|
200 | return Misc1Unit(Misc1Expnt(0, 0, 0, 0, 0, 0, 0, 1)); |
| 129 | } | ||
| 130 | |||
| 131 | 100 | Misc1Unit createMisc1SolidAngle() { | |
| 132 |
2/2✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
|
200 | return Misc1Unit(Misc1Expnt(0, 0, 0, 0, 0, 0, 0, 0, 1)); |
| 133 | } | ||
| 134 | |||
| 135 | 101 | Misc1Unit createMisc1People() { | |
| 136 |
2/2✓ Branch 1 taken 101 times.
✓ Branch 5 taken 101 times.
|
202 | return Misc1Unit(Misc1Expnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 1)); |
| 137 | } | ||
| 138 | |||
| 139 | 100 | Misc1Unit createMisc1Cycle() { | |
| 140 |
2/2✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
|
200 | return Misc1Unit(Misc1Expnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)); |
| 141 | } | ||
| 142 | |||
| 143 | ✗ | Misc1Unit createMisc1Currency() { | |
| 144 | ✗ | return Misc1Unit(Misc1Expnt(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1)); | |
| 145 | } | ||
| 146 | |||
| 147 | 134 | Misc1Unit createMisc1Volume() { | |
| 148 |
2/2✓ Branch 1 taken 134 times.
✓ Branch 5 taken 134 times.
|
268 | return Misc1Unit(Misc1Expnt(0, 1), 0, "L"); |
| 149 | } | ||
| 150 | |||
| 151 | 100 | Misc1Unit createMisc1LuminousFlux() { | |
| 152 |
2/2✓ Branch 1 taken 100 times.
✓ Branch 5 taken 100 times.
|
200 | return Misc1Unit(Misc1Expnt(0, 0, 0, 0, 0, 1, 0, 0, 1), 0, "lm"); |
| 153 | } | ||
| 154 | |||
| 155 | } // namespace openstudio | ||
| 156 |