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

A reference to a multidimensional array that does not keep it alive. More...

#include <vitrio/array/array_ref.hpp>

Public Member Functions

 array_ref () noexcept
 Construct a reference to nothing.
 
 array_ref (span< byte > memory, const array_descriptor &descriptor)
 Construct a reference to memory the caller keeps alive.
 
 array_ref (span< byte > memory, const array_descriptor &&descriptor)=delete
 
 array_ref (array &other) noexcept
 Construct a reference to an array.
 
 array_ref (array &&other)=delete
 
 array_ref (const array_ref &other) noexcept=default
 
array_ref & operator= (const array_ref &other) noexcept=default
 
const array_descriptor & get_descriptor () const noexcept
 Get how the memory is read as an array.
 
byte * get_data () const noexcept
 Get the memory holding the elements.
 

Detailed Description

A reference to a multidimensional array that does not keep it alive.

A reference is two pointers, one to the memory of an array and one to its descriptor. It owns neither, so copying it copies the two pointers and nothing else, as copying a span does.

It is the parameter type of a function that uses an array only until it returns. What it refers to must outlive it, so a reference should not be stored.

An array converts to a reference to itself.

See also
array
const_array_ref

Constructor & Destructor Documentation

◆ array_ref() [1/3]

vitrio::array_ref::array_ref ( )
noexcept

Construct a reference to nothing.

Its descriptor is not initialized and it has no memory.

◆ array_ref() [2/3]

vitrio::array_ref::array_ref ( span< byte >  memory,
const array_descriptor &  descriptor 
)

Construct a reference to memory the caller keeps alive.

Parameters
memoryThe memory holding the elements. It must outlive the reference and its copies.
descriptorHow memory is read as an array. It must outlive the reference and its copies.
Exceptions
std::invalid_argumentIf descriptor is not initialized, or if memory is not aligned to the elements.
std::out_of_rangeIf an element descriptor addresses lies outside memory.

◆ array_ref() [3/3]

vitrio::array_ref::array_ref ( array &  other)
noexcept

Construct a reference to an array.

Parameters
otherThe array to refer to. It must outlive the reference and its copies.

Member Function Documentation

◆ get_data()

byte * vitrio::array_ref::get_data ( ) const
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 reference is to nothing.

◆ get_descriptor()

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

Get how the memory is read as an array.

Returns
const array_descriptor& The descriptor. Not initialized when the reference is to nothing.

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