blob: 15ca5ad27e46643b141ebf361eea29121dec91f6 (
plain)
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
|
/*
* The Unix Channel
*
* by Michel Beaudouin-Lafon
*
* Copyright 1990-1993
* Laboratoire de Recherche en Informatique (LRI)
*
* Client side: services
*
* $Id$
* $CurLog$
*/
#ifndef Service_H_
#define Service_H_
#include "Message.h"
#include "MsgStream.h"
#include "error.h"
#include "cplus_bugs.h"
#include "ccu/List.h"
class UchService;
// events are messages sent by a server that are linked into an event list
//
class UchEventMsg : public UchMessage {
friend class UchService;
protected:
UchMsgStream* From;
public:
inline UchEventMsg () : UchMessage (), From (0) { }
~UchEventMsg ();
inline UchMsgStream* GetSource () { return From; }
};
class UchGenEvtMsg : public UchEventMsg {
protected:
UchMessage* Msg;
public:
inline UchGenEvtMsg () : UchEventMsg () { Msg = 0; }
inline UchGenEvtMsg (UchMessage* m) : UchEventMsg () { Msg = m; }
~UchGenEvtMsg ();
void WriteTo (UchMsgBuffer&);
void ReadFrom (UchMsgBuffer&, lword);
inline void SetMsg (UchMessage* m) { if (Msg) delete Msg; Msg = m; }
inline UchMessage* GetMsg () { return Msg; }
};
// class for storing and retrieving events
//
class UchEvtMsgQueue : public CcuSmartData {
protected:
#ifndef CPLUS_BUG19
CcuListOf <UchEventMsg> Queue;
#else
CcuList Queue;
#endif
public:
UchEvtMsgQueue ();
~UchEvtMsgQueue ();
inline void Put (UchEventMsg* m) { Queue.Append (m); }
#ifndef CPLUS_BUG19
inline UchEventMsg* Peek () { return Queue.First (); }
inline UchEventMsg* Get () { return Queue.RemoveFirst (); }
#else
inline UchEventMsg* Peek () { return (UchEventMsg*) Queue.First (); }
inline UchEventMsg* Get () { return (UchEventMsg*) Queue.RemoveFirst (); }
#endif
inline void PutBack (UchEventMsg* m) { Queue.Prepend (m); }
#ifndef CPLUS_BUG19
inline operator const CcuListOf <UchEventMsg>& () const { return Queue; }
#else
inline operator const CcuList& () const { return Queue; }
#endif
};
PointerClass (pUchEvtMsgQueue, UchEvtMsgQueue)
// UchService is the client's view of a server
// we use smart pointers so that the event queue can be shared
//
class UchService : public UchMsgStream {
protected:
pUchEvtMsgQueue EvQueue;
public:
UchService ();
UchService (UchAddress*);
UchService (const UchService&);
~UchService ();
UchChannel* Copy () const;
void SetEvQueue (UchEvtMsgQueue*);
UchEventMsg* PeekEvent (bool = TRUE);
UchEventMsg* GetEvent (bool = TRUE);
void PutEvent (UchEventMsg*);
void PutBackEvent (UchEventMsg*);
};
#endif /* Service_H_ */
|