# ADT:Object:Storage

Note: This module is a reduced version of the ``Storage`' module from the old abandoned ADT library effort. All references to ``alien`' objects have been removed, otherwise the functionality is unchanged.

Syntax of externalized objects:

>     file = {object}.
>     object = NUM(ref) [ objdescr ].
>     objdescr = type data {object data}.
>     type = NUM(tref) [ module_name type_name ].
>     module_name = {char} 0X.
>     type_name = {char} 0X.

``ref`' is a unique reference number assigned to an object when it is externalized. The first occurrence of a reference number is followed by the object's qualified type name, and the object's value. ``tref`' is a type reference number; it is allocated in a similar way.

``data`' is a sequence of bytes (possibly empty), produced by calling Storable.Object.Store on a object. The sequence does not contain any embedded objects, but it does contain NIL pointers.

### Import List

        ADT:Storable
        IO
        Object
        Object

Class List
Reader | A reader for serialized object data.
Writer | A writer of serialized object data.

Class Summary: Reader [Detail]

      +---IO:BinaryRider.Reader
           |
           +---ADT:Storable.Reader
                |
                +--ADT:Object:Storage.Reader

A reader for serialized object data.

Inherited Fields
From IO:BinaryRider.Reader: byteOrder, channel
Constructor Summary
ConnectReader(ByteChannel): Reader Creates a new reader instance operating on channel ch.
Method Summary
Disconnect() Disconnects reader r, and cleans up the internal data structures.
INIT(ByteChannel) Initializes a new reader instance r for channel ch.
ReadObject(VAR Object) Reads an object reference from the channel underlying the reader r.
Inherited Methods
From IO:BinaryRider.Reader: ReadBool, ReadBytes, ReadChar, ReadInt, ReadLChar, ReadLInt, ReadLReal, ReadLString, ReadNum, ReadReal, ReadSInt, ReadSet, ReadStr, ReadString, SetByteOrder, SetPos From ADT:Storable.Reader: Disconnect, INIT, ReadObject

Class Summary: Writer [Detail]

      +---IO:BinaryRider.Writer
           |
           +---ADT:Storable.Writer
                |
                +--ADT:Object:Storage.Writer

A writer of serialized object data.

Inherited Fields
From IO:BinaryRider.Writer: byteOrder, channel
Constructor Summary
ConnectWriter(ByteChannel): Writer Creates a new writer instance operating on channel ch.
Method Summary
Disconnect() Completes the data written to the channel of writer w, and cleans up the internal data structures.
INIT(ByteChannel) Initializes a new writer instance w for channel ch.
WriteObject(Object) Writes object to the channel underlying the writer w.
Inherited Methods
From IO:BinaryRider.Writer: SetByteOrder, SetPos, WriteBool, WriteBytes, WriteChar, WriteInt, WriteLChar, WriteLInt, WriteLReal, WriteLString, WriteNum, WriteReal, WriteSInt, WriteSet, WriteStr, WriteString From ADT:Storable.Writer: Disconnect, INIT, WriteObject

Type Summary
[CharBuffer] = ARRAY n OF CHAR
[ObjectArray] = POINTER TO ARRAY OF Object
[TypeArray] = POINTER TO ARRAY OF RECORD ... END
[TypeRefMap] = POINTER TO ARRAY OF RECORD ... END

Class Detail: Reader

Constructor Detail

### ConnectReader

    PROCEDURE ConnectReader(ch: ByteChannel): Reader

> Creates a new reader instance operating on channel ch.

Method Detail

### Disconnect

    PROCEDURE (r: Reader) Disconnect()

> Disconnects reader r, and cleans up the internal data structures. Any resources allocated by the reader are freed.

> [Description inherited from Disconnect]

> Redefines: Disconnect

### INIT

    PROCEDURE (r: Reader) INIT(ch: ByteChannel)

> Initializes a new reader instance r for channel ch. Little endian byte ordering is used by the reader.

> [Description inherited from INIT]

> Redefines: INIT, INIT

### ReadObject

    PROCEDURE (r: Reader) ReadObject(VAR obj: Object)
      RAISES Error;

> Reads an object reference from the channel underlying the reader r. The object obj itself is required to provide the necessary type-bound procedure Object.Load to restore its own data from r.

> [Description inherited from ReadObject]

> Redefines: ReadObject

Class Detail: Writer

Constructor Detail

### ConnectWriter

    PROCEDURE ConnectWriter(ch: ByteChannel): Writer

> Creates a new writer instance operating on channel ch.

Method Detail

### Disconnect

    PROCEDURE (w: Writer) Disconnect()

> Completes the data written to the channel of writer w, and cleans up the internal data structures. Without calling Writer.Disconnect the externalized objects may be left in a invalid state, and no new externalization process can be started. After Writer.Disconnect, all operations on w are undefined.

> [Description inherited from Disconnect]

> Redefines: Disconnect

### INIT

    PROCEDURE (w: Writer) INIT(ch: ByteChannel)

> Initializes a new writer instance w for channel ch. Little endian byte ordering is used by the writer.

> [Description inherited from INIT]

> Redefines: INIT, INIT

### WriteObject

    PROCEDURE (w: Writer) WriteObject(obj: Object)
      RAISES Error;

> Writes object to the channel underlying the writer w. The externalization framework is provided by the concrete instance of writer w. The object itself is required to provide the necessary type-bound procedure Object.Store to pass its own data to w.

> Pre-condition: obj is NIL, or it is an instance of Object.

> [Description inherited from WriteObject]

> Redefines: WriteObject

Type Detail

### CharBuffer

    TYPE [CharBuffer] = ARRAY n OF CHAR

### ObjectArray

    TYPE [ObjectArray] = POINTER TO ARRAY OF Object

### TypeArray

    TYPE [TypeArray] = POINTER TO ARRAY OF RECORD
    YYYYEND

### TypeRefMap

    TYPE [TypeRefMap] = POINTER TO ARRAY OF RECORD
    YYYYEND