BASE: PLUGINS: Add helper methods which match MetaEngine to Engine & vice-versa
This commit is contained in:
parent
f2dd03e7d8
commit
50e9f0d875
2 changed files with 83 additions and 0 deletions
|
@ -266,6 +266,65 @@ void PluginManager::addPluginProvider(PluginProvider *pp) {
|
||||||
_providers.push_back(pp);
|
_providers.push_back(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Plugin *PluginManager::giveEngineFromMetaEngine(const Plugin *plugin) {
|
||||||
|
assert(plugin->getType() == PLUGIN_TYPE_METAENGINE);
|
||||||
|
|
||||||
|
PluginList pl = PluginMan.getPlugins(PLUGIN_TYPE_ENGINE);
|
||||||
|
Plugin *enginePlugin = nullptr;
|
||||||
|
|
||||||
|
// Use the engineID from MetaEngine for comparasion.
|
||||||
|
Common::String metaEnginePluginName = plugin->getEngineId();
|
||||||
|
|
||||||
|
// Iterate over all engine plugins.
|
||||||
|
for (PluginList::const_iterator itr = pl.begin(); itr != pl.end(); itr++) {
|
||||||
|
// The getName() provides a name which is similiar to getEngineId.
|
||||||
|
// Because engines are engines themselves, this function is simply named getName.
|
||||||
|
Common::String enginePluginName((*itr)->getName());
|
||||||
|
|
||||||
|
if (metaEnginePluginName.equalsIgnoreCase(enginePluginName)) {
|
||||||
|
enginePlugin = (*itr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (enginePlugin) {
|
||||||
|
warning("MetaEngine: %s \t matched to \t Engine: %s", plugin->getName(), enginePlugin->getFileName());
|
||||||
|
return enginePlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
warning("MetaEngine: %s couldn't find a match for an engine plugin.", plugin->getName());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Plugin *PluginManager::giveMetaEngineFromEngine(const Plugin *plugin) {
|
||||||
|
assert(plugin->getType() == PLUGIN_TYPE_ENGINE);
|
||||||
|
|
||||||
|
Plugin *metaEngine = nullptr;
|
||||||
|
|
||||||
|
PluginList pl = PluginMan.getPlugins(PLUGIN_TYPE_METAENGINE);
|
||||||
|
|
||||||
|
// This will return a name of the Engine plugin, which will be identical to
|
||||||
|
// a getEngineID from a relevant MetaEngine.
|
||||||
|
Common::String enginePluginName(plugin->getName());
|
||||||
|
|
||||||
|
for (PluginList::const_iterator itr = pl.begin(); itr != pl.end(); itr++) {
|
||||||
|
Common::String metaEngineName = (*itr)->getEngineId();
|
||||||
|
|
||||||
|
if (metaEngineName.equalsIgnoreCase(enginePluginName)) {
|
||||||
|
metaEngine = (*itr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (metaEngine) {
|
||||||
|
warning("Engine: %s matched to MetaEngine: %s", plugin->getFileName(), metaEngine->getName());
|
||||||
|
return metaEngine;
|
||||||
|
}
|
||||||
|
|
||||||
|
warning("Engine: %s couldn't find a match for an MetaEngine plugin.", plugin->getFileName());
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should only be called once by main()
|
* This should only be called once by main()
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -326,6 +326,30 @@ public:
|
||||||
|
|
||||||
void addPluginProvider(PluginProvider *pp);
|
void addPluginProvider(PluginProvider *pp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A method which takes in a plugin of type ENGINE,
|
||||||
|
* and returns the appropriate & matching METAENGINE.
|
||||||
|
* It uses the Engine plugin's getName method, which is an identifier,
|
||||||
|
* and then tries to matches it with each plugin present in memory.
|
||||||
|
*
|
||||||
|
* @param A plugin of type ENGINE.
|
||||||
|
*
|
||||||
|
* @return A plugin of type METAENGINE.
|
||||||
|
*/
|
||||||
|
Plugin *giveMetaEngineFromEngine(const Plugin *plugin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A method which takes in a plugin of type METAENGINE,
|
||||||
|
* and returns the appropriate & matching ENGINE.
|
||||||
|
* It uses the MetaEngine's getEngineID to reconstruct the name
|
||||||
|
* of engine plugin, and then tries to matches it with each plugin in memory.
|
||||||
|
*
|
||||||
|
* @param A plugin of type METAENGINE.
|
||||||
|
*
|
||||||
|
* @return A plugin of type ENGINE.
|
||||||
|
*/
|
||||||
|
Plugin *giveEngineFromMetaEngine(const Plugin *plugin);
|
||||||
|
|
||||||
// Functions used by the uncached PluginManager
|
// Functions used by the uncached PluginManager
|
||||||
virtual void init() {}
|
virtual void init() {}
|
||||||
virtual void loadFirstPlugin() {}
|
virtual void loadFirstPlugin() {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue