GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 86.0% 43 / 0 / 50
Functions: 100.0% 8 / 0 / 8
Branches: 86.4% 38 / 0 / 44

src/utilities/idf/WorkspaceExtensibleGroup.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 "WorkspaceExtensibleGroup.hpp"
7 #include "WorkspaceObject.hpp"
8 #include "WorkspaceObject_Impl.hpp"
9
10 using std::shared_ptr;
11 using std::dynamic_pointer_cast;
12
13 namespace openstudio {
14
15 // GETTERS
16
17 7987 OptionalWorkspaceObject WorkspaceExtensibleGroup::getTarget(unsigned fieldIndex) const {
18
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7987 times.
7987 if (!isValid(fieldIndex)) {
19 ✗ return boost::none;
20 }
21
2/2
✓ Branch 3 taken 7987 times.
✓ Branch 6 taken 7987 times.
7987 return getImpl<detail::WorkspaceObject_Impl>()->getTarget(mf_toIndex(fieldIndex));
22 }
23
24 2 WorkspaceObjectVector WorkspaceExtensibleGroup::getTargets() const {
25 2 WorkspaceObjectVector result;
26
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
2 if (empty()) {
27 ✗ return result;
28 }
29
3/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 2 times.
6 for (unsigned fieldIndex = 0, n = numFields(); fieldIndex < n; ++fieldIndex) {
30
1/1
✓ Branch 1 taken 4 times.
4 OptionalWorkspaceObject owo = getTarget(fieldIndex);
31
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 3 times.
4 if (owo) {
32
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 result.push_back(*owo);
33 }
34 4 }
35 2 return result;
36 ✗ }
37
38 2 std::vector<unsigned> WorkspaceExtensibleGroup::getSourceFieldIndices(const Handle& targetHandle) const {
39 2 UnsignedVector result;
40
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
2 if (empty()) {
41 ✗ return result;
42 }
43
1/1
✓ Branch 3 taken 2 times.
2 UnsignedVector candidates = dynamic_pointer_cast<detail::WorkspaceObject_Impl>(m_impl)->getSourceIndices(targetHandle);
44
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 result = mf_subsetAndToFieldIndices(candidates);
45 2 return result;
46 2 }
47
48 // SETTERS
49 6989 bool WorkspaceExtensibleGroup::setPointer(unsigned fieldIndex, const Handle& targetHandle) {
50 6989 return setPointer(fieldIndex, targetHandle, true);
51 }
52
53 7104 bool WorkspaceExtensibleGroup::setPointer(unsigned fieldIndex, const Handle& targetHandle, bool checkValidity) {
54
2/2
✓ Branch 0 taken 6989 times.
✓ Branch 1 taken 115 times.
7104 if (checkValidity) {
55
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 6989 times.
6989 if (!isValid(fieldIndex)) {
56 ✗ return false;
57 }
58 }
59
2/2
✓ Branch 3 taken 7104 times.
✓ Branch 6 taken 7104 times.
7104 return getImpl<detail::WorkspaceObject_Impl>()->setPointer(mf_toIndex(fieldIndex), targetHandle, checkValidity);
60 }
61
62 // QUERIES
63
64 3 bool WorkspaceExtensibleGroup::isSource() const {
65 3 bool result = false;
66
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if (empty()) {
67 ✗ return result;
68 }
69
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
7 for (unsigned fieldIndex = 0, n = numFields(); fieldIndex < n; ++fieldIndex) {
70
2/2
✓ Branch 3 taken 5 times.
✓ Branch 6 taken 5 times.
5 result = getImpl<detail::WorkspaceObject_Impl>()->isSource(mf_toIndex(fieldIndex));
71
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 4 times.
5 if (result) {
72 1 break;
73 }
74 }
75 3 return result;
76 }
77
78 3 bool WorkspaceExtensibleGroup::canBeSource() const {
79 3 bool result = false;
80
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if (empty()) {
81 ✗ return result;
82 }
83
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 time.
6 for (unsigned fieldIndex = 0, n = numFields(); fieldIndex < n; ++fieldIndex) {
84
2/2
✓ Branch 4 taken 5 times.
✓ Branch 7 taken 5 times.
5 result = getImpl<detail::WorkspaceObject_Impl>()->canBeSource(mf_toIndex(fieldIndex));
85
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
5 if (result) {
86 2 break;
87 }
88 }
89 3 return result;
90 }
91
92 // PROTECTED
93 341377 WorkspaceExtensibleGroup::WorkspaceExtensibleGroup(std::shared_ptr<detail::WorkspaceObject_Impl> impl, unsigned index)
94
1/1
✓ Branch 2 taken 341377 times.
341377 : IdfExtensibleGroup(impl, index) {}
95
96 } // namespace openstudio
97