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_DETAIL_FORMATWRITER_H
39 #define OME_BIOFORMATS_DETAIL_FORMATWRITER_H
40 
41 #include <ome/bioformats/FormatWriter.h>
42 #include <ome/bioformats/FormatHandler.h>
43 
44 #include <map>
45 
46 namespace ome
47 {
48  namespace bioformats
49  {
50  namespace detail
51  {
52 
57  {
59  typedef std::map<std::string,
60  std::set<ome::xml::model::enums::PixelType> > codec_pixel_type_map;
61 
63  std::string name;
65  std::string description;
67  std::vector<boost::filesystem::path> suffixes;
69  std::vector<boost::filesystem::path> compression_suffixes;
71  std::set<std::string> compression_types;
73  codec_pixel_type_map codec_pixel_types;
75  bool stacks;
76 
83  WriterProperties(const std::string& name,
84  const std::string& description):
85  name(name),
86  description(description),
87  suffixes(),
88  compression_suffixes(),
89  compression_types(),
90  codec_pixel_types(),
91  stacks()
92  {
93  compression_suffixes.push_back(boost::filesystem::path(""));
94  }
95  };
96 
109  virtual public ::ome::bioformats::FormatHandler
110  {
111  protected:
114 
116  boost::optional<boost::filesystem::path> currentId;
117 
119  ome::compat::shared_ptr<std::ostream> out;
120 
123 
125  boost::optional<std::string> compression;
126 
129 
132 
137  ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve> metadataRetrieve;
138 
139  protected:
142 
143  private:
145  FormatWriter (const FormatWriter&);
146 
148  FormatWriter&
149  operator= (const FormatWriter&);
150 
151  public:
153  virtual
154  ~FormatWriter();
155 
156  // Documented in superclass.
157  bool
158  isThisType(const boost::filesystem::path& name,
159  bool open = true) const;
160 
161  // Documented in superclass.
162  void
164 
165  // Documented in superclass.
166  void
168  VariantPixelBuffer& buf);
169 
170  // Documented in superclass.
171  void
173  VariantPixelBuffer& buf,
177  dimension_size_type h) = 0;
178 
179  // Documented in superclass.
180  void
181  setSeries(dimension_size_type no) const;
182 
183  // Documented in superclass.
185  getSeries() const;
186 
187  // Documented in superclass.
188  bool
189  canDoStacks() const;
190 
191  // Documented in superclass.
192  void
193  setMetadataRetrieve(ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve>& retrieve);
194 
195  // Documented in superclass.
196  const ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve>&
197  getMetadataRetrieve() const;
198 
199  // Documented in superclass.
200  ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve>&
202 
203  // Documented in superclass.
204  void
206 
207  // Documented in superclass.
209  getFramesPerSecond() const;
210 
211  // Documented in superclass.
212  const std::set<ome::xml::model::enums::PixelType>&
213  getPixelTypes() const;
214 
215  // Documented in superclass.
216  const std::set<ome::xml::model::enums::PixelType>&
217  getPixelTypes(const std::string& codec) const;
218 
219  // Documented in superclass.
220  bool
222 
223  // Documented in superclass.
224  bool
226  const std::string& codec) const;
227 
228  // Documented in superclass.
229  const std::set<std::string>&
230  getCompressionTypes() const ;
231 
232  // Documented in superclass.
233  void
234  setCompression(const std::string& compression);
235 
236  // Documented in superclass.
237  const boost::optional<std::string>&
238  getCompression() const;
239 
240  // Documented in superclass.
241  void
242  changeOutputFile(const boost::filesystem::path& id);
243 
244  // Documented in superclass.
245  void
246  setWriteSequentially(bool sequential = true);
247 
248  // Documented in superclass.
249  bool
250  getWriteSequentially() const;
251 
252  // Documented in superclass.
253  void
254  setId(const boost::filesystem::path& id);
255 
256  // Documented in superclass.
257  void
258  close(bool fileOnly = false);
259 
260  // Documented in superclass.
261  const std::string&
262  getFormat() const;
263 
264  // Documented in superclass.
265  const std::string&
266  getFormatDescription() const;
267 
268  // Documented in superclass.
269  const std::vector<boost::filesystem::path>&
270  getSuffixes() const;
271 
272  // Documented in superclass.
273  const std::vector<boost::filesystem::path>&
274  getCompressionSuffixes() const;
275  };
276 
277  }
278  }
279 }
280 
281 #endif // OME_BIOFORMATS_DETAIL_FORMATWRITER_H
282 
283 /*
284  * Local Variables:
285  * mode:C++
286  * End:
287  */
bool getWriteSequentially() const
Check if planes are written sequentially.
Definition: FormatWriter.cpp:259
virtual ~FormatWriter()
Destructor.
Definition: FormatWriter.cpp:92
codec_pixel_type_map codec_pixel_types
Supported pixel types.
Definition: FormatWriter.h:73
WriterProperties(const std::string &name, const std::string &description)
Constructor.
Definition: FormatWriter.h:83
const std::set< ome::xml::model::enums::PixelType > & getPixelTypes() const
Get supported pixel types.
Definition: FormatWriter.cpp:193
Interface for all biological file format readers and writers.
Definition: FormatHandler.h:64
void setSeries(dimension_size_type no) const
Set the active series.
Definition: FormatWriter.cpp:163
bool sequential
Planes are written sequentially.
Definition: FormatWriter.h:128
const std::vector< boost::filesystem::path > & getCompressionSuffixes() const
Get the default compression suffixes for this file format.
Definition: FormatWriter.cpp:306
const WriterProperties & writerProperties
Writer properties specific to the derived file format.
Definition: FormatWriter.h:113
const std::vector< boost::filesystem::path > & getSuffixes() const
Get the default file suffixes for this file format.
Definition: FormatWriter.cpp:300
std::vector< boost::filesystem::path > compression_suffixes
Filename compression suffixes this format can handle.
Definition: FormatWriter.h:69
Interface for all biological file format writers (default behaviour).
Definition: FormatWriter.h:108
uint16_t frame_rate_type
Frame rate type.
Definition: FormatWriter.h:86
Interface for all biological file format writers.
Definition: FormatWriter.h:82
void saveBytes(dimension_size_type no, VariantPixelBuffer &buf)
Save an image plane.
Definition: FormatWriter.cpp:152
dimension_size_type series
Current series.
Definition: FormatWriter.h:122
bool isThisType(const boost::filesystem::path &name, bool open=true) const
Check if the given file is a valid instance of this file format.
Definition: FormatWriter.cpp:137
FormatWriter & operator=(const FormatWriter &)
Assignment operator (deleted).
std::set< std::string > compression_types
Supported compression types.
Definition: FormatWriter.h:71
void setFramesPerSecond(frame_rate_type rate)
Set the frame rate to use when writing.
Definition: FormatWriter.cpp:181
std::vector< boost::filesystem::path > suffixes
Filename suffixes this format can handle.
Definition: FormatWriter.h:67
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
void close(bool fileOnly=false)
Close the currently open file.
Definition: FormatWriter.cpp:125
bool stacks
Stacks are supported.
Definition: FormatWriter.h:75
void changeOutputFile(const boost::filesystem::path &id)
Switch the output file for the current dataset.
Definition: FormatWriter.cpp:245
bool canDoStacks() const
Get whether or not the writer can save multiple images in a single file.
Definition: FormatWriter.cpp:318
const std::set< std::string > & getCompressionTypes() const
Get supported compression types.
Definition: FormatWriter.cpp:312
void setMetadataRetrieve(ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve > &retrieve)
Set the default metadata store for this writer.
Definition: FormatWriter.cpp:265
dimension_size_type getSeries() const
Get the active series.
Definition: FormatWriter.cpp:175
std::string description
Format description.
Definition: FormatWriter.h:65
frame_rate_type getFramesPerSecond() const
Get the frame rate to use when writing.
Definition: FormatWriter.cpp:187
const std::string & getFormat() const
Get the name of this file format.
Definition: FormatWriter.cpp:288
PixelType enumeration.
Definition: PixelType.h:70
const ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve > & getMetadataRetrieve() const
Get the current metadata store for this writer.
Definition: FormatWriter.cpp:276
frame_rate_type framesPerSecond
The frames per second to use when writing.
Definition: FormatWriter.h:131
const std::string & getFormatDescription() const
Get the description of this file format.
Definition: FormatWriter.cpp:294
Buffer for all pixel types.
Definition: VariantPixelBuffer.h:72
void setId(const boost::filesystem::path &id)
Set the current file name.
Definition: FormatWriter.cpp:97
boost::optional< std::string > compression
The compression type to use.
Definition: FormatWriter.h:125
FormatWriter()
Constructor.
Definition: FormatWriter.h:141
std::map< std::string, std::set< ome::xml::model::enums::PixelType > > codec_pixel_type_map
Map of codec to pixel types.
Definition: FormatWriter.h:60
std::string name
Format name.
Definition: FormatWriter.h:63
void setCompression(const std::string &compression)
Set the compression type to use when writing.
Definition: FormatWriter.cpp:225
boost::optional< boost::filesystem::path > currentId
The identifier (path) of the currently open file.
Definition: FormatWriter.h:116
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
bool isSupportedType(ome::xml::model::enums::PixelType type) const
Check if the pixel type is supported.
Definition: FormatWriter.cpp:210
ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve > metadataRetrieve
Current metadata store.
Definition: FormatWriter.h:137
Properties specific to a particular writer.
Definition: FormatWriter.h:56
const boost::optional< std::string > & getCompression() const
Get the compression type to use when writing.
Definition: FormatWriter.cpp:239
void setWriteSequentially(bool sequential=true)
Write planes sequentially.
Definition: FormatWriter.cpp:253
void setLookupTable(const VariantPixelBuffer &buf)
Set the color lookup table associated with the current series.
Definition: FormatWriter.cpp:146
ome::compat::shared_ptr< std::ostream > out
Current output.
Definition: FormatWriter.h:119