home *** CD-ROM | disk | FTP | other *** search
- /*
- IXStoreBlock.h
- Copyright 1991, NeXT Computer, Inc.
- */
-
- #import "protocols.h"
- #import "IXStore.h"
-
- #import <remote/transport.h>
- #import <machkit/reference.h>
- #import <objc/Object.h>
-
- extern unsigned
- IXWriteRootObjectToStore(IXStore *aStore, unsigned aHandle, id anObject);
-
- extern id
- IXReadObjectFromStore(IXStore *aStore, unsigned aHandle, NXZone *aZone);
-
- // This is a convenience class, most often used to associate a named store
- // directory entry with an archived object. It distributes by copy, using the
- // exportBlock:atOffset:forLength: and importBlock:atOffset:forLength: methods
- // of IXStore to provide remote access the contents of the block.
-
- @interface IXStoreBlock: Object <NXReference,NXTransport,IXBlockAndStoreAccess>
- {
- unsigned _references;
- @public
- IXStore *store;
- unsigned handle;
- unsigned blockSize;
- @protected
- id blockData;
- unsigned readOffset;
- unsigned readLength;
- }
-
- // Returns the receiver's store, primarily as a convenience for transaction
- // management - e.g., [[client store] startTransaction].
-
- - (IXStore *)store;
-
- // Closes the block if there is only one outstanding reference. This makes the
- // block available to other contexts, unless the block has been modified.
-
- - close;
-
- // Opens the block for reading, returning a pointer to a copy of the block's
- // contents. Each invocation invalidates the pointer returned by the previous
- // invocation, unless the supplied offset and length are the same as for the
- // previous invocation. The block's contents will not be modified, regardless
- // of what the sender does to the copy, until writeAtOffset:forLength: is sent.
-
- - (unsigned char *)readAtOffset:(unsigned)offset forLength:(unsigned)length;
-
- // These two methods return the offset and length supplied to the most recent
- // invocation of readAtOffset:forLength:.
-
- - (unsigned)readOffset;
- - (unsigned)readLength;
-
- // Writes the copy of the block's contents, as modified by the sender, to the
- // store, opening the block for modification in the process. The supplied
- // offset and length must define a complete subset of the range opened by the
- // previous invocation of readAtOffset:forLength:.
-
- - writeAtOffset:(unsigned)offset forLength:(unsigned)length;
-
- // Copies the block, returning the handle of the result of the copy.
- - (unsigned)copyAtOffset:(unsigned)offset forLength:(unsigned)length;
-
- - (unsigned)size; // Locks and determines the size of the block.
-
- // Resizes the block. This invalidates the pointer to the block's contents
- // returned by readAtOffset:forLength:. A new pointer to the block's contents
- // must be accquired if further access to the contents is necessary.
-
- - resizeTo:(unsigned)size;
-
- // Opens typed stream on the block's contents, and calls NXReadObject() to
- // unarchive the contents of the typed stream.
-
- - readObject;
-
- // Calls NXWriteRootObject() on the supplied object, resizes the block to fit
- // the resulting buffer, and copies the contents of the buffer to the block
- // with writeAtOffset:forLength:.
-
- - writeObject:anObject;
-
- // This method does not distribute, since it returns a pointer to the actual
- // block contents obtained from openBlock:atOffset:forLength:. It is provided
- // for compatibility and for efficiency with a local store.
-
- - (unsigned char *)openAtOffset:(unsigned)offset forLength:(unsigned)length;
-
- @end
-
-