source: trunk/vizservers/nanovis/imgLoaders/ImageLoaderFactory.cpp @ 823

Last change on this file since 823 was 823, checked in by vrinside, 16 years ago

Image Loaders - BMP (Currently BMP loader was implmented)
For extensibility, Bridge/Singleton? Pattern was used

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