ome-files  0.5.0
Public Types | Public Member Functions | Protected Member Functions | List of all members
ome::files::FormatWriter Class Referenceabstract

Interface for all biological file format writers. More...

#include <ome/files/FormatWriter.h>

+ Inheritance diagram for ome::files::FormatWriter:
+ Collaboration diagram for ome::files::FormatWriter:

Public Types

typedef uint16_t frame_rate_type
 Frame rate type.
 

Public Member Functions

virtual ~FormatWriter ()
 Destructor.
 
virtual void setLookupTable (dimension_size_type plane, const VariantPixelBuffer &buf)=0
 Set the color lookup table associated with the current series. More...
 
virtual void saveBytes (dimension_size_type plane, VariantPixelBuffer &buf)=0
 Save an image plane. More...
 
virtual void saveBytes (dimension_size_type plane, VariantPixelBuffer &buf, dimension_size_type x, dimension_size_type y, dimension_size_type w, dimension_size_type h)=0
 Save an image plane. More...
 
virtual void setSeries (dimension_size_type series) const =0
 Set the active series. More...
 
virtual dimension_size_type getSeries () const =0
 Get the active series. More...
 
virtual void setPlane (dimension_size_type plane) const =0
 Set the active plane. More...
 
virtual dimension_size_type getPlane () const =0
 Get the active plane. More...
 
virtual bool canDoStacks () const =0
 Get whether or not the writer can save multiple images in a single file. More...
 
virtual void setMetadataRetrieve (std::shared_ptr<::ome::xml::meta::MetadataRetrieve > &retrieve)=0
 Set the default metadata store for this writer. More...
 
virtual const std::shared_ptr<::ome::xml::meta::MetadataRetrieve > & getMetadataRetrieve () const =0
 Get the current metadata store for this writer. More...
 
virtual std::shared_ptr<::ome::xml::meta::MetadataRetrieve > & getMetadataRetrieve ()=0
 Get the current metadata store for this writer. More...
 
virtual void setFramesPerSecond (frame_rate_type rate)=0
 Set the frame rate to use when writing. More...
 
virtual frame_rate_type getFramesPerSecond () const =0
 Get the frame rate to use when writing. More...
 
virtual const std::set< ome::xml::model::enums::PixelTypegetPixelTypes () const =0
 Get supported pixel types. More...
 
virtual const std::set< ome::xml::model::enums::PixelTypegetPixelTypes (const std::string &codec) const =0
 Get supported pixel types for the given codec. More...
 
virtual bool isSupportedType (ome::xml::model::enums::PixelType type) const =0
 Check if the pixel type is supported. More...
 
virtual bool isSupportedType (ome::xml::model::enums::PixelType type, const std::string &codec) const =0
 Check if the pixel type is supported by the given codex. More...
 
virtual const std::set< std::string > & getCompressionTypes () const =0
 Get supported compression types. More...
 
virtual const std::set< std::string > & getCompressionTypes (ome::xml::model::enums::PixelType type) const =0
 Get supported compression types for a given pixel type. More...
 
virtual void setCompression (const std::string &compression)=0
 Set the compression type to use when writing. More...
 
virtual const boost::optional< std::string > & getCompression () const =0
 Get the compression type to use when writing. More...
 
virtual void setInterleaved (bool interleaved)=0
 Set subchannel interleaving. More...
 
virtual const boost::optional< bool > & getInterleaved () const =0
 Set subchannel interleaving. More...
 
virtual void changeOutputFile (const boost::filesystem::path &id)=0
 Switch the output file for the current dataset. More...
 
virtual void setWriteSequentially (bool sequential=true)=0
 Write planes sequentially. More...
 
virtual bool getWriteSequentially () const =0
 Check if planes are written sequentially. More...
 
virtual dimension_size_type setTileSizeX (boost::optional< dimension_size_type > size)=0
 Set the requested tile width. More...
 
virtual dimension_size_type getTileSizeX () const =0
 Get the effective tile width. More...
 
