2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Message.h /main/1 1996/07/29 16:56:58 cde-hp $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
27 #ifndef Message_INCLUDED
28 #define Message_INCLUDED 1
37 #include "CopyOwner.h"
40 #include "MessageArg.h"
43 namespace SP_NAMESPACE {
46 class SP_API MessageFragment {
52 MessageFragment(unsigned module, unsigned number, const char *text = 0);
53 unsigned module() const;
54 unsigned number() const;
55 const char *text() const;
57 unsigned short number_;
58 unsigned char module_;
62 #ifndef SP_NO_MESSAGE_TEXT
67 class SP_API MessageType : public MessageFragment {
76 MessageType(Severity, unsigned module, unsigned number,
77 const char *text = 0, const char *auxText = 0);
78 Severity severity() const;
79 MessageFragment auxFragment() const;
80 Boolean isError() const;
82 #ifndef SP_NO_MESSAGE_TEXT
88 class SP_API MessageType0 : public MessageType {
90 MessageType0(Severity, unsigned module, unsigned number, const char *text = 0);
93 class SP_API MessageType1 : public MessageType {
95 MessageType1(Severity, unsigned module, unsigned number, const char *text = 0);
98 class SP_API MessageType2 : public MessageType {
100 MessageType2(Severity, unsigned module, unsigned number, const char *text = 0);
103 class SP_API MessageType3 : public MessageType {
105 MessageType3(Severity, unsigned module, unsigned number, const char *text = 0);
108 class SP_API MessageType4 : public MessageType {
110 MessageType4(Severity, unsigned module, unsigned number, const char *text = 0);
113 class SP_API MessageType5 : public MessageType {
115 MessageType5(Severity, unsigned module, unsigned number, const char *text = 0);
118 class SP_API MessageType6 : public MessageType {
120 MessageType6(Severity, unsigned module, unsigned number, const char *text = 0);
123 class SP_API MessageType0L : public MessageType {
125 MessageType0L(Severity, unsigned module, unsigned number, const char *text = 0,
126 const char *auxText = 0);
129 class SP_API MessageType1L : public MessageType {
131 MessageType1L(Severity, unsigned module, unsigned number, const char *text = 0,
132 const char *auxText = 0);
135 class SP_API OpenElementInfo {
138 PackedBoolean included;
144 class SP_API Message {
148 const MessageType *type;
151 Vector<CopyOwner<MessageArg> > args;
152 Vector<OpenElementInfo> openElementInfo;
153 void swap(Message &);
154 Boolean isError() const;
157 class SP_API Messenger {
160 virtual ~Messenger();
161 void message(const MessageType0 &);
162 void message(const MessageType1 &, const MessageArg &);
163 void message(const MessageType2 &,
166 void message(const MessageType3 &,
170 void message(const MessageType4 &,
175 void message(const MessageType5 &,
181 void message(const MessageType6 &,
188 void message(const MessageType0L &, const Location &);
189 void message(const MessageType1L &, const MessageArg &, const Location &);
190 void setNextLocation(const Location &);
191 virtual void initMessage(Message &);
192 virtual void dispatchMessage(const Message &) = 0;
193 virtual void dispatchMessage(Message &);
195 void doInitMessage(Message &);
196 Boolean haveNextLocation_;
197 Location nextLocation_;
200 class SP_API ForwardingMessenger : public Messenger {
202 ForwardingMessenger(Messenger &);
203 void dispatchMessage(const Message &);
204 void dispatchMessage(Message &);
205 void initMessage(Message &);
210 class SP_API ParentLocationMessenger : public ForwardingMessenger {
212 ParentLocationMessenger(Messenger &);
213 void initMessage(Message &);
216 class SP_API NullMessenger : public Messenger {
219 void dispatchMessage(const Message &);
220 void dispatchMessage(Message &);
224 unsigned MessageFragment::module() const
230 unsigned MessageFragment::number() const
236 const char *MessageFragment::text() const
238 #ifdef SP_NO_MESSAGE_TEXT
246 MessageType::Severity MessageType::severity() const
248 return Severity(spare_);
252 MessageFragment MessageType::auxFragment() const
254 return MessageFragment(module(),
256 #ifdef SP_NO_MESSAGE_TEXT
265 Boolean MessageType::isError() const
267 return severity() != info && severity() != warning;
271 Boolean Message::isError() const
273 return type->isError();
280 #endif /* not Message_INCLUDED */