rawfilefactory.cpp

00001 /*
00002  * libopenraw - rawfilefactory.cpp
00003  *
00004  * Copyright (C) 2006 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
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of 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, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 #include <iostream>
00022 #include <cassert>
00023 
00024 #include "rawfilefactory.h"
00025 #include "debug.h"
00026 
00027 using namespace Debug;
00028 
00029 namespace OpenRaw {
00030 
00031     namespace Internals {
00032 
00033 
00034         RawFileFactory::RawFileFactory(RawFile::Type type, 
00035                                                                      RawFileFactory::raw_file_creator fn,
00036                                                                      const char *ext)
00037         {
00038             Trace(DEBUG1) << "registering type " 
00039                                         << (int)type << "\n";
00040             registerType(type, fn, ext);
00041         }
00042 
00043 
00044         void RawFileFactory::registerType(RawFile::Type type, 
00045                                                                             RawFileFactory::raw_file_creator fn,
00046                                                                             const char *ext)
00047         {
00048             if (fn == NULL)
00049             {
00050                 Trace(ERROR) << "NULL fn for registerFactory()\n";
00051                 assert(fn == NULL);
00052             }
00053             table()[type] = fn;
00054             extensions()[ext] = type;
00055         }
00056 
00057 
00058         void RawFileFactory::unRegisterType(RawFile::Type type)
00059         {
00060             Table::iterator iter = table().find(type);
00061             if (iter == table().end())
00062             {
00063                 Trace(ERROR) << "attempting to unregisterFactory() in unregistered "
00064                     "element\n";
00065                 assert(true);
00066             }
00067             table().erase(iter);
00068         }
00069 
00070     }
00071 }
00072 

Generated on Sat Jan 27 11:36:13 2007 for libopenraw by  doxygen 1.4.7