ome-files 0.2.2

TIFF.h
1 /*
2 * #%L
3 * OME-FILES C++ library for image IO.
4 * Copyright © 2006 - 2015 Open Microscopy Environment:
5 * - Massachusetts Institute of Technology
6 * - National Institutes of Health
7 * - University of Dundee
8 * - Board of Regents of the University of Wisconsin-Madison
9 * - Glencoe Software, Inc.
10 * %%
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * The views and conclusions contained in the software and documentation are
33 * those of the authors and should not be interpreted as representing official
34 * policies, either expressed or implied, of any organization.
35 * #L%
36 */
37
38 #ifndef OME_FILES_TIFF_TIFF_H
39 #define OME_FILES_TIFF_TIFF_H
40
41 #include <string>
42
43 #include <boost/filesystem/path.hpp>
44 #include <boost/iterator/iterator_facade.hpp>
45
46 #include <ome/files/tiff/Types.h>
47
48 #include <ome/compat/cstdint.h>
49 #include <ome/compat/memory.h>
50
51 namespace ome
52 {
53 namespace files
54 {
58 namespace tiff
59 {
60
61 class IFD;
62
66 template<typename Value>
67 class IFDIterator : public boost::iterator_facade<IFDIterator<Value>,
68 ome::compat::shared_ptr<Value>,
69 boost::forward_traversal_tag>
70 {
71 public:
77 IFDIterator():
78 pos()
79 {}
80
88 IFDIterator(ome::compat::shared_ptr<IFD>& ifd):
89 pos(ifd)
90 {}
91
97 template <class OtherValue>
98 IFDIterator(const IFDIterator<OtherValue>& rhs)
99 : pos(rhs.pos) {}
100
101 private:
108 mutable ome::compat::shared_ptr<Value> pos;
109
110 friend class boost::iterator_core_access;
111 template <class> friend class IFDIterator;
112
120 void
121 increment();
122
129 bool
130 equal(IFDIterator const& rhs) const
131 {
132 return this->pos == rhs.pos;
133 }
134
140 ome::compat::shared_ptr<Value>&
141 dereference() const
142 {
143 return pos;
144 }
145 };
146
155 class TIFF : public ome::compat::enable_shared_from_this<TIFF>
156 {
157 private:
158 class Impl;
159 class wrapped_type;
161 ome::compat::shared_ptr<Impl> impl;
162
163 protected:
165 TIFF(const boost::filesystem::path& filename,
166 const std::string& mode);
167
168 private:
170 TIFF (const TIFF&);
171
173 TIFF&
174 operator= (const TIFF&);
175
176 public:
178 ~TIFF();
179
192 static ome::compat::shared_ptr<TIFF>
193 open(const boost::filesystem::path& filename,
194 const std::string& mode);
195
203 void
204 close();
205
212 operator bool ();
213
219 directory_index_type
220 directoryCount() const;
221
230 ome::compat::shared_ptr<IFD>
231 getDirectoryByIndex(directory_index_type index) const;
232
241 ome::compat::shared_ptr<IFD>
242 getDirectoryByOffset(offset_type offset) const;
243
250 ome::compat::shared_ptr<IFD>
251 getCurrentDirectory() const;
252
261 void
262 writeCurrentDirectory();
263
283 wrapped_type *
284 getWrapped() const;
285
286 friend class IFD;
287
289 typedef IFDIterator<IFD> iterator;
291 typedef IFDIterator<const IFD> const_iterator;
292
298 iterator
299 begin();
300
306 const_iterator
307 begin() const;
308
314 iterator
315 end();
316
322 const_iterator
323 end() const;
324
325 private:
327 void
328 registerImageJTags();
329 };
330
331 }
332 }
333 }
334
335 #endif // OME_FILES_TIFF_TIFF_H
336
337 /*
338 * Local Variables:
339 * mode:C++
340 * End:
341 */
ome::files::tiff::IFDIterator::dereference
ome::compat::shared_ptr< Value > & dereference() const
Dereference the iterator.
Definition: TIFF.h:141
ome::files::tiff::TIFF::Impl
Internal implementation details of TIFF.
Definition: TIFF.cpp:107
ome::files::tiff::TIFF
Tagged Image File Format (TIFF).
Definition: TIFF.h:155
ome::files::tiff::IFDIterator::IFDIterator
IFDIterator()
Default constructor.
Definition: TIFF.h:77
ome::files::tiff::TIFF::iterator
IFDIterator< IFD > iterator
IFD iterator.
Definition: TIFF.h:289
ome::files::tiff::IFDIterator::increment
void increment()
Increment the iterator by one position.
ome::files::tiff::IFDIterator::pos
ome::compat::shared_ptr< Value > pos
The current position.
Definition: TIFF.h:108
ome::files::tiff::offset_type
uint64_t offset_type
IFD offset.
Definition: Types.h:65
ome::files::tiff::IFDIterator
Iterator for IFDs contained within a TIFF.
Definition: TIFF.h:67
ome
Open Microscopy Environment C++.
ome::files::tiff::IFDIterator::IFDIterator
IFDIterator(const IFDIterator< OtherValue > &rhs)
Construct from an existing iterator.
Definition: TIFF.h:98
memory.h
cstdint.h
ome::files::tiff::IFDIterator::equal
bool equal(IFDIterator const &rhs) const
Check for equality.
Definition: TIFF.h:130
ome::files::tiff::TIFF::impl
ome::compat::shared_ptr< Impl > impl
Private implementation details.
Definition: TIFF.h:159
ome::files::tiff::TIFF::const_iterator
IFDIterator< const IFD > const_iterator
const IFD iterator.
Definition: TIFF.h:291
ome::files::tiff::directory_index_type
uint16_t directory_index_type
IFD index.
Definition: Types.h:62
ome::files::tiff::IFD
Image File Directory (IFD).
Definition: IFD.h:71
ome::files::tiff::IFDIterator::IFDIterator
IFDIterator(ome::compat::shared_ptr< IFD > &ifd)
Construct with an initial starting position.
Definition: TIFF.h:88