|
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_RUNTIMEMESSAGE_HPP 00010 #define STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP 00011 00012 #include <iosfwd> 00013 #include <vector> 00014 #include <cstddef> 00015 00016 #include <stk_util/parallel/Parallel.hpp> 00017 00018 namespace stk_classic { 00019 00024 00042 typedef ptrdiff_t MessageId; 00043 // typedef std::vector<void *>::difference_type MessageId; 00044 00053 enum MessageType { 00054 MSG_WARNING = 0, 00055 MSG_DOOMED = 1, 00056 MSG_EXCEPTION = 2, 00057 MSG_INFORMATION = 3, 00058 00059 MSG_TYPE_MASK = 0x0FFFFFFF, 00060 MSG_SYMMETRIC = 0x80000000, 00061 MSG_DEFERRED = 0x40000000, 00062 MSG_UNUSED0 = 0x20000000, 00063 MSG_UNUSED1 = 0x10000000 00064 }; 00065 00075 enum ThrottleGroup { 00076 MSG_APPLICATION = 0, 00077 MSG_TIME_STEP = 1 00078 }; 00079 00084 struct Throttle 00085 { 00096 Throttle(size_t cutoff, int group) 00097 : m_cutoff(cutoff), 00098 m_group(group), 00099 m_count(0) 00100 {} 00101 00102 size_t m_cutoff; 00103 int m_group; 00104 size_t m_count; 00105 }; 00106 00124 struct MessageCode 00125 { 00136 MessageCode(size_t throttle_cutoff = 5, int throttle_group = MSG_APPLICATION) 00137 : m_id(&m_id - (MessageId *) 0), 00138 m_throttle(throttle_cutoff, throttle_group) 00139 {} 00140 00156 MessageCode(MessageId message_id, size_t throttle_cutoff, int throttle_group) 00157 : m_id(message_id), 00158 m_throttle(throttle_cutoff, throttle_group) 00159 {} 00160 00161 static MessageCode s_defaultMessageCode; 00162 00163 MessageId m_id; 00164 Throttle m_throttle; 00165 }; 00166 00174 unsigned get_message_count(unsigned message_type); 00175 00182 void reset_message_count(unsigned message_type); 00183 00192 void set_max_message_count(unsigned message_type, unsigned max_count); 00193 00201 unsigned get_max_message_count(unsigned message_type); 00202 00210 const std::string &get_message_name(unsigned message_type); 00211 00222 void register_message_type(unsigned message_type, unsigned max_count, const char *name); 00223 00231 void reset_throttle_group(int throttle_group); 00232 00244 void report_message(const char *message, unsigned message_type, const MessageCode &message_code); 00245 00264 void add_deferred_message(int message_type, MessageId message_id, size_t throttle_cutoff, int throttle_group, const char *header, const char *aggegrate); 00265 00273 void report_deferred_messages(ParallelMachine comm); 00274 00288 void aggregate_messages(ParallelMachine comm, std::ostringstream &os, const char *separator = ", "); 00289 00300 std::ostream &operator<<(std::ostream &os, const MessageType &message_type); 00301 00305 00306 } // namespace stk_classic 00307 00308 #endif // STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP