A safe windowing class that opens onto array-like containers. More...
#include <formatters.hpp>
Public Types | |
typedef Array::const_iterator | const_iterator |
Uses the array's constant iterator type. More... | |
typedef Array::const_reference | const_reference |
Uses the array's element const reference type. More... | |
typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
Uses the array's constant reverse iterator type. More... | |
typedef std::ptrdiff_t | difference_type |
typedef formatters::StencilFormatter< value_type, Array > | Formatter |
typedef Array::iterator | iterator |
Uses the array's iterator type. More... | |
typedef Array::reference | reference |
Uses the array's element reference type. More... | |
typedef std::reverse_iterator< iterator > | reverse_iterator |
Uses the array's reverse iterator type. More... | |
typedef std::size_t | size_type |
Uses the array's type used to denote the length of the array. More... | |
typedef Array::value_type | value_type |
Uses the array's element type. More... | |
Private Attributes | |
Array & | array |
iterator | b_iter |
iterator | e_iter |
Friends | |
template<typename OutputStream , typename ArrayType > | |
OutputStream & | operator<< (OutputStream &ostream, const Stencil< ArrayType > &stencil) |
Insertion operator for stencils. More... | |
A safe windowing class that opens onto array-like containers.
Functions often require access to just a portion of an array. In these cases pointers are typically used, but these end up being dangerous alot of times. The underlying array may disappear, or its size may change and the resulting pointers are left dangling, pointing at rubbish.
This class allows such an operation to be performed with two additional benefits:
Currently this works with anything that measures up to the ecl concept of a container.
Usage:
Definition at line 40 of file stencil/formatters.hpp.
typedef Array::const_iterator ecl::Stencil< Array >::const_iterator |
Uses the array's constant iterator type.
Definition at line 82 of file stencil/stencil.hpp.
typedef Array::const_reference ecl::Stencil< Array >::const_reference |
Uses the array's element const reference type.
Definition at line 84 of file stencil/stencil.hpp.
typedef std::reverse_iterator<const_iterator> ecl::Stencil< Array >::const_reverse_iterator |
Uses the array's constant reverse iterator type.
Definition at line 92 of file stencil/stencil.hpp.
typedef std::ptrdiff_t ecl::Stencil< Array >::difference_type |
Definition at line 90 of file stencil/stencil.hpp.
typedef formatters::StencilFormatter<value_type,Array> ecl::Stencil< Array >::Formatter |
Definition at line 93 of file stencil/stencil.hpp.
typedef Array::iterator ecl::Stencil< Array >::iterator |
Uses the array's iterator type.
Definition at line 81 of file stencil/stencil.hpp.
typedef Array::reference ecl::Stencil< Array >::reference |
Uses the array's element reference type.
Definition at line 83 of file stencil/stencil.hpp.
typedef std::reverse_iterator<iterator> ecl::Stencil< Array >::reverse_iterator |
Uses the array's reverse iterator type.
Definition at line 91 of file stencil/stencil.hpp.
typedef std::size_t ecl::Stencil< Array >::size_type |
Uses the array's type used to denote the length of the array.
Definition at line 89 of file stencil/stencil.hpp.
typedef Array::value_type ecl::Stencil< Array >::value_type |
Uses the array's element type.
Definition at line 78 of file stencil/stencil.hpp.
|
inline |
Initialises with a reference to the underlying container and boundary constraints.
Sets up the underlying storage container along with boundary constraints in the style of stl containers.
Concept Check: makes sure the template parameter provided for the class is a container type with the required functionality.
underlying_array | : reference to the underlying array. |
begin_iter | : start of the stencil window. |
end_iter | : end of the stencil window. |
StandardException : throws if the indices provided are out of range [debug mode only]. |
Definition at line 113 of file stencil/stencil.hpp.
|
inline |
Initialises with a reference to the underlying container and boundary constraints.
Sets up the underlying storage container along with boundary constraints in the style of eigen block intialisations.
Concept Check: makes sure the template parameter provided for the class is a container type with the required functionality.
underlying_array | : reference to the underlying array. |
start_index | : start of the stencil window. |
n | : number of elements to include in the window. |
StandardException : throws if the indices provided are out of range [debug mode only]. |
Definition at line 138 of file stencil/stencil.hpp.
|
inlinevirtual |
Definition at line 148 of file stencil/stencil.hpp.
|
inline |
Accesses elements in the stencil, returning references to the requested element. This accessor always does range checks. Compare this with the [] accessor which only checks if NDEBUG is not defined.
i | : the index of the requested element. |
StandardException : throws if range is requested element is out of range. |
Definition at line 431 of file stencil/stencil.hpp.
|
inline |
Accesses elements in the stencil, returning references to the requested element. This accessor always does range checks. Compare this with the [] accessor which only checks if NDEBUG is not defined. This also ensures the references are constant, which in turn ensures the contents cannot of the array cannot be modified.
i | : the index of the requested element. |
StandardException : throws if range is requested element is out of range. |
Definition at line 455 of file stencil/stencil.hpp.
|
inline |
Generates an reference to the last element in the array.
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 370 of file stencil/stencil.hpp.
|
inline |
Generates a constant reference to the last element in the array (cannot change the value).
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 380 of file stencil/stencil.hpp.
|
inline |
Generates a pointer (iterator) pointing to the start of the stencil.
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 266 of file stencil/stencil.hpp.
|
inline |
Generates a const pointer (iterator) pointing to the start of the array.
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 276 of file stencil/stencil.hpp.
|
inline |
Generates an pointer (iterator) pointing to the end of the array.
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 286 of file stencil/stencil.hpp.
|
inline |
Generates a const pointer (iterator) pointing to the end of the array.
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 296 of file stencil/stencil.hpp.
|
inline |
Generates an reference to the first element in the array.
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 350 of file stencil/stencil.hpp.
|
inline |
Generates a constant reference to the first element in the array (cannot change the value).
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 360 of file stencil/stencil.hpp.
|
inline |
Provides a comma initialisation facility. This initiates the comma initialiser with an iterator to the underlying array and then leaves the initialiser to do the rest. The initialiser will do range checking if NDEBUG is not defined.
value | : the first value to enter , ElementType, ArraySizeinto the array. |
Definition at line 206 of file stencil/stencil.hpp.
|
inline |
This either resettles this stencil or copies across to it (depending on the rhs stencil).
The assignment operator has one of two effects - it will either reassign this stencil if both stencils work on the same underlying array, OR it copies across if acting on two different arrays.
Usage:
The first case, resettling:
The second case, copying:
s |
StandardException : if copying from another stencil/array, throws if size exceeded [debug mode only]. |
Definition at line 240 of file stencil/stencil.hpp.
|
inline |
Accesses elements in the stencil, returning references to the requested element. This accessor only does range checks in debug mode (NDEBUG is not defined). Compare this with the at() accessor which always checks if the range is exceeded.
StandardException : throws if range is requested element is out of range [debug mode only]. |
Definition at line 398 of file stencil/stencil.hpp.
|
inline |
Accesses elements in the stencil, returning references to the requested element. This accessor only does range checks in debug mode (NDEBUG is not defined). Compare this with the at() accessor which always checks if the range is exceeded. This also ensures the references are constant, which in turn ensures the contents cannot of the array cannot be modified.
StandardException : throws if range is requested element is out of range [debug mode only]. |
Definition at line 415 of file stencil/stencil.hpp.
|
inline |
Generates a reverse iterator pointing to the end of the array.
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 306 of file stencil/stencil.hpp.
|
inline |
Generates a constant reverse iterator pointing to the end of the array.
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 316 of file stencil/stencil.hpp.
|
inline |
Generates a reverse iterator pointing to the beginning of the array.
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 326 of file stencil/stencil.hpp.
|
inline |
Generates a constant reverse iterator pointing to the beginning of the array.
StandardException : throws if the underlying array changed size and the stencil is now out of range [debug mode only]. |
Definition at line 336 of file stencil/stencil.hpp.
|
inline |
Resettle the stencil on a different range over the same underlying array.
Resets the range of the stencil operating on the currently referenced array. Using a starting index + size is in line with the way eigen blocks and segments work.
start_index | : start of the stencil window. |
n | : number of elements to include in the window. |
StandardException : throws if the indices provided are out of range [debug mode only]. |
Definition at line 181 of file stencil/stencil.hpp.
|
inline |
The size of the stencil.
Definition at line 476 of file stencil/stencil.hpp.
|
inline |
Generate a sub-stencil.
Opens another window on this stencil. Using a starting index + size is in line with the way eigen blocks and segments work.
start_index | : start of the stencil window. |
n | : number of elements to include in the window. |
StandardException : throws if the indices provided are out of range [debug mode only]. |
Definition at line 163 of file stencil/stencil.hpp.
|
friend |
Insertion operator for stencils.
Insertion operator for sending the stencil to an output stream. This is raw, and has no formatting.
Concept Check: makes sure the template parameter provided for the stream is a stream type with the required functionality.
ostream | : the output stream. |
stencil | : the stencil to be inserted. |
OutputStream | : the stream being used. |
ArrayType | : the type of the underlying array. |
Definition at line 510 of file stencil/stencil.hpp.
|
private |
Definition at line 501 of file stencil/stencil.hpp.
|
private |
Definition at line 502 of file stencil/stencil.hpp.
|
private |
Definition at line 502 of file stencil/stencil.hpp.