virtual dimension_size_type setTileSizeY (boost::optional< dimension_size_type > size)=0
 Set the requested tile height. More...
 
virtual dimension_size_type getTileSizeY () const =0
 Get the effective tile height. More...
 
- Public Member Functions inherited from ome::files::FormatHandler
virtual ~FormatHandler ()
 Destructor.
 
virtual bool isThisType (const boost::filesystem::path &name, bool open=true) const =0
 Check if the given file is a valid instance of this file format. More...
 
virtual const std::string & getFormat () const =0
 Get the name of this file format. More...
 
virtual const std::string & getFormatDescription () const =0
 Get the description of this file format. More...
 
virtual const std::vector< boost::filesystem::path > & getSuffixes () const =0
 Get the default file suffixes for this file format. More...
 
virtual const std::vector< boost::filesystem::path > & getCompressionSuffixes () const =0
 Get the default compression suffixes for this file format. More...
 
virtual void setId (const boost::filesystem::path &id)=0
 Set the current file name. More...
 
virtual void close (bool fileOnly=false)=0
 Close the currently open file. More...
 

Protected Member Functions

 FormatWriter ()
 Constructor.
 
- Protected Member Functions inherited from ome::files::FormatHandler
 FormatHandler ()
 Constructor.
 

Additional Inherited Members

- Static Public Member Functions inherited from ome::files::FormatHandler
static bool checkSuffix (const boost::filesystem::path &name, const boost::filesystem::path &suffix)
 Perform suffix matching for the given filename. More...
 
static bool checkSuffix (const boost::filesystem::path &name, const std::vector< boost::filesystem::path > &suffixes)
 Perform suffix matching for the given filename. More...
 
static bool checkSuffix (const boost::filesystem::path &name, const std::vector< boost::filesystem::path > &suffixes, const std::vector< boost::filesystem::path > &compression_suffixes)
 Perform suffix matching for the given filename. More...
 
static void assertId (const boost::optional< boost::filesystem::path > &id, bool notNull=true)
 Assert that the current file is valid. More...
 

Detailed Description

Interface for all biological file format writers.

Note
No IOException in C++.
getColorModel and setColorModel not implemented; it is Java-specific and if needed will require reimplementing in C++.
getCodecOptions and setCodec options not implemented; these rely on the Java-specific ColorModel and its design reflects that of Java c javax.imageio which we can't use here, though bits of it might require reimplementing.
Todo:
Implement saveBytes methods using 2D Region with and/or in terms of Boost.MultiArray index ranges.

Member Function Documentation

◆ canDoStacks()

virtual bool ome::files::FormatWriter::canDoStacks ( ) const
pure virtual

Get whether or not the writer can save multiple images in a single file.

Returns
true if the writer supports multiple images, false otherwise.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ changeOutputFile()

virtual void ome::files::FormatWriter::changeOutputFile ( const boost::filesystem::path &  id)
pure virtual

Switch the output file for the current dataset.

Parameters
idthe new file name.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getCompression()

virtual const boost::optional<std::string>& ome::files::FormatWriter::getCompression ( ) const
pure virtual

Get the compression type to use when writing.

Returns
the compression type.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getCompressionTypes() [1/2]

virtual const std::set<std::string>& ome::files::FormatWriter::getCompressionTypes ( ) const
pure virtual

Get supported compression types.

Returns
the supported compression types.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getCompressionTypes() [2/2]

virtual const std::set<std::string>& ome::files::FormatWriter::getCompressionTypes ( ome::xml::model::enums::PixelType  type) const
pure virtual

Get supported compression types for a given pixel type.

Parameters
typethe pixel type to use.
Returns
the supported compression types.

Implemented in ome::files::detail::FormatWriter.

◆ getFramesPerSecond()

virtual frame_rate_type ome::files::FormatWriter::getFramesPerSecond ( ) const
pure virtual

Get the frame rate to use when writing.

Returns
the frame rate (number of frames per second).

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getInterleaved()

virtual const boost::optional<bool>& ome::files::FormatWriter::getInterleaved ( ) const
pure virtual

Set subchannel interleaving.

