Reputation: 4245
Is it possible to provide an implementation to QueryInterface for classes using ATL
?
BEGIN_COM_MAP(CConcrete) // Defines _InternalQueryInterface
COM_INTERFACE_ENTRY(IInterface)
END_COM_MAP() // Defines QueryInterface as a pure virtual function which
// is overridden in CComObject<CConcrete>
I'm overriding for mocking purposes, allowing a user to simulate a QueryInterface
failure. I would like to maintain the default ATL
QueryInterface functionality when not being explicitly configured.
The call stack looks like this:
CComObjectRootBase::InternalQueryInterface
CConcrete::_InternalQueryInterface // BEGIN_COM_MAP
CComObject<CConcrete>::QueryInterface // Override of QI from END_COM_MAP
Upvotes: 1
Views: 1033
Reputation: 4245
What I ended up doing was creating a new version of BEGIN_COM_MAP
that doesn't include an implementation for _InternalQueryInterface
. I then put my mocking code in there, and forwarded non-mocked calls to InternalQueryInterface
.
Upvotes: 1