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
stk_classic::RuntimeWarningSymmetric::~RuntimeWarningSymmetric
~RuntimeWarningSymmetric()
Destroys a RuntimeWarningSymmetric instance.
Definition: RuntimeWarning.cpp:93
stk_classic::RuntimeWarningAdHoc::~RuntimeWarningAdHoc
~RuntimeWarningAdHoc()
Destroys a RuntimeWarningAdHoc instance.
Definition: RuntimeWarning.cpp:77
stk_classic::RuntimeWarningDeferred::message
std::ostringstream message
Stream to receive message header content.
Definition: RuntimeWarning.hpp:377
stk_classic::RuntimeWarningDeferred::aggregate
std::ostringstream aggregate
Stream to receive message aggregate content.
Definition: RuntimeWarning.hpp:378
stk_classic::reset_warning_count
void reset_warning_count()
Function reset_warning_count sets the accumulated warning count to zero.
Definition: RuntimeWarning.cpp:22
stk_classic::Throttle::m_group
int m_group
Throttle group of message.
Definition: RuntimeMessage.hpp:103
stk_classic::MessageCode::m_throttle
Throttle m_throttle
Throttle characteristics.
Definition: RuntimeMessage.hpp:164
stk_classic::reset_message_count
void reset_message_count(unsigned message_type)
Member function reset_message_count ...
Definition: RuntimeMessage.cpp:185
stk_classic::report_deferred_warning
void report_deferred_warning(const char *message, const char *aggregate, const MessageCode &message_code)
Member function report_deferred_warning ...
Definition: RuntimeWarning.cpp:62
stk_classic::report_symmetric_warning
void report_symmetric_warning(const char *message, const MessageCode &message_code)
Function report_symmetric_warning sends a warning message to the reporter.
Definition: RuntimeWarning.cpp:53
stk_classic::Throttle::m_cutoff
size_t m_cutoff
Maximum number to display.
Definition: RuntimeMessage.hpp:102
stk_classic::RuntimeWarningDeferred::~RuntimeWarningDeferred
~RuntimeWarningDeferred()
Destroys a RuntimeWarning instance.
Definition: RuntimeWarning.cpp:109
stk_classic
Sierra Toolkit.
Definition: AlgorithmRunner.cpp:16
stk_classic::RuntimeWarningAdHoc::message
std::ostringstream message
Stream to receive message content.
Definition: RuntimeWarning.hpp:183
stk_classic::get_max_warning_count
unsigned get_max_warning_count()
Function set_max_messages sets the maximum number of warning and doomed messages displayed before the...
Definition: RuntimeWarning.cpp:37
stk_classic::RuntimeWarningDeferred::RuntimeWarningDeferred
RuntimeWarningDeferred(const MessageCode &message_code)
Creates a new RuntimeWarningDeferred instance, setting the message code.
Definition: RuntimeWarning.cpp:103
stk_classic::add_deferred_message
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.
Definition: RuntimeMessage.cpp:267
stk_classic::RuntimeWarningSymmetric::RuntimeWarningSymmetric
RuntimeWarningSymmetric(MessageCode &message_code=MessageCode::s_defaultMessageCode)
Creates a new RuntimeWarning instance, setting the message code.
Definition: RuntimeWarning.cpp:87
stk_classic::MessageCode
Class MessageCode declares a message identifier and throttle characteristics for a message....
Definition: RuntimeMessage.hpp:124
stk_classic::report_message
void report_message(const char *message, unsigned message_type, const MessageCode &message_code)
Member function report_message ...
Definition: RuntimeMessage.cpp:218
stk_classic::get_message_count
unsigned get_message_count(unsigned message_type)
Member function get_message_count ...
Definition: RuntimeMessage.cpp:169
stk_classic::MSG_SYMMETRIC
Message is symmetrical.
Definition: RuntimeMessage.hpp:60
stk_classic::RuntimeWarningAdHoc::RuntimeWarningAdHoc
RuntimeWarningAdHoc(MessageCode &message_code=MessageCode::s_defaultMessageCode)
Creates a new RuntimeWarningAdHoc instance, setting the message code.
Definition: RuntimeWarning.cpp:71
stk_classic::set_max_warning_count
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...
Definition: RuntimeWarning.cpp:29
stk_classic::report_warning
void report_warning(const char *message, const MessageCode &message_code)
Member function report_warning ...
Definition: RuntimeWarning.cpp:44
stk_classic::set_max_message_count
void set_max_message_count(unsigned message_type, unsigned max_count)
Member function set_max_message_count ...
Definition: RuntimeMessage.cpp:201
stk_classic::MSG_WARNING
Message is a warning.
Definition: RuntimeMessage.hpp:54
stk_classic::RuntimeWarningSymmetric::message
std::ostringstream message
Stream to receive message content.
Definition: RuntimeWarning.hpp:278
stk_classic::MessageCode::m_id
MessageId m_id
Message identifier.
Definition: RuntimeMessage.hpp:163
stk_classic::get_max_message_count
unsigned get_max_message_count(unsigned message_type)
Member function get_max_message_count ...
Definition: RuntimeMessage.cpp:210
stk_classic::get_warning_count
unsigned get_warning_count()
Function get_warning_count returns the accumulated warning count.
Definition: RuntimeWarning.cpp:15