Moved the stream related methods into a separate streamable interface that
can be implemented by objects that are streamable but that don't have an associated type code. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@263 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
//
|
||||||
|
// $Id: Streamable.java,v 1.1 2001/08/16 03:25:14 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.cocktail.cher.io;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A streamable is an object that knows how to read and write itself on a
|
||||||
|
* stream. We are obliged to reimplement an object serialization framework
|
||||||
|
* rather than use the one provided by Java because we're interested in
|
||||||
|
* taking maximal advantage of situations where we know the types of
|
||||||
|
* objects that are being streamed and in those cases we avoid writing
|
||||||
|
* type information for the objects and only write the values. In other
|
||||||
|
* cases, we assign unique codes to object classes (see {@link
|
||||||
|
* TypedObject}) to minimize the network footprint of the serialized
|
||||||
|
* objects.
|
||||||
|
*/
|
||||||
|
public interface Streamable
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Writes all of the members of this object to the supplied data
|
||||||
|
* output stream.
|
||||||
|
*/
|
||||||
|
public void writeTo (DataOutputStream out)
|
||||||
|
throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads all of the members of this object in from the supplied data
|
||||||
|
* input stream.
|
||||||
|
*/
|
||||||
|
public void readFrom (DataInputStream in)
|
||||||
|
throws IOException;
|
||||||
|
}
|
||||||
@@ -1,12 +1,8 @@
|
|||||||
//
|
//
|
||||||
// $Id: TypedObject.java,v 1.3 2001/05/30 23:58:31 mdb Exp $
|
// $Id: TypedObject.java,v 1.4 2001/08/16 03:25:14 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.cher.io;
|
package com.threerings.cocktail.cher.io;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A typed object is one that is associated with a particular type code.
|
* A typed object is one that is associated with a particular type code.
|
||||||
* The type code can be communicated on the wire and used by the receiving
|
* The type code can be communicated on the wire and used by the receiving
|
||||||
@@ -15,7 +11,7 @@ import java.io.DataOutputStream;
|
|||||||
*
|
*
|
||||||
* @see TypedObjectFactory
|
* @see TypedObjectFactory
|
||||||
*/
|
*/
|
||||||
public interface TypedObject
|
public interface TypedObject extends Streamable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Each typed object class must associate itself with a type value via
|
* Each typed object class must associate itself with a type value via
|
||||||
@@ -26,16 +22,4 @@ public interface TypedObject
|
|||||||
* @return The type code associated with this object.
|
* @return The type code associated with this object.
|
||||||
*/
|
*/
|
||||||
public short getType ();
|
public short getType ();
|
||||||
|
|
||||||
/**
|
|
||||||
* Each typed object class must be able to write itself to a stream.
|
|
||||||
*/
|
|
||||||
public void writeTo (DataOutputStream out)
|
|
||||||
throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Each typed object class must be able to read itself from a stream.
|
|
||||||
*/
|
|
||||||
public void readFrom (DataInputStream in)
|
|
||||||
throws IOException;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user