Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef _GMTL_VEC_H_
00007 #define _GMTL_VEC_H_
00008
00009 #include <gmtl/Defines.h>
00010 #include <gmtl/Config.h>
00011 #include <gmtl/VecBase.h>
00012 #include <gmtl/Util/StaticAssert.h>
00013
00014 namespace gmtl
00015 {
00016
00029 template<class DATA_TYPE, unsigned SIZE>
00030 #ifdef GMTL_NO_METAPROG
00031 class Vec : public VecBase<DATA_TYPE, SIZE>
00032 #else
00033 class Vec : public VecBase<DATA_TYPE, SIZE, meta::DefaultVecTag>
00034 #endif
00035 {
00036 public:
00038 typedef DATA_TYPE DataType;
00039
00041 enum Params { Size = SIZE };
00042
00044 typedef VecBase<DATA_TYPE, SIZE> BaseType;
00045 typedef Vec<DATA_TYPE, SIZE> VecType;
00046
00047 public:
00051 Vec()
00052 {
00053 for (unsigned i = 0; i < SIZE; ++i)
00054 this->mData[i] = (DATA_TYPE)0;
00055 }
00056
00058
00059
00064
00065
00066
00067
00068
00069
00070 #ifdef GMTL_NO_METAPROG
00071 Vec( const VecBase<DATA_TYPE, SIZE>& rVec )
00072 : BaseType( rVec )
00073 {
00074 }
00075 #else
00076 template<typename REP2>
00077 Vec( const VecBase<DATA_TYPE, SIZE, REP2>& rVec )
00078 : BaseType( rVec )
00079 {
00080 }
00081 #endif
00082
00086 Vec(const DATA_TYPE& val0,const DATA_TYPE& val1)
00087 : BaseType(val0, val1)
00088 {
00089 GMTL_STATIC_ASSERT( SIZE == 2, Out_Of_Bounds_Element_Access_In_Vec );
00090 }
00091
00092 Vec(const DATA_TYPE& val0,const DATA_TYPE& val1,const DATA_TYPE& val2)
00093 : BaseType(val0, val1, val2)
00094 {
00095 GMTL_STATIC_ASSERT( SIZE == 3, Out_Of_Bounds_Element_Access_In_Vec );
00096 }
00097
00098 Vec(const DATA_TYPE& val0,const DATA_TYPE& val1,const DATA_TYPE& val2,const DATA_TYPE& val3)
00099 : BaseType(val0, val1, val2, val3)
00100 {
00101 GMTL_STATIC_ASSERT( SIZE == 4, Out_Of_Bounds_Element_Access_In_Vec );
00102 }
00104
00106 #ifdef GMTL_NO_METAPROG
00107 inline VecType& operator=(const VecBase<DATA_TYPE,SIZE>& rhs)
00108 {
00109 BaseType::operator=(rhs);
00110 return *this;
00111 }
00112 #else
00113 template<typename REP2>
00114 inline VecType& operator=(const VecBase<DATA_TYPE,SIZE,REP2>& rhs)
00115 {
00116 BaseType::operator=(rhs);
00117 return *this;
00118 }
00119 #endif
00120 };
00121
00122
00123 typedef Vec<int, 2> Vec2i;
00124 typedef Vec<float,2> Vec2f;
00125 typedef Vec<double,2> Vec2d;
00126 typedef Vec<int, 3> Vec3i;
00127 typedef Vec<float,3> Vec3f;
00128 typedef Vec<double,3> Vec3d;
00129 typedef Vec<int, 4> Vec4i;
00130 typedef Vec<float,4> Vec4f;
00131 typedef Vec<double,4> Vec4d;
00132
00133 }
00134
00135 #endif