Returns
the current interleaving setting; false if unset.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getMetadataRetrieve() [1/2]

virtual const std::shared_ptr<::ome::xml::meta::MetadataRetrieve>& ome::files::FormatWriter::getMetadataRetrieve ( ) const
pure virtual

Get the current metadata store for this writer.

Returns
the metadata store, which will never be null.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getMetadataRetrieve() [2/2]

virtual std::shared_ptr<::ome::xml::meta::MetadataRetrieve>& ome::files::FormatWriter::getMetadataRetrieve ( )
pure virtual

Get the current metadata store for this writer.

Returns
the metadata store, which will never be null.

Implemented in ome::files::detail::FormatWriter.

◆ getPixelTypes() [1/2]

virtual const std::set<ome::xml::model::enums::PixelType> ome::files::FormatWriter::getPixelTypes ( ) const
pure virtual

Get supported pixel types.

Returns
the supported pixel types.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getPixelTypes() [2/2]

virtual const std::set<ome::xml::model::enums::PixelType> ome::files::FormatWriter::getPixelTypes ( const std::string &  codec) const
pure virtual

Get supported pixel types for the given codec.

Parameters
codecthe codec to check.
Returns
the supported pixel types.

Implemented in ome::files::detail::FormatWriter.

◆ getPlane()

virtual dimension_size_type ome::files::FormatWriter::getPlane ( ) const
pure virtual

Get the active plane.

Returns
the active plane.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getSeries()

virtual dimension_size_type ome::files::FormatWriter::getSeries ( ) const
pure virtual

Get the active series.

Returns
the active series.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getTileSizeX()

virtual dimension_size_type ome::files::FormatWriter::getTileSizeX ( ) const
pure virtual

Get the effective tile width.

This is intended for use with saveBytes().

Returns
the effective tile width.

Implemented in ome::files::detail::FormatWriter, ome::files::out::OMETIFFWriter, and ome::files::out::MinimalTIFFWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getTileSizeY()

virtual dimension_size_type ome::files::FormatWriter::getTileSizeY ( ) const
pure virtual

Get the effective tile height.

This is intended for use with saveBytes().

Returns
the effective tile height.

Implemented in ome::files::detail::FormatWriter, ome::files::out::OMETIFFWriter, and ome::files::out::MinimalTIFFWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ getWriteSequentially()

virtual bool ome::files::FormatWriter::getWriteSequentially ( ) const
pure virtual

Check if planes are written sequentially.

Returns
true if sequential, false if not.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ isSupportedType() [1/2]

virtual bool ome::files::FormatWriter::isSupportedType ( ome::xml::model::enums::PixelType  type) const
pure virtual

Check if the pixel type is supported.

Parameters
typethe pixel type to check.
Returns
true if supported, false otherwise.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ isSupportedType() [2/2]

virtual bool ome::files::FormatWriter::isSupportedType ( ome::xml::model::enums::PixelType  type,
const std::string &  codec 
) const
pure virtual

Check if the pixel type is supported by the given codex.

Parameters
typethe pixel type to check.
codecthe codec to check.
Returns
true if supported, false otherwise.

Implemented in ome::files::detail::FormatWriter.

◆ saveBytes() [1/2]

virtual void ome::files::FormatWriter::saveBytes ( dimension_size_type  plane,
VariantPixelBuffer buf 
)
pure virtual

Save an image plane.

Write an image plane from a VariantPixelBuffer of size

getSizeX * getSizeY * bytesPerPixel * getRGBChannelCount()

to the current series in the current file.

Parameters
planethe plane index within the series.
bufthe source pixel buffer.
Exceptions
FormatExceptionif any of the parameters are invalid.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ saveBytes() [2/2]

virtual void ome::files::FormatWriter::saveBytes ( dimension_size_type  plane,
VariantPixelBuffer buf,
dimension_size_type  x,
dimension_size_type  y,
dimension_size_type  w,
dimension_size_type  h 
)
pure virtual

Save an image plane.

Write an image plane from a VariantPixelBuffer of size

