GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 0 / 1 / 1
Functions: -% 0 / 1 / 1
Branches: -% 0 / 1 / 1

src/utilities/units/QuantityFactory.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_QUANTITYFACTORY_HPP
7 #define UTILITIES_UNITS_QUANTITYFACTORY_HPP
8
9 #include "../UtilitiesAPI.hpp"
10
11 #include "Quantity.hpp"
12 #include "UnitFactory.hpp"
13
14 #include "../core/Logger.hpp"
15
16 #include <set>
17 #include <map>
18
19 namespace openstudio {
20
21 class UTILITIES_API QuantityFactory
22 {
23 public:
24 static QuantityFactory& instance();
25
26 QuantityFactory(const QuantityFactory& other) = delete;
27 QuantityFactory(QuantityFactory&& other) = delete;
28 QuantityFactory& operator=(const QuantityFactory&) = delete;
29 QuantityFactory& operator=(QuantityFactory&&) = delete;
30
31 // FACTORY USE
32
33 /** Parses quantity string to separate the value from the unit. Then creates the quantity
34 * with the help of UnitFactory. Uses openstudio::getSystem to intuit the appropriate system,
35 * if possible. */
36 boost::optional<Quantity> createQuantity(const std::string& quantityString) const;
37
38 /** Parses quantity string to separate the value from the unit. Then creates the quantity
39 * with the help of UnitFactory. system specifies the preferred unit system--it does not
40 * guarantee that the returned result will be in that system. */
41 boost::optional<Quantity> createQuantity(const std::string& quantityString, UnitSystem system) const;
42
43 /** Creates a quantity from value and unitString, which is passed to UnitFactory. Uses
44 * openstudio::getSystem to intuit the appropriate system, if possible. */
45 boost::optional<Quantity> createQuantity(double value, const std::string& unitString) const;
46
47 /** Creates a quantity from value and unitString, which is passed to UnitFactory. system
48 * specifies the preferred unit system--it does not guarantee that the returned result will
49 * be in that system. */
50 boost::optional<Quantity> createQuantity(double value, const std::string& unitString, UnitSystem system) const;
51
52 private:
53 QuantityFactory() = default;
54 ~QuantityFactory() = default;
55
56 − REGISTER_LOGGER("openstudio.units.QuantityFactory");
57 };
58
59 /** Creates a Quantity object from quantityString (a string that matches
60 * openstudio::regexQuantity()). */
61 UTILITIES_API boost::optional<Quantity> createQuantity(const std::string& quantityString);
62
63 UTILITIES_API boost::optional<Quantity> createQuantity(const std::string& quantityString, UnitSystem system);
64
65 /** Creates a general Quantity object corresponding to value * unitString. */
66 UTILITIES_API boost::optional<Quantity> createQuantity(double value, const std::string& unitString);
67
68 UTILITIES_API boost::optional<Quantity> createQuantity(double value, const std::string& unitString, UnitSystem system);
69
70 } // namespace openstudio
71
72 #endif // UTILITIES_UNITS_QUANTITYFACTORY_HPP
73