Sierra Toolkit  Version of the Day
RuntimeDoomed.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_RUNTIMEDOOMED_HPP
10 #define STK_UTIL_ENVIRONMENT_RUNTIMEDOOMED_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_doomed_count();
31 
37 inline bool is_doomed() {
38  return get_doomed_count() > 0;
39 }
40 
45 void reset_doomed_count();
46 
54 void set_max_doomed_count(unsigned int max_messages);
55 
61 unsigned get_max_doomed_count();
62 
79 void report_doomed(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode);
80 
97 void report_symmetric_doomed(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode);
98 
109 void report_deferred_doomed(const char *message, const char *aggregate, const MessageCode &message_code);
110 
127 {
128 public:
136  explicit RuntimeDoomedAdHoc(const MessageCode &message_code = MessageCode::s_defaultMessageCode);
137 
146 
147 private:
153 
158  RuntimeDoomedAdHoc &operator=(const RuntimeDoomedAdHoc &);
159 
160 public:
167  RuntimeDoomedAdHoc &operator<<(OStreamFunctionPtr f) {
168  f(message);
169  return *this;
170  }
171 
178  RuntimeDoomedAdHoc &operator<<(IOSBaseFunctionPtr f) {
179  f(message);
180  return *this;
181  }
182 
192  template <class T>
194  message << t;
195  return *this;
196  }
197 
198 public:
199  std::ostringstream message;
200 
201 private:
202  const MessageCode m_messageCode;
203 };
204 
205 
222 {
223 public:
232 
241 
242 private:
248 
254 
255 public:
262  RuntimeDoomedSymmetric &operator<<(OStreamFunctionPtr f) {
263  f(message);
264  return *this;
265  }
266 
273  RuntimeDoomedSymmetric &operator<<(IOSBaseFunctionPtr f) {
274  f(message);
275  return *this;
276  }
277 
287  template <class T>
289  message << t;
290  return *this;
291  }
292 
293 public:
294  std::ostringstream message;
295 
296 private:
297  const MessageCode m_messageCode;
298 };
299 
300 
322 {
323 public:
331  explicit RuntimeDoomedDeferred(const MessageCode &message_code);
332 
340 
341 private:
347 
352  RuntimeDoomedDeferred &operator=(const RuntimeDoomedDeferred &);
353 
354 public:
361  RuntimeDoomedDeferred &operator<<(OStreamFunctionPtr f) {
362  f(message);
363  return *this;
364  }
365 
372  RuntimeDoomedDeferred &operator<<(IOSBaseFunctionPtr f) {
373  f(message);
374  return *this;
375  }
376 
386  template <class T>
388  message << t;
389  return *this;
390  }
391 
392 public:
393  std::ostringstream message;
394  std::ostringstream aggregate;
395 
396 private:
397  const MessageCode m_messageCode;
398 };
399 
403 
404 } // namespace stk_classic
405 
406 #endif // STK_UTIL_ENVIRONMENT_RUNTIMEDOOMED_HPP
void report_deferred_doomed(const char *message, const char *aggregate, const MessageCode &message_code)
Member function report_deferred_doomed ...
~RuntimeDoomedDeferred()
Destroys a RuntimeDoomed instance.
RuntimeDoomedAdHoc & operator<<(IOSBaseFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
void set_max_doomed_count(unsigned int max_messages)
Function set_max_messages sets the maximum number of doomed before no more doomed will be displayed...
RuntimeDoomedDeferred(const MessageCode &message_code)
Creates a new RuntimeDoomedDeferred instance, setting the message code.
std::ostringstream aggregate
Stream to receive message aggregate content.
RuntimeDoomedAdHoc & operator<<(OStreamFunctionPtr f)
Member function operator<< passes the output stream manipulator to the output stream.
RuntimeDoomedSymmetric(const MessageCode &message_code=MessageCode::s_defaultMessageCode)
Creates a new RuntimeDoomedSymmetric instance, setting the message code.
std::ostringstream message
Stream to receive message header content.
RuntimeDoomedAdHoc & operator<<(const T &t)
Member function operator<< passes any data type to the exception string class for conversion to a str...
RuntimeDoomedSymmetric & operator<<(OStreamFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
void report_doomed(const char *message, const MessageCode &message_code)
Function report_symmetric_doomed sends a doomed message to the reporter.
Class MessageCode declares a message identifier and throttle characteristics for a message...
RuntimeDoomedDeferred & operator<<(OStreamFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
RuntimeDoomedDeferred & operator<<(const T &t)
Member function operator<< passes any data type to the exception string class for conversion to a str...
~RuntimeDoomedAdHoc()
Destroys a RuntimeDoomedAdHoc instance.
Class RuntimeDoomedDeferred reports a deferred fatal error message to the report system.
void report_symmetric_doomed(const char *message, const MessageCode &message_code)
Function report_symmetric_doomed sends a doomed message to the reporter.
RuntimeDoomedDeferred & operator<<(IOSBaseFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
RuntimeDoomedSymmetric & operator<<(const T &t)
Member function operator<< passes any data type to the exception string class for conversion to a str...
~RuntimeDoomedSymmetric()
Destroys a RuntimeDoomedSymmetric instance.
std::ostringstream message
Stream to receive message content.
unsigned int get_doomed_count()
Function get_doomed_count returns the accumulated doomed count.
Sierra Toolkit.
std::ostringstream message
Stream to receive message content.
unsigned get_max_doomed_count()
Function set_max_messages sets the maximum number of doomed and doomed messages displayed before the ...
Class RuntimeDoomedSymmetric reports a fatal error message to the report system.
RuntimeDoomedAdHoc(const MessageCode &message_code=MessageCode::s_defaultMessageCode)
Creates a new RuntimeDoomedAdHoc instance, setting the message code.
bool is_doomed()
Function is_doomed returns true if get_doomed_count() > 0.
RuntimeDoomedSymmetric & operator<<(IOSBaseFunctionPtr f)
Member function operator<< passes the ios_base manipulator to the output stream.
static MessageCode s_defaultMessageCode
Default message code.
Class RuntimeDoomedAdHoc reports an ad hoc doomed message to the report system.
void reset_doomed_count()
Function reset_doomed_count sets the accumulated doomed count to zero.