getSizeX * getSizeY * bytesPerPixel * getRGBChannelCount()

to the current series in the current file.

Parameters
planethe plane index within the series.
bufthe source pixel buffer.
xthe X coordinate of the upper-left corner of the sub-image.
ythe Y coordinate of the upper-left corner of the sub-image.
wthe width of the sub-image.
hthe height of the sub-image.
Exceptions
FormatExceptionif any of the parameters are invalid.

Implemented in ome::files::out::OMETIFFWriter, and ome::files::out::MinimalTIFFWriter.

◆ setCompression()

virtual void ome::files::FormatWriter::setCompression ( const std::string &  compression)
pure virtual

Set the compression type to use when writing.

Parameters
compressionthe compression type.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ setFramesPerSecond()

virtual void ome::files::FormatWriter::setFramesPerSecond ( frame_rate_type  rate)
pure virtual

Set the frame rate to use when writing.

Parameters
ratethe frame rate (number of frames per second).

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ setInterleaved()

virtual void ome::files::FormatWriter::setInterleaved ( bool  interleaved)
pure virtual

Set subchannel interleaving.

Parameters
interleavedtrue to enable interleaving (chunky) or false to disable interleaving (planar).

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ setLookupTable()

virtual void ome::files::FormatWriter::setLookupTable ( dimension_size_type  plane,
const VariantPixelBuffer buf 
)
pure virtual

Set the color lookup table associated with the current series.

If the pixel type of the lookup table is unsupported by the file format, this method will throw an exception.

Parameters
planethe plane index within the series.
bufthe source pixel buffer.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ setMetadataRetrieve()

virtual void ome::files::FormatWriter::setMetadataRetrieve ( std::shared_ptr<::ome::xml::meta::MetadataRetrieve > &  retrieve)
pure virtual

Set the default metadata store for this writer.

Parameters
retrievea metadata retrieve implementation.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ setPlane()

virtual void ome::files::FormatWriter::setPlane ( dimension_size_type  plane) const
pure virtual

Set the active plane.

Parameters
planethe plane to activate.
Todo:
Remove use of stateful API which requires use of plane switching in const methods.

Implemented in ome::files::detail::FormatWriter, ome::files::out::OMETIFFWriter, and ome::files::out::MinimalTIFFWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ setSeries()

virtual void ome::files::FormatWriter::setSeries ( dimension_size_type  series) const
pure virtual

Set the active series.

Parameters
seriesthe series to activate.
Todo:
Remove use of stateful API which requires use of series switching in const methods.

Implemented in ome::files::detail::FormatWriter, ome::files::out::OMETIFFWriter, and ome::files::out::MinimalTIFFWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ setTileSizeX()

virtual dimension_size_type ome::files::FormatWriter::setTileSizeX ( boost::optional< dimension_size_type size)
pure virtual

Set the requested tile width.

The requested tile width may not be supported by the underlying file format. If the width requested is unsupported, the writer may set the nearest supported size, or the full image width or greater if no smaller tile sizes are supported. Call getTileSizeX() to get the effective size in use by the writer, or use the return value.

Parameters
sizethe requested tile width.
Returns
the effective tile width.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ setTileSizeY()

virtual dimension_size_type ome::files::FormatWriter::setTileSizeY ( boost::optional< dimension_size_type size)
pure virtual

Set the requested tile height.

The requested tile height may not be supported by the underlying file format. If the height requested is unsupported, the writer may set the nearest supported size, or the full image height or greater if no smaller tile sizes are supported. Call getTileSizeY() to get the effective size in use by the writer, or use the return value.

Parameters
sizethe requested tile height.
Returns
the effective tile height.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

◆ setWriteSequentially()

virtual void ome::files::FormatWriter::setWriteSequentially ( bool  sequential = true)
pure virtual

Write planes sequentially.

Set if planes will be written sequentially. If planes are written sequentially and this flag is set, then performance will be slightly improved.

Parameters
sequentialtrue if sequential, false if not.

Implemented in ome::files::detail::FormatWriter.

Referenced by ~FormatWriter().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: