SheafSystem  0.0.0.0
error_message.h
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Interface for class error_message.
19 
20 #ifndef ERROR_MESSAGE_H
21 #define ERROR_MESSAGE_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef STD_STRING_H
28 #include "SheafSystem/std_string.h"
29 #endif
30 
31 namespace sheaf
32 {
33 
37 class SHEAF_DLL_SPEC error_message
38 {
39 
40 public:
41 
42  // ===========================================================
43  // ERROR_MESSAGE FACET
44  // ===========================================================
45 
49  error_message();
50 
54  error_message(const error_message& xother);
55 
59  error_message& operator=(const error_message& xother);
60 
64  virtual ~error_message();
65 
70  {
71  UNSPECIFIED = 0,
72  INFORMATION,
73  WARNING,
74  SEVERE_ERROR,
75  FATAL_ERROR,
76  LEVEL_TYPE_UB // Must be last.
77  };
78 
82  error_message(level_type xlevel, const std::string& xsource, const std::string& xtext);
83 
89  const std::string& xfile,
90  int xline,
91  const std::string& xtext);
92 
96  std::string source() const;
97 
101  std::string text() const;
102 
106  level_type level() const;
107 
111  void post(bool xforce_exit = false) const;
112 
116  static const std::string& level_name(level_type xlevel);
117 
118 private:
122  std::string _source;
123 
127  std::string _text;
128 
132  level_type _level;
133 
134 };
135 
136 // ===========================================================
137 // NON-MEMBER FUNCTIONS
138 // ===========================================================
139 
143 SHEAF_DLL_SPEC
144 std::ostream & operator << (std::ostream &xos, const error_message& xmsg);
145 
146 #define SOURCE_CODE_LOCATION \
147 error_message(error_message::UNSPECIFIED, __FILE__, __LINE__, "")
148 
149 #define post_information_message(x) \
150 {error_message msg(error_message::INFORMATION, __FILE__, __LINE__, (x)); msg.post(0);}
151 
152 #define post_warning_message(x) \
153 {error_message msg(error_message::WARNING, __FILE__, __LINE__, (x)); msg.post(0);}
154 
155 #define post_severe_error_message(x) \
156 {error_message msg(error_message::SEVERE_ERROR, __FILE__, __LINE__, (x)); msg.post(0);}
157 
158 #define post_fatal_error_message(x) \
159 {error_message msg(error_message::FATAL_ERROR, __FILE__, __LINE__, (x)); msg.post(1);}
160 
161 } // namespace sheaf
162 
163 #endif // ifndef ERROR_MESSAGE_H
level_type
The set of predefined error levels.
Definition: error_message.h:69
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
Namespace for the sheaves component of the sheaf system.
A message to report error conditions.
Definition: error_message.h:37