From 5cc7d4298f09086a9c3d97e5d75efce3a16ad9fd Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 02:04:00 +0200 Subject: Made factory a template. (bzr r11608.1.95) --- src/sp-factory.cpp | 64 +++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'src/sp-factory.cpp') diff --git a/src/sp-factory.cpp b/src/sp-factory.cpp index 389589d09..27aa6a973 100644 --- a/src/sp-factory.cpp +++ b/src/sp-factory.cpp @@ -1,34 +1,34 @@ #include "sp-factory.h" -#include - -#include "sp-object.h" -#include "xml/node.h" - - -SPFactory::TypeNotRegistered::TypeNotRegistered(const std::string& type) - : std::exception(), type(type) { -} - -const char* SPFactory::TypeNotRegistered::what() const throw() { - return type.c_str(); -} - -SPFactory& SPFactory::instance() { - static SPFactory factory; - return factory; -} - -bool SPFactory::registerObject(const std::string& id, CreateFunction* createFunction) { - return this->objectMap.insert(std::make_pair(id, createFunction)).second; -} - -SPObject* SPFactory::createObject(const std::string& id) const { - std::map::const_iterator it = this->objectMap.find(id); - - if (it == this->objectMap.end()) { - throw TypeNotRegistered(id); - } - - return (*it).second(); -} +//#include + +//#include "sp-object.h" +//#include "xml/node.h" + + +//SPFactory::TypeNotRegistered::TypeNotRegistered(const std::string& type) +// : std::exception(), type(type) { +//} +// +//const char* SPFactory::TypeNotRegistered::what() const throw() { +// return type.c_str(); +//} + +//SPFactory& SPFactory::instance() { +// static SPFactory factory; +// return factory; +//} + +//bool SPFactory::registerObject(const std::string& id, CreateFunction* createFunction) { +// return this->objectMap.insert(std::make_pair(id, createFunction)).second; +//} + +//SPObject* SPFactory::createObject(const std::string& id) const { +// std::map::const_iterator it = this->objectMap.find(id); +// +// if (it == this->objectMap.end()) { +// throw TypeNotRegistered(id); +// } +// +// return (*it).second(); +//} -- cgit v1.2.3