GCC Code Coverage Report


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

src/utilities/idf/ObjectPointer.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_IDF_OBJECTPOINTER_HPP
7 #define UTILITIES_IDF_OBJECTPOINTER_HPP
8
9 #include "Handle.hpp"
10
11 namespace openstudio {
12
13 /** Data structure for specifying connections between IdfWorkspace and other object collections.
14 * Other object collections include other IdfWorkspaces, IdfFile, IdfObjectVector. */
15 template <class T, class U>
16 struct ObjectPointer
17 {
18 using source_type = T;
19 using target_type = U;
20
21 T source;
22 unsigned fieldIndex;
23 U target;
24
25 ObjectPointer() = default;
26 7639 ObjectPointer(const T& s, unsigned fi, const U& t) : source(s), fieldIndex(fi), target(t) {}
27 };
28
29 template <class T>
30 struct FieldIndexLess
31 {
32 3323464 bool operator()(const T& left, const T& right) const {
33 3323464 return (left.fieldIndex < right.fieldIndex);
34 }
35 };
36
37 template <class T>
38 29348298 bool fieldIndexEqualTo(const T& object, unsigned value) {
39 29348298 return (object.fieldIndex == value);
40 }
41
42 /** ObjectPointer with source as index in IdfObjectVector, target as Handle. For Workspace, source
43 * will be outside of workspace, target will be within workspace. */
44 using UHPointer = ObjectPointer<unsigned int, Handle>;
45 /** ObjectPointer with source as Handle, target as index in IdfObjectVector. For Workspace, source
46 * will be within workspace, target will be outside of workspace. */
47 using HUPointer = ObjectPointer<Handle, unsigned int>;
48 /** ObjectPointer with source and target as Handles. For Workspace, both objects must be in a
49 * workspace. */
50 using HHPointer = ObjectPointer<Handle, Handle>;
51
52 using UHPointerVector = std::vector<UHPointer>;
53 using HUPointerVector = std::vector<HUPointer>;
54 using HHPointerVector = std::vector<HHPointer>;
55
56 } // namespace openstudio
57
58 #endif // UTILITIES_IDF_OBJECTPOINTER_HPP
59