bioformats  5.1.0
FormatWriter.h
1 /*
2  * #%L
3  * OME-BIOFORMATS 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_BIOFORMATS_FORMATWRITER_H
39 #define OME_BIOFORMATS_FORMATWRITER_H
40 
41 #include <set>
42 #include <string>
43 #include <vector>
44 #include <map>
45 
46 #include <boost/optional.hpp>
47 
48 #include <ome/bioformats/CoreMetadata.h>
49 #include <ome/bioformats/FileInfo.h>
50 #include <ome/bioformats/FormatHandler.h>
51 #include <ome/bioformats/MetadataConfigurable.h>
52 #include <ome/bioformats/MetadataMap.h>
53 #include <ome/bioformats/Types.h>
54 
55 #include <ome/compat/array.h>
56 
57 #include <ome/xml/meta/MetadataRetrieve.h>
58 
59 namespace ome
60 {
61  namespace bioformats
62  {
63 
64  class VariantPixelBuffer;
65 
82  class FormatWriter : virtual public FormatHandler
83  {
84  public:
86  typedef uint16_t frame_rate_type;
87 
88  protected:
102  {
103  private:
108 
109  public:
115  SaveSeries(const FormatWriter& writer):
116  writer(writer),
117  series(writer.getSeries())
118  {}
119 
126  {
127  try
128  {
129  if (series != writer.getSeries())
130  writer.setSeries(series);
131  }
132  catch (...)
133  {
134  // We can't throw in a destructor.
135  }
136  }
137  };
138 
139  protected:
142  {}
143 
144  private:
146  FormatWriter (const FormatWriter&);
147 
149  FormatWriter&
150  operator= (const FormatWriter&);
151 
152  public:
154  virtual
156  {}
157 
167  virtual
168  void
169  setLookupTable(const VariantPixelBuffer& buf) = 0;
170 
187  virtual
188  void
190  VariantPixelBuffer& buf) = 0;
191 
212  virtual
213  void
215  VariantPixelBuffer& buf,
219  dimension_size_type h) = 0;
220 
229  virtual
230  void
231  setSeries(dimension_size_type no) const = 0;
232 
238  virtual
240  getSeries() const = 0;
241 
249  virtual
250  bool
251  canDoStacks() const = 0;
252 
258  virtual
259  void
260  setMetadataRetrieve(ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve>& retrieve) = 0;
261 
267  virtual
268  const ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve>&
269  getMetadataRetrieve() const = 0;
270 
276  virtual
277  ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve>&
278  getMetadataRetrieve() = 0;
279 
285  virtual
286  void
287  setFramesPerSecond(frame_rate_type rate) = 0;
288 
294  virtual
295  frame_rate_type
296  getFramesPerSecond() const = 0;
297 
303  virtual
304  const std::set<ome::xml::model::enums::PixelType>&
305  getPixelTypes() const = 0;
306 
313  virtual
314  const std::set<ome::xml::model::enums::PixelType>&
315  getPixelTypes(const std::string& codec) const = 0;
316 
323  virtual
324  bool
326 
334  virtual
335  bool
337  const std::string& codec) const = 0;
338 
344  virtual
345  const std::set<std::string>&
346  getCompressionTypes() const = 0;
347 
353  virtual
354  void
355  setCompression(const std::string& compression) = 0;
356 
362  virtual
363  const boost::optional<std::string>&
364  getCompression() const = 0;
365 
371  virtual
372  void
373  changeOutputFile(const boost::filesystem::path& id) = 0;
374 
384  virtual
385  void
386  setWriteSequentially(bool sequential = true) = 0;
387 
393  virtual
394  bool
395  getWriteSequentially() const = 0;
396  };
397 
398  }
399 }
400 
401 #endif // OME_BIOFORMATS_FORMATWRITER_H
402 
403 /*
404  * Local Variables:
405  * mode:C++
406  * End:
407  */
virtual void setSeries(dimension_size_type no) const =0
Set the active series.
virtual frame_rate_type getFramesPerSecond() const =0
Get the frame rate to use when writing.
virtual void setMetadataRetrieve(ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve > &retrieve)=0
Set the default metadata store for this writer.
Interface for all biological file format readers and writers.
Definition: FormatHandler.h:64
Sentry for saving and restoring writer series state.
Definition: FormatWriter.h:101
uint16_t frame_rate_type
Frame rate type.
Definition: FormatWriter.h:86
virtual const ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve > & getMetadataRetrieve() const =0
Get the current metadata store for this writer.
virtual dimension_size_type getSeries() const =0
Get the active series.
Interface for all biological file format writers.
Definition: FormatWriter.h:82
virtual void setLookupTable(const VariantPixelBuffer &buf)=0
Set the color lookup table associated with the current series.
virtual void setCompression(const std::string &compression)=0
Set the compression type to use when writing.
Array type substitution.
virtual bool getWriteSequentially() const =0
Check if planes are written sequentially.
FormatWriter & operator=(const FormatWriter &)
Assignment operator (deleted).
virtual ~FormatWriter()
Destructor.
Definition: FormatWriter.h:155
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
virtual const std::set< std::string > & getCompressionTypes() const =0
Get supported compression types.
virtual void setWriteSequentially(bool sequential=true)=0
Write planes sequentially.
virtual void saveBytes(dimension_size_type no, VariantPixelBuffer &buf)=0
Save an image plane.
dimension_size_type series
Saved state.
Definition: FormatWriter.h:107
virtual const boost::optional< std::string > & getCompression() const =0
Get the compression type to use when writing.
~SaveSeries()
Destructor.
Definition: FormatWriter.h:125
virtual const std::set< ome::xml::model::enums::PixelType > & getPixelTypes() const =0
Get supported pixel types.
SaveSeries(const FormatWriter &writer)
Constructor.
Definition: FormatWriter.h:115
PixelType enumeration.
Definition: PixelType.h:70
virtual bool isSupportedType(ome::xml::model::enums::PixelType type) const =0
Check if the pixel type is supported.
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:72
virtual bool canDoStacks() const =0
Get whether or not the writer can save multiple images in a single file.
FormatWriter()
Constructor.
Definition: FormatWriter.h:141
virtual void setFramesPerSecond(frame_rate_type rate)=0
Set the frame rate to use when writing.
virtual void changeOutputFile(const boost::filesystem::path &id)=0
Switch the output file for the current dataset.
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
const FormatWriter & writer
Writer for which the state will be saved and restored.
Definition: FormatWriter.h:105