author | Claus Gittinger <cg@exept.de> |
Fri, 20 Sep 1996 09:34:11 +0200 | |
changeset 446 | cdc38afc4957 |
parent 337 | a2266ae17d1b |
child 554 | 84eb4d58dd04 |
permissions | -rw-r--r-- |
166 | 1 |
" |
2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
Stream subclass:#ActorStream |
|
252 | 14 |
instanceVariableNames:'nextPutBlock nextPutAllBlock nextBlock' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Streams' |
|
166 | 18 |
! |
19 |
||
20 |
!ActorStream class methodsFor:'documentation'! |
|
21 |
||
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
This class provides a hook for general objects to behave like Stream objects. |
|
39 |
To the outside, actorStreams behave like streams and respond to the |
|
40 |
usual stream messages (i.e. nextPut:, nextPutAll: etc). |
|
41 |
In the inside, for every nextPut-message, the nextPutBlock is evaluated |
|
42 |
passing the argument of nextPut: as block argument. |
|
43 |
||
44 |
These blocks are to be provided by the user of the ActorStream. |
|
45 |
Example use is in the Transcript, which is made Stream-like this way. |
|
46 |
||
252 | 47 |
[Instance variables:] |
48 |
nextPutBlock <Block> the block to evaluate for nextPut:-messages |
|
49 |
nextPutAllBlock <Block> same for nextPutAll:-messages |
|
50 |
nextBlock <Block> the Block to evaluate for the next element |
|
51 |
||
259 | 52 |
[author:] |
53 |
Claus Gittinger |
|
54 |
||
252 | 55 |
[See also:] |
56 |
TextCollector |
|
57 |
||
166 | 58 |
" |
59 |
! ! |
|
60 |
||
61 |
!ActorStream class methodsFor:'instance creation'! |
|
62 |
||
63 |
new |
|
64 |
"have to re-allow new - it was disabled in Stream" |
|
65 |
^ self basicNew |
|
66 |
! ! |
|
67 |
||
68 |
!ActorStream methodsFor:'accessing-read/write'! |
|
69 |
||
70 |
next |
|
71 |
"return the next element from the stream by evaluating the nextBlock" |
|
72 |
||
73 |
nextBlock notNil ifTrue:[ |
|
74 |
^ nextBlock value |
|
75 |
]. |
|
76 |
self error:'action for next is undefined' |
|
77 |
! |
|
78 |
||
79 |
nextPut:something |
|
80 |
"put something onto the stream by evaluating the nextPutBlock with |
|
81 |
something as argument" |
|
82 |
||
83 |
nextPutBlock notNil ifTrue:[ |
|
84 |
^ nextPutBlock value:something |
|
85 |
]. |
|
86 |
self error:'action for nextPut: is undefined' |
|
87 |
! |
|
88 |
||
89 |
nextPutAll:something |
|
90 |
"put all elements of something onto the stream by evaluating |
|
91 |
the nextPutAllBlock with something as argument" |
|
92 |
||
93 |
nextPutAllBlock notNil ifTrue:[ |
|
94 |
^ nextPutAllBlock value:something |
|
95 |
]. |
|
96 |
super nextPutAll:something |
|
97 |
! ! |
|
98 |
||
99 |
!ActorStream methodsFor:'defining actions'! |
|
100 |
||
101 |
nextBlock:aBlock |
|
102 |
"define the block to be evaluated for every next-message" |
|
103 |
||
104 |
nextBlock := aBlock |
|
105 |
! |
|
106 |
||
107 |
nextPutAllBlock:aBlock |
|
108 |
"define the block to be evaluated for every nextPutAll-message" |
|
109 |
||
110 |
nextPutAllBlock := aBlock |
|
111 |
! |
|
112 |
||
113 |
nextPutBlock:aBlock |
|
114 |
"define the block to be evaluated for every nextPut-message" |
|
115 |
||
116 |
nextPutBlock := aBlock |
|
117 |
! ! |
|
118 |
||
119 |
!ActorStream methodsFor:'queries'! |
|
120 |
||
121 |
atEnd |
|
122 |
"return true, if at the end - actorStreams are never" |
|
123 |
||
124 |
^ false |
|
125 |
! ! |
|
126 |
||
127 |
!ActorStream class methodsFor:'documentation'! |
|
128 |
||
129 |
version |
|
446
cdc38afc4957
code cleanup, comments & removed unused files in Make.proto
Claus Gittinger <cg@exept.de>
parents:
337
diff
changeset
|
130 |
^ '$Header: /cvs/stx/stx/libbasic2/ActorStream.st,v 1.5 1996-09-20 07:34:04 cg Exp $' |
166 | 131 |
! ! |