libopenraw

rawfilefactory.h

00001 /*
00002  * libopenraw - rawfilefactory.h
00003  *
00004  * Copyright (C) 2006, 2008 Hubert Figuiere
00005  *
00006  * This library is free software: you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public License
00008  * as published by the Free Software Foundation, either version 3 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library.  If not, see
00018  * <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 
00022 
00023 #ifndef __RAWFILEFACTORY_H
00024 #define __RAWFILEFACTORY_H
00025 
00026 
00027 #include <string>
00028 #include <map>
00029 #include <boost/function.hpp>
00030 
00031 #include <libopenraw++/rawfile.h>
00032 
00033 namespace OpenRaw {
00034 namespace Internals {
00035         
00036 class RawFileFactory
00037 {
00038 public:
00039     typedef boost::function<RawFile *(IO::Stream *)> raw_file_factory_t;
00043     typedef 
00044     std::map<RawFile::Type, raw_file_factory_t> Table;
00045     typedef
00046     std::map<std::string, RawFile::Type> Extensions;
00047             
00055     RawFileFactory(RawFile::Type type, 
00056                    const raw_file_factory_t & fn, 
00057                    const char * ext);
00058 
00060     static Table & table();
00062     static Extensions & extensions();
00063     
00065     static const char **fileExtensions();
00066 
00067     static void registerType(RawFile::Type type, 
00068                              const raw_file_factory_t & fn,
00069                              const char * ext);
00070     static void unRegisterType(RawFile::Type type);
00071 };
00072 
00073 
00074 
00078 inline RawFileFactory::Table & RawFileFactory::table()
00079 {
00081     static Table rawFactoryTable;
00082     return rawFactoryTable;
00083 }
00084 
00085 inline RawFileFactory::Extensions & RawFileFactory::extensions()
00086 {
00088     static Extensions rawExtensionsTable;
00089     return rawExtensionsTable;
00090 }
00091         
00092 
00093 }
00094 }
00095 
00096 #endif
00097 /*
00098   Local Variables:
00099   mode:c++
00100   c-file-style:"stroustrup"
00101   c-file-offsets:((innamespace . 0))
00102   indent-tabs-mode:nil
00103   fill-column:80
00104   End:
00105 */