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
|
/*
* The Unix Channel
*
* by Michel Beaudouin-Lafon
*
* Copyright 1990-1993
* Laboratoire de Recherche en Informatique (LRI)
*
* UchMessage streams
*
* $Id$
* $CurLog$
*/
#ifndef MsgStream_H_
#define MsgStream_H_
#include "Stream.h"
#include "ccu/SmartPointer.h"
#include "MsgBuffer.h"
class UchMessage;
class UchMsgStream : public UchStream {
private:
protected:
UchMsgBuffer InBuffer;
int InSize;
UchMsgBuffer OutBuffer;
int OutSize;
enum STATE { WAITING, GOT_TYPE, GOT_LENGTH, DONE};
enum TYPE { MSG = 1, ASK, ANS, SYNC, ASYNC, OK };
STATE State;
bool BufferedMessages;
UchMsgBuffer Buffered;
bool WaitingForAnswer;
bool WaitingReply;
int InLength;
byte InType;
bool Sync;
void ProcessInput (UchMsgBuffer&, bool);
int ReadInput ();
public:
UchMsgStream ();
UchMsgStream (const UchMsgStream&);
UchMsgStream (UchAddress*, UchAddress*);
~UchMsgStream ();
void InputBuffer (int min, int grow, int max);
void OutputBuffer (int min, int grow, int max);
inline void FlushSize (int n) { OutSize = n; }
UchChannel* Copy () const;
void HandleRead ();
void HandleWrite ();
bool HandleSelect ();
inline bool GetSyncMode () { return Sync; }
inline void SetSyncMode (bool s) { Sync = s; Flush (); }
virtual bool NewMessage (UchMsgBuffer&, bool);
virtual void* ConvertAnswer (UchMsgBuffer&);
virtual void Delete ();
void Send (UchMessage&, bool = FALSE);
void* Ask (UchMessage&);
void Reply (UchMessage&);
void Flush ();
void Send (UchMsgBuffer&, bool = FALSE);
};
#endif /* MsgStream_H_ */
|