How to Add Polymorphic Persistence
The saveGuts() and restoreGuts() virtual functions are responsible for saving and restoring the internal state of RWCollectable objects. To add persistence to your RWCollectable class, you must override the saveGuts() and restoreGuts() virtual member functions so that they write out all of your object's member data. Virtual Functions saveGuts(RWFile&) and saveGuts(RWvostream&) and Virtual Functions restoreGuts(RWFile&) and restoreGuts(RWvistream&) describe approaches you can use to correctly define these functions. Multiply-referenced Objects describes how these functions handle multiply-referenced objects.
Polymorphically saving an object to a file may require some knowledge of the number of bytes that need to be allocated for storage of an object. The binaryStoreSize() function calculates this value. Virtual Function binaryStoreSize() describes how to use binaryStoreSize().
RWCollection has its own versions of the saveGuts() and restoreGuts() functions that are used to polymorphically save collections that inherit from that class. Polymorphically Persisting Custom Collections briefly describes how these functions work.