Polymorphic persistence, Operators, Chapter 14 – HP Integrity NonStop J-Series User Manual
Page 198: Polymorphic, Persistence

Click on the banner to return to the user guide home page.
©Copyright 1996 Rogue Wave Software
Polymorphic Persistence
Polymorphic persistence preserves pointer relationships (or morphology) among persisted
objects, and also allows the restoring process to restore an object without prior knowledge of that
object's type.
Tools.h++ uses classes derived from
RWCollectable
to do polymorphic persistence. The objects
created from those classes may be any of the different types derived from RWCollectable. A
group of such objects, where the objects may have different types, is called a heterogeneous
collection.
Table 7 lists the classes that use polymorphic persistence.
Category
Description
RWCollectable
(Smalltalk-like) classes
RWCollectableDate,
RWCollectableString...
RWCollection
classes (which derive from
RWCollectable
)
RWBinaryTree,
RWBag
...
Operators
The storage and retrieval of polymorphic objects that inherit from
RWCollectable
is a powerful
and adaptable feature of the Tools.h++ class library. Like other persistence mechanisms,
polymorphic persistence uses the overloaded extraction and insertion operators (operator<< and
operator>>). When these operators are used in polymorphic persistence, not only are objects
isomorphically saved and restored, but objects of unknown type can be restored.
Polymorphic persistence uses the operators listed below.
●
Operators that save references to
RWCollectable
objects:
Rwvostream& operator<<(RWvostream&, const RWCollectable&);
RWFile& operator<<(RWFile&, const RWCollectable&);
Each
RWCollectable
-derived object is saved isomorphically with a class ID that uniquely
identifies the object's class.
●
Operators that save
RWCollectable
pointers: