Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Advanced Tools Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

5.4 Serialization Package Architecture

The object streams in the Serialization package are based on the streams abstractions defined in the Streams package.

5.4.1 How Does Serialization Work?

Figure 20 shows how serialization typically works in a distributed application:

  1. You stream an object to a portable format.

  2. You pass the portable format between processes.

  3. You have the receiving process stream the object from the portable format back into an instance of the original C++ class.

In this example, a client downloads data from a server. The portable format used is a compact object stream, which lets you reconstruct the serialized objects.

Figure 20: Passing an object by value in a distributed application

Both the server and the client maintain classes that encapsulate data and functionality. The original object's data is transferred to the client and used to create a copy. In effect, the object is passed between processes by value. After the transfer, the sender and receiver side each own an object of that class.

5.4.2 Relationship to the Streams Package

The Streams package starts with byte streams or character streams, and then moves up to data streams. Object streams are the next level in the hierarchy above data streams. Many of these streams can be chained together to provide independent control at multiple levels of abstraction. Chaining is key to the Streams package architecture (see Section 3.4, "Streams Package Architecture.")

Object streams follow the same pattern as the classes in the Streams package: the object streams interface is defined by a pair of handle classes, RWObjectOutputStream and RWObjectInputStream. Concrete implementation classes are derived from RWObjectOutputStreamImp and RWObjectInputStreamImp. These classes, in turn, are derived from RWFilteredDataOutputStreamImp and RWFilteredDataInputStreamImp, which allow object streams to be chained to data streams. Object streams also inherit all the primitive type operators from data streams.

Although the classes RWObjectOutputStream and RWObjectInputStream are part of the Serialization package, they are actually part of the Streams package architecture, as shown in Figure 21 and Figure 22. The relationship between the object streams and the Streams package is the same as the relationship between Java object streams and Java data streams.

Figure 21: Object output streams as part of the Streams package architecture

Figure 22: Object input streams as part of the Streams package architecture

5.4.3 Handle-Body Architecture

Like the Streams package, object streams use the handle-body pattern. This means that the classes RWObjectOutputStream and RWObjectInputStream, the handle classes, are intended to be used as-is. Object streaming behavior is extended and customized by deriving from the classes in the RWObjectOutputStreamImp and RWObjectInputStreamImp hierarchies, the body classes. Use of the handle-body pattern for streams means that they can be used as automatic variables (on the stack) and as instance variables without worrying about dynamic memory management.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.