Public Types | Public Member Functions | Public Attributes

gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag > Class Template Reference

Specialized version of VecBase that is actually used for all user interaction with a traditional vector. More...

#include <VecBase.h>

Inheritance diagram for gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >:
Inheritance graph
[legend]
Collaboration diagram for gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >:
Collaboration graph
[legend]

List of all members.

Public Types

enum  Params { Size = SIZE }
 

The number of components this VecBase has.

More...
typedef DATA_TYPE DataType
 The datatype used for the components of this VecBase.
typedef VecBase< DATA_TYPE,
SIZE, meta::DefaultVecTag
VecType

Public Member Functions

 VecBase ()
 Default constructor.
 VecBase (const VecBase< DATA_TYPE, SIZE > &rVec)
 Makes an exact copy of the given VecBase object.
template<typename REP2 >
 VecBase (const VecBase< DATA_TYPE, SIZE, REP2 > &rVec)
void set (const DATA_TYPE *dataPtr)
 Sets the components in this VecBase using the given array.
template<typename REP2 >
VecTypeoperator= (const VecBase< DATA_TYPE, SIZE, REP2 > &rhs)
 Assign from different rep.

 VecBase (const DATA_TYPE &val0, const DATA_TYPE &val1)
 Creates a new VecBase initialized to the given values.
 VecBase (const DATA_TYPE &val0, const DATA_TYPE &val1, const DATA_TYPE &val2)
 VecBase (const DATA_TYPE &val0, const DATA_TYPE &val1, const DATA_TYPE &val2, const DATA_TYPE &val3)

void set (const DATA_TYPE &val0)
 Sets the components in this VecBase to the given values.
void set (const DATA_TYPE &val0, const DATA_TYPE &val1)
void set (const DATA_TYPE &val0, const DATA_TYPE &val1, const DATA_TYPE &val2)
void set (const DATA_TYPE &val0, const DATA_TYPE &val1, const DATA_TYPE &val2, const DATA_TYPE &val3)

DATA_TYPE & operator[] (const unsigned i)
 Gets the ith component in this VecBase.
const DATA_TYPE & operator[] (const unsigned i) const

DATA_TYPE * getData ()
 Gets the internal array of the components.
const DATA_TYPE * getData () const

Public Attributes

DATA_TYPE mData [SIZE]
 The array of components.

Detailed Description

template<class DATA_TYPE, unsigned SIZE>
class gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >

Specialized version of VecBase that is actually used for all user interaction with a traditional vector.

Parameters:
DATA_TYPE the datatype to use for the components
SIZE the number of components this VecBase has

Definition at line 94 of file VecBase.h.


Member Typedef Documentation

template<class DATA_TYPE , unsigned SIZE>
typedef DATA_TYPE gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::DataType

The datatype used for the components of this VecBase.

Reimplemented in gmtl::Vec< DATA_TYPE, SIZE >, gmtl::Vec< DATA_TYPE, 3 >, and gmtl::Vec< DATA_TYPE, 4 >.

Definition at line 99 of file VecBase.h.

template<class DATA_TYPE , unsigned SIZE>
typedef VecBase<DATA_TYPE, SIZE, meta::DefaultVecTag> gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::VecType

Member Enumeration Documentation

template<class DATA_TYPE , unsigned SIZE>
enum gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::Params

The number of components this VecBase has.

Enumerator:
Size 

Reimplemented in gmtl::Vec< DATA_TYPE, SIZE >, gmtl::Vec< DATA_TYPE, 3 >, and gmtl::Vec< DATA_TYPE, 4 >.

Definition at line 108 of file VecBase.h.

{ Size = SIZE };


Constructor & Destructor Documentation

template<class DATA_TYPE , unsigned SIZE>
gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::VecBase (  )  [inline]

Default constructor.

Does nothing, leaves data alone. This is for performance because this constructor is called by derived class constructors Even when they just want to set the data directly

Definition at line 117 of file VecBase.h.

   {
#ifdef GMTL_COUNT_CONSTRUCT_CALLS
      gmtl::helpers::VecCtrCounterInstance()->inc();
#endif
   }

template<class DATA_TYPE , unsigned SIZE>
gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::VecBase ( const VecBase< DATA_TYPE, SIZE > &  rVec  )  [inline]

Makes an exact copy of the given VecBase object.

Parameters:
rVec the VecBase object to copy

Definition at line 129 of file VecBase.h.

   {
#ifdef GMTL_COUNT_CONSTRUCT_CALLS
      gmtl::helpers::VecCtrCounterInstance()->inc();
#endif
#ifdef GMTL_NO_METAPROG
      for(unsigned i=0;i<SIZE;++i)
         mData[i] = rVec.mData[i];
#else
      gmtl::meta::AssignVecUnrolled<SIZE-1, VecBase<DATA_TYPE,SIZE> >::func(*this, rVec);
#endif
   }

template<class DATA_TYPE , unsigned SIZE>
template<typename REP2 >
gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::VecBase ( const VecBase< DATA_TYPE, SIZE, REP2 > &  rVec  )  [inline]

Definition at line 144 of file VecBase.h.

   {
#ifdef GMTL_COUNT_CONSTRUCT_CALLS
      gmtl::helpers::VecCtrCounterInstance()->inc();
#endif
      for(unsigned i=0;i<SIZE;++i)
      {  mData[i] = rVec[i]; }
   }

template<class DATA_TYPE , unsigned SIZE>
gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::VecBase ( const DATA_TYPE &  val0,
const DATA_TYPE &  val1 
) [inline]

Creates a new VecBase initialized to the given values.

Definition at line 158 of file VecBase.h.

   {
#ifdef GMTL_COUNT_CONSTRUCT_CALLS
      gmtl::helpers::VecCtrCounterInstance()->inc();
#endif
      GMTL_STATIC_ASSERT( SIZE == 2, Invalid_constructor_of_size_2_used);
      mData[0] = val0; mData[1] = val1;
   }

template<class DATA_TYPE , unsigned SIZE>
gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::VecBase ( const DATA_TYPE &  val0,
const DATA_TYPE &  val1,
const DATA_TYPE &  val2 
) [inline]

Definition at line 166 of file VecBase.h.

   {
#ifdef GMTL_COUNT_CONSTRUCT_CALLS
      gmtl::helpers::VecCtrCounterInstance()->inc();
#endif
      GMTL_STATIC_ASSERT( SIZE == 3, Invalid_constructor_of_size_3_used );
      mData[0] = val0;  mData[1] = val1;  mData[2] = val2;
   }

template<class DATA_TYPE , unsigned SIZE>
gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::VecBase ( const DATA_TYPE &  val0,
const DATA_TYPE &  val1,
const DATA_TYPE &  val2,
const DATA_TYPE &  val3 
) [inline]

Definition at line 174 of file VecBase.h.

   {
#ifdef GMTL_COUNT_CONSTRUCT_CALLS
      gmtl::helpers::VecCtrCounterInstance()->inc();
#endif
      // @todo need compile time assert
      GMTL_STATIC_ASSERT( SIZE == 4, Invalid_constructor_of_size_4_used);
      mData[0] = val0;  mData[1] = val1;  mData[2] = val2;  mData[3] = val3;
   }


Member Function Documentation

template<class DATA_TYPE , unsigned SIZE>
DATA_TYPE* gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::getData (  )  [inline]

Gets the internal array of the components.

Returns:
a pointer to the component array with length SIZE

Definition at line 292 of file VecBase.h.

   { return mData; }

template<class DATA_TYPE , unsigned SIZE>
const DATA_TYPE* gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::getData (  )  const [inline]

Definition at line 294 of file VecBase.h.

   { return mData; }

