Sierra Toolkit  Version of the Day
RuntimeWarning.hpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #ifndef STK_UTIL_ENVIRONMENT_RUNTIMEWARNING_HPP
10 #define STK_UTIL_ENVIRONMENT_RUNTIMEWARNING_HPP
11 
12 #include <sstream>
13 
15 
16 namespace stk_classic {
17 
18 typedef std::ostream &(*OStreamFunctionPtr)(std::ostream &);
19 typedef std::ios_base &(*IOSBaseFunctionPtr)(std::ios_base &);
20 
25 
30 unsigned get_warning_count();
31 
36 void reset_warning_count();
37 
45 void set_max_warning_count(unsigned int max_messages);
46 
52 unsigned get_max_warning_count();
53 
62 void report_warning(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode);
63 
79 void report_symmetric_warning(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode);
80 
91 void report_deferred_warning(const char *message, const char *aggregate, const MessageCode &message_code);
92 
111 {
112 public:
121 
130 
131 private:
137 
142  RuntimeWarningAdHoc &operator=(const RuntimeWarningAdHoc &);
143 
144 public:
151  RuntimeWarningAdHoc &operator<<(OStreamFunctionPtr f) {
152  f(message);
153  return *this;
154  }
155 
162  RuntimeWarningAdHoc &operator<<(IOSBaseFunctionPtr f) {
163  f(message);
164  return *this;
165  }
166 
176  template <class T>
178  message << t;
179  return *this;
180  }
181 
182 public:
183  std::ostringstream message;
184 
185 private:
186  const MessageCode m_messageCode;
187 };
188 
189 
206 {
207 public:
216 
225 
226 private:
232 
238 
239 public:
246  RuntimeWarningSymmetric &operator<<(OStreamFunctionPtr f) {
247  f(message);
248  return *this;
249  }
250 
257  RuntimeWarningSymmetric &operator<<(IOSBaseFunctionPtr f) {
258  f(message);
259  return *this;
260  }
261 
271  template <class T>
273  message << t;
274  return *this;
275  }
276 
277 public:
278  std::ostringstream message;
279 
280 private:
281  const MessageCode m_messageCode;
282 };
283 
284 
306 {
307 public:
315  explicit RuntimeWarningDeferred(const MessageCode &message_code);
316 
324 
325 private:
331 
337 
338 public:
345  RuntimeWarningDeferred &operator<<(OStreamFunctionPtr f) {
346  f(message);
347  return *this;
348  }
349 
356  RuntimeWarningDeferred &operator<<(IOSBaseFunctionPtr f) {
357  f(message);
358  return *this;
359  }
360 
370  template <class T>
372  message << t;
373  return *this;
374  }
375 
376 public:
377  std::ostringstream message;
378  std::ostringstream aggregate;
379 
380 private:
381  const MessageCode m_messageCode;
382 };
383 
387 
388 } // namespace stk_classic
389 
390 #endif // STK_UTIL_ENVIRONMENT_RUNTIMEWARNING_HPP
void reset_warning_count()
Function reset_warning_count sets the accumulated warning count to zero.
RuntimeWarningSymmetric & operator<<(OStreamFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
void set_max_warning_count(unsigned int max_warnings)
Function set_max_messages sets the maximum number of warning before no more warning will be displayed...
RuntimeWarningSymmetric(MessageCode &message_code=MessageCode::s_defaultMessageCode)
Creates a new RuntimeWarning instance, setting the message code.
std::ostringstream message
Stream to receive message header content.
RuntimeWarningDeferred(const MessageCode &message_code)
Creates a new RuntimeWarningDeferred instance, setting the message code.
RuntimeWarningAdHoc & operator<<(IOSBaseFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
Class RuntimeWarningSymmetric reports a symmetric warning message to the report system.
RuntimeWarningAdHoc & operator<<(OStreamFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
Class MessageCode declares a message identifier and throttle characteristics for a message...
RuntimeWarningDeferred & operator<<(const T &t)
Member function operator<< passes any data type to the exception string class for conversion to a str...
RuntimeWarningSymmetric & operator<<(const T &t)
Member function operator<< passes any data type to the exception string class for conversion to a str...
std::ostringstream message
Stream to receive message content.
void report_deferred_warning(const char *message, const char *aggregate, const MessageCode &message_code)
Member function report_deferred_warning ...
void report_warning(const char *message, const MessageCode &message_code)
Member function report_warning ...
std::ostringstream aggregate
Stream to receive message aggregate content.
~RuntimeWarningSymmetric()
Destroys a RuntimeWarningSymmetric instance.
std::ostringstream message
Stream to receive message content.
void report_symmetric_warning(const char *message, const MessageCode &message_code)
Function report_symmetric_warning sends a warning message to the reporter.
~RuntimeWarningDeferred()
Destroys a RuntimeWarning instance.
Class RuntimeWarningDeferred reports a deferred warning message to the report system.
unsigned get_max_warning_count()
Function set_max_messages sets the maximum number of warning and doomed messages displayed before the...
RuntimeWarningSymmetric & operator<<(IOSBaseFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
RuntimeWarningDeferred & operator<<(OStreamFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
Sierra Toolkit.
Class RuntimeWarningAdHoc reports an ad hoc warning message to the report system. ...
RuntimeWarningAdHoc(MessageCode &message_code=MessageCode::s_defaultMessageCode)
Creates a new RuntimeWarningAdHoc instance, setting the message code.
RuntimeWarningDeferred & operator<<(IOSBaseFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
RuntimeWarningAdHoc & operator<<(const T &t)
Member function operator<< passes any data type to the exception string class for conversion to a str...
unsigned get_warning_count()
Function get_warning_count returns the accumulated warning count.
static MessageCode s_defaultMessageCode
Default message code.
~RuntimeWarningAdHoc()
Destroys a RuntimeWarningAdHoc instance.