eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ActorStream':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ActorStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--PeekableStream
         |
         +--ActorStream

Package:
stx:libbasic2
Category:
Streams
Version:
rev: 1.25 date: 2021/01/20 13:03:30
user: cg
file: ActorStream.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


This class provides a hook for general objects to behave like Stream objects.
To the outside, actorStreams behave like streams and respond to the
usual stream messages (i.e. nextPut:, nextPutAll: etc).
In the inside, for every nextPut-message, the nextPutBlock is evaluated
passing the argument of nextPut: as block argument.

These blocks are to be provided by the user of the ActorStream.
Example use is in the Transcript, which is made Stream-like this way.

[Instance variables:]
    nextPutBlock    <Block>   the block to evaluate for nextPut:-messages
    nextPutAllBlock <Block>   same for nextPutAll:-messages
    nextBlock       <Block>   the Block to evaluate for the next element

copyright

COPYRIGHT (c) 1989 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

example

|s i| i := 0. s := ActorStream new. s contentsSpecies:OrderedCollection. s nextBlock:[i := i + 1. i]. s next. s next:10.

Class protocol:

instance creation
o  new
have to re-allow new - it was disabled in Stream


Instance protocol:

accessing
o  contentsSpecies
return a class of which instances will be returned, when
parts of the collection are asked for.
(see upTo-kind of methods in Stream)

o  contentsSpecies: aCollectionClass

converting
o  readStream
return a readStream from the receiver.
Since this is (hopefully) already a readStream, return self.

defining actions
o  atEndBlock: aBlock
define the block to be evaluated for every atEnd-message

o  nextBlock: aBlock
define the block to be evaluated for every next-message

o  nextPutAllBlock: aBlock
define the block to be evaluated for every nextPutAll-message.
If undefined, nextPuts will be used (as inherited)

o  nextPutBlock: aBlock
define the block to be evaluated for every nextPut-message

o  nextPutLineBlock: aBlock
define the block to be evaluated for every nextPutLineBlock-message.
If undefined, nextPutAll/nextPut will be used (as inherited)

o  peekBlock: aBlock
define the block to be evaluated for every peek-message

queries
o  atEnd
return true, if at the end - actorStreams are never

reading
o  next
return the next element from the stream by evaluating the nextBlock

o  peek
peek ahead for return the next element from the stream by evaluating the peekBlock

writing
o  flush
any buffered, but not yet written partial line?
This only happens if the actorStream has only a nextPutLine action,
but no nextPutAll/nextPut action,
and no linefeed appeared.
Useful to ensure that any remaining data is processed.

o  nextPut: aCharacter
put aCharacter onto the stream by evaluating the nextPutBlock with aCharacter as argument.
Answer anObject

o  nextPutAll: something
put all elements of something onto the stream by evaluating
the nextPutAllBlock with something as argument.
If there is no nextPutAllBlock, nextPuts will be used (as inherited).
Answer the receiver.

o  nextPutAll: count from: buffer startingAt: start
put some elements of something onto the stream by evaluating
the nextPutAllBlock with something as argument.
If there is no nextPutAllBlock, individual nextPuts will be used (as inherited).
Answer the number of elements that were appended.

o  nextPutAll: something startingAt: start to: stop
put some elements of something onto the stream by evaluating
the nextPutAllBlock with something as argument.
If there is no nextPutAllBlock, nextPuts will be used (as inherited)

o  nextPutByte: something
put something onto the stream by evaluating the nextPutBlock with
something as argument

o  nextPutLine: something
put the line onto the stream by evaluating
the nextPutLineBlock with something as argument.
If there is no nextPutLineBlock, nextPutAll/nextPut will be used (as inherited)



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 08:23:13 GMT