template<class DATA_TYPE , unsigned SIZE>
template<typename REP2 >
VecType& gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::operator= ( const VecBase< DATA_TYPE, SIZE, REP2 > &  rhs  )  [inline]

Assign from different rep.

Reimplemented in gmtl::Vec< DATA_TYPE, SIZE >, gmtl::Vec< DATA_TYPE, 3 >, and gmtl::Vec< DATA_TYPE, 4 >.

Definition at line 262 of file VecBase.h.

   {
      for(unsigned i=0;i<SIZE;++i)
      {
         mData[i] = rhs[i];
      }

      //gmtl::meta::AssignVecUnrolled<SIZE-1, VecBase<DATA_TYPE,SIZE> >::func(*this, rVec);
      return *this;
   }

template<class DATA_TYPE , unsigned SIZE>
DATA_TYPE& gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::operator[] ( const unsigned  i  )  [inline]

Gets the ith component in this VecBase.

Parameters:
i the zero-based index of the component to access.
Precondition:
i < SIZE
Returns:
a reference to the ith component

Definition at line 237 of file VecBase.h.

   {
      gmtlASSERT(i < SIZE);
      return mData[i];
   }

template<class DATA_TYPE , unsigned SIZE>
const DATA_TYPE& gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::operator[] ( const unsigned  i  )  const [inline]

Definition at line 242 of file VecBase.h.

   {
      gmtlASSERT(i < SIZE);
      return mData[i];
   }

template<class DATA_TYPE , unsigned SIZE>
void gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::set ( const DATA_TYPE &  val0,
const DATA_TYPE &  val1 
) [inline]

Definition at line 211 of file VecBase.h.

   {
      GMTL_STATIC_ASSERT( SIZE >= 2, Set_out_of_valid_range);
      mData[0] = val0; mData[1] = val1;
   }

template<class DATA_TYPE , unsigned SIZE>
void gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::set ( const DATA_TYPE &  val0,
const DATA_TYPE &  val1,
const DATA_TYPE &  val2,
const DATA_TYPE &  val3 
) [inline]

Definition at line 221 of file VecBase.h.

   {
      GMTL_STATIC_ASSERT( SIZE >= 4, Set_out_of_valid_range);
      mData[0] = val0;  mData[1] = val1;  mData[2] = val2;  mData[3] = val3;
   }

template<class DATA_TYPE , unsigned SIZE>
void gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::set ( const DATA_TYPE &  val0  )  [inline]

Sets the components in this VecBase to the given values.

Definition at line 208 of file VecBase.h.

   { mData[0] = val0; }

template<class DATA_TYPE , unsigned SIZE>
void gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::set ( const DATA_TYPE *  dataPtr  )  [inline]

Sets the components in this VecBase using the given array.

Parameters:
dataPtr the array containing the values to copy
Precondition:
dataPtr has at least SIZE elements

Definition at line 191 of file VecBase.h.

   {
#ifdef GMTL_NO_METAPROG
      for ( unsigned int i = 0; i < SIZE; ++i )
      {
         mData[i] = dataPtr[i];
      }
#else
      gmtl::meta::AssignArrayUnrolled<SIZE-1, DATA_TYPE>::func(&(mData[0]),
                                                               dataPtr);
#endif
   }

template<class DATA_TYPE , unsigned SIZE>
void gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::set ( const DATA_TYPE &  val0,
const DATA_TYPE &  val1,
const DATA_TYPE &  val2 
) [inline]

Definition at line 216 of file VecBase.h.

   {
      GMTL_STATIC_ASSERT( SIZE >= 3, Set_out_of_valid_range);
      mData[0] = val0;  mData[1] = val1;  mData[2] = val2;
   }


Member Data Documentation

template<class DATA_TYPE , unsigned SIZE>
DATA_TYPE gmtl::VecBase< DATA_TYPE, SIZE, meta::DefaultVecTag >::mData[SIZE]

The array of components.

Definition at line 300 of file VecBase.h.


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