Sierra Toolkit Version of the Day
RuntimeWarning.hpp
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 #ifndef STK_UTIL_ENVIRONMENT_RUNTIMEWARNING_HPP
00010 #define STK_UTIL_ENVIRONMENT_RUNTIMEWARNING_HPP
00011 
00012 #include <sstream>
00013 
00014 #include <stk_util/environment/RuntimeMessage.hpp>
00015 
00016 namespace stk {
00017 
00018 typedef std::ostream &(*OStreamFunctionPtr)(std::ostream &);
00019 typedef std::ios_base &(*IOSBaseFunctionPtr)(std::ios_base &);
00020 
00025 
00030 unsigned get_warning_count();
00031 
00036 void reset_warning_count();
00037 
00045 void set_max_warning_count(unsigned int max_messages);
00046 
00052 unsigned get_max_warning_count();
00053 
00062 void report_warning(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode);
00063 
00079 void report_symmetric_warning(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode);
00080 
00091 void report_deferred_warning(const char *message, const char *aggregate, const MessageCode &message_code);
00092 
00110 class RuntimeWarningAdHoc
00111 {
00112 public:
00120   explicit RuntimeWarningAdHoc(MessageCode &message_code = MessageCode::s_defaultMessageCode);
00121 
00129   ~RuntimeWarningAdHoc();
00130 
00131 private:
00136   RuntimeWarningAdHoc(const RuntimeWarningAdHoc &);
00137 
00142   RuntimeWarningAdHoc &operator=(const RuntimeWarningAdHoc &);
00143   
00144 public:
00151   RuntimeWarningAdHoc &operator<<(OStreamFunctionPtr f) {
00152     f(message);
00153     return *this;
00154   }
00155 
00162   RuntimeWarningAdHoc &operator<<(IOSBaseFunctionPtr f) {
00163     f(message);
00164     return *this;
00165   }
00166 
00176   template <class T>
00177   RuntimeWarningAdHoc &operator<<(const T &t) {
00178     message << t;
00179     return *this;
00180   }
00181 
00182 public:
00183   std::ostringstream    message;                
00184 
00185 private:
00186   const MessageCode     m_messageCode;          
00187 };
00188 
00189 
00205 class RuntimeWarningSymmetric
00206 {
00207 public:
00215   explicit RuntimeWarningSymmetric(MessageCode &message_code = MessageCode::s_defaultMessageCode);
00216 
00224   ~RuntimeWarningSymmetric();
00225 
00226 private:
00231   RuntimeWarningSymmetric(const RuntimeWarningSymmetric &);
00232 
00237   RuntimeWarningSymmetric &operator=(const RuntimeWarningSymmetric &);
00238   
00239 public:
00246   RuntimeWarningSymmetric &operator<<(OStreamFunctionPtr f) {
00247     f(message);
00248     return *this;
00249   }
00250 
00257   RuntimeWarningSymmetric &operator<<(IOSBaseFunctionPtr f) {
00258     f(message);
00259     return *this;
00260   }
00261 
00271   template <class T>
00272   RuntimeWarningSymmetric &operator<<(const T &t) {
00273     message << t;
00274     return *this;
00275   }
00276 
00277 public:
00278   std::ostringstream    message;                
00279 
00280 private:
00281   const MessageCode     m_messageCode;          
00282 };
00283 
00284 
00305 class RuntimeWarningDeferred
00306 {
00307 public:
00315   explicit RuntimeWarningDeferred(const MessageCode &message_code);
00316 
00323   ~RuntimeWarningDeferred();
00324 
00325 private:
00330   RuntimeWarningDeferred(const RuntimeWarningDeferred &);
00331 
00336   RuntimeWarningDeferred &operator=(const RuntimeWarningDeferred &);
00337 
00338 public:
00345   RuntimeWarningDeferred &operator<<(OStreamFunctionPtr f) {
00346     f(message);
00347     return *this;
00348   }
00349 
00356   RuntimeWarningDeferred &operator<<(IOSBaseFunctionPtr f) {
00357     f(message);
00358     return *this;
00359   }
00360 
00370   template <class T>
00371   RuntimeWarningDeferred &operator<<(const T &t) {
00372     message << t;
00373     return *this;
00374   }
00375 
00376 public:
00377   std::ostringstream    message;                
00378   std::ostringstream    aggregate;              
00379 
00380 private:
00381   const MessageCode     m_messageCode;          
00382 };
00383 
00387 
00388 } // namespace stk
00389 
00390 #endif // STK_UTIL_ENVIRONMENT_RUNTIMEWARNING_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends