Sierra Toolkit Version of the Day
RuntimeWarning.cpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 #include <stk_util/environment/ReportHandler.hpp>
00010 #include <stk_util/environment/RuntimeWarning.hpp>
00011 
00012 namespace stk {
00013 
00014 unsigned 
00015 get_warning_count()
00016 {
00017   return get_message_count(MSG_WARNING);
00018 }
00019 
00020 
00021 void
00022 reset_warning_count()
00023 {
00024   reset_message_count(MSG_WARNING);
00025 }
00026 
00027 
00028 void
00029 set_max_warning_count(
00030   unsigned int  max_warnings)
00031 {
00032   set_max_message_count(MSG_WARNING, max_warnings);
00033 }
00034 
00035 
00036 unsigned 
00037 get_max_warning_count()
00038 {
00039   return   get_max_message_count(MSG_WARNING);
00040 }
00041 
00042 
00043 void
00044 report_warning(
00045   const char *          message,
00046   const MessageCode &   message_code)
00047 {
00048   report_message(message, MSG_WARNING, message_code);
00049 }
00050 
00051 
00052 void
00053 report_symmetric_warning(
00054   const char *          message,
00055   const MessageCode &   message_code)
00056 {
00057   report_message(message, MSG_SYMMETRIC | MSG_WARNING, message_code);
00058 }
00059 
00060 
00061 void
00062 report_deferred_warning(
00063   const char *          message,
00064   const char *          aggregate,
00065   const MessageCode &   message_code)
00066 {
00067   add_deferred_message(MSG_WARNING, message_code.m_id, message_code.m_throttle.m_cutoff, message_code.m_throttle.m_group, message, aggregate);
00068 }
00069 
00070 
00071 RuntimeWarningAdHoc::RuntimeWarningAdHoc(
00072   MessageCode &   message_code)
00073   : m_messageCode(message_code)
00074 {}
00075 
00076 
00077 RuntimeWarningAdHoc::~RuntimeWarningAdHoc()
00078 {
00079   try {
00080     report_warning(message.str().c_str(), m_messageCode);
00081   }
00082   catch (std::exception &)
00083   {}
00084 }
00085 
00086 
00087 RuntimeWarningSymmetric::RuntimeWarningSymmetric(
00088   MessageCode &   message_code)
00089   : m_messageCode(message_code)
00090 {}
00091 
00092 
00093 RuntimeWarningSymmetric::~RuntimeWarningSymmetric()
00094 {
00095   try {
00096     report_symmetric_warning(message.str().c_str(), m_messageCode);
00097   }
00098   catch (std::exception &)
00099   {}
00100 }
00101 
00102 
00103 RuntimeWarningDeferred::RuntimeWarningDeferred(
00104   const MessageCode &   message_code)
00105   : m_messageCode(message_code)
00106 {}
00107 
00108 
00109 RuntimeWarningDeferred::~RuntimeWarningDeferred()
00110 {
00111   try {
00112     report_deferred_warning(message.str().c_str(), aggregate.str().c_str(), m_messageCode);
00113   }
00114   catch (std::exception &)
00115   {}
00116 }
00117 
00118 } // namespace stk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends