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/IddFileAndFactoryWrapper.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_IDDFILEANDFACTORYWRAPPER_HPP
7 #define UTILITIES_IDD_IDDFILEANDFACTORYWRAPPER_HPP
8
9 #include "../UtilitiesAPI.hpp"
10 #include "IddFile.hpp"
11 #include "IddEnums.hpp"
12
13 namespace openstudio {
14
15 /** Wraps the functionality of IddFile and \link IddFactory IddFactory \endlink
16 * into one class for use by IdfFile and Workspace. */
17 class UTILITIES_API IddFileAndFactoryWrapper
18 {
19 public:
20 /** @name Constructors and Destructors */
21 //@{
22
23 /** Default constructor sets IddFileType to IddFileType::OpenStudio. */
24 IddFileAndFactoryWrapper();
25
26 /** Construct from UserCustom IddFile. */
27 IddFileAndFactoryWrapper(const IddFile& iddFile);
28
29 /** Construct wrapper that provides access to the iddFileType IddFile through the \link
30 * IddFactory IddFactory \endlink. Logs a warning if iddFileType ==
31 * IddFileType::UserCustom, since this results in an empty IddFile. */
32 IddFileAndFactoryWrapper(IddFileType iddFileType);
33
34 //@}
35 /** @name Getters */
36 //@{
37
38 /** Get the file version. */
39 std::string version() const;
40
41 /** Get the file header. */
42 std::string header() const;
43
44 /** Get all the objects in the file. */
45 std::vector<IddObject> objects() const;
46
47 /** Get all groups in the file (e.g. "" and "Simulation Parameters"). */
48 std::vector<std::string> groups() const;
49
50 /** Get all the objects in group (e.g. "Simulation Parameters"). */
51 std::vector<IddObject> getObjectsInGroup(const std::string& group) const;
52
53 /** Get the IddObjects that match objectRegex. */
54 std::vector<IddObject> getObjects(const boost::regex& objectRegex) const;
55
56 /** If possible, returns the version IddObject for this IddFile. */
57 boost::optional<IddObject> versionObject() const;
58
59 /** Get the IddObject named objectName. Return value will evaluate to false if there is no
60 * such object in the file. */
61 boost::optional<IddObject> getObject(const std::string& objectName) const;
62
63 /** Get the IddObject of type objectType. Return value will evaluate to false if there is no
64 * such object in the IddFile, or if IddObjectType == IddObjectType::UserCustom. */
65 boost::optional<IddObject> getObject(IddObjectType objectType) const;
66
67 /** Get all \link IddObject IddObjects\endlink in the file that are required. An IdfFile
68 * (or Workspace) conforming to this IddFile must contain at least one object of each of these
69 * types. */
70 std::vector<IddObject> requiredObjects() const;
71
72 /** Get all \link IddObject IddObjects\endlink in the file that are marked as unique. An IdfFile
73 * (or Workspace) conforming to this IddFile must contain at most one object of each of these
74 * types. */
75 std::vector<IddObject> uniqueObjects() const;
76
77 /** Get the IddFile, which may have been explicitly specified by the user, or may be implicitly
78 * specified by reference to the \link IddFactory IddFactory\endlink. */
79 IddFile iddFile() const;
80
81 /** Get the IddFileType. If iddFileType() == IddFileType::UserCustom, then the file has been
82 * explicitly specified by the user. Otherwise, the file is implicitly defined and accessed
83 * through IddFactory. */
84 IddFileType iddFileType() const;
85
86 //@}
87 /** @name Setters */
88 //@{
89
90 /** Set the IddFile explicitly. This option does not use the \link IddFactory
91 * IddFactory\endlink. */
92 void setIddFile(const IddFile& iddFile);
93
94 /** Set the IddFile by specifying iddFileType. This option uses the \link IddFactory
95 * IddFactory\endlink, unless iddFileType == IddFileType::UserCustom, in which case a warning
96 * is logged. */
97 void setIddFile(IddFileType iddFileType);
98
99 //@}
100 /** @name Queries */
101 //@{
102
103 /** Returns whether an IddObject of objectType is in iddFile(), unless objectType ==
104 * IddObjectType::UserCustom. In the latter case, false will always be returned. To test whether
105 * a UserCustom file is being used, check the value of iddFileType(). */
106 bool isInFile(IddObjectType objectType) const;
107
108 /** Returns whether there is an IddObject named objectName in iddFile(). */
109 bool isInFile(const std::string& objectName) const;
110
111 //@}
112 private:
113 boost::optional<IddFile> m_iddFile;
114 boost::optional<IddFileType> m_iddFileType;
115
116 // configure logging
117 − REGISTER_LOGGER("utilities.IddFileAndFactoryWrapper");
118 };
119
120 // helper function to get a particular Idd File that was released with CBECC-Com but not OpenStudio
121 UTILITIES_API IddFile get_1_9_0_CBECC_IddFile();
122
123 } // namespace openstudio
124
125 #endif // UTILITIES_IDD_IDDFILEANDFACTORYWRAPPER_HPP
126