WeakInterestConverter.st
author Claus Gittinger <cg@exept.de>
Wed, 21 May 1997 14:17:57 +0200
changeset 2656 c71176e82d85
child 5273 7fc2109a0ed0
permissions -rw-r--r--
intitial checkin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2656
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
Object subclass:#WeakInterestConverter
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
	instanceVariableNames:'destinationHolder selector aspect'
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
	classVariableNames:''
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
	poolDictionaries:''
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
	category:'Interface-Support-Models'
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
!
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
!WeakInterestConverter class methodsFor:'documentation'!
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
documentation
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
    these are much like InterestConverters; however, the reference to
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
    the destination is weak, which allows for them to be garbage collected.
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
    [author:]
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
        Claus Gittinger
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
! !
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
!WeakInterestConverter class methodsFor:'instance creation'!
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
destination:anObject selector:aSelector
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
    "create & return an interestConverter, which sends aSelector
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
     to anObject when a change notification arrives"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
    ^ self basicNew destination:anObject selector:aSelector
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
    "Created: 21.5.1997 / 14:08:49 / cg"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
!
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
destination:anObject selector:aSelector aspect:aspect
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
    "create & return an interestConverter, which sends aSelector
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
     to anObject when a change notification for aspect arrives"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
    ^ self basicNew destination:anObject selector:aSelector aspect:aspect
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
    "Created: 21.5.1997 / 14:08:49 / cg"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
! !
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
!WeakInterestConverter methodsFor:'accessing'!
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
aspect
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    "return my aspect (if any)"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    ^ aspect
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
    "Created: 21.5.1997 / 14:08:49 / cg"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
!
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
destination
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    "return my destination"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    ^ destinationHolder at:1
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    "Created: 21.5.1997 / 14:08:49 / cg"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
!
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
destination:dest selector:sel
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    "set destination and selector"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    destinationHolder := WeakArray with:dest.
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    selector := sel
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    "Created: 21.5.1997 / 14:08:49 / cg"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
!
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
destination:dest selector:sel aspect:a
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    "set destination, selector and aspect"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
    destinationHolder := WeakArray with:dest.
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    selector := sel.
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
    aspect := a
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    "Created: 21.5.1997 / 14:08:49 / cg"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
! !
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
!WeakInterestConverter methodsFor:'change & update'!
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
update:something with:aParameter from:someObject
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    |destination|
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    (aspect isNil or:[aspect == something]) ifTrue:[
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
        destination := destinationHolder at:1.
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
        destination notNil ifTrue:[
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
            destination perform:selector
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
        ]
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    ]
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    "Modified: 8.3.1996 / 22:41:53 / cg"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    "Created: 21.5.1997 / 14:08:49 / cg"
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
! !
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
!WeakInterestConverter class methodsFor:'documentation'!
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
version
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    ^ '$Header: /cvs/stx/stx/libbasic/WeakInterestConverter.st,v 1.1 1997-05-21 12:17:57 cg Exp $'
c71176e82d85 intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
! !