encapsulate factory/preset alloc in one method.

throw typed exception in allocate()
This commit is contained in:
carm
2012-11-11 23:11:21 -05:00
parent 176fad1b79
commit c4d44203de
3 changed files with 29 additions and 11 deletions

View File

@ -19,6 +19,7 @@
#include "NativePresetFactory/NativePresetFactory.hpp"
#endif
#include "Common.hpp"
#include <sstream>
PresetFactoryManager::PresetFactoryManager() : _gx(0), _gy(0), initialized(false) {}
@ -75,6 +76,22 @@ void PresetFactoryManager::registerFactory(const std::string & extensions, Prese
}
}
std::auto_ptr<Preset> PresetFactoryManager::allocate(const std::string & url, const std::string & name)
{
try {
const std::string extension = parseExtension (url);
return factory(extension).allocate(url, name);
} catch (const std::exception & e) {
throw PresetFactoryException(e.what());
} catch (...) {
throw PresetFactoryException("uncaught preset factory exception");
}
}
PresetFactory & PresetFactoryManager::factory(const std::string & extension) {
if (!_factoryMap.count(extension)) {