GCC Code Coverage Report


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

src/model/Component.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_COMPONENT_HPP
7 #define MODEL_COMPONENT_HPP
8
9 #include "Model.hpp"
10
11 namespace openstudio {
12
13 namespace detail {
14 class Workspace_Impl;
15 }
16
17 namespace model {
18
19 class ComponentData;
20
21 namespace detail {
22 class Component_Impl;
23 class ModelObject_Impl;
24 class ParentObject_Impl;
25 } // namespace detail
26
27 /** Component is a Model that contains exactly one ComponentData object. All objects other than
28 * the ComponentData object and the version object are the Component contents. There is a
29 * primary ModelObject that provides the Component's type. There are no public constructors,
30 * as Components are to be constructed through the ModelObject method \link
31 * ModelObject::createComponent createComponent\endlink. Similarly, Model-level object addition
32 * and removal, and SqlFile functionality, has been disabled. */
33 class MODEL_API Component : public Model
34 {
35 public:
36 /** @name Constructors and Destructors */
37 //@{
38
39 /** Construct from an IdfFile. Must contain exactly one ComponentData object, and contents
40 * list in ComponentData must exactly match the contents of idfFile. */
41 explicit Component(const openstudio::IdfFile& idfFile);
42
43 191 virtual ~Component() override = default;
44 // Default the copy and move operators because the virtual dtor is explicit
45 26 Component(const Component& other) = default;
46 16 Component(Component&& other) = default;
47 ✗ Component& operator=(const Component&) = default;
48 ✗ Component& operator=(Component&&) = default;
49
50 //@}
51 /** @name Getters */
52 //@{
53
54 /** Returns the object that contains the contents list, unique identifiers, and timestamps
55 * for this Component. */
56 ComponentData componentData() const;
57
58 /** Returns the primary ModelObject of this Component. Can be used to access the Component
59 * type by using .optionalCast or iddObjectType(). */
60 ModelObject primaryObject() const;
61
62 //@}
63 /** @name Serialization */
64 //@{
65
66 /** Load Component from path p, if possible. */
67 static boost::optional<Component> load(const path& p);
68
69 /** Save Component to path p. Will construct the parent folder if its parent folder exists.
70 * An existing file will only be overwritten if if overwrite==true. If no extension is provided,
71 * componentFileExtension() will be used. */
72 virtual bool save(const openstudio::path& p, bool overwrite = false);
73
74 //@}
75 protected:
76 /// @cond
77 using ImplType = detail::Component_Impl;
78
79 friend class openstudio::Workspace;
80 friend class openstudio::detail::Workspace_Impl;
81 friend class detail::Component_Impl;
82 friend class detail::ModelObject_Impl;
83 friend class detail::ParentObject_Impl;
84
85 /** Protected constructor from impl. */
86 Component(std::shared_ptr<detail::Component_Impl> impl);
87
88 /// @endcond
89
90 /** Construct from a vector of ModelObjects, all in the same .model(). The primary object
91 * must be listed first. Throws if contents.empty() or if more than one .model() is found.
92 * StrictnessLevel is always set to Draft. Not for general use; used by
93 * ModelObject::createComponent. */
94 Component(const std::vector<ModelObject>& contents);
95
96 private:
97 − REGISTER_LOGGER("openstudio.model.Component");
98 };
99
100 /** \relates Component */
101 using OptionalComponent = boost::optional<Component>;
102
103 /** \relates Component */
104 using ComponentVector = std::vector<Component>;
105
106 } // namespace model
107 } // namespace openstudio
108
109 #endif // MODEL_COMPONENT_HPP
110