To enable RRDC for a class:
RRDC is only available when one of the tagged stream formats is used. Raw binary stream formats, which omit the tags that delimit object data on a stream, are not suitable for persistent data or for streaming between systems that may have different DLLs installed. It is up to the client that specifies the stream to choose an appropriate encoding. RRDC enabled classes will stream out their data correctly on nontagged streams, but they will be unable to detect the end of a frame on streaming in.
In the following example, the fData variable is replaced, in a later version of the class, by fOldData and fNewData.
Here is the original version of DerivedClass::writeToStream:
void DerivedClass::writeToStream(IDataStream& toStream) const { IStreamOutFrame streamContext(toStream); // Must be declared on stack. BaseClass::writeToStream(toStream); // Write base class data first. fData >>= toStream; // Write instance data to stream. }
This is the original version of DerivedClass::readFromStream:
void DerivedClass::readFromStream(IDataStream& fromStream) { IStreamInFrame streamContext(fromStream); // Must be declared on stack BaseClass::readFromStream(fromStream); // Read base class data first. fData <<= fromStream; // Read instance data from stream. }
This is the new version of DerivedClass::writeToStream:
void DerivedClass::writeToStream(IDataStream& toStream) const { IStreamOutFrame streamContext(toStream); BaseClass::writeToStream(toStream); fOldData >>= toStream; // Used to be fData fNewData >>= toStream; }
This is the new version of DerivedClass::readFromStream:
void DerivedClass::readFromStream(IDataStream& fromStream) const { IStreamInFrame streamContext(fromStream); BaseClass::readFromStream(fromStream); fOldData <<= fromStream; // fNewData may or may not be on the stream depending on // which version of the class wrote to the stream. if (!streamContext.atEnd()) { fNewData <<= fromWhere; } else { fNewData = fOldData; // The new data wasn't there so // use the old data. } }
Introduction
to the Streaming Classes
Release-to-Release
Data Compatibility (RRDC)
Data Streams
Application
Data Interfaces
Adding Streaming Support
to Structs and Simple Classes
Creating a Streamable
Class
Creating a Streamable
Template Class
Instantiating a
Stream Module
Streaming Base Classes
Streaming
Aliases and Aliased Objects
Streaming
Objects Monomorphically
Streaming
Objects Polymorphically
Transitioning from
Older Streaming Constructs