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/ScheduleRule.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_SCHEDULERULE_HPP
7 #define MODEL_SCHEDULERULE_HPP
8
9 #include "ModelAPI.hpp"
10 #include "ParentObject.hpp"
11
12 namespace openstudio {
13
14 class Date;
15
16 namespace model {
17
18 class ScheduleDay;
19 class ScheduleRuleset;
20
21 namespace detail {
22
23 class ScheduleRule_Impl;
24 class ScheduleRuleset_Impl;
25
26 } // namespace detail
27
28 /** ScheduleRule is a ParentObject that wraps the OpenStudio IDD object 'OS:Schedule:Rule'. */
29 class MODEL_API ScheduleRule : public ParentObject
30 {
31 public:
32 /** @name Constructors and Destructors */
33 //@{
34
35 /// Constructor associates this rule with the given ruleset. This rule is made to be the highest priority rule.
36 /// A new ScheduleDay is created which is owned by (a child of) this rule.
37 explicit ScheduleRule(ScheduleRuleset& scheduleRuleset);
38
39 /// Constructor associates this rule with the given ruleset. This rule is made to be the highest priority rule.
40 /// The given daySchedule is cloned and the new object is owned by (a child of) this rule.
41 explicit ScheduleRule(ScheduleRuleset& scheduleRuleset, const ScheduleDay& daySchedule);
42
43 44333 virtual ~ScheduleRule() override = default;
44 // Default the copy and move operators because the virtual dtor is explicit
45 380 ScheduleRule(const ScheduleRule& other) = default;
46 12660 ScheduleRule(ScheduleRule&& other) = default;
47 ✗ ScheduleRule& operator=(const ScheduleRule&) = default;
48 5169 ScheduleRule& operator=(ScheduleRule&&) = default;
49
50 //@}
51
52 static IddObjectType iddObjectType();
53
54 static std::vector<std::string> validDateSpecificationTypeValues();
55
56 /** @name Getters */
57 //@{
58
59 ScheduleRuleset scheduleRuleset() const;
60
61 int ruleIndex() const;
62
63 ScheduleDay daySchedule() const;
64
65 bool applySunday() const;
66
67 bool applyMonday() const;
68
69 bool applyTuesday() const;
70
71 bool applyWednesday() const;
72
73 bool applyThursday() const;
74
75 bool applyFriday() const;
76
77 bool applySaturday() const;
78
79 // Note: there is no applyHoliday, instead that's implemented at the ScheduleRule's level
80
81 std::string dateSpecificationType() const;
82
83 /// Returns the start date of the date range if set.
84 /// A start date > end date indicates that the range wraps around the year.
85 boost::optional<openstudio::Date> startDate() const;
86
87 /// Returns the end date of the date range if set.
88 /// A start date > end date indicates that the range wraps around the year.
89 boost::optional<openstudio::Date> endDate() const;
90
91 /// Returns the specific dates specified if any.
92 std::vector<openstudio::Date> specificDates() const;
93
94 //@}
95 /** @name Setters */
96 //@{
97
98 bool setApplySunday(bool applySunday);
99
100 void setApplySundayNoFail(bool applySunday);
101
102 bool setApplyMonday(bool applyMonday);
103
104 void setApplyMondayNoFail(bool applyMonday);
105
106 bool setApplyTuesday(bool applyTuesday);
107
108 void setApplyTuesdayNoFail(bool applyTuesday);
109
110 bool setApplyWednesday(bool applyWednesday);
111
112 void setApplyWednesdayNoFail(bool applyWednesday);
113
114 bool setApplyThursday(bool applyThursday);
115
116 void setApplyThursdayNoFail(bool applyThursday);
117
118 bool setApplyFriday(bool applyFriday);
119
120 void setApplyFridayNoFail(bool applyFriday);
121
122 bool setApplySaturday(bool applySaturday);
123
124 void setApplySaturdayNoFail(bool applySaturday);
125
126 /// Sets the start date of the date range, will delete any specific dates specified.
127 /// A start date > end date indicates that the range wraps around the year.
128 bool setStartDate(const openstudio::Date& date);
129
130 /// Sets the end date of the date range, will delete any specific dates specified.
131 /// A start date > end date indicates that the range wraps around the year.
132 bool setEndDate(const openstudio::Date& date);
133
134 /// Adds a specific date, will delete start and end dates.
135 bool addSpecificDate(const openstudio::Date& date);
136
137 // ensure that this object does not contain the date 2/29
138 void ensureNoLeapDays();
139
140 //@}
141 /** @name Other */
142 //@{
143
144 /// Returns true if this rule covers the given date.
145 bool containsDate(const openstudio::Date& date);
146
147 /// Returns whether or not this rule covers each given date.
148 std::vector<bool> containsDates(const std::vector<openstudio::Date>& dates);
149
150 // Convenience methods
151 /** Returns true if the rule applies to all days from Monday to Sunday */
152 bool applyAllDays() const;
153 /** Returns true if the rule applies to all weekdays Monday to Friday */
154 bool applyWeekdays() const;
155 /** Returns true if the rule applies to Saturday and Sunday */
156 bool applyWeekends() const;
157
158 // calls setApplyMonday to setApplySunday */
159 bool setApplyAllDays(bool applyAllDays);
160
161 // calls setApplyMonday to setApplyFriday */
162 bool setApplyWeekdays(bool applyWeekdays);
163
164 // calls setApplySaturday and setApplySunday */
165 bool setApplyWeekends(bool applyWeekends);
166
167 //@}
168 protected:
169 friend class detail::ScheduleRuleset_Impl;
170 bool setRuleIndex(int index);
171
172 /// @cond
173 using ImplType = detail::ScheduleRule_Impl;
174
175 explicit ScheduleRule(std::shared_ptr<detail::ScheduleRule_Impl> impl);
176
177 friend class detail::ScheduleRule_Impl;
178 friend class Model;
179 friend class IdfObject;
180 friend class openstudio::detail::IdfObject_Impl;
181
182 /// @endcond
183 private:
184 REGISTER_LOGGER("openstudio.model.ScheduleRule");
185 };
186
187 /** \relates ScheduleRule */
188 using OptionalScheduleRule = boost::optional<ScheduleRule>;
189
190 /** \relates ScheduleRule */
191 using ScheduleRuleVector = std::vector<ScheduleRule>;
192
193 } // namespace model
194 } // namespace openstudio
195
196 #endif // MODEL_SCHEDULERULE_HPP
197