Stream classes

The main stream classes are shown in the hierarchy in Figure 43.


You will usually create instances of one of the three classes at the bottom of the hierarchy: TChunkyStream, TContiguousMemoryStream, or TFileStream.

The primary consideration is whether you want to stream to memory or to disk. If you intend to stream to memory use either TChunkyStream or TContiguousMemoryStream. These are the primary classes that implement the virtual memory API. These memory streams act as wrappers around an actual memory object and the class you select depends on whether your memory object must be allocated as contiguous memory (as in the case of a bitmap) or whether the memory can be allocated in separate chunks.

If you want to stream data to a disk file, use an instance of TFileStream. Instead of being associated with virtual memory, a TFileStream object is associated with an instance of TFile as specified in the constructors for TFileStream. Other than this, the protocol for memory streams is identical to file streams. Most importantly, because of the common protocol shared by memory streams and file streams, you can switch between types of streams later if you decide a different type of stream is more appropriate for your application.

The primary protocols for various stream classes are shown in Figure 44.



[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker