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.

ATL Internals. Working with ATL 8
ATL Internals: Working with ATL 8 (2nd Edition)
ISBN: 0321159624
EAN: 2147483647
Year: 2004
Pages: 172 © 2008-2017.
If you may any questions please contact us: