...
The ComponentEntry.Notify callback in conjunction with the ComponentEntry.QueryInitInterfaces callback can work as a way to hold off initialisation of your own interfaces. To do this, have your QueryInitInterfaces callback return false until all dependent interfaces have been registered. e.g.
Code Block | ||
---|---|---|
| ||
/*
NOTE: Pointers to the QueryInitInterfaces and Notify functions are set in your ComponentEntry which is registered with RegisterComponent
*/
bool QueryInitInterfaces(ComponentEntry* Entry, bool bLastChance)
{
return hasComms && hasPersistence;
}
int Notify(DWORD dwWhat, ComponentEntry* Entry, void* pData)
{
if(dwWhat != COMPONENT_NOTIFY_NEWINTERFACE)
{
return 0;
}
ComponentInterfaceEntry* pInterface = (ComponentInterfaceEntry*)pData;
if(IsEqualGUID(pInterface->guid, HOST_COMMS_INTERFACE_UUID))
{
hasComms = true;
return 0;
}
if(IsEqualGUID(pInterface->guid, PERSISTENCE_PROVIDER_INTERFACE_UUID))
{
hasPersistence = true;
return 0;
}
} |
In the above example, once the host comms and persistence provider interfaces have been registered, your component will return true from ComponentEntry.QueryInitInterfaces and the framework then knows it can safely call your ComponentEntry.InitInterfaces callback.
See Also