|
vitrio 0.3.1
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
|
Abstract writable view of one image file. More...
#include <vitrio/image_writer.hpp>

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. | |
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.
|
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.
| done | Where the outcome is reported. Must not be null. |
| std::invalid_argument | If 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.
|
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.
|
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.
| source | The values to write. Must be initialized. |
| regions | The regions to write and where each one comes from. |
| done | Where the outcome is reported. Must not be null. |
| std::invalid_argument | If done is null. Every other failure is reported to done rather than thrown:
|
Implemented in vitrio::synchronous_image_writer.