DUDS
Distributed Update of Data from Something
duds::data::QuantityIterator< I > Class Template Reference

An iterator template for QuantityArray and QuantityNddArray that provides a Quantity object when dereferenced. More...

#include <QuantityArray.hpp>

Collaboration diagram for duds::data::QuantityIterator< I >:

Public Types

typedef void difference_type
 
typedef std::iterator_traits< I >::iterator_category iterator_category
 
typedef std::iterator_traits< I >::pointer pointer
 
typedef std::iterator_traits< I >::reference reference
 
typedef Quantity value_type
 

Public Member Functions

 QuantityIterator ()=default
 Make an iterator to nowhere. More...
 
 QuantityIterator (const I &i, Unit u)
 Construct a new iterator with the given units. More...
 
bool operator!= (const QuantityIterator &it) const
 
Quantity operator* () const
 Returns a new Quantity object. More...
 
QuantityIteratoroperator++ ()
 
QuantityIteratoroperator++ (int)
 
QuantityIteratoroperator-- ()
 
QuantityIteratoroperator-- (int)
 
bool operator== (const QuantityIterator &it) const
 
Unit unit () const
 Returns the units of all quantities stored in the container. More...
 
auto value () const
 Returns a reference to the value stored in the container. More...
 

Private Attributes

Unit arrayUnit
 The units used for all Quantities in the array. More...
 
iter
 The iterator wrapped by this object. More...
 

Detailed Description

template<class I>
class duds::data::QuantityIterator< I >

An iterator template for QuantityArray and QuantityNddArray that provides a Quantity object when dereferenced.

It is intended to be a BidirectionalIterator. It fails to be an OutputIterator because dereferencing the iterator creates and returns a new Quantity object. However, the underlying value is available and writable through value(). The Unit for all quantities is also accessible, but not writable, through unit().

Author
Jeff Jackowski

Definition at line 33 of file QuantityArray.hpp.

Member Typedef Documentation

◆ difference_type

template<class I >
typedef void duds::data::QuantityIterator< I >::difference_type

Definition at line 49 of file QuantityArray.hpp.

◆ iterator_category

template<class I >
typedef std::iterator_traits<I>::iterator_category duds::data::QuantityIterator< I >::iterator_category

Definition at line 48 of file QuantityArray.hpp.

◆ pointer

template<class I >
typedef std::iterator_traits<I>::pointer duds::data::QuantityIterator< I >::pointer

Definition at line 46 of file QuantityArray.hpp.

◆ reference

template<class I >
typedef std::iterator_traits<I>::reference duds::data::QuantityIterator< I >::reference

Definition at line 47 of file QuantityArray.hpp.

◆ value_type

template<class I >
typedef Quantity duds::data::QuantityIterator< I >::value_type

Definition at line 45 of file QuantityArray.hpp.

Constructor & Destructor Documentation

◆ QuantityIterator() [1/2]

template<class I >
duds::data::QuantityIterator< I >::QuantityIterator ( )
default

Make an iterator to nowhere.

◆ QuantityIterator() [2/2]

template<class I >
duds::data::QuantityIterator< I >::QuantityIterator ( const I &  i,
Unit  u 
)
inline

Construct a new iterator with the given units.

Parameters
iThe wrapped iterator. It must yield a double when dereferenced.
uThe units of all items the iterator can reference.

Definition at line 59 of file QuantityArray.hpp.

Member Function Documentation

◆ operator!=()

template<class I >
bool duds::data::QuantityIterator< I >::operator!= ( const QuantityIterator< I > &  it) const
inline

Definition at line 81 of file QuantityArray.hpp.

◆ operator*()

template<class I >
Quantity duds::data::QuantityIterator< I >::operator* ( ) const
inline

Returns a new Quantity object.

Since the object is created here, it cannot be used to change the data in the container.

Definition at line 88 of file QuantityArray.hpp.

◆ operator++() [1/2]

template<class I >
QuantityIterator& duds::data::QuantityIterator< I >::operator++ ( )
inline

Definition at line 60 of file QuantityArray.hpp.

◆ operator++() [2/2]

template<class I >
QuantityIterator& duds::data::QuantityIterator< I >::operator++ ( int  )
inline

Definition at line 64 of file QuantityArray.hpp.

◆ operator--() [1/2]

template<class I >
QuantityIterator& duds::data::QuantityIterator< I >::operator-- ( )
inline

Definition at line 69 of file QuantityArray.hpp.

◆ operator--() [2/2]

template<class I >
QuantityIterator& duds::data::QuantityIterator< I >::operator-- ( int  )
inline

Definition at line 73 of file QuantityArray.hpp.

◆ operator==()

template<class I >
bool duds::data::QuantityIterator< I >::operator== ( const QuantityIterator< I > &  it) const
inline

Definition at line 78 of file QuantityArray.hpp.

◆ unit()

◆ value()

template<class I >
auto duds::data::QuantityIterator< I >::value ( ) const
inline

Returns a reference to the value stored in the container.

Returns
The dereferenced value from the container. If this is a const iterator, the return type will also be const.

Definition at line 96 of file QuantityArray.hpp.

Member Data Documentation

◆ arrayUnit

template<class I >
Unit duds::data::QuantityIterator< I >::arrayUnit
private

The units used for all Quantities in the array.

This could have been a pointer to the array, but that would use as much or more memory.

Definition at line 42 of file QuantityArray.hpp.

Referenced by duds::data::QuantityIterator< I >::unit().

◆ iter


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