GCC Code Coverage Report


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

src/model/LifeCycleCost.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 MODEL_LIFECYCLECOST_HPP
7 #define MODEL_LIFECYCLECOST_HPP
8
9 #include "ModelAPI.hpp"
10 #include "ModelObject.hpp"
11 #include "ModelExtensibleGroup.hpp"
12
13 #include "../utilities/core/Optional.hpp"
14
15 namespace openstudio {
16 namespace model {
17
18 namespace detail {
19 class LifeCycleCost_Impl;
20 }
21
22 /** LifeCycleCost derives from ModelObject and is an interface to the OpenStudio IDD object named "OS:LifeCycleCost".
23 *
24 * LifeCycleCost objects are used to add costs related to building construction and operation.
25 * The LifeCycleCost's lineItemType will be set based on the type of ModelObject.
26 */
27 class MODEL_API LifeCycleCost : public ModelObject
28 {
29
30 public:
31 /** @name Constructors and Destructors */
32 //@{
33
34 /// Constructs a new LifeCycleCost object in the model.
35 /// This will throw if the object type is not known
36 explicit LifeCycleCost(const ModelObject& modelObject);
37
38 368 virtual ~LifeCycleCost() override = default;
39 // Default the copy and move operators because the virtual dtor is explicit
40 57 LifeCycleCost(const LifeCycleCost& other) = default;
41 169 LifeCycleCost(LifeCycleCost&& other) = default;
42 ✗ LifeCycleCost& operator=(const LifeCycleCost&) = default;
43 1 LifeCycleCost& operator=(LifeCycleCost&&) = default;
44
45 //@}
46 /** @name Static Methods */
47 //@{
48
49 static IddObjectType iddObjectType();
50
51 static std::vector<std::string> validCategoryValues();
52
53 static std::vector<std::string> validItemTypeValues();
54
55 static std::vector<std::string> validStartOfCostsValues();
56
57 /// Create a LifeCycleCost for the given ModelObject with cost, costUnits, category, and optional repeatPeriodYear.
58 /// Will return an empty result if ModelObject type is unknown or if costUnits or category are not valid
59 static boost::optional<LifeCycleCost> createLifeCycleCost(const std::string& name, const ModelObject& modelObject, double cost,
60 const std::string& costUnits, const std::string& category, int repeatPeriodYears = 0,
61 int yearsFromStart = 0);
62
63 //@}
64 /** @name Getters */
65 //@{
66
67 /// Returns the category
68 std::string category() const;
69
70 /// Returns the type of ModelObject this LifeCycleCost applies to
71 std::string itemType() const;
72
73 /// Returns the ModelObject this LifeCycleCost applies to
74 ModelObject item() const;
75
76 /// Returns the cost
77 double cost() const;
78
79 /// Returns a list of valid cost units based on lineItemType.
80 std::vector<std::string> validCostUnitsValues() const;
81
82 /// Returns the cost units
83 std::string costUnits() const;
84
85 /// The First Year of Cost is based on the number of years past the Start of Costs. For most maintenance costs the Start of Costs should be Service Period.
86 std::string startOfCosts() const;
87 bool isStartOfCostsDefaulted() const;
88
89 /// Years from start is added to months from start to give the time at which the costs start to occur.
90 int yearsFromStart() const;
91 bool isYearsFromStartDefaulted() const;
92 int monthsFromStart() const;
93 bool isMonthsFromStartDefaulted() const;
94
95 /// Repeat period years is added to repeat period months to give the interval at which this cost reccurs.
96 /// If both repeat period years and repeat period months are zero (default), this cost does not recurr.
97 int repeatPeriodYears() const;
98 bool isRepeatPeriodYearsDefaulted() const;
99 int repeatPeriodMonths() const;
100 bool isRepeatPeriodMonthsDefaulted() const;
101
102 //@}
103 /** @name Setters */
104 //@{
105
106 bool setCategory(const std::string& category);
107
108 bool setCost(double cost);
109
110 bool setCostUnits(const std::string& costUnits);
111
112 bool setStartOfCosts(const std::string& startOfCosts);
113 void resetStartOfCosts();
114
115 bool setYearsFromStart(int yearsFromStart);
116 void resetYearsFromStart();
117 bool setMonthsFromStart(int monthsFromStart);
118 void resetMonthsFromStart();
119
120 bool setRepeatPeriodYears(int repeatPeriodYears);
121 void resetRepeatPeriodYears();
122 bool setRepeatPeriodMonths(int repeatPeriodMonths);
123 void resetRepeatPeriodMonths();
124
125 //@}
126
127 /// Returns the total cost based on number of units.
128 double totalCost() const;
129
130 /// Attemps to convert cost units to "CostPerEach" and set cost to totalCost
131 bool convertToCostPerEach();
132
133 /// Compute the number of objects that would be used for CostPerEach.
134 /// Includes space and instance multipliers.
135 boost::optional<int> costedQuantity() const;
136
137 /// Compute the area that would be used for CostPerArea.
138 /// Includes space and instance multipliers.
139 boost::optional<double> costedArea() const;
140
141 /// Compute the number of ThermalZone objects that would be used for CostPerThermalZone.
142 /// Includes space and instance multipliers.
143 boost::optional<int> costedThermalZones() const;
144
145 protected:
146 /// @cond
147 using ImplType = detail::LifeCycleCost_Impl;
148
149 friend class Model;
150 friend class IdfObject;
151
152 // constructor
153 explicit LifeCycleCost(std::shared_ptr<detail::LifeCycleCost_Impl> impl);
154
155 private:
156 REGISTER_LOGGER("openstudio.model.LifeCycleCost");
157
158 /// @endcond
159 };
160
161 /** \relates LifeCycleCost */
162 using OptionalLifeCycleCost = boost::optional<LifeCycleCost>;
163
164 /** \relates LifeCycleCost */
165 using LifeCycleCostVector = std::vector<LifeCycleCost>;
166
167 } // namespace model
168 } // namespace openstudio
169
170 #endif // MODEL_LIFECYCLECOST_HPP
171