GCC Code Coverage Report


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

src/utilities/idd/IddFile_Impl.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_IDD_IDDFILE_IMPL_HPP
7 #define UTILITIES_IDD_IDDFILE_IMPL_HPP
8
9 #include "../UtilitiesAPI.hpp"
10 #include "IddObject.hpp"
11 #include "../core/Logger.hpp"
12
13 #include <string>
14 #include <ostream>
15 #include <vector>
16
17 #include <boost/algorithm/string.hpp>
18
19 namespace openstudio {
20 namespace detail {
21
22 /// Implementation of IddFile
23 class UTILITIES_API IddFile_Impl
24 {
25 public:
26 /** @name Constructors */
27 //@{
28
29 /// default constructor: it's defaulted
30 // IddFile_Impl() = default;
31
32 //@}
33 /** @name Getters */
34 //@{
35
36 /// get version
37 std::string version() const;
38
39 /// get build
40 std::string build() const;
41
42 /// get header
43 std::string header() const;
44
45 /// get all objects
46 std::vector<IddObject> objects() const;
47
48 /// get all groups in file (e.g. "" and "Simulation Parameters")
49 std::vector<std::string> groups() const;
50
51 /// get all objects in group (e.g. "Simulation Parameters")
52 std::vector<IddObject> getObjectsInGroup(const std::string& group) const;
53
54 /** Get the IddObjects that match objectRegex. */
55 std::vector<IddObject> getObjects(const boost::regex& objectRegex) const;
56
57 /** If possible, returns the version IddObject for this IddFile. */
58 boost::optional<IddObject> versionObject() const;
59
60 /// get object by name
61 boost::optional<IddObject> getObject(const std::string& objectName) const;
62
63 /// get object by type
64 boost::optional<IddObject> getObject(IddObjectType objectType) const;
65
66 /// required objects, occur at least once
67 std::vector<IddObject> requiredObjects() const;
68
69 /// unique objects, occur at most one time
70 std::vector<IddObject> uniqueObjects() const;
71
72 //@}
73 /** @name Setters */
74 //@{
75
76 /// set version
77 void setVersion(const std::string& version);
78
79 /// set header
80 void setHeader(const std::string& header);
81
82 /// add an object
83 void addObject(const IddObject& object);
84
85 //@}
86 /** @name Serialization */
87 //@{
88
89 /// parse text from input stream to construct an IddFile_Impl
90 static std::shared_ptr<IddFile_Impl> load(std::istream& is);
91
92 /// print
93 std::ostream& print(std::ostream& os) const;
94
95 //@}
96
97 private:
98 /// Parse file text to populate this IddFile.
99 void parse(std::istream& is);
100
101 /// Version string required to be at top of any IddFile.
102 std::string m_version;
103
104 /// Build string which might be at the top of an IddFile
105 std::string m_build;
106
107 /// The first comment block in an IddFile is its header.
108 std::string m_header;
109
110 /// The vector of IddObjects that constitute this IddFile.
111 std::vector<IddObject> m_objects;
112
113 /// Cache the Version IddObject
114 mutable boost::optional<IddObject> m_versionObject;
115
116 /// Configure logging.
117 − REGISTER_LOGGER("utilities.idd.IddFile");
118 };
119
120 } // namespace detail
121 } // namespace openstudio
122
123 #endif // UTILITIES_IDD_IDDFILE_IMPL_HPP
124