previous page
next page

ATL Persistence Implementation Classes

ATL provides implementations of the IPersistPropertyBag. IPersistStreamInit and IPersistStorage interfaces called IPersistPropertyBagImpl, IPersistStreamInitImpl, and IPersistStorageImpl, respectively. Each template class takes one parameter, the name of the deriving class. You add support for these three persistence interfaces to your object like this:

class ATL_NO_VTABLE CDemagogue :
    public IPersistPropertyBagImpl<CDemagogue>,
    public IPersistStreamInitImpl<CDemagogue>,
    public IPersistStorageImpl<CDemagogue> {
 ...
 BEGIN_COM_MAP(CDemagogue)
     ...
     COM_INTERFACE_ENTRY2(IPersist, IPersistPropertyBag)
     COM_INTERFACE_ENTRY(IPersistPropertyBag)
     COM_INTERFACE_ENTRY(IPersistStreamInit)
     COM_INTERFACE_ENTRY(IPersistStream)
     COM_INTERFACE_ENTRY(IPersistStorage)
 END_COM_MAP()
     ...
};

Don't forget to add the COM MAP enTRy for IPersist. All three persistence interfaces derive from IPersist, not IUnknown, so you need to respond affirmatively to queries for IPersist. Note also that you need to use the COM_INTERFACE_ENTRY2 (or COM_INTERFACE_ENTRY_IID) macro because multiple base classes derive from IPersist.


previous page
next page
Converted from CHM to HTML with chm2web Pro 2.75 (unicode)