author | Claus Gittinger <cg@exept.de> |
Thu, 07 Dec 1995 11:34:06 +0100 | |
changeset 134 | f83c245371c2 |
parent 114 | e577a2f332d0 |
child 137 | 449db28201ec |
permissions | -rw-r--r-- |
88 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
114
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
96
diff
changeset
|
3 |
All Rights Reserved |
88 | 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 |
||
55 | 13 |
'From Smalltalk/X, Version:2.10.5 on 26-mar-1995 at 4:21:12 am'! |
54 | 14 |
|
55 | 15 |
Model subclass:#Plug |
54 | 16 |
instanceVariableNames:'simulatedProtocol' |
17 |
classVariableNames:'' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Kernel-Objects' |
|
20 |
! |
|
21 |
||
22 |
!Plug class methodsFor:'documentation'! |
|
23 |
||
88 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
114
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
96
diff
changeset
|
27 |
All Rights Reserved |
88 | 28 |
|
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
54 | 38 |
version |
114
e577a2f332d0
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
96
diff
changeset
|
39 |
^ '$Header: /cvs/stx/stx/libview2/Plug.st,v 1.6 1995-11-11 16:04:51 cg Exp $' |
54 | 40 |
! |
41 |
||
42 |
documentation |
|
43 |
" |
|
44 |
A Plug is an objcet which simulates a protocol and evaluates |
|
45 |
a corresponding block when receiving messages. |
|
46 |
Its main use is for the demo doIts, to play the role of a model. |
|
47 |
Plugs are not used in the system and exist as a demo only. |
|
48 |
This class may be changed/removed/replaced without notice. |
|
49 |
" |
|
50 |
! |
|
51 |
||
52 |
examples |
|
53 |
" |
|
54 |
|plug| |
|
55 |
||
56 |
plug := Plug new. |
|
57 |
plug respondTo:#foo with:[Transcript showCr:'received foo']. |
|
58 |
plug respondTo:#foo: with:[:arg | Transcript showCr:'received foo: ', arg printString]. |
|
59 |
||
60 |
plug foo. |
|
61 |
plug foo:'some argument' |
|
62 |
" |
|
63 |
! ! |
|
64 |
||
65 |
!Plug class methodsFor:'instance creation'! |
|
66 |
||
67 |
new |
|
68 |
^ super basicNew privateInitialize |
|
69 |
! ! |
|
70 |
||
71 |
!Plug methodsFor:'message sending'! |
|
72 |
||
73 |
doesNotUnderstand:aMessage |
|
74 |
|block| |
|
75 |
||
76 |
block := simulatedProtocol at:aMessage selector ifAbsent:[]. |
|
77 |
block isNil ifTrue:[ |
|
82 | 78 |
^ super doesNotUnderstand:aMessage |
54 | 79 |
]. |
80 |
^ block valueWithArguments:(aMessage arguments) |
|
81 |
! ! |
|
82 |
||
82 | 83 |
!Plug methodsFor:'queries'! |
84 |
||
85 |
respondsTo:aSelector |
|
86 |
(simulatedProtocol includesKey:aSelector) ifTrue:[^ true]. |
|
87 |
^ super respondsTo:aSelector |
|
88 |
! ! |
|
89 |
||
55 | 90 |
!Plug methodsFor:'protocol definition'! |
91 |
||
92 |
respondTo:aSelector with:aBlock |
|
93 |
simulatedProtocol at:aSelector put:aBlock |
|
94 |
! ! |
|
95 |
||
54 | 96 |
!Plug methodsFor:'initialization'! |
97 |
||
98 |
privateInitialize |
|
99 |
"this method is NOT called initialize to allow plugging that |
|
100 |
selector ..." |
|
101 |
||
102 |
simulatedProtocol := IdentityDictionary new. |
|
103 |
! ! |
|
104 |