GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 93.1% 27 / 0 / 29
Functions: 100.0% 7 / 0 / 7
Branches: 60.7% 17 / 0 / 28

src/model/Schedule.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 "Schedule.hpp"
7 #include "Schedule_Impl.hpp"
8
9 #include "Model.hpp"
10 #include "ScheduleTypeLimits.hpp"
11 #include "ScheduleTypeRegistry.hpp"
12 #include "ScheduleDay.hpp"
13 #include "ScheduleDay_Impl.hpp"
14
15 #include "../utilities/idf/ValidityReport.hpp"
16
17 #include "../utilities/core/Assert.hpp"
18
19 using openstudio::Handle;
20 using openstudio::OptionalHandle;
21 using openstudio::HandleVector;
22 using openstudio::IdfObject;
23 using openstudio::WorkspaceObject;
24 using openstudio::OptionalWorkspaceObject;
25 using openstudio::WorkspaceObjectVector;
26 using openstudio::Workspace;
27
28 namespace openstudio {
29 namespace model {
30
31 namespace detail {
32
33 // constructor
34 8330 Schedule_Impl::Schedule_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) : ScheduleBase_Impl(idfObject, model, keepHandle) {}
35
36 1334 Schedule_Impl::Schedule_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
37 1334 : ScheduleBase_Impl(other, model, keepHandle) {}
38
39 3078 Schedule_Impl::Schedule_Impl(const Schedule_Impl& other, Model_Impl* model, bool keepHandles) : ScheduleBase_Impl(other, model, keepHandles) {}
40
41 6533 bool Schedule_Impl::candidateIsCompatibleWithCurrentUse(const ScheduleTypeLimits& candidate) const {
42
2/2
✓ Branch 1 taken 6533 times.
✓ Branch 4 taken 6533 times.
6533 ModelObjectVector users = getObject<Schedule>().getModelObjectSources<ModelObject>();
43
1/1
✓ Branch 1 taken 6533 times.
6533 auto copyOfThis = getObject<Schedule>();
44
2/2
✓ Branch 5 taken 2073 times.
✓ Branch 6 taken 6533 times.
8606 for (const ModelObject& user : users) {
45
1/1
✓ Branch 1 taken 2073 times.
2073 std::vector<ScheduleTypeKey> keys = user.getScheduleTypeKeys(copyOfThis);
46 // ETH@20120806 - Ideally would make the following OS_ASSERT, but is too
47 // strict for now. (Too easy for a user to trigger this first, before a unit
48 // test or app tester catches it.)
49 // OS_ASSERT(!keys.empty());
50
1/2
✗ Branch 5 not taken.
✓ Branch 6 taken 2073 times.
2073 for (const ScheduleTypeKey& key : keys) {
51 ✗ if (!isCompatible(key.className(), key.scheduleDisplayName(), candidate)) {
52 ✗ return false;
53 }
54 }
55 2073 }
56 6533 return true;
57 6533 }
58
59 5 bool Schedule_Impl::okToResetScheduleTypeLimits() const {
60 // ok to zero out if all users are schedules
61
1/1
✓ Branch 1 taken 5 times.
5 auto copyOfThis = getObject<Schedule>();
62
4/4
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
✓ Branch 12 taken 1 time.
✓ Branch 13 taken 4 times.
5 for (const ModelObject& user : getObject<Schedule>().getModelObjectSources<ModelObject>()) {
63
2/3
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
1 if (!user.getScheduleTypeKeys(copyOfThis).empty()) {
64 1 return false;
65 }
66 5 }
67 4 return true;
68 5 }
69
70 } // namespace detail
71
72 6981 Schedule::Schedule(IddObjectType type, const Model& model) : ScheduleBase(type, model) {
73
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 6981 times.
✗ Branch 5 not taken.
6981 OS_ASSERT(getImpl<detail::Schedule_Impl>());
74 6981 }
75
76 // constructor from impl
77
1/1
✓ Branch 3 taken 52971 times.
52971 Schedule::Schedule(std::shared_ptr<detail::Schedule_Impl> impl) : ScheduleBase(std::move(impl)) {
78
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 52971 times.
✗ Branch 5 not taken.
52971 OS_ASSERT(getImpl<detail::Schedule_Impl>());
79 52971 }
80
81 } // namespace model
82 } // namespace openstudio
83