Just Say No

Just Say "No"


Sometimes, you want to short-circuit the interface request by explicitly returning E_NOINTERFACE when a specific interface is requested. For this, ATL provides COM_INTERFACE_ENTRY_NOINTERFACE:

#define COM_INTERFACE_ENTRY_NOINTERFACE(x) \   { &_ATL_IIDOF(x), NULL, _NoInterface },    

The _NoInterface function does pretty much what you'd expect:

static HRESULT WINAPI                                   CComObjectRootBase::_NoInterface(void*, REFIID, void**,   DWORD_PTR)                                            { return E_NOINTERFACE; }                               

This interface map macro is handy when you've got blind entries in the interface map, as in blind aggregation or chaining, and you want to remove functionality that the inner object or the base class provides. For example

class CBigNiceBeachBall :   public CBeachBall,   public IBigObject { public: BEGIN_COM_MAP(CBigNiceBeachBall)   COM_INTERFACE_ENTRY(IBigObject)   COM_INTERFACE_ENTRY_NOINTERFACE(ILethalObject)   COM_INTERFACE_ENTRY_CHAIN(CBeachBall) END_COM_MAP() ... }; 

ATL Internals. Working with ATL 8
ATL Internals: Working with ATL 8 (2nd Edition)
ISBN: 0321159624
EAN: 2147483647
Year: 2004
Pages: 172

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net