File: OutMessages.h

package info (click to toggle)
magnus 20060324-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 19,404 kB
  • ctags: 20,466
  • sloc: cpp: 130,118; ansic: 37,076; tcl: 10,970; perl: 1,109; makefile: 963; sh: 403; yacc: 372; csh: 57; awk: 33; asm: 10
file content (344 lines) | stat: -rw-r--r-- 8,642 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
// Copyright (C) 1995 The New York Group Theory Cooperative
// See magnus/doc/COPYRIGHT for the full notice.

// Contents: Declarations of class OutMessage, and derivatives
//           ARCUpdate, CheckinMessage, FEDataUpdate, LogMessage,
//           ParseErrorMessage, StateTransition, Warning
//
// Principal Author: Roger Needham
//
// Status: useable
//
// Revision History:
//
// 01/25/98 @am added ParseParamErrorMessage class. It reports to
// the front end about parsing errors in parameters.
//
// 01/27/2000 @am added PackageInfoMessage class. 

#ifndef _OUTMESSAGES_H_
#define _OUTMESSAGES_H_

#include <stdio.h>
#include <iostream.h>
#include "Chars.h"
#include "List.h"
#include "ARC.h"
#include "ARCSlotID.h"
#include "FEData.h"
#include "VectorPtr.h"

//---------------------------------------------------------------------------//
//--------------------------- OutMessage ------------------------------------//
//---------------------------------------------------------------------------//

// At some point we should use a hidden ostream, not cout.

class OutMessage
{
public:

  void send( ) const;

protected:

  OutMessage( ) { } //@rn gcc 2.6.3 claims I need this...

  virtual void print(ostream& ostr) const = 0;
  // Used by class SessionManager.

private:

  OutMessage( const OutMessage& );
  // Hidden, not to be implemented.
};


//---------------------------------------------------------------------------//
//--------------------------- LogMessage ------------------------------------//
//---------------------------------------------------------------------------//

//@njz
//class LogMessage : public OutMessage, protected FEData, public ostrstream
class LogMessage : public OutMessage, protected FEData, public std::ostrstream
//
{
public:

  // Do *NOT* mess with the ostrstream directly, unless you like debugging.
  // It is imported publicly only to get the existing << operators.

  // The following ctors initialize a message to the logs of the views of
  // the indicated OIDs (no OID means the session log only).
  // message_level == 1 means the message should be echoed to the session log;
  // message_level == 2 means the message is only for the addressed log.

  LogMessage(int message_level = 1);

  LogMessage(OID o, int message_level = 1);

  LogMessage(OID o1, OID o2, int message_level = 1);

  LogMessage(OID o1, OID o2, OID o3, int message_level = 1);

  LogMessage( const char* msg, int message_level = 1);

  LogMessage(OID o, const char* msg, int message_level = 1);

protected:

  void print(ostream& ostr) const;  // overrides OutMessage

private:

  int num_addressees;

  VectorPtrOf<OID> oids; //[3];
  
  int level;
};


//---------------------------------------------------------------------------//
//------------------------ ParseErrorMessage --------------------------------//
//---------------------------------------------------------------------------//


class ParseErrorMessage : public OutMessage
{
public:

  ParseErrorMessage(const Chars name, const Chars diagnosis);
  // The FE requires that `diagnosis' start with an int indicating the
  // position of the error, followed by a ' '. Use 0 if no other value
  // is appropriate.

protected:

  void print(ostream& ostr) const;  // overrides OutMessage

private:

  const Chars theName;
  const Chars theDiagnosis;
};

//---------------------------------------------------------------------------//
//------------------------ PackageInfoMessage ---------------------------//
//---------------------------------------------------------------------------//

class PackageInfoMessage : public OutMessage
{
public:
  
  PackageInfoMessage(const Chars& name, const Chars& command, 
                     const Chars& ch_type, const Chars& obj);
protected:
  
  void print(ostream& ostr) const;  // overrides OutMessage
  
private:
  
  const Chars theChType;
  const Chars theName;
  const Chars theObject;
  const Chars theCommand;
 
};

//---------------------------------------------------------------------------//
//------------------------ ParseParamErrorMessage ---------------------------//
//---------------------------------------------------------------------------//

class ParseParamErrorMessage : public OutMessage
{
public:
  
  ParseParamErrorMessage(OID o,const Chars& name, 
			 const Chars& type,
			 const Chars& msg);
protected:
  
  void print(ostream& ostr) const;  // overrides OutMessage
  
private:
  
  OID theOID;
  const Chars theType;
  const Chars theName;
  const Chars theMsg;
  
};

//---------------------------------------------------------------------------//
//------------------------ ParseParamOk -------------------------------------//
//---------------------------------------------------------------------------//

class ParseParamOk : public ParseParamErrorMessage
{
public:
  
  ParseParamOk(OID o):
    ParseParamErrorMessage(o,"Parameters","","none") { }
};

//---------------------------------------------------------------------------//
//------------------------- CheckinMessage ----------------------------------//
//---------------------------------------------------------------------------//

class CheckinMessage : public OutMessage
{
public:

  CheckinMessage(const class SMObject& smo,
		 const Chars name,
		 const ListOf<OID> dependencies,
		 bool bPrintDefinition = true
		 );

  // Copy ctor and dtor supplied by compiler

protected:

  void print(ostream& ostr) const;  // overrides OutMessage

private:

  const class SMObject& theSMO;
  const Chars theName;
  const ListOf<OID> theDependencies;
  bool BPrintDefinition;

};


//---------------------------------------------------------------------------//
//-------------------------- FEDataUpdate -----------------------------------//
//---------------------------------------------------------------------------//

class FEDataUpdate : public OutMessage, protected FEData
{
public:
  
  FEDataUpdate( const Key& key, const Expression& datum )
    : theKey( key ), theDatum( datum )
  { }

protected:
  
  void print(ostream& ostr) const;  // overrides OutMessage

private:

  const Key theKey;
  const Expression theDatum;
};


//---------------------------------------------------------------------------//
//------------------------- StateTransition ---------------------------------//
//---------------------------------------------------------------------------//

class StateTransition : public OutMessage
{
public:

  enum Kind { START, SUSPEND, RESUME, TERMINATE, STALLED };

  StateTransition(Kind k, OID o) : kind( k ), oid( o ) { }

protected:
  
  void print(ostream& ostr) const;  // overrides OutMessage

private:

  const Kind kind;
  const OID oid;
};


//---------------------------------------------------------------------------//
//---------------------------- ARCUpdate ------------------------------------//
//---------------------------------------------------------------------------//

class ARCUpdate : public OutMessage
{
public:

  ARCUpdate(OID o, ARCSlotID a, ARC v) : oid( o ), asi( a ), value( v ) { }

protected:
  
  void print(ostream& ostr) const;  // overrides OutMessage

private:

  OID oid;
  ARCSlotID asi;
  ARC value;

};


//---------------------------------------------------------------------------//
//----------------------------- Warning -------------------------------------//
//---------------------------------------------------------------------------//

//@njz
//class Warning : public OutMessage, protected FEData, public ostrstream
class Warning : public OutMessage, protected FEData, public std::ostrstream
//
{
  // Do *NOT* mess with the ostrstream directly, unless you like debugging.
  // It is imported publicly only to get the existing << operators.

protected:
  
  void print(ostream& ostr) const;  // overrides OutMessage

};


//----------------------------- Message -------------------------------------//


//@njz
//class Message : public OutMessage, protected FEData, public ostrstream
class Message : public OutMessage, protected FEData, public std::ostrstream
//
{

public:
  
  Message( Chars title = "Information" ) : theTitle( title ) { }

protected:
  
  void print(ostream& ostr) const;  // overrides OutMessage

private:

  Chars theTitle;
};

//-------------------------- InvokingMessage --------------------------------//


//@njz
//class InvokingMessage : public OutMessage, protected FEData, public ostrstream
class InvokingMessage : public OutMessage, protected FEData, public std::ostrstream
//
{

public:
  
  InvokingMessage( ) { }

protected:
  
  void print(ostream& ostr) const;  // overrides OutMessage
};


#endif