vitrio 0.3.1
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
vitrio::image_writer Class Referenceabstract

Abstract writable view of one image file. More...

#include <vitrio/image_writer.hpp>

Inheritance diagram for vitrio::image_writer:

Public Member Functions

 image_writer (const image_writer &other)=delete
 image_writer (image_writer &&other)=delete
image_writer & operator= (const image_writer &other)=delete
image_writer & operator= (image_writer &&other)=delete
virtual const image_descriptor & get_descriptor () const noexcept=0
 Get the shape and data type of the file.
virtual void write_async (const_array source, image_transfer_plan regions, std::shared_ptr< completion_notifier > done)=0
 Start writing a set of hyperrectangles of the file from one array.
virtual void flush_async (std::shared_ptr< completion_notifier > done)=0
 Start making what has been written reach the storage.

Detailed Description

Abstract writable view of one image file.

The mirror of image_reader, with the same regions, described by the same image_transfer_plan, the same conversion rule and the opposite direction. A writer is opened over complete extents, so the shape of the file is settled before anything is written; the file can be laid out once up front and a region can be written wherever it belongs, in any order.

Member Function Documentation

◆ flush_async()

virtual void vitrio::image_writer::flush_async ( std::shared_ptr< completion_notifier > done)
pure virtual

Start making what has been written reach the storage.

What has been written is what every write that reported to its notifier before this was called wrote. A write still under way is not covered.

Call this before dropping a writer whose failures matter. A writer flushes itself when it is destroyed, but a destructor can not report a failure, so a write that only fails on the way out is lost unless it was flushed explicitly.

The flush may still be under way when this returns. It reports to done exactly once: when what has been written has reached the storage, or with what made it fail.

Parameters
doneWhere the outcome is reported. Must not be null.
Exceptions
std::invalid_argumentIf done is null. Every other failure is reported to done rather than thrown: image_file_error if what has been written could not reach the storage.

Implemented in vitrio::synchronous_image_writer.

◆ get_descriptor()

virtual const image_descriptor & vitrio::image_writer::get_descriptor ( ) const
pure virtualnoexcept

Get the shape and data type of the file.

The ones the writer was created over. The extents bound every region that may be written, and a write converts to the data type from whatever it is given. How the file lays its elements out within the extents is the format's own business and is not reported.

Returns
const image_descriptor& The descriptor. It refers to storage owned by this writer.

◆ write_async()

virtual void vitrio::image_writer::write_async ( const_array source,
image_transfer_plan regions,
std::shared_ptr< completion_notifier > done )
pure virtual

Start writing a set of hyperrectangles of the file from one array.

The mirror of image_reader::read_async, sharing its plan and naming its sides the same way: the file is the file side and source the array side, so every region names where it is taken from in source and where it lands in the file, and all of them share the extents the plan carries. The plan is therefore built the same way for a write as for a read. Passing every region in one call lets a writer order and merge the accesses it is about to make, and pays for the source's geometry once.

source is the whole array and may be strided. Its rank must be the array rank of the plan and the file's the file rank, and values are converted as a cast between the two types does, without scaling or normalising.

Regions that do not overlap may be written by concurrent calls. Overlapping ones may not, and where two regions of one call land on the same elements of the file, which one prevails is unspecified.

A region that is never written keeps whatever the format leaves in a file it has laid out but not filled. An empty plan writes nothing and reports success.

The write may still be under way when this returns. It reports to done exactly once: when every region has been written, or with what made it fail. It keeps source, and with it the memory it writes from, until then.

Parameters
sourceThe values to write. Must be initialized.
regionsThe regions to write and where each one comes from.
doneWhere the outcome is reported. Must not be null.
Exceptions
std::invalid_argumentIf done is null. Every other failure is reported to done rather than thrown:
  • std::invalid_argument if the array offsets do not have the rank of source, if the file offsets do not have the rank of the file, or if source is not initialized;
  • std::out_of_range if a region is not contained in the file, or is not contained in source where it is taken from;
  • unsupported_operation_error if the data type of the file can not be produced from the one of source;
  • image_file_error if the file can not be written.

Implemented in vitrio::synchronous_image_writer.


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