author | Claus Gittinger <cg@exept.de> |
Tue, 14 Nov 1995 20:02:34 +0100 | |
changeset 544 | d78012b20769 |
parent 528 | a083413dfbe8 |
child 611 | 80bb0f1a7bab |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
155 | 3 |
All Rights Reserved |
0 | 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 |
||
54 | 13 |
Stream subclass:#ActorStream |
0 | 14 |
instanceVariableNames:'nextPutBlock nextPutAllBlock nextBlock' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Streams' |
|
18 |
! |
|
19 |
||
28 | 20 |
!ActorStream class methodsFor:'documentation'! |
21 |
||
82 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
155 | 25 |
All Rights Reserved |
82 | 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 |
version |
|
528
a083413dfbe8
converted version methods from comment-only to returning-a-string
Claus Gittinger <cg@exept.de>
parents:
384
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libbasic/Attic/ActorStr.st,v 1.13 1995-11-11 14:26:26 cg Exp $' |
82 | 38 |
! |
39 |
||
28 | 40 |
documentation |
41 |
" |
|
155 | 42 |
This class provides a hook for general objects to behave like Stream objects. |
43 |
To the outside, actorStreams behave like streams and respond to the |
|
44 |
usual stream messages (i.e. nextPut:, nextPutAll: etc). |
|
77 | 45 |
In the inside, for every nextPut-message, the nextPutBlock is evaluated |
46 |
passing the argument of nextPut: as block argument. |
|
54 | 47 |
|
77 | 48 |
These blocks are to be provided by the user of the ActorStream. |
49 |
Example use is in the Transcript, which is made Stream-like this way. |
|
0 | 50 |
|
77 | 51 |
Instance variables: |
0 | 52 |
|
77 | 53 |
nextPutBlock <Block> the block to evaluate for nextPut:-messages |
54 |
nextPutAllBlock <Block> same for nextPutAll:-messages |
|
55 |
nextBlock <Block> the Block to evaluate for the next element |
|
28 | 56 |
" |
57 |
! ! |
|
0 | 58 |
|
59 |
!ActorStream class methodsFor:'instance creation'! |
|
60 |
||
61 |
new |
|
62 |
"have to re-allow new - it was disabled in Stream" |
|
63 |
^ self basicNew |
|
64 |
! ! |
|
65 |
||
66 |
!ActorStream methodsFor:'defining actions'! |
|
67 |
||
68 |
nextBlock:aBlock |
|
69 |
"define the block to be evaluated for every next-message" |
|
70 |
||
71 |
nextBlock := aBlock |
|
72 |
! |
|
73 |
||
74 |
nextPutBlock:aBlock |
|
75 |
"define the block to be evaluated for every nextPut-message" |
|
76 |
||
77 |
nextPutBlock := aBlock |
|
78 |
! |
|
79 |
||
80 |
nextPutAllBlock:aBlock |
|
81 |
"define the block to be evaluated for every nextPutAll-message" |
|
82 |
||
83 |
nextPutAllBlock := aBlock |
|
84 |
! ! |
|
85 |
||
54 | 86 |
!ActorStream methodsFor:'queries'! |
87 |
||
88 |
atEnd |
|
89 |
"return true, if at the end - actorStreams are never" |
|
90 |
||
91 |
^ false |
|
92 |
! ! |
|
93 |
||
155 | 94 |
!ActorStream methodsFor:'ignored style messages'! |
95 |
||
96 |
bold |
|
97 |
"ignored here. |
|
98 |
this allows actorStreams to be used interchangeable with printStreams" |
|
99 |
||
100 |
^ self |
|
101 |
! |
|
102 |
||
103 |
normal |
|
104 |
"ignored here. |
|
105 |
this allows actorStreams to be used interchangeable with printStreams" |
|
106 |
||
107 |
^ self |
|
108 |
! |
|
109 |
||
110 |
italic |
|
111 |
"ignored here. |
|
112 |
this allows actorStreams to be used interchangeable with printStreams" |
|
113 |
||
114 |
^ self |
|
115 |
! ! |
|
116 |
||
0 | 117 |
!ActorStream methodsFor:'accessing-read/write'! |
118 |
||
119 |
next |
|
120 |
"return the next element from the stream by evaluating the nextBlock" |
|
121 |
||
122 |
nextBlock notNil ifTrue:[ |
|
155 | 123 |
^ nextBlock value |
0 | 124 |
]. |
125 |
self error:'action for next is undefined' |
|
126 |
! |
|
127 |
||
128 |
nextPut:something |
|
129 |
"put something onto the stream by evaluating the nextPutBlock with |
|
130 |
something as argument" |
|
131 |
||
132 |
nextPutBlock notNil ifTrue:[ |
|
155 | 133 |
^ nextPutBlock value:something |
0 | 134 |
]. |
54 | 135 |
self error:'action for nextPut: is undefined' |
0 | 136 |
! |
137 |
||
138 |
nextPutAll:something |
|
139 |
"put all elements of something onto the stream by evaluating |
|
140 |
the nextPutAllBlock with something as argument" |
|
141 |
||
142 |
nextPutAllBlock notNil ifTrue:[ |
|
155 | 143 |
^ nextPutAllBlock value:something |
0 | 144 |
]. |
145 |
super nextPutAll:something |
|
146 |
! ! |