• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Vec.h

Go to the documentation of this file.
00001 // GMTL is (C) Copyright 2001-2010 by Allen Bierbaum
00002 // Distributed under the GNU Lesser General Public License 2.1 with an
00003 // addendum covering inlined code. (See accompanying files LICENSE and
00004 // LICENSE.addendum or http://www.gnu.org/copyleft/lesser.txt)
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    Vec( const Vec<DATA_TYPE, SIZE>& rVec )
00066       : BaseType( static_cast<BaseType>( rVec ) )
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 // --- helper types --- //
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

Generated on Sun Sep 19 2010 14:35:14 for GenericMathTemplateLibrary by  doxygen 1.7.1