bioformats  5.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
ome::bioformats::detail::FormatWriter Class Referenceabstract

Interface for all biological file format writers (default behaviour). More...

#include <ome/bioformats/detail/FormatWriter.h>

+ Inheritance diagram for ome::bioformats::detail::FormatWriter:
+ Collaboration diagram for ome::bioformats::detail::FormatWriter:

Public Member Functions

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

Protected Member Functions

 FormatWriter (const WriterProperties &)
 Constructor.
 
- Protected Member Functions inherited from ome::bioformats::FormatWriter
 FormatWriter ()
 Constructor.
 
- Protected Member Functions inherited from ome::bioformats::FormatHandler
 FormatHandler ()
 Constructor.
 

Protected Attributes

const WriterPropertieswriterProperties
 Writer properties specific to the derived file format.
 
boost::optional< boost::filesystem::path > currentId
 The identifier (path) of the currently open file.
 
ome::compat::shared_ptr< std::ostream > out
 Current output.
 
dimension_size_type series
 Current series.
 
boost::optional< std::string > compression
 The compression type to use.
 
bool sequential
 Planes are written sequentially.
 
frame_rate_type framesPerSecond
 The frames per second to use when writing.
 
ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrievemetadataRetrieve
 Current metadata store. More...
 

Private Member Functions

 FormatWriter (const FormatWriter &)
 Copy constructor (deleted).
 
FormatWriteroperator= (const FormatWriter &)
 Assignment operator (deleted).
 

Additional Inherited Members

- Public Types inherited from ome::bioformats::FormatWriter
typedef uint16_t frame_rate_type
 Frame rate type.
 
- Static Public Member Functions inherited from ome::bioformats::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 (default behaviour).

Note
The ColorModel isn't stored here; this is Java-specific and not implemented in C++.
The current output stream isn't stored here; this is the responsibility of the individual writer. Having a reference to the base ostream here and keeping this in sync with the derived writer is an unnecessary complication.

Member Function Documentation

bool ome::bioformats::detail::FormatWriter::canDoStacks ( ) const
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.

Implements ome::bioformats::FormatWriter.

References ome::bioformats::detail::WriterProperties::stacks, and writerProperties.

void ome::bioformats::detail::FormatWriter::changeOutputFile ( const boost::filesystem::path &  id)
virtual

Switch the output file for the current dataset.

Parameters
idthe new file name.

Implements ome::bioformats::FormatWriter.

References ome::bioformats::FormatHandler::assertId(), currentId, and setId().

void ome::bioformats::detail::FormatWriter::close ( bool  fileOnly = false)
virtual

Close the currently open file.

Parameters
fileOnlyclose the open file only if true, or else free all internal state if false.

Implements ome::bioformats::FormatHandler.

References currentId, out, and series.

const boost::optional< std::string > & ome::bioformats::detail::FormatWriter::getCompression ( ) const
virtual

Get the compression type to use when writing.

Returns
the compression type.

Implements ome::bioformats::FormatWriter.

References compression.

const std::vector< boost::filesystem::path > & ome::bioformats::detail::FormatWriter::getCompressionSuffixes ( ) const
virtual

Get the default compression suffixes for this file format.

Returns
a list of file suffixes.

Implements ome::bioformats::FormatHandler.

References ome::bioformats::detail::WriterProperties::compression_suffixes, and writerProperties.

const std::set< std::string > & ome::bioformats::detail::FormatWriter::getCompressionTypes ( ) const
virtual

Get supported compression types.

Returns
the supported compression types.

Implements ome::bioformats::FormatWriter.

References ome::bioformats::detail::WriterProperties::compression_types, and writerProperties.

const std::string & ome::bioformats::detail::FormatWriter::getFormat ( ) const
virtual

Get the name of this file format.

Returns
the file format name.

Implements ome::bioformats::FormatHandler.

References ome::bioformats::detail::WriterProperties::name, and writerProperties.

const std::string & ome::bioformats::detail::FormatWriter::getFormatDescription ( ) const
virtual

Get the description of this file format.

Returns
the file format description.

Implements ome::bioformats::FormatHandler.

References ome::bioformats::detail::WriterProperties::description, and writerProperties.

FormatWriter::frame_rate_type ome::bioformats::detail::FormatWriter::getFramesPerSecond ( ) const
virtual

Get the frame rate to use when writing.

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

Implements ome::bioformats::FormatWriter.

References framesPerSecond.

const ome::compat::shared_ptr<::ome::xml::meta::MetadataRetrieve > & ome::bioformats::detail::FormatWriter::getMetadataRetrieve ( ) const
virtual

Get the current metadata store for this writer.

Returns
the metadata store, which will never be null.

Implements ome::bioformats::FormatWriter.

References metadataRetrieve.

Referenced by setId().

+ Here is the caller graph for this function:

ome::compat::shared_ptr<::ome::xml::meta::MetadataRetrieve > & ome::bioformats::detail::FormatWriter::getMetadataRetrieve ( )
virtual

Get the current metadata store for this writer.

Returns
the metadata store, which will never be null.

Implements ome::bioformats::FormatWriter.

References metadataRetrieve.

const std::set< ome::xml::model::enums::PixelType > & ome::bioformats::detail::FormatWriter::getPixelTypes ( ) const
virtual

Get supported pixel types.

