GCC Code Coverage Report


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

src/model/PortList.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_PORTLIST_HPP
7 #define MODEL_PORTLIST_HPP
8
9 #include "ModelAPI.hpp"
10 #include "ModelObject.hpp"
11
12 namespace openstudio {
13
14 namespace model {
15
16 class Node;
17
18 class ThermalZone;
19
20 class HVACComponent;
21
22 namespace detail {
23
24 class PortList_Impl;
25
26 class ThermalZone_Impl;
27
28 } // namespace detail
29
30 /** PortList is a ModelObject that wraps the OpenStudio IDD object 'OS:PortList'. */
31 class MODEL_API PortList : public ModelObject
32 {
33 public:
34 explicit PortList(const HVACComponent& comp);
35
36 133297 virtual ~PortList() override = default;
37 // Default the copy and move operators because the virtual dtor is explicit
38 28164 PortList(const PortList& other) = default;
39 62954 PortList(PortList&& other) = default;
40 ✗ PortList& operator=(const PortList&) = default;
41 ✗ PortList& operator=(PortList&&) = default;
42
43 static IddObjectType iddObjectType();
44
45 /** Returns the port for portIndex. Ports are consequtively
46 * indexed starting from 0.
47 */
48 unsigned port(unsigned portIndex) const;
49
50 /** Given a port, return the port index.
51 * Consider that a "port" is simply an unsigned, so
52 * port and port index share the same type, but they do not share the same value.
53 */
54 unsigned portIndex(unsigned port) const;
55
56 /** Returns the next available port. This will be the first port
57 * with no connected objects */
58 unsigned nextPort() const;
59
60 /** Returns the optional ModelObject connected to the port designated by portIndex.
61 * If there is no connected object then the optional will be false.
62 */
63 boost::optional<ModelObject> modelObject(unsigned portIndex) const;
64
65 /** Returns the optional ModelObject connected to the last port of the PortList.
66 * If there are no connections to the list's outlet ports, then the
67 * optional will be false.
68 */
69 boost::optional<ModelObject> lastModelObject();
70
71 /** Returns a vector of all objects connected to the PortList's ports.
72 * If no objects are connected to the PortList then an empty vector will be returned.
73 */
74 std::vector<ModelObject> modelObjects() const;
75
76 /** Returns the port index for the ModelObject specified by modelObject.
77 */
78 unsigned portIndexForModelObject(ModelObject& modelObject) const;
79
80 /** Returns the index of the next available port */
81 unsigned nextPortIndex() const;
82
83 ThermalZone thermalZone() const;
84
85 /** Returns the port connected to an AirLoopHVAC object.
86 * If there is no AirLoopHVAC object, then the next available port is returned
87 */
88 unsigned airLoopHVACPort() const;
89
90 std::vector<unsigned> airLoopHVACPorts() const;
91
92 /** Returns the port Index connected to an AirLoopHVAC object.
93 * If there is no AirLoopHVAC object, then the next available portIndex is returned
94 */
95 unsigned airLoopHVACPortIndex() const;
96
97 std::vector<unsigned> airLoopHVACPortIndexes() const;
98
99 /** Returns the object connected to an AirLoopHVAC object. */
100 boost::optional<ModelObject> airLoopHVACModelObject() const;
101
102 std::vector<ModelObject> airLoopHVACModelObjects() const;
103
104 protected:
105 /// @cond
106 using ImplType = detail::PortList_Impl;
107
108 explicit PortList(std::shared_ptr<detail::PortList_Impl> impl);
109
110 friend class detail::PortList_Impl;
111 friend class Model;
112 friend class IdfObject;
113 friend class ThermalZone;
114 friend class detail::ThermalZone_Impl;
115 friend class openstudio::detail::IdfObject_Impl;
116
117 /// @endcond
118
119 private:
120 REGISTER_LOGGER("openstudio.model.PortList");
121 };
122
123 /** \relates PortList*/
124 using OptionalPortList = boost::optional<PortList>;
125
126 /** \relates PortList*/
127 using PortListVector = std::vector<PortList>;
128
129 } // namespace model
130 } // namespace openstudio
131
132 #endif // MODEL_PORTLIST_HPP
133