source: nanovis/trunk/imgLoaders/ImageLoaderFactory.cpp @ 5722

Last change on this file since 5722 was 2840, checked in by ldelgass, 12 years ago

Use trace macros in image loader. Formatting fixes in libs

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2#include <map>
3#include <string>
4
5#include "ImageLoader.h"
6#include "ImageLoaderImpl.h"
7#include "ImageLoaderFactory.h"
8#include "Trace.h"
9
10ImageLoaderFactory *ImageLoaderFactory::_instance = NULL;
11
12ImageLoaderFactory::ImageLoaderFactory()
13{
14}
15
16ImageLoaderFactory *ImageLoaderFactory::getInstance()
17{
18    if (_instance == NULL) {
19        _instance = new ImageLoaderFactory();
20    }
21
22    return _instance;
23}
24
25void ImageLoaderFactory::addLoaderImpl(const std::string& ext, ImageLoaderImpl *loaderImpl)
26{
27    std::map<std::string, ImageLoaderImpl *>::iterator iter;
28    iter = _loaderImpls.find(ext);
29    if (iter == _loaderImpls.end()) {
30        _loaderImpls[ext] = loaderImpl;
31    } else {
32        TRACE("conflicting data loader for .%s files\n", ext.c_str());
33        return;
34    }
35}
36
37ImageLoader *ImageLoaderFactory::createLoader(const std::string& ext)
38{
39    std::map<std::string, ImageLoaderImpl *>::iterator iter;
40    iter = _loaderImpls.find(ext);
41    if (iter != _loaderImpls.end()) {
42        ImageLoader *imageLoader = new ImageLoader();
43        imageLoader->setLoaderImpl((*iter).second);
44        return imageLoader;
45    } else {
46        TRACE("%s file not supported\n", ext.c_str());
47    }
48    return 0;
49}
50
51
Note: See TracBrowser for help on using the repository browser.