ome-files  0.5.0
FormatWriter.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_FORMATWRITER_H
39 #define OME_FILES_FORMATWRITER_H
40 
41 #include <array>
42 #include <memory>
43 #include <set>
44 #include <string>
45 #include <vector>
46 #include <map>
47 
48 #include <boost/optional.hpp>
49 
50 #include <ome/files/CoreMetadata.h>
51 #include <ome/files/FileInfo.h>
52 #include <ome/files/FormatHandler.h>
53 #include <ome/files/MetadataConfigurable.h>
54 #include <ome/files/MetadataMap.h>
55 #include <ome/files/Types.h>
56 
57 #include <ome/xml/meta/MetadataRetrieve.h>
58 
59 namespace ome
60 {
61  namespace files
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:
91  {}
92 
94  FormatWriter (const FormatWriter&) = delete;
95 
97  operator= (const FormatWriter&) = delete;
99 
100  public:
102  virtual
104  {}
105 
116  virtual
117  void
119  const VariantPixelBuffer& buf) = 0;
120 
137  virtual
138  void
140  VariantPixelBuffer& buf) = 0;
141 
162  virtual
163  void
165  VariantPixelBuffer& buf,
169  dimension_size_type h) = 0;
170 
179  virtual
180  void
181  setSeries(dimension_size_type series) const = 0;
182 
188  virtual
190  getSeries() const = 0;
191 
200  virtual void
201  setPlane(dimension_size_type plane) const = 0;
202 
208  virtual dimension_size_type
209  getPlane() const = 0;
210 
218  virtual
219  bool
220  canDoStacks() const = 0;
221 
227  virtual
228  void
229  setMetadataRetrieve(std::shared_ptr<::ome::xml::meta::MetadataRetrieve>& retrieve) = 0;
230 
236  virtual
237  const std::shared_ptr<::ome::xml::meta::MetadataRetrieve>&
238  getMetadataRetrieve() const = 0;
239 
245  virtual
246  std::shared_ptr<::ome::xml::meta::MetadataRetrieve>&
247  getMetadataRetrieve() = 0;
248 
254  virtual
255  void
256  setFramesPerSecond(frame_rate_type rate) = 0;
257 
263  virtual
264  frame_rate_type
265  getFramesPerSecond() const = 0;
266 
272  virtual
273  const std::set<ome::xml::model::enums::PixelType>
274  getPixelTypes() const = 0;
275 
282  virtual
283  const std::set<ome::xml::model::enums::PixelType>
284  getPixelTypes(const std::string& codec) const = 0;
285 
292  virtual
293  bool
295 
303  virtual
304  bool
306  const std::string& codec) const = 0;
307 
313  virtual
314  const std::set<std::string>&
315  getCompressionTypes() const = 0;
316 
323  virtual
324  const std::set<std::string>&
326 
332  virtual
333  void
334  setCompression(const std::string& compression) = 0;
335 
341  virtual
342  const boost::optional<std::string>&
343  getCompression() const = 0;
344 
351  virtual
352  void
353  setInterleaved(bool interleaved) = 0;
354 
360  virtual
361  const boost::optional<bool>&
362  getInterleaved() const = 0;
363 
369  virtual
370  void
371  changeOutputFile(const boost::filesystem::path& id) = 0;
372 
382  virtual
383  void
384  setWriteSequentially(bool sequential = true) = 0;
385 
391  virtual
392  bool
393  getWriteSequentially() const = 0;
394 
408  virtual
410  setTileSizeX(boost::optional<dimension_size_type> size) = 0;
411 
419  virtual
421  getTileSizeX() const = 0;
422 
436  virtual
438  setTileSizeY(boost::optional<dimension_size_type> size) = 0;
439 
447  virtual
449  getTileSizeY() const = 0;
450  };
451 
452  }
453 }
454 
455 #endif // OME_FILES_FORMATWRITER_H
456 
457 /*
458  * Local Variables:
459  * mode:C++
460  * End:
461  */
virtual dimension_size_type getTileSizeX() const =0
Get the effective tile width.
virtual void changeOutputFile(const boost::filesystem::path &id)=0
Switch the output file for the current dataset.
virtual ~FormatWriter()
Destructor.
Definition: FormatWriter.h:103
virtual dimension_size_type setTileSizeY(boost::optional< dimension_size_type > size)=0
Set the requested tile height.
Interface for all biological file format writers.
Definition: FormatWriter.h:82
virtual void setLookupTable(dimension_size_type plane, const VariantPixelBuffer &buf)=0
Set the color lookup table associated with the current series.
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:58
FormatWriter()
Constructor.
Definition: FormatWriter.h:90
virtual void setSeries(dimension_size_type series) const =0
Set the active series.
virtual void saveBytes(dimension_size_type plane, VariantPixelBuffer &buf)=0
Save an image plane.
virtual bool getWriteSequentially() const =0
Check if planes are written sequentially.
virtual dimension_size_type getSeries() const =0
Get the active series.
virtual bool canDoStacks() const =0
Get whether or not the writer can save multiple images in a single file.
virtual dimension_size_type getPlane() const =0
Get the active plane.
Open Microscopy Environment C++.
virtual void setPlane(dimension_size_type plane) const =0
Set the active plane.
virtual void setFramesPerSecond(frame_rate_type rate)=0
Set the frame rate to use when writing.
virtual dimension_size_type getTileSizeY() const =0
Get the effective tile height.
virtual const std::shared_ptr<::ome::xml::meta::MetadataRetrieve > & getMetadataRetrieve() const =0
Get the current metadata store for this writer.
virtual const std::set< std::string > & getCompressionTypes() const =0
Get supported compression types.
virtual void setInterleaved(bool interleaved)=0
Set subchannel interleaving.
virtual frame_rate_type getFramesPerSecond() const =0
Get the frame rate to use when writing.
virtual void setCompression(const std::string &compression)=0
Set the compression type to use when writing.
virtual void setMetadataRetrieve(std::shared_ptr<::ome::xml::meta::MetadataRetrieve > &retrieve)=0
Set the default metadata store for this writer.
virtual bool isSupportedType(ome::xml::model::enums::PixelType type) const =0
Check if the pixel type is supported.
virtual dimension_size_type setTileSizeX(boost::optional< dimension_size_type > size)=0
Set the requested tile width.
uint16_t frame_rate_type
Frame rate type.
Definition: FormatWriter.h:86
virtual void setWriteSequentially(bool sequential=true)=0
Write planes sequentially.
virtual const boost::optional< bool > & getInterleaved() const =0
Set subchannel interleaving.
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:78
Interface for all biological file format readers and writers.
Definition: FormatHandler.h:63
virtual const boost::optional< std::string > & getCompression() const =0
Get the compression type to use when writing.
virtual const std::set< ome::xml::model::enums::PixelType > getPixelTypes() const =0
Get supported pixel types.