mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-27 17:35:41 +00:00
encapsulate factory/preset alloc in one method.
throw typed exception in allocate()
This commit is contained in:
@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user