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_transaction_plan Class Reference

List of regions to transfer between many files and one array. More...

#include <vitrio/image_transaction_plan.hpp>

Public Member Functions

 image_transaction_plan (image_transfer_shape shape)
 Construct an empty plan of a given shape.
 
 image_transaction_plan (const image_transaction_plan &other)
 
 image_transaction_plan (image_transaction_plan &&other) noexcept
 
image_transaction_plan & operator= (const image_transaction_plan &other)
 
image_transaction_plan & operator= (image_transaction_plan &&other) noexcept
 
std::size_t add_file (std::string key)
 Name a file the regions may address.
 
void add (std::size_t file_index, span< const std::size_t > file_offset, span< const std::size_t > array_offset)
 Append one region.
 
void clear () noexcept
 Drop the files and the regions, keeping the shape and the capacity.
 
void reserve (std::size_t files, std::size_t regions)
 Make room 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.
 
std::size_t get_file_count () const noexcept
 Get how many distinct files the regions may address.
 
const std::string & get_file (std::size_t file_index) const noexcept
 Get the key of one of the files.
 
std::size_t get_region_file (std::size_t region_index) const noexcept
 Get which file one region addresses.
 
span< const std::size_t > get_file_offset (std::size_t region_index) const noexcept
 Get where a region starts in its 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

List of regions to transfer between many files and one array.

Every region pairs an offset into a file with an offset into the array, names the file it belongs to, and shares one image_transfer_shape with every other region in the plan. The file rank of the shape is the rank of every file.

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

Regions are held in the order they were added, not grouped by file.

See also
image_transfer_plan

Constructor & Destructor Documentation

◆ image_transaction_plan()

vitrio::image_transaction_plan::image_transaction_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 files and the regions are added and dropped.

Parameters
shapeThe shape of every region.

Member Function Documentation

◆ add()

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

Append one region.

Parameters
file_indexIndex of the file it addresses, as add_file returned it.
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::out_of_rangeIf file_index names no file.
std::invalid_argumentIf either offset has the wrong rank.

◆ add_file()

std::size_t vitrio::image_transaction_plan::add_file ( std::string  key)

Name a file the regions may address.

A key equal to one already named yields the index it was given the first time, so the file of every region may be named without checking whether it has been named already.

Parameters
keyKey of the file.
Returns
std::size_t Index of the file, below get_file_count.

◆ get_array_offset()

span< const std::size_t > vitrio::image_transaction_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()

const std::string & vitrio::image_transaction_plan::get_file ( std::size_t  file_index) const
noexcept

Get the key of one of the files.

Parameters
file_indexIndex of the file. Must be below get_file_count.
Returns
const std::string& The key. It refers to storage owned by this plan.

◆ get_file_count()

std::size_t vitrio::image_transaction_plan::get_file_count ( ) const
noexcept

Get how many distinct files the regions may address.

Counts every file named, including one no region addresses.

Returns
std::size_t The number of files.

◆ get_file_offset()

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

Get where a region starts in its 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_transaction_plan::get_region_count ( ) const
noexcept

Get how many regions are held.

Returns
std::size_t The number of regions.

◆ get_region_file()

std::size_t vitrio::image_transaction_plan::get_region_file ( std::size_t  region_index) const
noexcept

Get which file one region addresses.

Parameters
region_indexIndex of the region. Must be below get_region_count.
Returns
std::size_t The file index, below get_file_count.

◆ get_shape()

const image_transfer_shape & vitrio::image_transaction_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_transaction_plan::reserve ( std::size_t  files,
std::size_t  regions 
)

Make room without allocating later.

Parameters
filesNumber of distinct files to make room for.
regionsNumber of regions to make room for.

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