|
|
Class: BinaryObjectStorage
Object
|
+--BinaryObjectStorage
- Package:
- stx:libboss
- Category:
- System-BinaryStorage
- Version:
- rev:
1.27
date: 2007/10/01 10:14:15
- user: cg
- file: BinaryObjectStorage.st directory: libboss
- module: stx stc-classLibrary: libboss
- Author:
- Claus Gittinger
This class provides an ST-80 compatible (I hope) interface to
BinaryInput- and BinaryOutputManager.
The protocol is not complete, PP seems to offer more (skip etc.)
this will be added as time goes by ...
The protocol has been implemented by 'guessing' what users of this
class expect from reading PD code.
No warranty here for completeness. I depend on your feedback in adding
more for compatibility; let me know what is required ....
BinaryIOManager
ObsoleteObject
PersistencyManager
Object
[binary object storage]
Signal constants
-
binaryLoadErrorSignal
-
return the signal raised, when a binary load fails for some reason.
This is the parent signal for all other binary load errors;
therefore, it can be used to handle all errors in a single handler.
-
changedIndexedInstSignal
-
return the signal raised, when an instance of a class is about to be filed in,
which has different indexed instvars (i.e. byte-insts vs. pointers etc)
-
changedInstLayoutSignal
-
return the signal raised, when an instance of a class is about to be filed in,
which has a different inst layout (i.e. the size matches, but the order of
instvars has changed)
-
changedInstSizeSignal
-
return the signal raised, when an instance of a class is about to be filed in,
which has a different inst-size (i.e. the number of named instvars has changed)
-
invalidBinaryFormatErrorSignal
-
return the signal raised, when a binary load fails due to format errors,
for example, if you try to fileIn a binary object from another smalltalk,
or from a stream which does not contain binary objects at all.
-
invalidClassSignal
-
return the signal raised, when an instance of a class is about to be filed in,
which is no longer compatible to the object,
or when such a class is referenced in an instvar of a loaded object.
-
nonexistingClassSignal
-
return the signal raised, when an instance of a class is about to be filed in,
which does not (or no-longer) exist.
-
requestConversionSignal
-
return the signal raised, when the binary storage manager requests
an obsolete object to be converted.
The handler gets an instance of a dummy class (which has the
old classes structure) and the new class as parameters, and is supposed to
return an instance of the new class with the dummy-instances contents.
instance creation
-
onNew: aStream
-
return an instance of myself to write objects to aStream
-
onOld: aStream
-
return an instance of myself to read objects from aStream
-
onOldNoScan: aStream
-
return an instance of myself to read objects from aStream
accessing
-
classEnvironment: aNameSpace
-
define the nameSpace, into which classes are installed.
The default is nil, which means that loaded classes are returned,
but not installed.
-
manager
-
-
sourceMode
-
return the mode-symbol which controls how sourceCode is stored
in nextPutClasses:. The value can be one of:
#keep - store the sourceCode with methods
#discard - forget (i.e. do not store) any sourceCode
#reference - store a reference into the classes source file.
-
sourceMode: aSymbol
-
set the mode-symbol which controls how sourceCode is stored
in nextPutClasses:. The value must be one of:
#keep - store the sourceCode with methods
#discard - forget (i.e. do not store) any sourceCode
#reference - store a reference into the classes source file.
object io
-
atEnd
-
-
close
-
close the storage (i.e. close the underlying stream)
-
contents
-
read all objects; return a collection of objects
-
next
-
read and return the next object
-
nextPut: anObject
-
write an object
-
nextPutAll: aCollectionOfObjects
-
write all objects of the argument, aCollectionOfObjects
-
nextPutClasses: aCollectionOfClasses
-
write all classes of the argument, aCollectionOfClasses.
The classes are stored in superclass order (supers first).
The classes can be retrieved with #next.
private
-
onNew: aStream
-
setup for saving objects onto the given stream.
-
onOld: aStream
-
setup for reading objects from the given stream.
-
onOldNoScan: aStream
-
compatibility.
example (taken from an article in comp.lang.smalltalk):
storing:
|bos testArray |
testArray := Array new: 4.
1 to: 4 do:
[:index |
| innerarray |
innerarray := Array new: 10.
1 to: 10 do:
[:innerIndex |
| innerinnerArray |
innerinnerArray := Array new: 1000 withAll: 0.
innerarray at: innerIndex put: innerinnerArray].
testArray at: index put: innerarray
].
bos := BinaryObjectStorage onNew:('array.boss' asFilename writeStream).
bos nextPut: testArray.
bos nextPut: #(1 2 3 4).
bos nextPut: 'hello'.
bos close.
|
retrieving:
|bos obj1 obj2 obj3|
bos := BinaryObjectStorage onOld:('array.boss' asFilename readStream).
obj1 := bos next.
obj2 := bos next.
obj3 := bos next.
bos close.
obj1 inspect.
obj2 inspect.
obj3 inspect.
|
storing classes:
|bos|
bos := BinaryObjectStorage onNew:('FBrowser.cls' asFilename writeStream).
bos nextPutClasses:(Array with:FileBrowser with:ChangesBrowser).
bos close.
|
retrieving:
|bos cls1 cls2|
bos := BinaryObjectStorage onOld:('FBrowser.cls' asFilename readStream).
cls1 := bos next.
cls2 := bos next.
bos close.
cls1 open.
cls2 open.
|
|