AFF --- A container for numbers (array) by Friederich and Forbriger.
aff::ConstCArray< T > Class Template Reference

Interface class to raw memory (C style array) More...

#include <Carray.h>

Inheritance diagram for aff::ConstCArray< T >:
Collaboration diagram for aff::ConstCArray< T >:

Public Types

Various types

In particular due to our concept of const-correctness we need several typedefs to declare types derived from the element type of the array.

See also
Member typedefs
Notes on the const-correctness of arrays
typedef ConstArray< T > Tarray
 Type of array to be interfaced. More...
 
typedef Tarray::Trepresentation Trepresentation
 Type of representation. More...
 
typedef Tarray::Tshape Tshape
 Type of shape. More...
 
typedef Tshape::TSizeVec TSizeVec
 we use this for one of the access operators More...
 
typedef Tarray::Tvalue Tvalue
 Element type. More...
 
typedef Tarray::Tpointer Tpointer
 Type of pointer to element. More...
 
typedef Tarray::Treference Treference
 Type of reference to element. More...
 
typedef Tarray::Tconst_value Tconst_value
 const element type More...
 
typedef Tarray::Tconst_pointer Tconst_pointer
 Type of pointer to const element. More...
 
typedef Tarray::Tconst_reference Tconst_reference
 Type of reference to const element. More...
 
typedef ConstCArray< T > Tcontainer
 Type of this array. More...
 
typedef Tcontainer Tcontainer_of_const
 Type of the array of const values. More...
 
typedef Tcontainer Tcoc
 Short for Tcontainer_of_const. More...
 

Public Member Functions

Constructors

No copy constructors or copy operators are provided since this is provided as an interface class only.

 ConstCArray (const Tarray &array)
 construct from shape and representation More...
 
Shape access
const Tsizesize (const Tsubscript &i) const
 size of dimension More...
 
const Tsizestride (const Tsubscript &i) const
 stride of dimension More...
 
const TSizeVecsize () const
 size of dimensions More...
 
const TSizeVecstride () const
 strides of dimensions More...
 
Memory access
Tconst_pointer pointer () const
 return pointer to first element in Fortran layout More...
 
template<class TT >
TT * castedpointer () const
 return type-casted pointer to first element in Fortran layout More...
 

Protected Member Functions

const TSizeVec::Tvalueoffset () const
 pass offset to derived class More...
 

Private Attributes

Trepresentation Mrepresentation
 representation member More...
 
TSizeVec Msize
 sizes of dimensions More...
 
TSizeVec Mstride
 strides of dimensions More...
 
TSizeVec::Tvalue Moffset
 offset to first index More...
 

Detailed Description

template<class T>
class aff::ConstCArray< T >

Interface class to raw memory (C style array)

This class together with aff::CArray is provided as an interface for users which have to provide the contents of an array through raw memory pointers in C style. Both classes take an aff::ConstArray or aff::Array instance respectively as an argument for their constructor. They provide a pointer to raw memory through their member functions pointer() and castedpointer(). If a pointer p to the raw memeory behind array is defined by

aff::CArray<T> carray(array);
T* p=carray.pointer();

then the array element array(i0,i1,i2,i3) is addressed by

p[i0*s0+i1*s1+i2*s2+i3*s3]

where the index value ranges are

  • i0=0,1,... n0-1
  • i1=0,1,... n1-1
  • i2=0,1,... n2-1
  • i3=0,1,... n3-1

and

  • n0=carray.size(0)
  • n1=carray.size(1)
  • n2=carray.size(2)
  • n3=carray.size(3)

and

  • s0=carray.stride(0)
  • s1=carray.stride(1)
  • s2=carray.stride(2)
  • s3=carray.stride(3)
Note
The pointers passed by the access functions of this class are (certainly) not reference counted. Make sure to keep an instance of one of the arrays maintining the underlying memory allocation as long as these pointers are in use.
See also
helpertest.cc

Definition at line 93 of file Carray.h.


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