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

A multidimensional array of numbers that cannot be written through. More...

#include <vitrio/array/const_array.hpp>

Public Member Functions

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

Friends

class array
 

Detailed Description

A multidimensional array of numbers that cannot be written through.

It is an array whose elements can only be read: it keeps its memory alive in the same way, and it cannot be copied either. The memory may be read-only, or it may be the memory of an array that is still written through elsewhere.

See also
array
const_array_ref

Constructor & Destructor Documentation

◆ const_array() [1/2]

vitrio::const_array::const_array ( )
noexcept

Construct an array that holds nothing.

Its descriptor is not initialized and it has no memory.

◆ const_array() [2/2]

vitrio::const_array::const_array ( span< const byte >  memory,
std::shared_ptr< const 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()

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

Get the memory holding the elements.

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_descriptor()

const array_descriptor & vitrio::const_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()

const_array vitrio::const_array::share ( ) const
noexcept

Make another read-only array over the same memory.

Returns
const_array An array with the same descriptor and the same elements.

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