1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2010, 2011 Free Sonftware Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 #ifndef OUTPUT_MESSAGE_ITEM_H
18 #define OUTPUT_MESSAGE_ITEM_H 1
22 A message item is a subclass of an output item (see
23 output/output-item.h).
25 A message item is an error, warning, or note to the user.
27 Message items should not be submitted directly to the output subsystem.
28 Instead, use the msg() function in libpspp/message.h, which will ensure that
29 the message gets routed properly for the PSPP user interface in use. */
32 #include "output/output-item.h"
37 struct output_item output_item;
41 struct message_item *message_item_create (const struct msg *);
43 const struct msg *message_item_get_msg (const struct message_item *);
45 /* This boilerplate for message_item, a subclass of output_item, was
46 autogenerated by mk-class-boilerplate. */
49 #include "libpspp/cast.h"
51 extern const struct output_item_class message_item_class;
53 /* Returns true if SUPER is a message_item, otherwise false. */
55 is_message_item (const struct output_item *super)
57 return super->class == &message_item_class;
60 /* Returns SUPER converted to message_item. SUPER must be a message_item, as
61 reported by is_message_item. */
62 static inline struct message_item *
63 to_message_item (const struct output_item *super)
65 assert (is_message_item (super));
66 return UP_CAST (super, struct message_item, output_item);
69 /* Returns INSTANCE converted to output_item. */
70 static inline struct output_item *
71 message_item_super (const struct message_item *instance)
73 return CONST_CAST (struct output_item *, &instance->output_item);
76 /* Increments INSTANCE's reference count and returns INSTANCE. */
77 static inline struct message_item *
78 message_item_ref (const struct message_item *instance)
80 return to_message_item (output_item_ref (&instance->output_item));
83 /* Decrements INSTANCE's reference count, then destroys INSTANCE if
84 the reference count is now zero. */
86 message_item_unref (struct message_item *instance)
88 output_item_unref (&instance->output_item);
91 /* Returns true if INSTANCE's reference count is greater than 1,
94 message_item_is_shared (const struct message_item *instance)
96 return output_item_is_shared (&instance->output_item);
99 void message_item_submit (struct message_item *);
101 #endif /* output/message-item.h */