RuntimeMessage.hpp

Go to the documentation of this file.
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 
00015 #include <stk_util/parallel/Parallel.hpp>
00016 
00017 namespace stk {
00018 
00023 
00041 typedef ptrdiff_t MessageId;
00042 // typedef std::vector<void *>::difference_type MessageId;
00043 
00052 enum MessageType {
00053   MSG_WARNING           = 0,                    
00054   MSG_DOOMED            = 1,                    
00055   MSG_EXCEPTION         = 2,                    
00056   MSG_INFORMATION       = 3,                    
00057 
00058   MSG_TYPE_MASK         = 0x0FFFFFFF,           
00059   MSG_SYMMETRIC         = 0x80000000,           
00060   MSG_DEFERRED          = 0x40000000,           
00061   MSG_UNUSED0           = 0x20000000,
00062   MSG_UNUSED1           = 0x10000000
00063 };
00064 
00074 enum ThrottleGroup {
00075   MSG_APPLICATION       = 0,
00076   MSG_TIME_STEP         = 1
00077 };
00078 
00083 struct Throttle
00084 {
00095   Throttle(size_t cutoff, int group)
00096     : m_cutoff(cutoff),
00097       m_group(group),
00098       m_count(0)
00099   {}
00100   
00101   size_t        m_cutoff;                       
00102   int           m_group;                        
00103   size_t        m_count;                        
00104 };
00105 
00123 struct MessageCode
00124 {
00135   MessageCode(size_t throttle_cutoff = 5, int throttle_group = MSG_APPLICATION)
00136     : m_id(&m_id - (MessageId *) 0),
00137       m_throttle(throttle_cutoff, throttle_group)
00138   {}
00139 
00155   MessageCode(MessageId message_id, size_t throttle_cutoff, int throttle_group)
00156     : m_id(message_id),
00157       m_throttle(throttle_cutoff, throttle_group)
00158   {}
00159 
00160   static MessageCode    s_defaultMessageCode;   
00161   
00162   MessageId             m_id;                   
00163   Throttle              m_throttle;             
00164 };
00165 
00173 unsigned get_message_count(unsigned message_type);
00174 
00181 void reset_message_count(unsigned message_type);
00182 
00191 void set_max_message_count(unsigned message_type, unsigned max_count);
00192 
00200 unsigned get_max_message_count(unsigned message_type);
00201 
00209 const std::string &get_message_name(unsigned message_type);
00210 
00221 void register_message_type(unsigned message_type, unsigned max_count, const char *name);
00222 
00230 void reset_throttle_group(int throttle_group);
00231 
00243 void report_message(const char *message, unsigned message_type, const MessageCode &message_code);
00244 
00263 void add_deferred_message(int message_type, MessageId message_id, size_t throttle_cutoff, int throttle_group, const char *header, const char *aggegrate);
00264 
00272 void report_deferred_messages(ParallelMachine comm);
00273 
00287 void aggregate_messages(ParallelMachine comm, std::ostringstream &os, const char *separator = ", ");
00288 
00299 std::ostream &operator<<(std::ostream &os, const MessageType &message_type);
00300 
00304 
00305 } // namespace stk
00306 
00307 #endif // STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP
Generated on Wed Apr 13 10:05:49 2011 for Sierra Toolkit by  doxygen 1.6.3