Implementing QueryGuid() is a tedious and repetitive task, so using macros to write most of the code is convenient. A GUID map is a set of macros that collectively implement the QueryGuid() function. They are nearly identical to ATL's BEGIN_COM_MAP and END_COM_MAP macros, which implement QueryInterface(). Example 4 shows how you can use GUID maps to implement QueryGuid().
class CCow : public IAnimal { public: BEGIN_GUID_MAP(CCow) GUID_ENTRY(IAnimal) GUID_ENTRY(IQueryGuid) END_GUID_MAP … }; |
The macros expand out to the same implementation of CCow::QueryGuid() shown in the previous sample.
In certain cases, a class may inherit an interface from more than one base class. That will produce an ambiguous reference in the GUID map that you must resolve with the GUID_ENTRY2 macro. Example 5 shows the GUID_ENTRY2 macro used to resolve an ambiguous reference to IQueryGuid.
class IFood : public IQueryGuid { public: virtual void BeConsumed() = 0; }; class CCow : public IAnimal, public IFood { public: BEGIN_GUID_MAP(CCow) GUID_ENTRY(IAnimal) GUID_ENTRY2(IQueryGuid, IAnimal) END_GUID_MAP … }; |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.