rawfilefactory.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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