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/idf/DataError.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_IDF_DATAERROR_HPP
7 #define UTILITIES_IDF_DATAERROR_HPP
8
9 #include "../UtilitiesAPI.hpp"
10
11 #include "ValidityEnums.hpp"
12 #include "Handle.hpp"
13
14 #include "../core/Logger.hpp"
15
16 #include "../idd/IddEnums.hpp"
17
18 #include <boost/optional.hpp>
19
20 namespace openstudio {
21
22 class IdfObject;
23
24 class UTILITIES_API DataError
25 {
26 public:
27 /** @name Construction */
28 //@{
29
30 /** Constructor for field-level error. */
31 DataError(unsigned fieldIndex, const IdfObject& object, DataErrorType errorType);
32
33 /** Constructor for object-level error. */
34 DataError(const IdfObject& object, DataErrorType errorType);
35
36 /** Constructor for collection-level error without a related IddObjectType. */
37 DataError(DataErrorType errorType);
38
39 /** Constructor for collection-level error with a related IddObjectType. */
40 DataError(DataErrorType errorType, IddObjectType objectType);
41
42 //@}
43 /** @name Inspection */
44 //@{
45
46 /** Returns the scope of the error. */
47 Scope scope() const;
48
49 /** Returns the enum that describes the error. The .valueDescription() contains a brief
50 * description. */
51 DataErrorType type() const;
52
53 /** Returns the index of the erroneous field, if scope() == Scope::Field, otherwise throws. */
54 unsigned fieldIdentifier() const;
55
56 /** Returns the handle of the erroneous object, if applicable. Otherwise, returned
57 * Handle.isNull(). */
58 Handle objectIdentifier() const;
59
60 /** Returns the name of the object identified by objectIdentifier(), or an empty string. */
61 std::string objectName() const;
62
63 /** Returns the type of the object identified by objectIdentifier() if the error is field- or
64 * object-level; if the error is collection level, the return value will either evaluate to
65 * false or be related to a cardinality constraint. */
66 boost::optional<IddObjectType> objectType() const;
67
68 /** Returns true if all data exactly equal. */
69 bool operator==(const DataError& otherError) const;
70
71 /** Negation of operator==. */
72 bool operator!=(const DataError& otherError) const;
73
74 //@}
75 private:
76 Scope m_scope;
77 DataErrorType m_type;
78 unsigned m_fieldIndex;
79 Handle m_objectHandle;
80 std::string m_objectName;
81 boost::optional<IddObjectType> m_objectType;
82
83 − REGISTER_LOGGER("utilities.idf.DataError");
84 };
85
86 /** Set comparator for DataError. \relates DataError */
87 struct UTILITIES_API DataErrorLess
88 {
89 bool operator()(const DataError& left, const DataError& right) const;
90 };
91
92 /** Set container for DataError. \relates DataError */
93 using DataErrorSet = std::set<DataError, DataErrorLess>;
94
95 /** \relates DataError */
96 using OptionalDataError = boost::optional<DataError>;
97
98 /** \relates DataError */
99 using DataErrorVector = std::vector<DataError>;
100
101 /** Ostream operator for DataError. \relates DataError */
102 UTILITIES_API std::ostream& operator<<(std::ostream& os, const DataError& error);
103
104 } // namespace openstudio
105
106 #endif // UTILITIES_IDF_DATAERROR_HPP
107