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::array Class Reference

A multidimensional array of numbers in host memory. More...

#include <vitrio/array/array.hpp>

Public Member Functions

 array () noexcept
 Construct an array that holds nothing.
 
 array (span< byte > memory, std::shared_ptr< void > owner, array_descriptor descriptor)
 Construct an array over memory allocated elsewhere.
 
 array (const array &other)=delete
 
 array (array &&other) noexcept
 
array & operator= (const array &other)=delete
 
array & operator= (array &&other) noexcept
 
const array_descriptor & get_descriptor () const noexcept
 Get how the memory is read as an array.
 
byte * get_data () noexcept
 Get the memory holding the elements.
 
const byte * get_data () const noexcept
 Get the memory holding the elements, to read them.
 
array share () noexcept
 Make another array over the same memory.
 
const_array share_const () const noexcept
 Make a read-only array over the same memory.
 

Detailed Description

A multidimensional array of numbers in host memory.

An array is a block of memory and the descriptor that says how to read it as a multidimensional array. It keeps the memory alive: the memory is released when the last array sharing it is destroyed.

An array cannot be copied, so that two names for the same elements are never made by accident. share makes another array over the same memory on purpose.

The array does nothing with its elements. It has no arithmetic, slicing or reshaping.

See also
const_array
array_ref
make_array

Constructor & Destructor Documentation

◆ array() [1/2]

vitrio::array::array ( )
noexcept

Construct an array that holds nothing.

Its descriptor is not initialized and it has no memory.

◆ array() [2/2]

vitrio::array::array ( span< byte >  memory,
std::shared_ptr< void >  owner,
array_descriptor  descriptor 
)

Construct an array over memory allocated elsewhere.

The array keeps owner for as long as it or any array sharing its memory lives. Whatever releasing owner does is how the memory is released, so the memory may come from anywhere.

Parameters
memoryThe memory holding the elements.
ownerWhat keeps memory alive. Must not be null.
descriptorHow memory is read as an array.
Exceptions
std::invalid_argumentIf owner is null, if descriptor is not initialized, or if memory is not aligned to the elements.
std::out_of_rangeIf an element descriptor addresses lies outside memory.

Member Function Documentation

◆ get_data() [1/2]

const byte * vitrio::array::get_data ( ) const
noexcept

Get the memory holding the elements, to read them.

Returns
const byte* The first byte of the memory. The element at the origin is at the offset the descriptor states. Null when the array holds nothing.

◆ get_data() [2/2]

byte * vitrio::array::get_data ( )
noexcept

Get the memory holding the elements.

Returns
byte* The first byte of the memory. The element at the origin is at the offset the descriptor states. Null when the array holds nothing.

◆ get_descriptor()

const array_descriptor & vitrio::array::get_descriptor ( ) const
noexcept

Get how the memory is read as an array.

Returns
const array_descriptor& The descriptor. Not initialized when the array holds nothing.

◆ share()

array vitrio::array::share ( )
noexcept

Make another array over the same memory.

Returns
array An array with the same descriptor and the same elements. Writing through either one changes both.

◆ share_const()

const_array vitrio::array::share_const ( ) const
noexcept

Make a read-only array over the same memory.

Returns
const_array An array with the same descriptor and the same elements, which cannot be written through.

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