libopenraw
rawfilefactory.cpp
1 /*
2  * libopenraw - rawfilefactory.cpp
3  *
4  * Copyright (C) 2006, 2008 Hubert Figuiere
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3 of
9  * the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #include <stdlib.h>
22 
23 #include <iostream>
24 #include <cassert>
25 
26 #include "rawfilefactory.h"
27 #include "trace.h"
28 
29 using namespace Debug;
30 
31 namespace OpenRaw {
32 
33  namespace Internals {
34 
35 
36  RawFileFactory::RawFileFactory(RawFile::Type type,
37  const RawFileFactory::raw_file_factory_t & fn,
38  const char *ext)
39  {
40  Trace(DEBUG1) << "registering type "
41  << (int)type << "\n";
42  registerType(type, fn, ext);
43  }
44 
45 
46  void RawFileFactory::registerType(RawFile::Type type,
47  const RawFileFactory::raw_file_factory_t & fn,
48  const char *ext)
49  {
50  if (fn == NULL)
51  {
52  Trace(ERROR) << "NULL fn for registerFactory()\n";
53  assert(fn == NULL);
54  }
55  table()[type] = fn;
56  extensions()[ext] = type;
57  }
58 
59 
60  void RawFileFactory::unRegisterType(RawFile::Type type)
61  {
62  Table::iterator iter = table().find(type);
63  if (iter == table().end())
64  {
65  Trace(ERROR) << "attempting to unregisterFactory() in unregistered "
66  "element\n";
67  assert(true);
68  }
69  table().erase(iter);
70  }
71 
72 const char **RawFileFactory::fileExtensions()
73 {
74  static const char **_fileExtensions = NULL;
75  if(!_fileExtensions) {
76  Extensions & ext = extensions();
77  size_t s = ext.size();
78  _fileExtensions = (const char**)calloc((s + 1), sizeof(char*));
79  const char **current = _fileExtensions;
80  Extensions::const_iterator iter(ext.begin());
81  for ( ; iter != ext.end(); ++iter) {
82  *current = iter->first.c_str();
83  current++;
84  }
85  }
86 
87  return _fileExtensions;
88 }
89 
90  }
91 }
92 
93 /*
94  Local Variables:
95  mode:c++
96  c-file-style:"stroustrup"
97  c-file-offsets:((innamespace . 0))
98  indent-tabs-mode:nil
99  fill-column:80
100  End:
101 */
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard. I guess it failed.
Definition: arwfile.cpp:33
Definition: trace.cpp:28