Aliased streaming comes into play when dealing with complex objects (such as collections) that may have several references (pointers) to some other object. When streaming out the complex object, we only want to write the "other" object once, rather than repeating it for each pointer in the main object. And, when streaming the complex object back in, we want each of the pointers that originally referred to the single "other" object to once again refer to a single instance of "other", not n repeated instances.
To accomplish this, the streaming system establishes a context and remembers all objects that are streamed during the duration of that context. A context will automatically be established whenever a read or write aliased object is performed and persist through any recursive calls to read/write aliased objects that are required to complete the original operation.
Class IStreamContextFrame allows a stream context to be explicitly established so that it can persist through the streaming of a group of related objects. The construction of the IStreamContextFrame establishes the context; the subsequent destruction terminates the stream contex.
Explicit (user created) IStreamContexts are not required when a context is needed only for the duration of the streaming of a single complex object.
IStreamContextFrame objects are intended to be created as local (stack) variables, which allows the context to be automatically shut down when the local variable goes out of scope at the end of the block in which it is declared.
This class is not thread aware.
Do not derive from this class.
Example of use:
void write3RelatedObjects(IDataStream &toWhere, IMRefCounted &obj1, &obj2, &obj3) { IStreamContextFrame aContext(aStream); writeAliasedObject(obj1, toWhere); writeAliasedObject(obj2, toWhere); writeAliasedObject(obj3, toWhere); } // The context is ended when the IStreamContextFrame object goes out of scope.
Constructors & DestructorThe constructor and destructor for this class.
![]() |
public:
~IStreamContextFrame()
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |
![]() |
public:
IStreamContextFrame(IDataStream& dataStream)
| Windows | OS/2 | AIX |
| Yes | Yes | Yes |