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