[Scummvm-cvs-logs] SF.net SVN: scummvm:[54900] tools/branches/gsoc2010-decompiler/decompiler
pidgeot at users.sourceforge.net
pidgeot at users.sourceforge.net
Mon Dec 13 03:19:27 CET 2010
Revision: 54900
http://scummvm.svn.sourceforge.net/scummvm/?rev=54900&view=rev
Author: pidgeot
Date: 2010-12-13 02:19:27 +0000 (Mon, 13 Dec 2010)
Log Message:
-----------
DECOMPILER: Add generic key types to ObjectFactory
Modified Paths:
--------------
tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
tools/branches/gsoc2010-decompiler/decompiler/objectFactory.h
Modified: tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-12-13 02:08:39 UTC (rev 54899)
+++ tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp 2010-12-13 02:19:27 UTC (rev 54900)
@@ -42,7 +42,7 @@
int main(int argc, char** argv) {
try {
std::map<std::string, std::string> engines;
- ObjectFactory<Engine> engineFactory;
+ ObjectFactory<std::string, Engine> engineFactory;
ENGINE("kyra2", "Legend of Kyrandia: Hand of Fate", Kyra::Kyra2Engine);
ENGINE("scummv6", "SCUMM v6", Scumm::v6::Scummv6Engine);
Modified: tools/branches/gsoc2010-decompiler/decompiler/objectFactory.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/objectFactory.h 2010-12-13 02:08:39 UTC (rev 54899)
+++ tools/branches/gsoc2010-decompiler/decompiler/objectFactory.h 2010-12-13 02:19:27 UTC (rev 54900)
@@ -39,7 +39,7 @@
/**
* Generic factory for a class and its subclasses.
*/
-template<typename BaseType>
+template<typename KeyType, typename BaseType>
class ObjectFactory {
private:
@@ -51,7 +51,7 @@
/**
* Type used to store registered entries.
*/
- typedef std::map<std::string, CreateFunc> RegistryMap;
+ typedef std::map<KeyType, CreateFunc> RegistryMap;
RegistryMap _registry; ///<Map from an identifier to a creation function.
@@ -59,21 +59,21 @@
/**
* Register a new entry.
*
- * @param name The name to register the class under.
+ * @param key The key to register the class under.
*/
template<typename Type>
- void addEntry(const std::string &name) {
- _registry[name] = &createObject<BaseType, Type>;
+ void addEntry(const KeyType &key) {
+ _registry[key] = &createObject<BaseType, Type>;
}
/**
* Creates an instance of some registered class.
*
- * @param name The name associated with the desired class.
+ * @param key The key associated with the desired class.
* @return NULL if the name is not registered, else an instance of the associated class.
*/
- BaseType *create(const std::string &name) const {
- typename RegistryMap::const_iterator entry = _registry.find(name);
+ BaseType *create(const KeyType &key) const {
+ typename RegistryMap::const_iterator entry = _registry.find(key);
if (entry == _registry.end())
return NULL;
return (entry->second)();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list