Sierra Toolkit  Version of the Day
RuntimeWarning.cpp
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 #include <stk_util/environment/ReportHandler.hpp>
10 #include <stk_util/environment/RuntimeWarning.hpp>
11 
12 namespace stk_classic {
13 
14 unsigned
16 {
18 }
19 
20 
21 void
23 {
25 }
26 
27 
28 void
30  unsigned int max_warnings)
31 {
32  set_max_message_count(MSG_WARNING, max_warnings);
33 }
34 
35 
36 unsigned
38 {
40 }
41 
42 
43 void
45  const char * message,
46  const MessageCode & message_code)
47 {
48  report_message(message, MSG_WARNING, message_code);
49 }
50 
51 
52 void
54  const char * message,
55  const MessageCode & message_code)
56 {
57  report_message(message, MSG_SYMMETRIC | MSG_WARNING, message_code);
58 }
59 
60 
61 void
63  const char * message,
64  const char * aggregate,
65  const MessageCode & message_code)
66 {
67  add_deferred_message(MSG_WARNING, message_code.m_id, message_code.m_throttle.m_cutoff, message_code.m_throttle.m_group, message, aggregate);
68 }
69 
70 
72  MessageCode & message_code)
73  : m_messageCode(message_code)
74 {}
75 
76 
78 {
79  try {
80  report_warning(message.str().c_str(), m_messageCode);
81  }
82  catch (std::exception &)
83  {}
84 }
85 
86 
88  MessageCode & message_code)
89  : m_messageCode(message_code)
90 {}
91 
92 
94 {
95  try {
96  report_symmetric_warning(message.str().c_str(), m_messageCode);
97  }
98  catch (std::exception &)
99  {}
100 }
101 
102 
104  const MessageCode & message_code)
105  : m_messageCode(message_code)
106 {}
107 
108 
110 {
111  try {
112  report_deferred_warning(message.str().c_str(), aggregate.str().c_str(), m_messageCode);
113  }
114  catch (std::exception &)
115  {}
116 }
117 
118 } // namespace stk_classic
void add_deferred_message(int message_type, MessageId message_id, size_t throttle_cutoff, int throttle_group, const char *header, const char *aggegrate)
Function add_deferred_message adds a message to the deferred message queue.
void reset_warning_count()
Function reset_warning_count sets the accumulated warning count to zero.
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.
void reset_message_count(unsigned message_type)
Member function reset_message_count ...
std::ostringstream message
Stream to receive message header content.
RuntimeWarningDeferred(const MessageCode &message_code)
Creates a new RuntimeWarningDeferred instance, setting the message code.
Class MessageCode declares a message identifier and throttle characteristics for a message...
Throttle m_throttle
Throttle characteristics.
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.
unsigned get_max_message_count(unsigned message_type)
Member function get_max_message_count ...
void report_message(const char *message, unsigned message_type, const MessageCode &message_code)
Member function report_message ...
void report_symmetric_warning(const char *message, const MessageCode &message_code)
Function report_symmetric_warning sends a warning message to the reporter.
Message is a warning.
unsigned get_message_count(unsigned message_type)
Member function get_message_count ...
~RuntimeWarningDeferred()
Destroys a RuntimeWarning instance.
size_t m_cutoff
Maximum number to display.
unsigned get_max_warning_count()
Function set_max_messages sets the maximum number of warning and doomed messages displayed before the...
Message is symmetrical.
Sierra Toolkit.
void set_max_message_count(unsigned message_type, unsigned max_count)
Member function set_max_message_count ...
RuntimeWarningAdHoc(MessageCode &message_code=MessageCode::s_defaultMessageCode)
Creates a new RuntimeWarningAdHoc instance, setting the message code.
MessageId m_id
Message identifier.
int m_group
Throttle group of message.
unsigned get_warning_count()
Function get_warning_count returns the accumulated warning count.
~RuntimeWarningAdHoc()
Destroys a RuntimeWarningAdHoc instance.