src/utilities/units/CelsiusUnit.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 "CelsiusUnit.hpp" | ||
| 7 | #include "CelsiusUnit_Impl.hpp" | ||
| 8 | |||
| 9 | #include "../core/Assert.hpp" | ||
| 10 | |||
| 11 | namespace openstudio { | ||
| 12 | namespace detail { | ||
| 13 | |||
| 14 | 3016 | CelsiusUnit_Impl::CelsiusUnit_Impl(int CExp, int scaleExponent, const std::string& prettyString) | |
| 15 |
2/2✓ Branch 1 taken 3016 times.
✓ Branch 4 taken 3016 times.
|
3016 | : TemperatureUnit_Impl(true, scaleExponent, prettyString, 1, UnitSystem::Celsius) { |
| 16 |
1/1✓ Branch 2 taken 3016 times.
|
3016 | m_units[0].first = "C"; |
| 17 | 3016 | m_units[0].second = CExp; | |
| 18 | 3016 | } | |
| 19 | |||
| 20 | ✗ | CelsiusUnit_Impl::CelsiusUnit_Impl(const std::string& scaleAbbreviation, int CExp, const std::string& prettyString) | |
| 21 | ✗ | : TemperatureUnit_Impl(true, scaleAbbreviation, prettyString, 1, UnitSystem::Celsius) { | |
| 22 | ✗ | m_units[0].first = "C"; | |
| 23 | ✗ | m_units[0].second = CExp; | |
| 24 | ✗ | } | |
| 25 | |||
| 26 | 320 | Unit CelsiusUnit_Impl::clone() const { | |
| 27 |
3/5✓ Branch 1 taken 320 times.
✓ Branch 4 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 10 not taken.
|
320 | OS_ASSERT(system() == UnitSystem::Celsius); |
| 28 |
3/5✓ Branch 1 taken 320 times.
✓ Branch 4 taken 320 times.
✓ Branch 7 taken 320 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
|
320 | std::shared_ptr<CelsiusUnit_Impl> impl(new CelsiusUnit_Impl(*this)); |
| 29 |
2/2✓ Branch 2 taken 320 times.
✓ Branch 5 taken 320 times.
|
640 | return CelsiusUnit(impl).cast<Unit>(); |
| 30 | 320 | } | |
| 31 | |||
| 32 | 86 | void CelsiusUnit_Impl::setBaseUnitExponent(const std::string& baseUnit, int exponent) { | |
| 33 |
1/1✓ Branch 1 taken 86 times.
|
86 | auto loc = findBaseUnit(baseUnit); |
| 34 |
1/2✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
|
86 | if (loc != m_units.end()) { |
| 35 | 86 | loc->second = exponent; | |
| 36 | } else { | ||
| 37 | ✗ | LOG_AND_THROW("Cannot add base units to an instance of CelsiusUnit."); | |
| 38 | } | ||
| 39 | 86 | } | |
| 40 | |||
| 41 | } // namespace detail | ||
| 42 | |||
| 43 | 3016 | CelsiusUnit::CelsiusUnit(int CExp, int scaleExponent, const std::string& prettyString) | |
| 44 |
4/6✓ Branch 1 taken 3016 times.
✓ Branch 4 taken 3016 times.
✓ Branch 7 taken 3016 times.
✓ Branch 11 taken 3016 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
|
3016 | : TemperatureUnit(std::shared_ptr<detail::CelsiusUnit_Impl>(new detail::CelsiusUnit_Impl(CExp, scaleExponent, prettyString))) {} |
| 45 | |||
| 46 | ✗ | CelsiusUnit::CelsiusUnit(const std::string& scaleAbbreviation, int CExp, const std::string& prettyString) | |
| 47 | ✗ | : TemperatureUnit(std::shared_ptr<detail::CelsiusUnit_Impl>(new detail::CelsiusUnit_Impl(scaleAbbreviation, CExp, prettyString))) {} | |
| 48 | |||
| 49 | /// @cond | ||
| 50 |
1/1✓ Branch 2 taken 322 times.
|
322 | CelsiusUnit::CelsiusUnit(std::shared_ptr<detail::CelsiusUnit_Impl> impl) : TemperatureUnit(impl) {} |
| 51 | /// @endcond | ||
| 52 | |||
| 53 | 2926 | CelsiusUnit createCelsiusTemperature() { | |
| 54 |
2/2✓ Branch 1 taken 2926 times.
✓ Branch 4 taken 2926 times.
|
5852 | return CelsiusUnit(1); |
| 55 | } | ||
| 56 | |||
| 57 | } // namespace openstudio | ||
| 58 |