Returns
the supported pixel types.

Implements ome::bioformats::FormatWriter.

Referenced by isSupportedType().

+ Here is the caller graph for this function:

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

Get supported pixel types for the given codec.

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

Implements ome::bioformats::FormatWriter.

References ome::bioformats::detail::WriterProperties::codec_pixel_types, and writerProperties.

dimension_size_type ome::bioformats::detail::FormatWriter::getSeries ( ) const
virtual

Get the active series.

Returns
the active series.

Implements ome::bioformats::FormatWriter.

References series.

Referenced by saveBytes().

+ Here is the caller graph for this function:

const std::vector< boost::filesystem::path > & ome::bioformats::detail::FormatWriter::getSuffixes ( ) const
virtual

Get the default file suffixes for this file format.

Returns
a list of file suffixes.

Implements ome::bioformats::FormatHandler.

References ome::bioformats::detail::WriterProperties::suffixes, and writerProperties.

bool ome::bioformats::detail::FormatWriter::getWriteSequentially ( ) const
virtual

Check if planes are written sequentially.

Returns
true if sequential, false if not.

Implements ome::bioformats::FormatWriter.

References sequential.

bool ome::bioformats::detail::FormatWriter::isSupportedType ( ome::xml::model::enums::PixelType  type) const
virtual

Check if the pixel type is supported.

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

Implements ome::bioformats::FormatWriter.

bool ome::bioformats::detail::FormatWriter::isSupportedType ( ome::xml::model::enums::PixelType  type,
const std::string &  codec 
) const
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.

Implements ome::bioformats::FormatWriter.

References getPixelTypes().

bool ome::bioformats::detail::FormatWriter::isThisType ( const boost::filesystem::path &  name,
bool  open = true 
) const
virtual

Check if the given file is a valid instance of this file format.

Parameters
namethe file to open for checking.
openIf true, and the file extension is insufficient to determine the file type, the file may be opened for further analysis, or other relatively expensive file system operations (such as file existence tests and directory listings) may be performed. If false, file system access is not allowed.
Returns
true if the file is valid, false otherwise.
Todo:
Could this method be static?

Implements ome::bioformats::FormatHandler.

References ome::bioformats::FormatHandler::checkSuffix(), ome::bioformats::detail::WriterProperties::compression_suffixes, ome::bioformats::detail::WriterProperties::suffixes, and writerProperties.

void ome::bioformats::detail::FormatWriter::saveBytes ( dimension_size_type  no,
VariantPixelBuffer buf 
)
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
nothe image index within the file.
bufthe source pixel buffer.
Exceptions
FormatExceptionif any of the parameters are invalid.

Implements ome::bioformats::FormatWriter.

References ome::bioformats::FormatHandler::assertId(), currentId, getSeries(), and metadataRetrieve.

void ome::bioformats::detail::FormatWriter::saveBytes ( dimension_size_type  no,
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
nothe image index within the file.
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.

Implements ome::bioformats::FormatWriter.

void ome::bioformats::detail::FormatWriter::setCompression ( const std::string &  compression)
virtual

Set the compression type to use when writing.

Parameters
compressionthe compression type.

Implements ome::bioformats::FormatWriter.

References compression, ome::bioformats::detail::WriterProperties::compression_types, and writerProperties.

void ome::bioformats::detail::FormatWriter::setFramesPerSecond ( frame_rate_type  rate)
virtual

Set the frame rate to use when writing.

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

Implements ome::bioformats::FormatWriter.

References framesPerSecond.

void ome::bioformats::detail::FormatWriter::setId ( const boost::filesystem::path &  id)
virtual

Set the current file name.

Note this will throw FormatException if there are problems opening the file.

Parameters
idthe filename to open.

Implements ome::bioformats::FormatHandler.

References currentId, getMetadataRetrieve(), out, and setSeries().

Referenced by changeOutputFile().

+ Here is the caller graph for this function:

void ome::bioformats::detail::FormatWriter::setLookupTable ( const VariantPixelBuffer buf)
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
bufthe source pixel buffer.

Implements ome::bioformats::FormatWriter.

References ome::bioformats::FormatHandler::assertId(), and currentId.

void ome::bioformats::detail::FormatWriter::setMetadataRetrieve ( ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve > &  retrieve)
virtual

Set the default metadata store for this writer.

Parameters
retrievea metadata retrieve implementation.

Implements ome::bioformats::FormatWriter.

References ome::bioformats::FormatHandler::assertId(), currentId, and metadataRetrieve.

void ome::bioformats::detail::FormatWriter::setSeries ( dimension_size_type  no) const
virtual

Set the active series.

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

Implements ome::bioformats::FormatWriter.

References metadataRetrieve, and series.

Referenced by setId().

+ Here is the caller graph for this function:

void ome::bioformats::detail::FormatWriter::setWriteSequentially ( bool  sequential = true)
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.

Implements ome::bioformats::FormatWriter.

References sequential.

Member Data Documentation

ome::compat::shared_ptr< ::ome::xml::meta::MetadataRetrieve> ome::bioformats::detail::FormatWriter::metadataRetrieve
protected

Current metadata store.

Should never be accessed directly as the semantics of getMetadataRetrieve() prevent "null" access.

Referenced by getMetadataRetrieve(), saveBytes(), setMetadataRetrieve(), and setSeries().


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