10 #ifndef QUANTITYARRAY_HPP 11 #define QUANTITYARRAY_HPP 17 namespace duds {
namespace data {
19 struct QuantityNddArray;
46 typedef typename std::iterator_traits<I>::pointer
pointer;
47 typedef typename std::iterator_traits<I>::reference
reference;
79 return iter == it.
iter;
82 return iter != it.
iter;
119 template <std::
size_t L>
124 typedef std::array<double, L>
Array;
142 return iterator(array.begin(),
unit);
145 return const_iterator(array.begin(),
unit);
148 return const_iterator(array.cbegin(),
unit);
151 return iterator(array.end(),
unit);
153 const_iterator
end()
const {
154 return const_iterator(array.end(),
unit);
157 return const_iterator(array.cend(),
unit);
180 if (unit != q.unit) {
183 array.at(pos) = q.value;
192 template <std::
size_t N>
195 std::size_t loop = std::min(L, N);
196 typename Array::iterator dest = array.begin();
198 for (; loop; ++dest, ++src, --loop) {
228 const double &
x()
const {
240 const double &
y()
const {
252 const double &
z()
const {
325 template <std::
size_t N>
342 return array.
empty();
356 return const_iterator(array.
begin(),
unit);
362 return iterator(array.
end(),
unit);
364 const_iterator
end()
const {
365 return const_iterator(array.
end(),
unit);
368 return const_iterator(array.
cend(),
unit);
408 if (unit != q.unit) {
411 array.
at<Dim>(pos) = q.value;
426 if (unit != q.unit) {
434 friend class boost::serialization::access;
437 a & BOOST_SERIALIZATION_NVP(array);
438 a & BOOST_SERIALIZATION_NVP(unit);
443 template <std::
size_t L>
453 #endif // #ifndef QUANTITYARRAY_HPP Unit unit
The units of all values in the array.
Quantity operator*() const
Returns a new Quantity object.
auto value() const
Returns a reference to the value stored in the container.
A container for a value and a unit to better describe the value.
Array array
The array of quantity values.
void clear()
Makes the Unit unitless.
QuantityNddArray(QuantityNddArray &&q) noexcept
Move constructor; the array of quantities is moved rather than copied.
const double & x() const
Returns the scalar value for the X-axis.
double & y()
Returns the scalar value for the Y-axis.
std::iterator_traits< I >::reference reference
An iterator template for QuantityArray and QuantityNddArray that provides a Quantity object when dere...
duds::general::NddArray< double > Array
The type of the array holding quantity values.
std::array< double, L > Array
The type of the array holding quantity values.
An array of quantites of dynamic size and number of dimensions.
const_iterator cend() const
double & z()
Returns the scalar value for the Z-axis.
A fixed size array of quantities all sharing the same units.
void clear() noexcept
Destroys the contents of the array.
Quantity xQ() const
Returns the Quantity for the X-axis.
Indicates that two different Unit objects were used in an operation that requires identical Unit obje...
const_iterator cbegin() const
move_impl move(unsigned int c, unsigned int r)
Display stream manipulator that moves the display cursor to the given location.
void copyTo(std::array< T, N > &a) const
Copies the contents of this object into a std::array.
QuantityIterator(const I &i, Unit u)
Construct a new iterator with the given units.
QuantityArray & operator=(const QuantityArray &a)=default
Copies one QuantityArray into another for an exact match.
bool operator==(const QuantityIterator &it) const
std::initializer_list< SizeType > DimList
A type that can specify the dimensions of the array, or a position of an element. ...
QuantityIterator< typename Array::const_iterator > const_iterator
A const iterator type that will yield Quantity objects when dereferenced.
const_iterator begin() const
QuantityIterator< typename Array::iterator > iterator
An iterator type that will yield Quantity objects when dereferenced.
std::iterator_traits< I >::iterator_category iterator_category
bool empty() const
True if the array has zero dimensions.
const_iterator cend() const
QuantityIterator< typename Array::iterator > iterator
An iterator type that will yield Quantity objects when dereferenced.
double & x()
Returns the scalar value for the X-axis.
T & at(const Dim &pos)
Obtain an element from the array stored at a specific position.
const T * cend() const
An iterator (really just a pointer) to one past the last element of the array.
void copyFrom(const AV &av)
Copies from a one dimensional container into this array.
Quantity zQ() const
Returns the Quantity for the Z-axis.
Unit unit
The units of all values in the array.
Unit arrayUnit
The units used for all Quantities in the array.
QuantityArray & copy(const QuantityArray< N > &a)
Copies one QuantityArray into another; sizes do not need to match.
Represents an SI unit, either base or derived.
Array array
The array of quantity values.
void serialize(A &a, const unsigned int)
T * begin()
An iterator (really just a pointer) to the first element of the array.
const_iterator end() const
const_iterator begin() const
QuantityIterator & operator--()
const_iterator cbegin() const
QuantityIterator< typename Array::const_iterator > const_iterator
A const iterator type that will yield Quantity objects when dereferenced.
bool operator!=(const QuantityIterator &it) const
A QuantityArray for the common usage of a three dimentional coordinate or a triple axis sample...
QuantityNddArray & operator=(const QuantityArray< N > &q)
Copies the contents of a QuantityArray into this object.
QuantityIterator & operator++()
Quantity yQ() const
Returns the Quantity for the Y-axis.
std::iterator_traits< I >::pointer pointer
const double & y() const
Returns the scalar value for the Y-axis.
const double & z() const
Returns the scalar value for the Z-axis.
Unit unit() const
Returns the units of all quantities stored in the container.
void clear() noexcept
Clears the array and units.
I iter
The iterator wrapped by this object.
T * end()
An iterator (really just a pointer) to one past the last element of the array.
QuantityIterator()=default
Make an iterator to nowhere.
const_iterator end() const
#define DUDS_THROW_EXCEPTION(x)
Works like BOOST_THROW_EXCEPTION, but includes a stack trace if DUDS_ERRORS_VERBOSE is defined...
const T * cbegin() const
An iterator (really just a pointer) to the first element of the array.
bool empty() const
True if the array is empty; units are immateral.