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 340 of file PndCAArray.h.

Member Typedef Documentation

◆ R

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

Definition at line 354 of file PndCAArray.h.

Constructor & Destructor Documentation

◆ ArrayBase() [1/2]

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

Definition at line 344 of file PndCAArray.h.

344 : 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 345 of file PndCAArray.h.

345 : 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 358 of file PndCAArray.h.

References BOUNDS_CHECK.

359  {
360  BOUNDS_CHECK(x * fStride + y, fData[0]);
361  return fData[x * fStride + y];
362  }
#define BOUNDS_CHECK(x, y)
Definition: PndCAArray.h:134

◆ 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 366 of file PndCAArray.h.

References BOUNDS_CHECK, and operator[]().

367  {
368  BOUNDS_CHECK(x * fStride + y, fData[0]);
369  return fData[x * fStride + y];
370  }
#define BOUNDS_CHECK(x, y)
Definition: PndCAArray.h:134

◆ operator=()

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

Definition at line 346 of file PndCAArray.h.

347  {
348  ArrayBoundsCheck::operator=(rhs);
349  fData = rhs.fData;
350  fSize = rhs.fSize;
351  fStride = rhs.fStride;
352  return *this;
353  } // 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 698 of file PndCAArray.h.

References BOUNDS_CHECK.

699 {
700  x *= fStride;
701  typedef PndCAArray<T, 1> AT1;
702  BOUNDS_CHECK(x, AT1());
704  a.fData = &fData[x];
705  a.ArrayBoundsCheck::operator=(*this);
706  a.MoveBounds(-x);
707  return a;
708 }
#define BOUNDS_CHECK(x, y)
Definition: PndCAArray.h:134

◆ 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 711 of file PndCAArray.h.

References BOUNDS_CHECK.

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

◆ SetSize()

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

Definition at line 384 of file PndCAArray.h.

385  {
386  fStride = y;
387  fSize = x * y;
388  }

Friends And Related Function Documentation

◆ ArrayBase< T, 3 >

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

Definition at line 341 of file PndCAArray.h.

Member Data Documentation

◆ fData

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

Definition at line 381 of file PndCAArray.h.

◆ fSize

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

Definition at line 382 of file PndCAArray.h.

◆ fStride

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

Definition at line 383 of file PndCAArray.h.


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