RE: [GD-General] Multiple Inheritance and RTTI
Brought to you by:
vexxed72
From: Gareth L. <GL...@cl...> - 2003-02-06 10:26:40
|
> Out of curiosity, can someone post a real example of using the > QueryInterface pattern (in performance-critical code)? QueryInterface is fairly quick. A lot depends on the number of interfaces you are implementing per object. But most things use macros like (note, this is psuedo code.) START_INTERFACELIST ADD_INTERFACE(IID_IRender) ADD_INTERFACE(IID_IFoo) END_INTERFACELIST which becomes somethinglike bool QueryInterface(GUID iid, void** ppObject) { if (iid == IID_IRender) { (*ppObject) = reinterpret_cast<void*>(this); return true; } if (iid == IID_IFoo) { (*ppObject) = reinterpret_cast<void*>(this); return true; } (*ppObject)=0; return false; } GUIDs can be anything. You could go the extreme "time+network card" which is overkill. FourCCs work very well as well. As long as you make sure not to clash. Depends on the size of the team I guess. If you have a lot of interfaces per concrete class you might need a diff solution. |