vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
vitrio::image_transfer_plan Class Reference

The regions to transfer between one file and one array. More...

#include <vitrio/image_transfer_plan.hpp>

Public Member Functions

 image_transfer_plan (image_transfer_shape shape)
 Construct an empty plan of a given shape.
 
 image_transfer_plan (const image_transfer_plan &other)
 
 image_transfer_plan (image_transfer_plan &&other) noexcept
 
image_transfer_plan & operator= (const image_transfer_plan &other)
 
image_transfer_plan & operator= (image_transfer_plan &&other) noexcept
 
void add (span< const std::size_t > file_offset, span< const std::size_t > array_offset)
 Append one region.
 
void clear () noexcept
 Drop the regions held, keeping the shape and the capacity.
 
void reserve (std::size_t count)
 Make room for a number of regions without allocating later.
 
std::size_t get_region_count () const noexcept
 Get how many regions are held.
 
const image_transfer_shape & get_shape () const noexcept
 Get the shape every region shares.
 
span< const std::size_t > get_file_offset (std::size_t region_index) const noexcept
 Get where a region starts in the file.
 
span< const std::size_t > get_array_offset (std::size_t region_index) const noexcept
 Get where a region starts in the array.
 

Detailed Description

The regions to transfer between one file and one array.

Every region pairs an offset into the file with an offset into the array, and every region in a plan shares one image_transfer_shape. The two sides are named file and array rather than source and destination, so the same plan describes a read and a write alike.

The shape is fixed when a plan is constructed; only the regions come and go.

The offsets are held in two index_table rather than one allocation per region, so any number of regions costs a bounded number of allocations, and clear keeps the capacity, so a plan refilled after its first use allocates nothing.

See also
image_transaction_plan

Constructor & Destructor Documentation

◆ image_transfer_plan()

vitrio::image_transfer_plan::image_transfer_plan ( image_transfer_shape  shape)
explicit

Construct an empty plan of a given shape.

The shape is what every region of the plan shares and is fixed for the life of it; only the regions are added and dropped.

Parameters
shapeThe shape of every region.

Member Function Documentation

◆ add()

void vitrio::image_transfer_plan::add ( span< const std::size_t >  file_offset,
span< const std::size_t >  array_offset 
)

Append one region.

Parameters
file_offsetIndex of the first element of the region in the file. Its size must equal the file rank of the shape.
array_offsetIndex of the first element of the region in the array. Its size must equal the array rank of the shape.
Exceptions
std::invalid_argumentIf either offset has the wrong rank.

◆ get_array_offset()

span< const std::size_t > vitrio::image_transfer_plan::get_array_offset ( std::size_t  region_index) const
noexcept

Get where a region starts in the array.

Parameters
region_indexIndex of the region. Must be below get_region_count.
Returns
span<const std::size_t> The offset, of the array rank of the shape. It refers to storage owned by this plan.

◆ get_file_offset()

span< const std::size_t > vitrio::image_transfer_plan::get_file_offset ( std::size_t  region_index) const
noexcept

Get where a region starts in the file.

Parameters
region_indexIndex of the region. Must be below get_region_count.
Returns
span<const std::size_t> The offset, of the file rank of the shape. It refers to storage owned by this plan.

◆ get_region_count()

std::size_t vitrio::image_transfer_plan::get_region_count ( ) const
noexcept

Get how many regions are held.

Returns
std::size_t The number of regions.

◆ get_shape()

const image_transfer_shape & vitrio::image_transfer_plan::get_shape ( ) const
noexcept

Get the shape every region shares.

Returns
const image_transfer_shape& The shape. It refers to storage owned by this plan.

◆ reserve()

void vitrio::image_transfer_plan::reserve ( std::size_t  count)

Make room for a number of regions without allocating later.

Parameters
countNumber of regions to make room for.

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