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