DUDS
Distributed Update of Data from Something
duds::data::QuantityArray< L > Struct Template Reference

A fixed size array of quantities all sharing the same units. More...

#include <QuantityArray.hpp>

Collaboration diagram for duds::data::QuantityArray< L >:

Public Types

typedef std::array< double, L > Array
 The type of the array holding quantity values. More...
 
typedef QuantityIterator< typename Array::const_iterator > const_iterator
 A const iterator type that will yield Quantity objects when dereferenced. More...
 
typedef QuantityIterator< typename Array::iterator > iterator
 An iterator type that will yield Quantity objects when dereferenced. More...
 

Public Member Functions

iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
template<std::size_t N>
QuantityArraycopy (const QuantityArray< N > &a)
 Copies one QuantityArray into another; sizes do not need to match. More...
 
iterator end ()
 
const_iterator end () const
 
Quantity get (std::size_t pos) const
 Returns a new Quantity object for the requested position. More...
 
QuantityArrayoperator= (const QuantityArray &a)=default
 Copies one QuantityArray into another for an exact match. More...
 
QuantityArrayoperator= (const QuantityNddArray &a)
 Copies the contents of a QuantityNddArray into this object. More...
 
void set (std::size_t pos, const Quantity &q)
 Sets a stored quantity to be the same as given Quantity object. More...
 

Public Attributes

Array array
 The array of quantity values. More...
 
Unit unit
 The units of all values in the array. More...
 

Detailed Description

template<std::size_t L>
struct duds::data::QuantityArray< L >

A fixed size array of quantities all sharing the same units.

A std::array is used to store the quantity values, doubles, instead of Quantity objects. This reduces the memory usage over having an array of Quantity objects. Functions are provided that work with Quantity objects.

Template Parameters
LThe length of the array.
Author
Jeff Jackowski

Definition at line 120 of file QuantityArray.hpp.

Member Typedef Documentation

◆ Array

template<std::size_t L>
typedef std::array<double, L> duds::data::QuantityArray< L >::Array

The type of the array holding quantity values.

Definition at line 124 of file QuantityArray.hpp.

◆ const_iterator

template<std::size_t L>
typedef QuantityIterator<typename Array::const_iterator> duds::data::QuantityArray< L >::const_iterator

A const iterator type that will yield Quantity objects when dereferenced.

Definition at line 140 of file QuantityArray.hpp.

◆ iterator

template<std::size_t L>
typedef QuantityIterator<typename Array::iterator> duds::data::QuantityArray< L >::iterator

An iterator type that will yield Quantity objects when dereferenced.

Definition at line 136 of file QuantityArray.hpp.

Member Function Documentation

◆ begin() [1/2]

template<std::size_t L>
iterator duds::data::QuantityArray< L >::begin ( )
inline

Definition at line 141 of file QuantityArray.hpp.

◆ begin() [2/2]

template<std::size_t L>
const_iterator duds::data::QuantityArray< L >::begin ( ) const
inline

Definition at line 144 of file QuantityArray.hpp.

◆ cbegin()

template<std::size_t L>
const_iterator duds::data::QuantityArray< L >::cbegin ( ) const
inline

Definition at line 147 of file QuantityArray.hpp.

◆ cend()

template<std::size_t L>
const_iterator duds::data::QuantityArray< L >::cend ( ) const
inline

Definition at line 156 of file QuantityArray.hpp.

◆ copy()

template<std::size_t L>
template<std::size_t N>
QuantityArray& duds::data::QuantityArray< L >::copy ( const QuantityArray< N > &  a)
inline

Copies one QuantityArray into another; sizes do not need to match.

Definition at line 193 of file QuantityArray.hpp.

◆ end() [1/2]

template<std::size_t L>
iterator duds::data::QuantityArray< L >::end ( )
inline

Definition at line 150 of file QuantityArray.hpp.

◆ end() [2/2]

template<std::size_t L>
const_iterator duds::data::QuantityArray< L >::end ( ) const
inline

Definition at line 153 of file QuantityArray.hpp.

◆ get()

template<std::size_t L>
Quantity duds::data::QuantityArray< L >::get ( std::size_t  pos) const
inline

Returns a new Quantity object for the requested position.

Parameters
posThe position in the array.
Exceptions
std::out_of_rangeThrown by Array::at() when the position is outside the array's boundries.

Definition at line 165 of file QuantityArray.hpp.

◆ operator=() [1/2]

template<std::size_t L>
QuantityArray& duds::data::QuantityArray< L >::operator= ( const QuantityArray< L > &  a)
default

Copies one QuantityArray into another for an exact match.

◆ operator=() [2/2]

template<std::size_t L>
QuantityArray< L > & duds::data::QuantityArray< L >::operator= ( const QuantityNddArray a)

Copies the contents of a QuantityNddArray into this object.

Parameters
aThe source array. It must be one dimensional. The intersection of the elements will be copied; the sizes do not need to match. If a is smaller than this array, some elements will remain unchanged.

Definition at line 444 of file QuantityArray.hpp.

◆ set()

template<std::size_t L>
void duds::data::QuantityArray< L >::set ( std::size_t  pos,
const Quantity q 
)
inline

Sets a stored quantity to be the same as given Quantity object.

Precondition
The given Quantity has the same units as all quantites in this array (unit).
Parameters
posThe position in the array.
qThe quantity to store.
Exceptions
UnitMismatchThe units of q are not the same as the units of this array.
std::out_of_rangeThrown by Array::at() when the position is outside the array's boundries.

Definition at line 179 of file QuantityArray.hpp.

Member Data Documentation

◆ array

template<std::size_t L>
Array duds::data::QuantityArray< L >::array

The array of quantity values.

Definition at line 128 of file QuantityArray.hpp.

Referenced by duds::data::QuantityArray< 3 >::copy(), and duds::data::QuantityNddArray::operator=().

◆ unit


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