interrest changes in model (nonWeak stuff)
authorClaus Gittinger <cg@exept.de>
Fri, 19 Apr 1996 17:56:08 +0200
changeset 188 38e92ed0e1b9
parent 187 9e35ae67f07c
child 189 a2c84aaac32d
interrest changes in model (nonWeak stuff)
Model.st
--- a/Model.st	Thu Apr 18 16:42:30 1996 +0200
+++ b/Model.st	Fri Apr 19 17:56:08 1996 +0200
@@ -64,13 +64,20 @@
 addDependent:anObject
     "make the argument, anObject be a dependent of the receiver"
 
-    |deps|
+    [
+        |deps|
 
-    [
         deps := dependents.
+        "/
+        "/ store the very first dependent directly in
+        "/ the dependents instVar
+        "/
         (deps isNil and:[anObject isCollection not]) ifTrue:[
             dependents := anObject
         ] ifFalse:[
+            "/
+            "/ store more dependents in the dependents collection
+            "/
             deps isCollection ifTrue:[
                 deps add:anObject
             ] ifFalse:[
@@ -79,19 +86,36 @@
         ]
     ] valueUninterruptably
 
-    "Modified: 20.2.1996 / 19:22:53 / cg"
+    "Modified: 19.4.1996 / 12:24:46 / cg"
 !
 
 dependents
     "return a Collection of dependents - nil if there is none"
 
-    ^ dependents
+    dependents isNil ifTrue:[^ nil].
+    dependents isCollection ifTrue:[
+        ^ dependents
+    ].
+    ^ IdentitySet with:dependents
+
+    "Modified: 19.4.1996 / 12:22:04 / cg"
 !
 
 dependents:aCollection
     "set the collection of dependents"
 
+    |dep|
+
+    aCollection size == 1 ifTrue:[
+        dep := aCollection first.
+        dep isCollection ifFalse:[
+            dependents := aCollection first.
+            ^ self
+        ]
+    ].
     dependents := aCollection
+
+    "Modified: 19.4.1996 / 12:23:05 / cg"
 !
 
 dependentsDo:aBlock
@@ -110,21 +134,31 @@
 !
 
 release
+    "remove all dependencies from the receiver"
+
     dependents := nil
+
+    "Modified: 19.4.1996 / 10:31:35 / cg"
 !
 
 removeDependent:anObject
     "make the argument, anObject be independent of the receiver"
 
-    |deps sz|
+    [
+        |deps sz dep|
 
-    [
         deps := dependents.
         deps notNil ifTrue:[
             deps isCollection ifTrue:[
                 deps remove:anObject ifAbsent:[].
                 (sz := deps size) == 0 ifTrue:[
                     dependents := nil
+                ] ifFalse:[
+                    sz == 1 ifTrue:[
+                        (dep := deps first) isCollection ifFalse:[
+                            dependents := dep
+                        ]
+                    ]
                 ]
             ] ifFalse:[
                 dependents := nil
@@ -132,7 +166,48 @@
         ]
     ] valueUninterruptably
 
-    "Modified: 20.2.1996 / 19:23:26 / cg"
+    "Modified: 19.4.1996 / 12:24:24 / cg"
+! !
+
+!Model methodsFor:'dependents access (non weak)'!
+
+addNonWeakDependent:anObject
+    "make the argument, anObject be a dependent of the receiver.
+     Since all dependencies are nonWeak in Model, this is simply
+     forwarded to addDependent:"
+
+    ^ self addDependent:anObject
+
+    "Created: 19.4.1996 / 10:28:53 / cg"
+!
+
+interrests
+    "return a Collection of interrests - nil if there is none.
+     Here, we use the normal dependents collection for interrests."
+
+    ^ dependents
+
+    "Created: 19.4.1996 / 12:28:23 / cg"
+!
+
+nonWeakDependents
+    "return a Collection of dependents - nil if there is none.
+     Since all dependencies are nonWeak in Model, this is a dummy."
+
+    ^ dependents
+
+    "Created: 19.4.1996 / 10:29:43 / cg"
+    "Modified: 19.4.1996 / 12:25:54 / cg"
+!
+
+removeNonWeakDependent:anObject
+    "make the argument, anObject be independent of the receiver.
+     Since all dependencies are nonWeak in Model, this is simply
+     forwarded to removeDependent:"
+
+    ^ self removeDependent:anObject
+
+    "Created: 19.4.1996 / 12:19:40 / cg"
 ! !
 
 !Model methodsFor:'drawing'!
@@ -152,5 +227,5 @@
 !Model class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/Model.st,v 1.19 1996-02-20 18:24:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/Model.st,v 1.20 1996-04-19 15:56:08 cg Exp $'
 ! !