libopenraw  0.3.7
crwfile.hpp
1 /* -*- Mode: C++; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil; -*- */
2 /*
3  * libopenraw - crwfile.hpp
4  *
5  * Copyright (C) 2006-2020 Hubert Figuière
6  *
7  * This library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 #pragma once
23 
24 #include <stdint.h>
25 #include <sys/types.h>
26 #include <string>
27 #include <vector>
28 
29 #include <libopenraw/consts.h>
30 
31 #include "rawfile.hpp"
32 #include "rawcontainer.hpp"
33 #include "io/stream.hpp"
34 
35 namespace OpenRaw {
36 
37 class MetaValue;
38 class RawData;
39 
40 namespace Internals {
41 
46 namespace CIFF {
47  class CiffMainIfd;
48  class CiffExifIfd;
49 }
50 
51 class CIFFContainer;
52 
54 class CRWFile
55  : public OpenRaw::RawFile
56 {
57  template<typename T>
58  friend void audit_coefficients();
59  friend class CIFF::CiffMainIfd;
60  friend class CIFF::CiffExifIfd;
61 
62 public:
63  static RawFile *factory(const IO::Stream::Ptr &);
64  CRWFile(const IO::Stream::Ptr &);
65  virtual ~CRWFile();
66 
67  CRWFile(const CRWFile&) = delete;
68  CRWFile & operator=(const CRWFile&) = delete;
69 
70 protected:
71 
72 
73  virtual RawContainer* getContainer() const override;
74  virtual ::or_error _enumThumbnailSizes(std::vector<uint32_t> &list) override;
75 
76  virtual ::or_error _getRawData(RawData & data, uint32_t options) override;
77  virtual IfdDir::Ref _locateCfaIfd() override
78  {
79  return _locateMainIfd();
80  }
81  virtual IfdDir::Ref _locateMainIfd() override;
82  virtual IfdDir::Ref _locateExifIfd() override;
83  virtual MakerNoteDir::Ref _locateMakerNoteIfd() override
84  {
85  return MakerNoteDir::Ref();
86  }
87  virtual MetaValue *_getMetaValue(int32_t meta_index) override;
88 
89  virtual void _identifyId() override;
90 
91  Option<uint32_t> getOrientation() const;
92  Option<std::string> getMakeOrModel(uint32_t index);
93 
94 private:
95  IO::Stream::Ptr m_io;
96  CIFFContainer *m_container;
97  uint32_t m_x;
98  uint32_t m_y;
99  std::string m_make;
100  std::string m_model;
101 
102  static const RawFile::camera_ids_t s_def[];
103 };
104 
106 }
107 }
std::shared_ptr< Stream > Ptr
Definition: stream.hpp:47
IFD that will synthesize the entries for the Exif.
Definition: ciffifd.hpp:68
IFD that will synthesize the entries for main.
Definition: ciffifd.hpp:58
virtual ::or_error _enumThumbnailSizes(std::vector< uint32_t > &list) override
Enumerate the thumbnail sizes.
Definition: crwfile.cpp:142
virtual void _identifyId() override
Identify the file and set the ID internally.
Definition: crwfile.cpp:388
virtual MetaValue * _getMetaValue(int32_t meta_index) override
Implementation for getMetaValue()
Definition: crwfile.cpp:335
virtual IfdDir::Ref _locateCfaIfd() override
Locate the IFD for the raw data.
Definition: crwfile.hpp:77
virtual RawContainer * getContainer() const override
Get the container.
Definition: crwfile.cpp:172
virtual MakerNoteDir::Ref _locateMakerNoteIfd() override
Locate the MakerNote IFD.
Definition: crwfile.hpp:83
virtual ::or_error _getRawData(RawData &data, uint32_t options) override
Get the RAW data.
Definition: crwfile.cpp:177
virtual IfdDir::Ref _locateMainIfd() override
Locate the main IFD.
Definition: crwfile.cpp:374
virtual IfdDir::Ref _locateExifIfd() override
Locate the Exif IFD.
Definition: crwfile.cpp:381
std::shared_ptr< IfdDir > Ref
Shared ptr of an IfdDir.
Definition: ifddir.hpp:56
Generic interface for the RAW file container.
Metadata value.
Definition: metavalue.hpp:35
Represent camera raw data.
Definition: rawdata.hpp:38
RAW file.
Definition: rawfile.hpp:66
An option type inspired by Rust.
Definition: option.hpp:47
or_error
Error codes returned by libopenraw.
Definition: consts.h:42
Global namespace for libopenraw.
Definition: arwfile.cpp:29