Persistence Interfaces [Previous] [Next]

Persistence Interfaces

To understand the ATL COM persistence implementations, let's first look at the interfaces involved and what they are designed to accomplish. Persistence involves three participants: the application, the object being persisted, and an object that handles the read/write operations on the actual data. The application initiates the load or the save by creating an object that implements the IStream, IStorage, or IPropertyBag interface. This interface pointer is then passed off to the persisted object, using one of the IPersistxxx interfaces (which the object must implement). The object then uses the interface pointer either to load or to save its state, as requested by the application. Objects can, and typically do, implement more than one persistence interface, allowing the containing application to choose its preferred method. ATL provides implementations for the IPersistStream, IPersistStreamInit, IPersistStorage, and IPersistPropertyBag interfaces. Figure 111 illustrates how the interfaces match up between the corresponding data object and persisted object.

Figure 11-1. Persistence interface pairs.

Here's a summary of the interfaces involved in ATL persistence and what they do: