~ubuntu-branches/ubuntu/precise/exiv2/precise

« back to all changes in this revision

Viewing changes to src/tiffvisitor.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Mercatante
  • Date: 2006-12-07 18:40:10 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20061207184010-0ouu8v0dr8nznob9
Tags: 0.12-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 */
21
21
/*!
22
22
  @file    tiffvisitor.hpp
23
 
  @brief
24
 
  @version $Rev: 808 $
 
23
  @brief   Operations on a TIFF composite tree, implemented as visitor classes.
 
24
  @version $Rev: 837 $
25
25
  @author  Andreas Huggel (ahu)
26
26
           <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
27
27
  @date    11-Apr-06, ahu: created
31
31
 
32
32
// *****************************************************************************
33
33
// included header files
 
34
#include "exif.hpp"
 
35
#include "tifffwd.hpp"
34
36
#include "types.hpp"
35
 
#include "tiffcomposite.hpp"
36
 
#include "exif.hpp"
37
37
 
38
38
// + standard includes
39
39
#include <memory>
47
47
namespace Exiv2 {
48
48
 
49
49
// *****************************************************************************
50
 
// class declarations
51
 
 
52
 
    class TiffIfdMakernote;
53
 
    class Image;
54
 
 
55
 
// *****************************************************************************
56
50
// class definitions
57
51
 
58
52
    /*!
106
100
          @brief Operation to perform for a TIFF directory, after all components
107
101
                 and before the next entry is processed.
108
102
         */
109
 
        virtual void visitDirectoryNext(TiffDirectory* object) {}
 
103
        virtual void visitDirectoryNext(TiffDirectory* /*object*/) {}
110
104
        /*!
111
105
          @brief Operation to perform for a TIFF directory, at the end of the
112
106
                 processing.
113
107
         */
114
 
        virtual void visitDirectoryEnd(TiffDirectory* object) {}
 
108
        virtual void visitDirectoryEnd(TiffDirectory* /*object*/) {}
115
109
        //! Operation to perform for a TIFF sub-IFD
116
110
        virtual void visitSubIfd(TiffSubIfd* object) =0;
117
111
        //! Operation to perform for the makernote component
119
113
        //! Operation to perform for an IFD makernote
120
114
        virtual void visitIfdMakernote(TiffIfdMakernote* object) =0;
121
115
        //! Operation to perform after processing an IFD makernote
122
 
        virtual void visitIfdMakernoteEnd(TiffIfdMakernote* object) {}
 
116
        virtual void visitIfdMakernoteEnd(TiffIfdMakernote* /*object*/) {}
123
117
        //! Operation to perform for an array entry (as found in Canon makernotes)
124
118
        virtual void visitArrayEntry(TiffArrayEntry* object) =0;
125
119
        //! Operation to perform for an array element
196
190
        TiffComponent* tiffComponent_;
197
191
    }; // class TiffFinder
198
192
 
199
 
    //! Function pointer type for a function to decode a TIFF component.
200
 
    typedef void (TiffMetadataDecoder::*DecoderFct)(const TiffEntryBase*);
201
 
 
202
 
    //! TIFF decoder table
203
 
    struct TiffDecoderInfo {
204
 
        struct Key;
205
 
        /*!
206
 
          @brief Compare a TiffDecoderInfo with a TiffDecoderInfo::Key.
207
 
                 The two are equal if TiffDecoderInfo::make_ equals a substring
208
 
                 of the key of the same size. E.g., decoder info = "OLYMPUS",
209
 
                 key = "OLYMPUS OPTICAL CO.,LTD" (found in the image) match,
210
 
                 the extendedTag is Tag::all or equal to the extended tag of the
211
 
                 key, and the group is equal to that of the key.
212
 
         */
213
 
        bool operator==(const Key& key) const;
214
 
        //! Return the tag corresponding to the extended tag
215
 
        uint16_t tag() const { return static_cast<uint16_t>(extendedTag_ & 0xffff); }
216
 
 
217
 
        // DATA
218
 
        const char* make_;        //!< Camera make for which this decoder function applies
219
 
        uint32_t    extendedTag_; //!< Tag (32 bit so that it can contain special tags)
220
 
        uint16_t    group_;       //!< Group that contains the tag
221
 
        DecoderFct  decoderFct_;  //!< Decoder function for matching tags
222
 
 
223
 
    }; // struct TiffDecoderInfo
224
 
 
225
 
    //! Search key for TIFF decoder structures.
226
 
    struct TiffDecoderInfo::Key {
227
 
        //! Constructor
228
 
        Key(const std::string& m, uint32_t e, uint16_t g) : m_(m), e_(e), g_(g) {}
229
 
        std::string m_;                    //!< Camera make
230
 
        uint32_t    e_;                    //!< Extended tag
231
 
        uint16_t    g_;                    //!< %Group
232
 
    };
233
 
 
234
193
    /*!
235
194
      @brief TIFF composite visitor to decode metadata from the TIFF tree and
236
195
             add it to an Image, which is supplied in the constructor (Visitor
250
209
         */
251
210
        TiffMetadataDecoder(Image* pImage,
252
211
                            TiffComponent* const pRoot,
 
212
                            FindDecoderFct findDecoderFct =0,
253
213
                            uint32_t threshold =0);
254
214
        //! Virtual destructor
255
215
        virtual ~TiffMetadataDecoder() {}
276
236
        //! Decode an array element
277
237
        virtual void visitArrayElement(TiffArrayElement* object);
278
238
 
 
239
        //! Entry function, determines how to decode each tag
 
240
        void decodeTiffEntry(const TiffEntryBase* object);
279
241
        //! Decode a standard TIFF entry
280
 
        void decodeTiffEntry(const TiffEntryBase* object);
 
242
        void decodeStdTiffEntry(const TiffEntryBase* object);
281
243
        //! Decode Olympus Thumbnail from the TIFF makernote into IFD1
282
244
        void decodeOlympThumb(const TiffEntryBase* object);
283
245
        //! Decode SubIFD contents to Image group if it contains primary image data
293
255
        // DATA
294
256
        Image* pImage_;              //!< Pointer to the image to which the metadata is added
295
257
        TiffComponent* const pRoot_; //!< Root element of the composite
 
258
        const FindDecoderFct findDecoderFct_; //!< Ptr to the function to find special decoding functions
296
259
        const uint32_t threshold_;   //!< Threshold, see constructor documentation.
297
260
        std::string make_;           //!< Camera make, determined from the tags to decode
298
261
 
300
263
        typedef std::map<uint16_t, uint32_t> GroupType;
301
264
        GroupType groupType_;        //!< NewSubfileType for each group
302
265
 
303
 
        static const TiffDecoderInfo tiffDecoderInfo_[]; //<! TIFF decoder table
304
 
 
305
266
    }; // class TiffMetadataDecoder
306
267
 
307
268
    /*!
428
389
        //! Return the base offset. See class TiffRwState for details
429
390
        uint32_t baseOffset() const;
430
391
        //! Create a TIFF component for \em extendedTag and group
431
 
        TiffComponent::AutoPtr create(uint32_t extendedTag, uint16_t group) const;
 
392
        std::auto_ptr<TiffComponent> create(uint32_t extendedTag, 
 
393
                                            uint16_t group) const;
 
394
        //@}
 
395
 
 
396
    private:
 
397
        //! @name Manipulators
 
398
        //@{
 
399
        //! Helper function to set the thumbnail data area
 
400
        void setDataArea(TiffEntryBase* pOffsetEntry, const Value* pSize);
432
401
        //@}
433
402
 
434
403
    private: