home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnusmalltalk / stream.st < prev    next >
Text File  |  1992-02-15  |  3KB  |  140 lines

  1. "======================================================================
  2. |
  3. |   Stream Method Definitions
  4. |
  5.  ======================================================================"
  6.  
  7.  
  8. "======================================================================
  9. |
  10. | Copyright (C) 1990, 1991, 1992 Free Software Foundation, Inc.
  11. | Written by Steve Byrne.
  12. |
  13. | This file is part of GNU Smalltalk.
  14. |
  15. | GNU Smalltalk is free software; you can redistribute it and/or modify it
  16. | under the terms of the GNU General Public License as published by the Free
  17. | Software Foundation; either version 1, or (at your option) any later version.
  18. | GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  19. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  20. | FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  21. | details.
  22. | You should have received a copy of the GNU General Public License along with
  23. | GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  24. | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  25. |
  26.  ======================================================================"
  27.  
  28.  
  29. "
  30. |     Change Log
  31. | ============================================================================
  32. | Author       Date       Change 
  33. | sbb         10 Jul 91      Added store: for streams (can't imagine why it wasn't
  34. |              here before).
  35. |
  36. | sbb         16 Mar 91      Class creation now separate statement.
  37. |
  38. | sbyrne     19 May 90      Added print: for streams.
  39. |
  40. | sbyrne     19 Sep 89      Changed to use real method categories.
  41. |
  42. | sbyrne      4 Jun 89      Made more of the methods defined here, but the class
  43. |              itself stays abstract; no implementations are given
  44. |              for next, nextPut:, etc.
  45. |
  46. | sbyrne     25 Apr 89      created.
  47. |
  48. "
  49.  
  50. Object subclass: #Stream
  51.        instanceVariableNames: ''
  52.        classVariableNames: ''
  53.        poolDictionaries: ''
  54.        category: nil
  55. !
  56.  
  57. Stream comment: 
  58. 'I am an abstract class that provides interruptable sequential access to
  59. objects.  I can return successive objects from a source, or accept
  60. successive objects and store them sequentially on a sink.  I provide
  61. some simple iteration over the contents of one of my instances, and 
  62. provide for writing collections sequentially.' !
  63.  
  64. !Stream methodsFor: 'accessing-reading'!
  65.  
  66. next
  67.     self subclassResponsibility
  68. !
  69.  
  70. next: anInteger
  71.     "### I think that I should be able to implement this, but I'm not sure
  72.     how to obtain the class element type in a generic fashion"
  73.     self subclassResponsibility
  74. !
  75.  
  76. nextMatchFor: anObject
  77.     ^anObject = self next
  78. !
  79.  
  80. contents
  81.     "### I think that this should be implemented here, but right now I can't
  82.     exactly see how to do it."
  83.     self subclassResponsibility
  84. !!
  85.  
  86.  
  87.  
  88. !Stream methodsFor: 'accessing-writing'!
  89.  
  90. nextPut: anObject
  91.     self subclassResponsibility
  92. !
  93.  
  94. nextPutAll: aCollection
  95.     aCollection do: [ :element | self nextPut: element ].
  96.     ^aCollection
  97. !
  98.  
  99. next: anInteger put: anObject
  100.     anInteger timesRepeat: [ self nextPut: anObject ].
  101.     ^anObject
  102. !!
  103.  
  104.  
  105.  
  106. !Stream methodsFor: 'testing'!
  107.  
  108. atEnd
  109.     self subclassResponsibility
  110. !!
  111.  
  112.  
  113.  
  114. !Stream methodsFor: 'enumerating'!
  115.  
  116. do: aBlock
  117.     [self atEnd] whileFalse:
  118.         [aBlock value: self next ]
  119.  
  120. !!
  121.  
  122.  
  123.  
  124. !Stream methodsFor: 'printing'!
  125.  
  126. print: anObject
  127.     anObject printOn: self
  128. !!
  129.  
  130.  
  131.  
  132. !Stream methodsFor: 'storing'!
  133.  
  134. store: anObject
  135.     anObject storeOn: self
  136. !!
  137.  
  138.