PandaRoot
PndCAInternal::ArrayBase< T, 2 > Class Template Reference

#include <PndCAArray.h>

Inheritance diagram for PndCAInternal::ArrayBase< T, 2 >:
PndCAInternal::ArrayBoundsCheck

Public Types

typedef ReturnTypeHelper< T >::Type R
 

Public Member Functions

 ArrayBase ()
 
 ArrayBase (const ArrayBase &rhs)
 
ArrayBaseoperator= (const ArrayBase &rhs)
 
Roperator() (int x, int y)
 
const Roperator() (int x, int y) const
 
PndCAArray< T, 1 > operator[] (int x)
 
const PndCAArray< T, 1 > operator[] (int x) const
 

Protected Member Functions

void SetSize (int x, int y, int)
 
- Protected Member Functions inherited from PndCAInternal::ArrayBoundsCheck
virtual ~ArrayBoundsCheck ()
 
bool IsInBounds (int) const
 
void SetBounds (int, int)
 
void MoveBounds (int)
 
void ReinterpretCast (const ArrayBoundsCheck &, int, int)
 

Protected Attributes

T * fData
 
int fSize
 
int fStride
 

Friends

class ArrayBase< T, 3 >
 

Detailed Description

template<typename T>
class PndCAInternal::ArrayBase< T, 2 >

2-dim arrays should use operator(int, int) operator[] can be used to return a 1-dim array

Definition at line 352 of file PndCAArray.h.

Member Typedef Documentation

◆ R

template<typename T >
typedef ReturnTypeHelper<T>::Type PndCAInternal::ArrayBase< T, 2 >::R

Definition at line 366 of file PndCAArray.h.

Constructor & Destructor Documentation

◆ ArrayBase() [1/2]

template<typename T >
PndCAInternal::ArrayBase< T, 2 >::ArrayBase ( )
inline

Definition at line 356 of file PndCAArray.h.

356 : fData(0), fSize(0), fStride(0) {} // XXX really shouldn't be done. But -Weffc++ wants it so

◆ ArrayBase() [2/2]

template<typename T >
PndCAInternal::ArrayBase< T, 2 >::ArrayBase ( const ArrayBase< T, 2 > &  rhs)
inline

Definition at line 357 of file PndCAArray.h.

357 : ArrayBoundsCheck(rhs), fData(rhs.fData), fSize(rhs.fSize), fStride(rhs.fStride) {} // XXX

Member Function Documentation

◆ operator()() [1/2]

template<typename T >
R& PndCAInternal::ArrayBase< T, 2 >::operator() ( int  x,
int  y 
)
inline

return a reference to the value at the given indexes

Definition at line 370 of file PndCAArray.h.

References BOUNDS_CHECK.

371  {
372  BOUNDS_CHECK(x * fStride + y, fData[0]);
373  return fData[x * fStride + y];
374  }
#define BOUNDS_CHECK(x, y)
Definition: PndCAArray.h:146

◆ operator()() [2/2]

template<typename T >
const R& PndCAInternal::ArrayBase< T, 2 >::operator() ( int  x,
int  y 
) const
inline

return a const reference to the value at the given indexes

Definition at line 378 of file PndCAArray.h.

References BOUNDS_CHECK, and operator[]().

379  {
380  BOUNDS_CHECK(x * fStride + y, fData[0]);
381  return fData[x * fStride + y];
382  }
#define BOUNDS_CHECK(x, y)
Definition: PndCAArray.h:146

◆ operator=()

template<typename T >
ArrayBase& PndCAInternal::ArrayBase< T, 2 >::operator= ( const ArrayBase< T, 2 > &  rhs)
inline

Definition at line 358 of file PndCAArray.h.

359  {
360  ArrayBoundsCheck::operator=(rhs);
361  fData = rhs.fData;
362  fSize = rhs.fSize;
363  fStride = rhs.fStride;
364  return *this;
365  } // XXX

◆ operator[]() [1/2]

template<typename T >
PndCAArray< T, 1 > PndCAInternal::ArrayBase< T, 2 >::operator[] ( int  x)
inline

return a 1-dim array at the given index. This makes it behave like a 2-dim C-Array.

Definition at line 710 of file PndCAArray.h.

References BOUNDS_CHECK.

711 {
712  x *= fStride;
713  typedef PndCAArray<T, 1> AT1;
714  BOUNDS_CHECK(x, AT1());
716  a.fData = &fData[x];
717  a.ArrayBoundsCheck::operator=(*this);
718  a.MoveBounds(-x);
719  return a;
720 }
#define BOUNDS_CHECK(x, y)
Definition: PndCAArray.h:146

◆ operator[]() [2/2]

template<typename T >
const PndCAArray< T, 1 > PndCAInternal::ArrayBase< T, 2 >::operator[] ( int  x) const
inline

return a const 1-dim array at the given index. This makes it behave like a 2-dim C-Array.

Definition at line 723 of file PndCAArray.h.

References BOUNDS_CHECK.

724 {
725  x *= fStride;
726  typedef PndCAArray<T, 1> AT1;
727  BOUNDS_CHECK(x, AT1());
729  a.fData = &fData[x];
730  a.ArrayBoundsCheck::operator=(*this);
731  a.MoveBounds(-x);
732  return a;
733 }
#define BOUNDS_CHECK(x, y)
Definition: PndCAArray.h:146

◆ SetSize()

template<typename T >
void PndCAInternal::ArrayBase< T, 2 >::SetSize ( int  x,
int  y,
int   
)
inlineprotected

Definition at line 396 of file PndCAArray.h.

397  {
398  fStride = y;
399  fSize = x * y;
400  }

Friends And Related Function Documentation

◆ ArrayBase< T, 3 >

template<typename T >
friend class ArrayBase< T, 3 >
friend

Definition at line 353 of file PndCAArray.h.

Member Data Documentation

◆ fData

template<typename T >
T* PndCAInternal::ArrayBase< T, 2 >::fData
protected

Definition at line 393 of file PndCAArray.h.

◆ fSize

template<typename T >
int PndCAInternal::ArrayBase< T, 2 >::fSize
protected

Definition at line 394 of file PndCAArray.h.

◆ fStride

template<typename T >
int PndCAInternal::ArrayBase< T, 2 >::fStride
protected

Definition at line 395 of file PndCAArray.h.


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