|
Sierra Toolkit
Version of the Day
|
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_RUNTIMEDOOMED_HPP 00010 #define STK_UTIL_ENVIRONMENT_RUNTIMEDOOMED_HPP 00011 00012 #include <sstream> 00013 00014 #include <stk_util/environment/RuntimeMessage.hpp> 00015 00016 namespace stk_classic { 00017 00018 typedef std::ostream &(*OStreamFunctionPtr)(std::ostream &); 00019 typedef std::ios_base &(*IOSBaseFunctionPtr)(std::ios_base &); 00020 00025 00030 unsigned get_doomed_count(); 00031 00037 inline bool is_doomed() { 00038 return get_doomed_count() > 0; 00039 } 00040 00045 void reset_doomed_count(); 00046 00054 void set_max_doomed_count(unsigned int max_messages); 00055 00061 unsigned get_max_doomed_count(); 00062 00079 void report_doomed(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode); 00080 00097 void report_symmetric_doomed(const char *message, const MessageCode &message_code = MessageCode::s_defaultMessageCode); 00098 00109 void report_deferred_doomed(const char *message, const char *aggregate, const MessageCode &message_code); 00110 00126 class RuntimeDoomedAdHoc 00127 { 00128 public: 00136 explicit RuntimeDoomedAdHoc(const MessageCode &message_code = MessageCode::s_defaultMessageCode); 00137 00145 ~RuntimeDoomedAdHoc(); 00146 00147 private: 00152 RuntimeDoomedAdHoc(const RuntimeDoomedAdHoc &); 00153 00158 RuntimeDoomedAdHoc &operator=(const RuntimeDoomedAdHoc &); 00159 00160 public: 00167 RuntimeDoomedAdHoc &operator<<(OStreamFunctionPtr f) { 00168 f(message); 00169 return *this; 00170 } 00171 00178 RuntimeDoomedAdHoc &operator<<(IOSBaseFunctionPtr f) { 00179 f(message); 00180 return *this; 00181 } 00182 00192 template <class T> 00193 RuntimeDoomedAdHoc &operator<<(const T &t) { 00194 message << t; 00195 return *this; 00196 } 00197 00198 public: 00199 std::ostringstream message; 00200 00201 private: 00202 const MessageCode m_messageCode; 00203 }; 00204 00205 00221 class RuntimeDoomedSymmetric 00222 { 00223 public: 00231 explicit RuntimeDoomedSymmetric(const MessageCode &message_code = MessageCode::s_defaultMessageCode); 00232 00240 ~RuntimeDoomedSymmetric(); 00241 00242 private: 00247 RuntimeDoomedSymmetric(const RuntimeDoomedSymmetric &); 00248 00253 RuntimeDoomedSymmetric &operator=(const RuntimeDoomedSymmetric &); 00254 00255 public: 00262 RuntimeDoomedSymmetric &operator<<(OStreamFunctionPtr f) { 00263 f(message); 00264 return *this; 00265 } 00266 00273 RuntimeDoomedSymmetric &operator<<(IOSBaseFunctionPtr f) { 00274 f(message); 00275 return *this; 00276 } 00277 00287 template <class T> 00288 RuntimeDoomedSymmetric &operator<<(const T &t) { 00289 message << t; 00290 return *this; 00291 } 00292 00293 public: 00294 std::ostringstream message; 00295 00296 private: 00297 const MessageCode m_messageCode; 00298 }; 00299 00300 00321 class RuntimeDoomedDeferred 00322 { 00323 public: 00331 explicit RuntimeDoomedDeferred(const MessageCode &message_code); 00332 00339 ~RuntimeDoomedDeferred(); 00340 00341 private: 00346 RuntimeDoomedDeferred(const RuntimeDoomedDeferred &); 00347 00352 RuntimeDoomedDeferred &operator=(const RuntimeDoomedDeferred &); 00353 00354 public: 00361 RuntimeDoomedDeferred &operator<<(OStreamFunctionPtr f) { 00362 f(message); 00363 return *this; 00364 } 00365 00372 RuntimeDoomedDeferred &operator<<(IOSBaseFunctionPtr f) { 00373 f(message); 00374 return *this; 00375 } 00376 00386 template <class T> 00387 RuntimeDoomedDeferred &operator<<(const T &t) { 00388 message << t; 00389 return *this; 00390 } 00391 00392 public: 00393 std::ostringstream message; 00394 std::ostringstream aggregate; 00395 00396 private: 00397 const MessageCode m_messageCode; 00398 }; 00399 00403 00404 } // namespace stk_classic 00405 00406 #endif // STK_UTIL_ENVIRONMENT_RUNTIMEDOOMED_HPP