RRDC allows a new version of a class to read in instance data streamed by an earlier version AND also allows an older class implementation to read data written by a newer implementation.
The streaming system is described in more detail in the description for classes IMStreamable and IDataStream.
For any application class that supports RRDC, the override of IMStreamable::readFromStream() must declare a local instance of IStreamInFrame before streaming in the member data of the class. The scope of this local variable must include all of the stream-ins of the member data.
In addition, readFromStream() function for any class that is in a second or greater release, and has extended the data it streams, must make a check at the point that it has read all of the data that would have been written by the older releases. If the stream was written by an older version, and thus does not contain the additional data, the readFromStream function must set the state of the object to a reasonable value and not attempt to stream in the missing data. IStreamInFrame::atEnd() allows this check to be made.
Use of stream frames is required in classes, even in their first release, if RRDC may be required for subsequent releases.
Example:
//
// An example of a class and readFromStream function for the first
// release of the class. RRDC with future releases is allowed for,
// through the use of IStreamInFrame.
//
class myClass: public IMStreamable {
...
int fData1;
someType fData2;
...
};
void myClass::readFromStream(IDataStream &fromWhere) {
IStreamInFrame frame(fromWhere);
fData1 <<= fromWhere;
fData2 <<= fromWhere;
}; // When the IStreamInFrame goes out of scope, as it does here,
// any extra data that may have been written by some future, unknown to us at this time,
// version of myClass will be automatically skipped, leaving the stream position
// correct for the next object to be streamed in.
Constructors & DestructorThe constructor and destructor for IStreamInFrame.
![]() |
public:
~IStreamInFrame()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
IStreamInFrame(IDataStream& aStream)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
Stream InfoThese methods allow users to query information about the stream.
![]() |
public:
bool atEnd()
This function (and class) is only used within the implementation of a readFromStream() function of a streamable class.
The readFromStream() function for any class that is in a 2nd or greater release and has extended the data that it writes to a stream should call atEnd() at the point(s) where all of the data written by earlier stream formats has been read. A return value of true indicates that the stream data was indeed written by an earlier version, and that there is no more data available to be read by this stream-in function. When this occurs, the readFromStream function should default all data items that have not yet been read, without reading any additional values from the stream.
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |