GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 64.9% 24 / 1 / 38
Functions: 76.9% 10 / 1 / 14
Branches: 70.0% 28 / 1 / 41

src/model/ModelExtensibleGroup.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_MODELEXTENSIBLEGROUP_HPP
7 #define MODEL_MODELEXTENSIBLEGROUP_HPP
8
9 #include "ModelAPI.hpp"
10 #include "../utilities/idf/WorkspaceExtensibleGroup.hpp"
11 #include "ModelObject.hpp"
12 #include "ModelObject_Impl.hpp"
13
14 #include "../utilities/core/Logger.hpp"
15
16 #include <boost/optional.hpp>
17
18 namespace openstudio {
19 namespace model {
20
21 class Schedule;
22
23 /** ModelExtensibleGroup is a WorkspaceExtensibleGroup with additional methods added to support
24 * extensible \link ModelObject ModelObjects\endlink. The ExtensibleGroup inheritance hierarchy
25 * roughly follows the IdfObject <- WorkspaceObject <- ModelObject <- etc. hierarchy, except that
26 * all concrete \link ModelObject ModelObjects \endlink with ExtensibleGroup derived classes
27 * derive directly from ModelExtensibleGroup--there are no extensions of ModelExtensibleGroup for
28 * intermediate abstract classes. */
29 class MODEL_API ModelExtensibleGroup : public WorkspaceExtensibleGroup
30 {
31 public:
32 536680 virtual ~ModelExtensibleGroup() override = default;
33 // Default the copy and move operators because the virtual dtor is explicit
34 22014 ModelExtensibleGroup(const ModelExtensibleGroup& other) = default;
35 185049 ModelExtensibleGroup(ModelExtensibleGroup&& other) = default;
36 ✗ ModelExtensibleGroup& operator=(const ModelExtensibleGroup&) = default;
37 ✗ ModelExtensibleGroup& operator=(ModelExtensibleGroup&&) = default;
38
39 /** @name Template Methods */
40 //@{
41
42 /** Get the ModelObject of type T pointed to from fieldIndex of this extensible group, if
43 * possible. */
44 template <typename T>
45 28528 boost::optional<T> getModelObjectTarget(unsigned fieldIndex) const {
46
7/16
boost::optional<openstudio::model::Material> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::Material>(unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 27009 times.
boost::optional<openstudio::model::ModelObject> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::ModelObject>(unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 1334 times.
boost::optional<openstudio::model::ModelObjectList> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::ModelObjectList>(unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
boost::optional<openstudio::model::People> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::People>(unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
boost::optional<openstudio::model::PlanarSurface> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::PlanarSurface>(unsigned int) const:
✗ Branch 1 not taken.
✗ Branch 2 not taken.
boost::optional<openstudio::model::Schedule> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::Schedule>(unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 82 times.
boost::optional<openstudio::model::Space> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::Space>(unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
boost::optional<openstudio::model::StandardGlazing> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::StandardGlazing>(unsigned int) const:
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
28528 if (!isValid(fieldIndex)) {
47 ✗ return boost::none;
48 }
49
21/24
boost::optional<openstudio::model::Material> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::Material>(unsigned int) const:
✓ Branch 2 taken 27009 times.
✓ Branch 5 taken 27009 times.
✓ Branch 8 taken 27009 times.
boost::optional<openstudio::model::ModelObject> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::ModelObject>(unsigned int) const:
✓ Branch 2 taken 1334 times.
✓ Branch 5 taken 1334 times.
✓ Branch 8 taken 1334 times.
boost::optional<openstudio::model::ModelObjectList> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::ModelObjectList>(unsigned int) const:
✓ Branch 2 taken 15 times.
✓ Branch 5 taken 15 times.
✓ Branch 8 taken 15 times.
boost::optional<openstudio::model::People> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::People>(unsigned int) const:
✓ Branch 2 taken 10 times.
✓ Branch 5 taken 10 times.
✓ Branch 8 taken 10 times.
boost::optional<openstudio::model::PlanarSurface> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::PlanarSurface>(unsigned int) const:
✗ Branch 2 not taken.
✗ Branch 5 not taken.
✗ Branch 8 not taken.
boost::optional<openstudio::model::Schedule> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::Schedule>(unsigned int) const:
✓ Branch 2 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 8 taken 82 times.
boost::optional<openstudio::model::Space> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::Space>(unsigned int) const:
✓ Branch 2 taken 8 times.
✓ Branch 5 taken 8 times.
✓ Branch 8 taken 8 times.
boost::optional<openstudio::model::StandardGlazing> openstudio::model::ModelExtensibleGroup::getModelObjectTarget<openstudio::model::StandardGlazing>(unsigned int) const:
✓ Branch 2 taken 70 times.
✓ Branch 5 taken 70 times.
✓ Branch 8 taken 70 times.
28528 return ModelObject(getImpl<detail::ModelObject_Impl>()).getModelObjectTarget<T>(mf_toIndex(fieldIndex));
50 }
51
52 /** Get all the \link ModelObject ModelObjects \endlink of type T pointed to from this
53 * extensible group. Return value will always be .empty() if this extensible group object is
54 * .empty(). */
55 template <typename T>
56 std::vector<T> getModelObjectTargets() const {
57 std::vector<T> result;
58 if (empty()) {
59 return result;
60 }
61 for (unsigned fieldIndex = 0, n = numFields(); fieldIndex < n; ++fieldIndex) {
62 boost::optional<T> oTarget = getModelObjectTarget<T>(fieldIndex);
63 if (oTarget) {
64 result.push_back(*oTarget);
65 }
66 }
67 return result;
68 }
69
70 /** Sets index to point to schedule if schedule's ScheduleTypeLimits are compatible with the
71 * ScheduleType in the ScheduleTypeRegistry for (className,scheduleDisplayName), or if
72 * schedule's ScheduleTypeLimits have not yet been set (in which case the ScheduleTypeRegistry
73 * is used to retrieve or create an appropriate one).
74 * Because ModelExtensibleGroup has no knowledge of its model,
75 * you should ensure that schedule belongs to the right model in the first place */
76 bool setSchedule(unsigned index, const std::string& className, const std::string& scheduleDisplayName, Schedule& schedule);
77
78 //@}
79 protected:
80 /// @cond
81 using ImplType = detail::ModelObject_Impl;
82
83 friend class IdfExtensibleGroup;
84
85 ModelExtensibleGroup(std::shared_ptr<detail::ModelObject_Impl> impl, unsigned index);
86
87 /// @endcond
88 private:
89 /** Private default constructor. */
90 ModelExtensibleGroup();
91
92 − REGISTER_LOGGER("openstudio.model.ModelExtensibleGroup");
93 };
94
95 } // namespace model
96 } // namespace openstudio
97
98 #endif // MODEL_MODELEXTENSIBLEGROUP_HPPP
99