libopenraw  0.3.7
rawfilefactory.hpp
1 /*
2  * libopenraw - rawfilefactory.hpp
3  *
4  * Copyright (C) 2006-2023 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 #pragma once
22 
23 #include <functional>
24 #include <map>
25 #include <string>
26 
27 #include "io/stream.hpp"
28 #include "rawfile.hpp"
29 
30 namespace OpenRaw {
31 namespace Internals {
32 
34 public:
35  typedef std::function<RawFile *(const IO::Stream::Ptr &)>
36  raw_file_factory_t;
40  typedef std::map<RawFile::Type, raw_file_factory_t> Table;
41  typedef std::map<std::string, RawFile::Type> Extensions;
42 
43  RawFileFactory() = delete;
44  ~RawFileFactory() = delete;
45 
47  static const Table &table() {
48  return table_mut();
49  }
51  static const Extensions &extensions() {
52  return extensions_mut();
53  }
54 
56  static const char **fileExtensions();
57 
65  static void registerType(RawFile::Type type, const raw_file_factory_t &fn,
66  const char *ext);
67 private:
69  static Table &table_mut();
71  static Extensions &extensions_mut();
73  static void unRegisterType(RawFile::Type type);
74 };
75 
76 }
77 }
78 /*
79  Local Variables:
80  mode:c++
81  c-file-style:"stroustrup"
82  c-file-offsets:((innamespace . 0))
83  indent-tabs-mode:nil
84  fill-column:80
85  End:
86 */
std::shared_ptr< Stream > Ptr
Definition: stream.hpp:47
static const char ** fileExtensions()
static const Extensions & extensions()
static void registerType(RawFile::Type type, const raw_file_factory_t &fn, const char *ext)
std::map< RawFile::Type, raw_file_factory_t > Table
RAW file.
Definition: rawfile.hpp:66
or_rawfile_type
Types of RAW files.
Definition: consts.h:59
Global namespace for libopenraw.
Definition: arwfile.cpp:29