Sierra Toolkit  Version of the Day
RuntimeMessage.hpp
Go to the documentation of this file.
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #ifndef STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP
10 #define STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP
11 
12 #include <iosfwd>
13 #include <vector>
14 #include <cstddef>
15 
16 #include <stk_util/parallel/Parallel.hpp>
17 
18 namespace stk_classic {
19 
24 
42 typedef ptrdiff_t MessageId;
43 // typedef std::vector<void *>::difference_type MessageId;
44 
55  MSG_DOOMED = 1,
58 
59  MSG_TYPE_MASK = 0x0FFFFFFF,
60  MSG_SYMMETRIC = 0x80000000,
61  MSG_DEFERRED = 0x40000000,
62  MSG_UNUSED0 = 0x20000000,
63  MSG_UNUSED1 = 0x10000000
64 };
65 
76  MSG_APPLICATION = 0,
77  MSG_TIME_STEP = 1
78 };
79 
84 struct Throttle
85 {
96  Throttle(size_t cutoff, int group)
97  : m_cutoff(cutoff),
98  m_group(group),
99  m_count(0)
100  {}
101 
102  size_t m_cutoff;
103  int m_group;
104  size_t m_count;
105 };
106 
125 {
136  MessageCode(size_t throttle_cutoff = 5, int throttle_group = MSG_APPLICATION)
137  : m_id(&m_id - (MessageId *) 0),
138  m_throttle(throttle_cutoff, throttle_group)
139  {}
140 
156  MessageCode(MessageId message_id, size_t throttle_cutoff, int throttle_group)
157  : m_id(message_id),
158  m_throttle(throttle_cutoff, throttle_group)
159  {}
160 
162 
165 };
166 
174 unsigned get_message_count(unsigned message_type);
175 
182 void reset_message_count(unsigned message_type);
183 
192 void set_max_message_count(unsigned message_type, unsigned max_count);
193 
201 unsigned get_max_message_count(unsigned message_type);
202 
210 const std::string &get_message_name(unsigned message_type);
211 
222 void register_message_type(unsigned message_type, unsigned max_count, const char *name);
223 
231 void reset_throttle_group(int throttle_group);
232 
244 void report_message(const char *message, unsigned message_type, const MessageCode &message_code);
245 
264 void add_deferred_message(int message_type, MessageId message_id, size_t throttle_cutoff, int throttle_group, const char *header, const char *aggegrate);
265 
274 
288 void aggregate_messages(ParallelMachine comm, std::ostringstream &os, const char *separator = ", ");
289 
300 std::ostream &operator<<(std::ostream &os, const MessageType &message_type);
301 
305 
306 } // namespace stk_classic
307 
308 #endif // STK_UTIL_ENVIRONMENT_RUNTIMEMESSAGE_HPP
void add_deferred_message(int message_type, MessageId message_id, size_t throttle_cutoff, int throttle_group, const char *header, const char *aggegrate)
Function add_deferred_message adds a message to the deferred message queue.
Message is an exception.
MessageType
Enumeration MessageType declares the global message types.
Message is informational.
ptrdiff_t MessageId
Typedef MessageId defines a message identifier.
ThrottleGroup
Enumeration ThrottleGroup lists defined throttling groups.
void reset_message_count(unsigned message_type)
Member function reset_message_count ...
void register_message_type(unsigned message_type, unsigned max_count, const char *name)
Member function set_message_name ...
size_t m_count
Number which have been displayed.
Class MessageCode declares a message identifier and throttle characteristics for a message...
Throttle m_throttle
Throttle characteristics.
MessageCode(MessageId message_id, size_t throttle_cutoff, int throttle_group)
Class Throttle describes the cutoff limits for a message throttle.
const std::string & get_message_name(unsigned message_type)
Member function get_message_name ...
unsigned get_max_message_count(unsigned message_type)
Member function get_max_message_count ...
void report_message(const char *message, unsigned message_type, const MessageCode &message_code)
Member function report_message ...
Message is a warning.
unsigned get_message_count(unsigned message_type)
Member function get_message_count ...
size_t m_cutoff
Maximum number to display.
Message is a fatal error.
Throttle(size_t cutoff, int group)
Message is symmetrical.
Sierra Toolkit.
void set_max_message_count(unsigned message_type, unsigned max_count)
Member function set_max_message_count ...
void reset_throttle_group(int throttle_group)
Function reset_message_group sets the count to zero of all messages in the specified throttle group...
MPI_Comm ParallelMachine
Definition: Parallel.hpp:32
MessageId m_id
Message identifier.
int m_group
Throttle group of message.
Message is deferred.
void report_deferred_messages(ParallelMachine comm)
Function report_deferred_messages aggregates and reports the message on the root processor.
MessageCode(size_t throttle_cutoff=5, int throttle_group=MSG_APPLICATION)
static MessageCode s_defaultMessageCode
Default message code.
void aggregate_messages(ParallelMachine comm, std::ostringstream &os, const char *separator)
Function aggregate_messages writes a message message to the output string by joining the messages fro...