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