No, it's only additive to the #minimumDepth. I had to look at the server method where it checks the depth while reading an object graph to see if a negative depth could be specified. Check out the method:
MaObjectBuffer>> appendGraphUsing: aMaReadStrategy into: aMaSerializedGraphBuffer currentDepth: currentDepth minDepth: minDepth with: alreadyAppendedSet filer: aMaObjectFiler
I agree it seems like that could be useful to subtract, but unfortunately it doesn't do that..
----- Original Message ---- From: Keith Hodges keith_hodges@yahoo.co.uk To: magma@lists.squeakfoundation.org Sent: Monday, September 18, 2006 1:48:17 AM Subject: Read Strategies
Chris,
is it possible to set the read strategy subtractively. I.e to a deep level with the exception of one attribute.
(MaReadStrategy new) forAny: Page readToDepth: 4; forVariableNamed: 'uselessStuff' readToDepth: 0.
many thanks in advance
Keith
___________________________________________________________ The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html _______________________________________________ Magma mailing list Magma@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/magma
I had a look at tweaking MaReadStrategy with the idea of being able to specify a default depth for attributes that do not have explicitly defined depths since it is currently 0.
This is what I came up with:
Store the default depth in the depthSpecifications as an association with with no value.
onAny: aClass readToDepth: anInteger
^depthSpecifications at: aClass ifAbsentPut: [ Association key:
anInteger value: nil ].
Store the specific depths for attributes in a dictionary in the Association value.
forVariableNamed: aString onAny: aClass readToDepth: anInteger
| specs |
(aClass allInstVarNames includes: aString) ifFalse: [ MagmaUserError signal: aString , ' is not an attribute
of ' , aClass name ].
specs := depthSpecifications at: aClass ifAbsent: [ self onAny: aClass
readToDepth: 0 ].
specs value ifNil: [ specs value: (self depthDictionaryOfSize: aClass
instSize) ].
specs value at: aString put: anInteger
Update the code that uses this datastructure.
instVarMapFor: aMaClassDefinition "Answer an Array with an instVarMap of aMaClassDefinition
according to
user-declared read depths."
| specifiedDepths answer | (aMaClassDefinition isDefined and: [ depthSpecifications includesKey: aMaClassDefinition
classObject ])
ifTrue: [ specifiedDepths _ depthSpecifications at:
aMaClassDefinition classObject.
specifiedDepths value ifNil: [ answer _ specifiedDepths key ] ifNotNil: [ answer _ self depthArrayOfSize:
aMaClassDefinition namedInstSize >default: specifiedDepths key.
specifiedDepths value keysAndValuesDo: [ : eachInstVarName : eachDepth | answer at: (aMaClassDefinition allInstVarNames
indexOf: eachInstVarName)
put: eachDepth ] ] ].
^ answer
I dont know whether this scheme is as efficient as it could be, but it seemed to me that filling the depthArray with the given default value would be the best answer here.
any thoughts?
Keith
___________________________________________________________ Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html
My previous mail outlines a potential strategy for doing the following
buildReadStrategyOn: strategy
strategy minimumDepth: 0; onAny: BigFatObject readToDepth: 2 ; forVariableNamed: 'uselessInfo' onAny: BigFatObject
readToDepth: 0;
yourself.
ie. the depthPsecifications Array looks like
depthSpecifications := Association key: 2 value: (Dictionary new key: 'uselessInfo' value: 0)
Specifying the default, with exceptions whereas in the previous implementation #onAny: would simply over-ride and the second more detailed attribute spec would have been ignored.
Keith
___________________________________________________________ All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine http://uk.docs.yahoo.com/nowyoucan.html
magma@lists.squeakfoundation.org